documentation icon indicating copy to clipboard operation
documentation copied to clipboard

[Observability] Metrics is missing in Python

Open rachfop opened this issue 3 years ago • 1 comments

Metrics is missing is Python


You can provide a code snippet in the comments or a link to the line numbers of the samples-repo. Once added, I'll update the app-dev page with the new code snippet.

rachfop avatar Aug 18 '22 20:08 rachfop

(this may change and is experimental for now, ref https://github.com/temporalio/sdk-python/issues/125)

Currently, metrics are configured globally be setting a Prometheus endpoint before any other Temporal code is used. To expose a Prometheus endpoint on port 9000:

from temporalio.bridge.telemetry import init_telemetry, TelemetryConfig, PrometheusMetricsConfig

init_telemetry(TelemetryConfig(prometheus_metrics=PrometheusMetricsConfig(bind_address="0.0.0.0:9000")))

cretz avatar Sep 02 '22 14:09 cretz

@rachfop - This just changed in Python 1.0.0 release to be:

from temporalio.runtime import Runtime, TelemetryConfig, PrometheusConfig

# Create a new runtime that has telemetry enabled. Create this first to avoid
# the default Runtime from being lazily created.
new_runtime = Runtime(telemetry=TelemetryConfig(metrics=PrometheusConfig(bind_address="0.0.0.0:9000")))
my_client = await Client.connect("my.temporal.host:7233", runtime=new_runtime)

cretz avatar Jan 05 '23 20:01 cretz