package documentation

OpenTelemetry integration for Temporal workers running on Google Cloud Run.

This package is designed for container-based Cloud Run workers, especially worker pools, and exports telemetry to an OpenTelemetry collector sidecar by default.

Warning

This package is experimental and may change in future versions. Use with caution in production environments.

Module _opentelemetry OpenTelemetry plugin with Google Cloud Run defaults.

From __init__.py:

Class OpenTelemetryPlugin OpenTelemetry plugin for Temporal workers running on Google Cloud Run.
Function build_metrics_telemetry_config Build Temporal Core telemetry with Google Cloud Run defaults.
Constant CLOUD_RUN_SERVICE_ENV_VAR Cloud Run environment variable containing the service name.
Constant CLOUD_RUN_WORKER_POOL_ENV_VAR Cloud Run environment variable containing the worker-pool name.
Constant DEFAULT_FLUSH_TIMEOUT Default timeout for tracing force-flush operations.
Constant DEFAULT_METRIC_PERIODICITY Default interval between Temporal Core metric exports.
Constant DEFAULT_OTLP_ENDPOINT Default local OTLP gRPC collector endpoint.
Constant DEFAULT_SERVICE_NAME Service name used outside a recognized Cloud Run environment.
Constant OTEL_EXPORTER_OTLP_ENDPOINT_ENV_VAR Standard OpenTelemetry environment variable for the common OTLP endpoint.
Constant OTEL_SERVICE_NAME_ENV_VAR Standard OpenTelemetry environment variable for service.name.
def build_metrics_telemetry_config(*, endpoint: str | None = None, service_name: str | None = None, metric_periodicity: timedelta | None = None) -> TelemetryConfig: (source)

Build Temporal Core telemetry with Google Cloud Run defaults.

This helper is useful when the application needs to customize runtime logging or other telemetry settings before constructing a temporalio.runtime.Runtime.

Parameters
endpoint:str | NoneOTLP gRPC endpoint, with the same resolution order as OpenTelemetryPlugin.
service_name:str | NoneService name, with the same resolution order as OpenTelemetryPlugin.
metric_periodicity:timedelta | NoneMetric export interval. Defaults to 60 seconds.
Returns
TelemetryConfigTelemetry configuration ready for a Temporal runtime.
CLOUD_RUN_SERVICE_ENV_VAR: str = (source)

Cloud Run environment variable containing the service name.

Value
'K_SERVICE'
CLOUD_RUN_WORKER_POOL_ENV_VAR: str = (source)

Cloud Run environment variable containing the worker-pool name.

Value
'CLOUD_RUN_WORKER_POOL'
DEFAULT_FLUSH_TIMEOUT = (source)

Default timeout for tracing force-flush operations.

Value
timedelta(seconds=10)
DEFAULT_METRIC_PERIODICITY = (source)

Default interval between Temporal Core metric exports.

Value
timedelta(seconds=60)
DEFAULT_OTLP_ENDPOINT: str = (source)

Default local OTLP gRPC collector endpoint.

Value
'http://localhost:4317'
DEFAULT_SERVICE_NAME: str = (source)

Service name used outside a recognized Cloud Run environment.

Value
'temporal-worker'
OTEL_EXPORTER_OTLP_ENDPOINT_ENV_VAR: str = (source)

Standard OpenTelemetry environment variable for the common OTLP endpoint.

Value
'OTEL_EXPORTER_OTLP_ENDPOINT'
OTEL_SERVICE_NAME_ENV_VAR: str = (source)

Standard OpenTelemetry environment variable for service.name.

Value
'OTEL_SERVICE_NAME'