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.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.3.0.tar.gz.

File metadata

  • Download URL: opentelemetry_sdk_extension_prometheus_multiprocess-1.3.0.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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.3.0.tar.gz
Algorithm Hash digest
SHA256 01885e05b7aa494efaad4330550c6021a2b5ce7772b3e1eb1aa524786b8edd02
MD5 73b46b28ee5e05671865cc9fff2778cd
BLAKE2b-256 bb59e537561356ff64dbfd5fa44d1839e6f1a82a4cb8bff5da358329728c5f7e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: opentelemetry_sdk_extension_prometheus_multiprocess-1.3.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 867902da2b439acbe52d4d7582f8df8bc9dc3db2061d50c8d7947edcdb3948dc
MD5 f2f315b9c91eee6398816cb47ed4bf5f
BLAKE2b-256 894d6db56adfeaae9da57519419bb492e4a396d8bc028475bd05d8475ed71d32

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