From a217a7d4c779e8b3ccb65008a0d401aab35d5ab1 Mon Sep 17 00:00:00 2001 From: Radhika Gupta Date: Mon, 4 May 2026 13:00:54 -0700 Subject: [PATCH 1/2] Add the span and log record processors for multi-agent GENAI systems --- sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md | 2 ++ .../azure/monitor/opentelemetry/_configure.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md b/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md index 940554b92da4..180c0646a224 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md @@ -3,6 +3,8 @@ ## 1.8.8 (Unreleased) ### Features Added +- Register GenAI main-agent attribution processors to automatically propagate + `microsoft.gen_ai.main_agent.*` attributes in multi-agent GenAI systems per [spec](https://github.com/aep-health-and-standards/Telemetry-Collection-Spec/blob/main/ApplicationInsights/genai_main_agent_attribution.md) ### Breaking Changes diff --git a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py index 415b522509b5..1f98f2eabde8 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py +++ b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py @@ -59,6 +59,10 @@ _QuickpulseLogRecordProcessor, _QuickpulseSpanProcessor, ) +from azure.monitor.opentelemetry.exporter._gen_ai._processor import ( # pylint: disable=import-error,no-name-in-module + _GenAIMainAgentLogRecordProcessor, + _GenAIMainAgentSpanProcessor, +) from azure.monitor.opentelemetry.exporter import ( # pylint: disable=import-error,no-name-in-module ApplicationInsightsSampler, AzureMonitorMetricExporter, @@ -182,6 +186,8 @@ def _setup_tracing(configurations: Dict[str, ConfigurationValue]): sampler=RateLimitedSampler(target_spans_per_second_limit=cast(float, traces_per_second)), resource=resource ) + # GenAI main-agent attribution processor must be registered first + tracer_provider.add_span_processor(_GenAIMainAgentSpanProcessor()) for span_processor in configurations[SPAN_PROCESSORS_ARG]: # type: ignore tracer_provider.add_span_processor(span_processor) # type: ignore if configurations.get(ENABLE_LIVE_METRICS_ARG): @@ -235,6 +241,8 @@ def _setup_logging(configurations: Dict[str, ConfigurationValue]): enable_performance_counters_config = configurations[ENABLE_PERFORMANCE_COUNTERS_ARG] logger_provider = LoggerProvider(resource=resource) enable_trace_based_sampling_for_logs = configurations[ENABLE_TRACE_BASED_SAMPLING_ARG] + # GenAI main-agent attribution processor must be registered first + logger_provider.add_log_record_processor(_GenAIMainAgentLogRecordProcessor()) for custom_log_record_processor in configurations[LOG_RECORD_PROCESSORS_ARG]: # type: ignore logger_provider.add_log_record_processor(custom_log_record_processor) # type: ignore if configurations.get(ENABLE_LIVE_METRICS_ARG): From fc98fa944abdc561498ecaec60f1d95527c364a0 Mon Sep 17 00:00:00 2001 From: Radhika Gupta Date: Mon, 4 May 2026 13:02:18 -0700 Subject: [PATCH 2/2] Update CHANGELOG --- sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md b/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md index 180c0646a224..4c9204813b00 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md @@ -5,6 +5,7 @@ ### Features Added - Register GenAI main-agent attribution processors to automatically propagate `microsoft.gen_ai.main_agent.*` attributes in multi-agent GenAI systems per [spec](https://github.com/aep-health-and-standards/Telemetry-Collection-Spec/blob/main/ApplicationInsights/genai_main_agent_attribution.md) + ([#46703](https://github.com/Azure/azure-sdk-for-python/pull/46703)) ### Breaking Changes