Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions temporalio/bridge/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions temporalio/bridge/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ pub struct OpenTelemetryConfig {
metric_temporality_delta: bool,
durations_as_seconds: bool,
http: bool,
histogram_bucket_overrides: Option<HashMap<String, Vec<f64>>>,
}

#[derive(FromPyObject)]
Expand Down Expand Up @@ -357,6 +358,11 @@ impl TryFrom<MetricsConfig> for Arc<dyn CoreMeter> {
} 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}")),
Expand Down
6 changes: 6 additions & 0 deletions temporalio/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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,
)


Expand Down