django-pgpubsub icon indicating copy to clipboard operation
django-pgpubsub copied to clipboard

Adds metrics export using opentelemetry API for notifications queue processing

Open romank0 opened this issue 1 year ago • 0 comments

In order to monitor the listener process it makes sense to export metrics. This PR uses opentelemetry API that allows to export metrics in a generic way if the client opts-in.

I've tested this with two configurations:

  1. using ConsoleExporter described in README
  2. using OTLP exporter to the DataDog agent (see here for details) using this factory:
class ListenerMeterProviderFactory(MeterProviderFactory):
    def get_meter_provider(self) -> MeterProvider:
        exporter = OTLPMetricExporter(endpoint="localhost:4317", insecure=True)
        reader = PeriodicExportingMetricReader(exporter, export_interval_millis=5000)
        metric_provider = MeterProvider(
            resource=Resource(
                attributes={SERVICE_NAME: "test-service", DEPLOYMENT_ENVIRONMENT: "dev"}
            ),
            metric_readers=[reader],
        )
        return metric_provider

romank0 avatar May 09 '23 17:05 romank0