def get_geneva_exporter_meter()

in src/worker/publisher/metrics_publisher.py [0:0]


def get_geneva_exporter_meter(metrics_auth, metrics_namespace):
    """
    Returns a meter that uses the OTLP exporter to send metrics to the collector
    Args:
        metrics_auth (str): The metrics auth
        metrics_namespace (str): The metrics namespace
    """
    resource = Resource(attributes={
        "microsoft_metrics_account": metrics_auth,
        "microsoft_metrics_namespace": metrics_namespace
    })

    temporality_delta = {Counter: AggregationTemporality.DELTA, Histogram: AggregationTemporality.DELTA}
    reader = PeriodicExportingMetricReader(
        OTLPMetricExporter(
            endpoint="0.0.0.0:4317",
            insecure=True,
            preferred_temporality=temporality_delta)
    )

    provider = MeterProvider(resource=resource, metric_readers=[reader])
    metrics.set_meter_provider(provider)
    meter = metrics.get_meter(__name__)
    return meter