Skip to main content

No project description provided

Project description

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file opentelemetry_sdk_extension_prometheus_multiprocess-1.4.0.tar.gz.

File metadata

  • Download URL: opentelemetry_sdk_extension_prometheus_multiprocess-1.4.0.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for opentelemetry_sdk_extension_prometheus_multiprocess-1.4.0.tar.gz
Algorithm Hash digest
SHA256 6391112463ce013e25d96609f70f66dbca9bf1e6780c3fcca443cf872363d750
MD5 a27cc3a43f087df5753de96a674402b1
BLAKE2b-256 b5c1e0fda37ef482e6b5ff8c7b4323e622f1c138ec6f0b3ea3a08713fd05428e

See more details on using hashes here.

File details

Details for the file opentelemetry_sdk_extension_prometheus_multiprocess-1.4.0-py2.py3-none-any.whl.

File metadata

  • Download URL: opentelemetry_sdk_extension_prometheus_multiprocess-1.4.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using 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}

File hashes

Hashes for opentelemetry_sdk_extension_prometheus_multiprocess-1.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1d533986db701b499a38520d08240551d4772a5cf307df9c57efbb55479dd70b
MD5 18f7a0d9f1796d180cc6cb78c8d84430
BLAKE2b-256 a3eefcb3e720cd1ffde513c51787f8afbb77c23d38aac4a5b20059822121efb9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page