The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(otlp): span exporter now inherits configured resource_attributes
joaomarcos628372de4696
diff --git a/agent/monitoring/otlp_exporter.py b/agent/monitoring/otlp_exporter.pyindex cde95673ec5..17c85cb8b6a 100644--- a/agent/monitoring/otlp_exporter.py+++ b/agent/monitoring/otlp_exporter.py@@ -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]):diff --git a/tests/monitoring/test_otlp_exporter.py b/tests/monitoring/test_otlp_exporter.pyindex eebaf48da90..5006b128bf2 100644--- a/tests/monitoring/test_otlp_exporter.py+++ b/tests/monitoring/test_otlp_exporter.py@@ -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):