Skip to main content

A Prometheus exporter for Python concurrent.futures executors

Project description

executor-exporter

codecov CI

A Prometheus metrics exporter for Python concurrent.futures executors. Provides instrumented drop-in replacements for ThreadedPoolExecutor and ProcessPoolExecutor.

water level ruler photo

Public domain photo by Patsy Lynch. More info

Install it from PyPI

pip install executor-exporter

Usage

from executor_exporter import ThreadPoolExecutor
# or
from executor_exporter import ProcessPoolExecutor

If you stick to the public APIs of concurrent.future executors (consisting of __init__, submit, map and shutdown methods), you just need to replace the builtin executor with its instrumented version provided by this package.

The provided executors act as proxies for the builtin executor while collecting the following metrics:

The __init__ methods of the instrumented executors take an additional exporter_id : Optional[str] parameter, used as the value for exporter metric label. If your use multiple executor instances of the same type you can measure them separately by defining a unique id for each instance. Conversely, by using the same id across multiple instances their metrics will be combined and exported as if they came from a single instance.

Custom executors

The instrumented executors are just wrappers around the builtin executors provided for convenience, while InstrumentedExecutorProxy does the heavy-lifting. If you're using a custom executor, you can wrap it like this:

from executor_exporter import InstrumentedExecutorProxy, ExecutorExporter

max_workers = 42
executor = YourCustomExecutor(max_workers)
exporter = ExecutorExporter(executor)

instrumented_executor = InstrumentedExecutorProxy(executor, exporter, max_workers)

TODO

  • Testing
  • Housekeeping
    • Makefile
    • metrics table gen
  • CI/CD
  • codecov

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

executor-exporter-0.1.2.tar.gz (8.5 kB view hashes)

Uploaded Source

Built Distribution

executor_exporter-0.1.2-py3-none-any.whl (9.5 kB view hashes)

Uploaded Python 3

Supported by

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