"""Metrics module with OTLP export support.

Mirrors t_obs.metrics interface for easy migration.
"""

from typing import Optional

from opentelemetry import metrics

from thoughtful.supervisor.telemetry.config import get_service_name


def get_meter(name: Optional[str] = None) -> metrics.Meter:
    """Get a namespaced meter for recording metrics.

    Args:
        name: Optional namespace suffix. Results in "{service}.{name}" meter.

    Returns:
        Meter instance for creating counters, histograms, and gauges.

    Example:
        from thoughtful.supervisor.telemetry.metrics import get_meter

        meter = get_meter()
        counter = meter.create_counter("my_counter")
        counter.add(1)
    """
    service_name = get_service_name()
    meter_name = service_name if name is None else f"{service_name}.{name}"
    return metrics.get_meter(meter_name)


__all__ = ["get_meter"]
