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 @@ -73,3 +73,4 @@ class TelemetryConfig:
tracing: Optional[TracingConfig]
logging: Optional[LoggingConfig]
metrics: Optional[MetricsConfig]
global_tags: Mapping[str, str]
4 changes: 4 additions & 0 deletions temporalio/bridge/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub struct TelemetryConfig {
tracing: Option<TracingConfig>,
logging: Option<LoggingConfig>,
metrics: Option<MetricsConfig>,
global_tags: Option<HashMap<String, String>>
}

#[derive(FromPyObject)]
Expand Down Expand Up @@ -129,6 +130,9 @@ impl TryFrom<TelemetryConfig> for TelemetryOptions {
));
});
}
if let Some(v) = conf.global_tags {
build.global_tags(v);
}
build
.build()
.map_err(|err| PyValueError::new_err(format!("Invalid telemetry config: {}", err)))
Expand Down
6 changes: 5 additions & 1 deletion temporalio/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from __future__ import annotations

from dataclasses import dataclass
from dataclasses import dataclass, field
from datetime import timedelta
from typing import ClassVar, Mapping, Optional, Union

Expand Down Expand Up @@ -175,6 +175,9 @@ class TelemetryConfig:
metrics: Optional[Union[OpenTelemetryConfig, PrometheusConfig]] = None
"""Metrics configuration."""

global_tags: Mapping[str, str] = field(default_factory=dict)
Copy link
Member

Choose a reason for hiding this comment

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

Are these tags applied to metrics and tracing? Does that include Prometheus metrics and OTel tracing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes to all of the above.
I did not test prometheus myself (as we don't use it) but I do pass these through to the initializer

Copy link
Member

Choose a reason for hiding this comment

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

Oh, just realized. Can we at least add one line of docs here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

"""OTel resource tags to be applied to all metrics and traces"""

def _to_bridge_config(self) -> temporalio.bridge.runtime.TelemetryConfig:
return temporalio.bridge.runtime.TelemetryConfig(
tracing=None if not self.tracing else self.tracing._to_bridge_config(),
Expand All @@ -189,4 +192,5 @@ def _to_bridge_config(self) -> temporalio.bridge.runtime.TelemetryConfig:
if not isinstance(self.metrics, PrometheusConfig)
else self.metrics._to_bridge_config(),
),
global_tags=self.global_tags,
)