import threading
from prometheus_client import Counter, start_http_server

_lock = threading.Lock()
_registry = None
_metrics = None

def get_metrics():
    global _metrics
    with _lock:
        if _metrics is None:
            start_http_server(9110)
            _metrics = {
                "people_in": Counter(
                    "people_in_count",
                    "Number of people who entered",
                ),
                "people_out": Counter(
                    "people_out_count",
                    "Number of people who exited",
                ),
            }
        return _metrics
