Skip to content

Commit 5b41249

Browse files
committed
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.
1 parent 79a140b commit 5b41249

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

temporalio/bridge/runtime.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class OpenTelemetryConfig:
7171
metric_temporality_delta: bool
7272
durations_as_seconds: bool
7373
http: bool
74+
histogram_bucket_overrides: Mapping[str, Sequence[float]] | None = None
7475

7576

7677
@dataclass(frozen=True)

temporalio/bridge/src/runtime.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ pub struct OpenTelemetryConfig {
7575
metric_temporality_delta: bool,
7676
durations_as_seconds: bool,
7777
http: bool,
78+
histogram_bucket_overrides: Option<HashMap<String, Vec<f64>>>,
7879
}
7980

8081
#[derive(FromPyObject)]
@@ -357,6 +358,11 @@ impl TryFrom<MetricsConfig> for Arc<dyn CoreMeter> {
357358
} else {
358359
None
359360
})
361+
.maybe_histogram_bucket_overrides(otel_conf.histogram_bucket_overrides.map(
362+
|overrides| temporalio_common::telemetry::HistogramBucketOverrides {
363+
overrides,
364+
},
365+
))
360366
.build();
361367
Ok(Arc::new(build_otlp_metric_exporter(otel_options).map_err(
362368
|err| PyValueError::new_err(format!("Failed building OTel exporter: {err}")),

temporalio/runtime.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,10 @@ class OpenTelemetryConfig:
335335
When enabled, the ``url`` should point to the HTTP endpoint
336336
(e.g. ``"http://localhost:4318/v1/metrics"``).
337337
Defaults to ``False`` (gRPC).
338+
histogram_bucket_overrides: Override the default histogram bucket
339+
boundaries for specific metrics. Keys are metric names and
340+
values are sequences of bucket boundaries (e.g.
341+
``{"workflow_task_schedule_to_start_latency": [0.01, 0.05, 0.1, 0.5, 1.0, 5.0]}``).
338342
"""
339343

340344
url: str
@@ -345,6 +349,7 @@ class OpenTelemetryConfig:
345349
)
346350
durations_as_seconds: bool = False
347351
http: bool = False
352+
histogram_bucket_overrides: Mapping[str, Sequence[float]] | None = None
348353

349354
def _to_bridge_config(self) -> temporalio.bridge.runtime.OpenTelemetryConfig:
350355
return temporalio.bridge.runtime.OpenTelemetryConfig(
@@ -360,6 +365,7 @@ def _to_bridge_config(self) -> temporalio.bridge.runtime.OpenTelemetryConfig:
360365
),
361366
durations_as_seconds=self.durations_as_seconds,
362367
http=self.http,
368+
histogram_bucket_overrides=self.histogram_bucket_overrides,
363369
)
364370

365371

0 commit comments

Comments
 (0)