Skip to content
Merged
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 @@ -69,6 +69,7 @@ class OpenTelemetryConfig:
metric_periodicity_millis: Optional[int]
metric_temporality_delta: bool
durations_as_seconds: bool
http: bool


@dataclass(frozen=True)
Expand Down
6 changes: 5 additions & 1 deletion temporalio/bridge/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use temporal_sdk_core::{CoreRuntime, TokioRuntimeBuilder};
use temporal_sdk_core_api::telemetry::metrics::{CoreMeter, MetricCallBufferer};
use temporal_sdk_core_api::telemetry::{
CoreLog, Logger, MetricTemporality, OtelCollectorOptionsBuilder,
PrometheusExporterOptionsBuilder, TelemetryOptionsBuilder,
PrometheusExporterOptionsBuilder, TelemetryOptionsBuilder, OtlpProtocol
};
use tokio::task::JoinHandle;
use tokio_stream::StreamExt;
Expand Down Expand Up @@ -74,6 +74,7 @@ pub struct OpenTelemetryConfig {
metric_periodicity_millis: Option<u64>,
metric_temporality_delta: bool,
durations_as_seconds: bool,
http: bool,
}

#[derive(FromPyObject)]
Expand Down Expand Up @@ -322,6 +323,9 @@ impl TryFrom<MetricsConfig> for Arc<dyn CoreMeter> {
if let Some(global_tags) = conf.global_tags {
build.global_tags(global_tags);
}
if otel_conf.http {
build.protocol(OtlpProtocol::Http);
}
let otel_options = build
.build()
.map_err(|err| PyValueError::new_err(format!("Invalid OTel config: {}", err)))?;
Expand Down
15 changes: 10 additions & 5 deletions temporalio/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,22 @@ class OpenTelemetryConfig:
OpenTelemetryMetricTemporality.CUMULATIVE
)
durations_as_seconds: bool = False
http: bool = False

def _to_bridge_config(self) -> temporalio.bridge.runtime.OpenTelemetryConfig:
return temporalio.bridge.runtime.OpenTelemetryConfig(
url=self.url,
headers=self.headers or {},
metric_periodicity_millis=None
if not self.metric_periodicity
else round(self.metric_periodicity.total_seconds() * 1000),
metric_temporality_delta=self.metric_temporality
== OpenTelemetryMetricTemporality.DELTA,
metric_periodicity_millis=(
None
if not self.metric_periodicity
else round(self.metric_periodicity.total_seconds() * 1000)
),
metric_temporality_delta=(
self.metric_temporality == OpenTelemetryMetricTemporality.DELTA
),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️ just prettifying the formatting

durations_as_seconds=self.durations_as_seconds,
http=self.http,
)


Expand Down
Loading