Skip to main content

Workaround to use prometheus_client multiprocess mode (for e.g. gunicorn, celery) with opentelemetry, where this model currently is not supported, and not even employing an additional otel collector currently solves this.

This package provides a customized MeterProvider, that uses the native prometheus_client metrics implementations, and thus their mechanisms for exporting/exposition (and not the opentelemetry ones).

Usage

  • See Multiprocess Mode Documentation for details on how to operate this.

  • Set environment variable PROMETHEUS_MULTIPROC_DIR to a directory where prometheus_client can store its metrics state files (that are shared between processes via mmap).

  • Configure opentelemetry meter provider:

    from opentelemetry.sdk.extension.prometheus_multiprocess import PrometheusMeterProvider
    import opentelemetry.metrics
    
    provider = PrometheusMeterProvider()
    opentelemetry.metrics.set_meter_provider(provider)
  • Set up prometheus metrics exposition, for example:

    registry = prometheus_client.CollectorRegistry()
    prometheus_client.multiprocess.MultiProcessCollector(registry)
    prometheus_client.start_http_server(8080, registry=registry)

    (The package also provides a MultiProcessRegistry to streamline this setup.)

  • Use opentelemetry metrics like normal:

    meter = opentelemetry.metrics.get_meter('mypackage', 'myversion')
    HTTP_DURATION = metrics.create_histogram('http.client.duration', unit='ms')
    
    from timeit import default_timer
    start = default_timer()
    # perform request here
    duration = (default_timer() - start) * 1000
    HTTP_DURATION.record(duration, {'http.response.status_code': 200})

Changelog

opentelemetry-sdk-extension-prometheus-multiprocess 1.4.0 (2026-04-17)

Changes

  • Prevent unbounded growth of label consistency check state (labels)

opentelemetry-sdk-extension-prometheus-multiprocess 1.3.0 (2026-04-13)

Changes

  • Ignore otel sdk internal metrics, they use async/observable collection, which we do not support (otel)

1.2.3 (2025-02-06)

Changes

  • More updates to otel 1.30 API (otel)

1.2.2 (2025-02-05)

Changes

  • More updates to otel 1.30 API (otel)

1.2.1 (2025-02-05)

Changes

  • Update to otel 1.30 API (otel)

1.2.0 (2024-12-20)

Changes

  • Support seconds as well as milliseconds in histogram buckets (histogram)

1.1.2 (2024-11-07)

Changes

  • otel: Update to otel 1.28 API (otel)

1.1.1 (2024-11-07)

Changes

  • Accept kw to make otel API forward-compatible (fwcompat)

1.1.0 (2024-06-25)

Changes

  • naming: Conform to prometheus metric name and unit conventions (naming)

1.0.0 (2024-04-26)

Changes

  • Initial release (initial)

Metadata

Release files for opentelemetry-sdk-extension-prometheus-multiprocess 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opentelemetry-sdk-extension-prometheus-multiprocess 1.4.0
File Size Uploaded Provenance Actions
opentelemetry_sdk_extension_prometheus_multiprocess-1.4.0.tar.gz 13.8 kB Without provenance Details for opentelemetry_sdk_extension_prometheus_multiprocess-1.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for opentelemetry-sdk-extension-prometheus-multiprocess 1.4.0
File Interpreter ABI Platform Actions
opentelemetry_sdk_extension_prometheus_multiprocess-1.4.0-py2.py3-none-any.whl Python 2, Python 3 none any Details for opentelemetry_sdk_extension_prometheus_multiprocess-1.4.0-py2.py3-none-any.whl

Total release size: 19.8 kB

Release files / opentelemetry_sdk_extension_prometheus_multiprocess-1.4.0.tar.gz

Download URL opentelemetry_sdk_extension_prometheus_multiprocess-1.4.0.tar.gz
Size 13.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6391112463ce013e25d96609f70f66dbca9bf1e6780c3fcca443cf872363d750
BLAKE2b-256 checksum
How to use checksums
b5c1e0fda37ef482e6b5ff8c7b4323e622f1c138ec6f0b3ea3a08713fd05428e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / opentelemetry_sdk_extension_prometheus_multiprocess-1.4.0-py2.py3-none-any.whl

Download URL opentelemetry_sdk_extension_prometheus_multiprocess-1.4.0-py2.py3-none-any.whl
Size 6.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
1d533986db701b499a38520d08240551d4772a5cf307df9c57efbb55479dd70b
BLAKE2b-256 checksum
How to use checksums
a3eefcb3e720cd1ffde513c51787f8afbb77c23d38aac4a5b20059822121efb9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for opentelemetry-sdk-extension-prometheus-multiprocess 1.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page