From 5b4124948fd57e1a53be4fa3431b3dafb41fbb37 Mon Sep 17 00:00:00 2001 From: Parth Jindal Date: Sun, 12 Apr 2026 11:52:41 +0530 Subject: [PATCH] Expose histogram_bucket_overrides on OpenTelemetryConfig Mirror the existing PrometheusConfig.histogram_bucket_overrides field. The underlying OtelCollectorOptions builder already supports this via maybe_histogram_bucket_overrides; this change wires it through the Python wrapper and pyo3 bridge. --- temporalio/bridge/runtime.py | 1 + temporalio/bridge/src/runtime.rs | 6 ++++++ temporalio/runtime.py | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/temporalio/bridge/runtime.py b/temporalio/bridge/runtime.py index fa7fb275d..87f03f9c3 100644 --- a/temporalio/bridge/runtime.py +++ b/temporalio/bridge/runtime.py @@ -71,6 +71,7 @@ class OpenTelemetryConfig: metric_temporality_delta: bool durations_as_seconds: bool http: bool + histogram_bucket_overrides: Mapping[str, Sequence[float]] | None = None @dataclass(frozen=True) diff --git a/temporalio/bridge/src/runtime.rs b/temporalio/bridge/src/runtime.rs index 94cf5a025..ef47317ef 100644 --- a/temporalio/bridge/src/runtime.rs +++ b/temporalio/bridge/src/runtime.rs @@ -75,6 +75,7 @@ pub struct OpenTelemetryConfig { metric_temporality_delta: bool, durations_as_seconds: bool, http: bool, + histogram_bucket_overrides: Option>>, } #[derive(FromPyObject)] @@ -357,6 +358,11 @@ impl TryFrom for Arc { } else { None }) + .maybe_histogram_bucket_overrides(otel_conf.histogram_bucket_overrides.map( + |overrides| temporalio_common::telemetry::HistogramBucketOverrides { + overrides, + }, + )) .build(); Ok(Arc::new(build_otlp_metric_exporter(otel_options).map_err( |err| PyValueError::new_err(format!("Failed building OTel exporter: {err}")), diff --git a/temporalio/runtime.py b/temporalio/runtime.py index 8fab68e9e..3043372c3 100644 --- a/temporalio/runtime.py +++ b/temporalio/runtime.py @@ -335,6 +335,10 @@ class OpenTelemetryConfig: When enabled, the ``url`` should point to the HTTP endpoint (e.g. ``"http://localhost:4318/v1/metrics"``). Defaults to ``False`` (gRPC). + histogram_bucket_overrides: Override the default histogram bucket + boundaries for specific metrics. Keys are metric names and + values are sequences of bucket boundaries (e.g. + ``{"workflow_task_schedule_to_start_latency": [0.01, 0.05, 0.1, 0.5, 1.0, 5.0]}``). """ url: str @@ -345,6 +349,7 @@ class OpenTelemetryConfig: ) durations_as_seconds: bool = False http: bool = False + histogram_bucket_overrides: Mapping[str, Sequence[float]] | None = None def _to_bridge_config(self) -> temporalio.bridge.runtime.OpenTelemetryConfig: return temporalio.bridge.runtime.OpenTelemetryConfig( @@ -360,6 +365,7 @@ def _to_bridge_config(self) -> temporalio.bridge.runtime.OpenTelemetryConfig: ), durations_as_seconds=self.durations_as_seconds, http=self.http, + histogram_bucket_overrides=self.histogram_bucket_overrides, )