fix(otlp): span exporter now inherits configured resource_attributes
_resource_attributes() in otlp_exporter.py built its own hardcoded resource dict (service.name/instance.id/telemetry.scope only) instead of reusing gateway_health_export.py's _runtime_resource_attributes(), which already applies the resource_attributes allowlist from config. Result: operator-configured attributes like deployment.environment.name reached metrics and diagnostic logs but never spans. Span resource building now delegates to the same _runtime_resource_attributes() helper metrics/logs already use, removing the duplicate implementation instead of patching it in place.
This commit is contained in:
@@ -116,14 +116,12 @@ def build_exporter(config: Dict[str, Any]):
|
||||
|
||||
|
||||
def _resource_attributes(config: Dict[str, Any]) -> Dict[str, str]:
|
||||
from agent.monitoring.gateway_health import _safe_instance_id
|
||||
from agent.monitoring.policy import ensure_install_id
|
||||
# Lazy import: gateway_health_export imports this module back (for
|
||||
# start_streaming), so the dependency must resolve at call time, not
|
||||
# at module load, to avoid a circular import.
|
||||
from agent.monitoring.gateway_health_export import _runtime_resource_attributes
|
||||
|
||||
return {
|
||||
"service.name": "hermes-gateway",
|
||||
"service.instance.id": _safe_instance_id(ensure_install_id(config)),
|
||||
"telemetry.scope": "gateway_monitoring",
|
||||
}
|
||||
return _runtime_resource_attributes(config, telemetry_scope="gateway_monitoring")
|
||||
|
||||
|
||||
def _make_provider(config: Dict[str, Any]):
|
||||
|
||||
@@ -66,6 +66,20 @@ def test_trace_resource_includes_stable_hashed_instance():
|
||||
assert attrs["telemetry.scope"] == "gateway_monitoring"
|
||||
|
||||
|
||||
def test_trace_resource_includes_configured_deployment_environment():
|
||||
attrs = OE._resource_attributes({
|
||||
"monitoring": {
|
||||
"install_id": "private-install-id",
|
||||
"gateway_health_export": {
|
||||
"resource_attributes": {"deployment.environment.name": "production"},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
assert attrs["deployment.environment.name"] == "production"
|
||||
assert attrs["service.name"] == "hermes-gateway"
|
||||
|
||||
|
||||
|
||||
|
||||
def test_streamer_receives_events_and_respects_filter(monkeypatch):
|
||||
|
||||
Reference in New Issue
Block a user