opentelemetry-python icon indicating copy to clipboard operation
opentelemetry-python copied to clipboard

Migrating from prometheus client - MultiProcessCollector feature

Open pavolloffay opened this issue 8 months ago • 4 comments

Is your feature request related to a problem?

Hello, we are considering migrating metrics instrumentation from the prometheus client. However the project depends in MultiProcessCollector:

  • https://prometheus.github.io/client_python/multiprocess/
  • https://github.com/prometheus/client_python/blob/master/prometheus_client/multiprocess.py#L19C7-L19C28

The feature does not seem to be available in the OpenTelemetry python.

Describe the solution you'd like

Support multi process mode in the OTEL python SDK for metrics

Describe alternatives you've considered

No response

Additional Context

Slack

Would you like to implement a fix?

None

pavolloffay avatar Apr 02 '25 14:04 pavolloffay

Support multi process mode in the OTEL python SDK for metrics

It sounds like you want to continue using Prometheus exporter/being scraped, is that right?

If sending OTLP to the prometheus server is an option for you (push), you can add a unique identifier to the service.instance.id to identify each process.

aabmass avatar Apr 02 '25 16:04 aabmass

The use case we solve with the Multiprocess Mode is to avoid reporting duplicated metrics by each process. The registry reports a single metric from multiple processes.

pavolloffay avatar Apr 03 '25 09:04 pavolloffay

If you're using the Prometheus exporter, it is not supported today https://github.com/open-telemetry/opentelemetry-python/issues/3747

What I mentioned above is your best option today. There are several issues in the backlog already for improving this with push metrics e.g. https://github.com/open-telemetry/opentelemetry-python/issues/3307.

aabmass avatar Apr 03 '25 15:04 aabmass

Thanks for the confirmation. We required prometheus exporter.

If sending OTLP to the prometheus server is an option for you (push), you can add a unique identifier to the service.instance.id to identify each process.

In case of OTLP exporter, can the SDK aggregate metrics from multiple processes like the prometheus client multiprocess/ feature?

pavolloffay avatar Apr 09 '25 08:04 pavolloffay