documentation
documentation copied to clipboard
[Observability] Metrics is missing in Python
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.
(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")))
@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)