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

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

File metadata

File hashes

Hashes for opentelemetry_sdk_extension_prometheus_multiprocess-1.2.3.tar.gz
Algorithm Hash digest
SHA256 53b3f9f10fee6acd7189c868324669156ca2324ad9c652b6b2418571413d60ca
MD5 ca3926c63a9b2d7fc3906fbb0cd9164b
BLAKE2b-256 25b05a8e9e4d9810bb18c33b7f247d115fde08b8dd9a19921f81471292b85969

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opentelemetry_sdk_extension_prometheus_multiprocess-1.2.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7cb55377a3c6cb9145712437da847e163df2452ecd67303885002954d2ba4cbf
MD5 d59f0ee87fe69841a30507f3b380d066
BLAKE2b-256 067cf3e2bc5a89fbaaf5c36254e6e3147da58dea975af5299af4cc4d44200b64

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