class OpenTelemetryPlugin(TemporalOpenTelemetryPlugin): (source)
Constructor: OpenTelemetryPlugin(endpoint, service_name, metric_periodicity, flush_timeout, ...)
OpenTelemetry plugin for Temporal workers running on Google Cloud Run.
The default configuration sends Temporal Core metrics and Python traces over OTLP gRPC to a collector on localhost:4317. The collector is responsible for Google Cloud resource detection, authentication, and export.
The plugin creates and installs a replay-safe global tracer provider unless
tracer_provider is supplied. It also creates a Temporal runtime for Core
metrics unless runtime is supplied. Call shutdown after every
worker using the plugin has stopped.
Warning
This class is experimental and may change in future versions. Use with caution in production environments.
| Method | __init__ |
Initialize the Google Cloud OpenTelemetry plugin. |
| Async Method | connect |
Install the metrics runtime before connecting the service client. |
| Method | force |
Export buffered Python traces without shutting down the provider. |
| Async Method | run |
Run a worker and optionally force-flush traces after it stops. |
| Method | shutdown |
Flush traces and shut down a provider created by the plugin. |
| Property | endpoint |
Resolved OTLP collector endpoint. |
| Property | runtime |
Temporal runtime used for Core metrics. |
| Property | service |
Resolved OpenTelemetry service name. |
| Property | tracer |
Replay-safe tracer provider used by the plugin. |
| Instance Variable | _endpoint |
Undocumented |
| Instance Variable | _flush |
Undocumented |
| Instance Variable | _flush |
Undocumented |
| Instance Variable | _owns |
Undocumented |
| Instance Variable | _runtime |
Undocumented |
| Instance Variable | _service |
Undocumented |
| Instance Variable | _shutdown |
Undocumented |
| Instance Variable | _shutdown |
Undocumented |
| Instance Variable | _shutdown |
Undocumented |
| Instance Variable | _tracer |
Undocumented |
Inherited from SimplePlugin (via OpenTelemetryPlugin):
| Method | configure |
See base class. |
| Method | configure |
See base class. |
| Method | configure |
See base class. |
| Method | name |
See base class. |
| Async Method | run |
See base class. |
| Instance Variable | activities |
Undocumented |
| Instance Variable | data |
Undocumented |
| Instance Variable | interceptors |
Undocumented |
| Instance Variable | nexus |
Undocumented |
| Instance Variable | run |
Undocumented |
| Instance Variable | workflow |
Undocumented |
| Instance Variable | workflow |
Undocumented |
| Instance Variable | workflows |
Undocumented |
| Instance Variable | _name |
Undocumented |
str | None = None, service_name: str | None = None, metric_periodicity: timedelta | None = None, flush_timeout: timedelta = DEFAULT_FLUSH_TIMEOUT, flush_on_worker_stop: bool = False, tracer_provider: TracerProvider | None = None, runtime: Runtime | None = None, add_temporal_spans: bool = False):
(source)
¶
Initialize the Google Cloud OpenTelemetry plugin.
| Parameters | |
endpoint:str | None | OTLP gRPC endpoint. Falls back to OTEL_EXPORTER_OTLP_ENDPOINT, then http://localhost:4317. |
servicestr | None | OpenTelemetry service name. Falls back to OTEL_SERVICE_NAME, CLOUD_RUN_WORKER_POOL, K_SERVICE, then temporal-worker. |
metrictimedelta | None | How often Temporal Core metrics are exported. Defaults to 60 seconds. Cannot be used with runtime. |
flushtimedelta | Default tracing force-flush timeout. |
flushbool | Whether to force-flush traces after each worker stops. Disabled by default because one plugin can be used by multiple workers. |
tracerTracerProvider | None | Application-owned replay-safe tracer provider. It
must have been created with
temporalio.contrib.opentelemetry.create_tracer_provider.
When supplied, the plugin does not create an exporter or shut
down the provider. |
runtime:Runtime | None | Application-owned Temporal runtime. When supplied, the
plugin does not create or modify Core metrics configuration. Use
build_metrics_telemetry_config to build a composable
telemetry configuration for a custom runtime. |
addbool | Whether the underlying Temporal OpenTelemetry plugin should add Temporal-specific operation spans. |
ConnectConfig, next: Callable[ [ ConnectConfig], Awaitable[ ServiceClient]]) -> ServiceClient:
(source)
¶
Install the metrics runtime before connecting the service client.
Export buffered Python traces without shutting down the provider.
Temporal Core metrics are exported periodically and the Python runtime currently has no explicit metrics-flush API.
| Parameters | |
timeout:timedelta | None | Maximum time to wait. Defaults to flush_timeout from the constructor. |
| Returns | |
bool | True when the tracer provider reports a successful flush. |
Flush traces and shut down a provider created by the plugin.
Application-owned tracer providers are force-flushed but are not shut down. This method is idempotent. Stop every worker using the plugin before calling it.
| Parameters | |
timeout:timedelta | None | Maximum time allowed for the tracing force-flush. Provider shutdown happens after that flush. |
| Returns | |
bool | True when the tracing force-flush succeeded. |