[.Net][ADR] OTel auto-instrumentation proposal#5971
Open
rogerbarreto wants to merge 2 commits into
Open
Conversation
Big OTel rock. Tribe pattern say AddXxxInstrumentation() on provider, kill switch env var. Agent Framework miss. ADR 0026 land options + decision. Recommended: embed extensions in core assemblies. AddAgentFrameworkInstrumentation() on TracerProviderBuilder + MeterProviderBuilder. Dep small: OpenTelemetry.Api.ProviderBuilderExtensions only, 2 net-new transitive packages. AsAIAgent() factories auto-wrap via IServiceProvider param when AgentFrameworkInstrumentationOptions registered. Workflow.AsAIAgent() join same. Workflow internal spans still opt-in via WorkflowBuilder.WithOpenTelemetry(). Kill switch: OTEL_DOTNET_AGENTFRAMEWORK_INSTRUMENTATION_ENABLED. Multi-call: last-wins. ADR-0003 not superseded. Source-naming questions deferred to follow-on ADR. Refs microsoft#5852
Contributor
There was a problem hiding this comment.
Pull request overview
Adds ADR 0026 proposing convention-aligned OpenTelemetry “auto-instrumentation” activation for the .NET Agent Framework (provider-builder AddXxxInstrumentation() entrypoints + DI-aware AsAIAgent() wrapping + env-var kill switch). This is documentation-only and is intended to set direction before implementation work begins.
Changes:
- Introduces a new ADR describing provider-builder activation APIs for agent + workflow telemetry.
- Proposes DI-driven auto-wrapping behavior for
AsAIAgent()factories and an env-var kill switch. - Outlines validation/testing expectations and open packaging questions (keep OTel primitives in-core vs move to dedicated packages).
Comments suppressed due to low confidence (1)
docs/decisions/0026-agent-otel-auto-instrumentation.md:139
- In Consequences, “Adds optional
IServiceProvider? services = nullto everyAsAIAgent()overload” reads as if this parameter is universally new. In practice, several providers already have aservicesparameter today, while a few (e.g., A2A / Copilot) do not. Suggest clarifying the impact as “addsservicesto the remainingAsAIAgentoverloads that lack it” and optionally call out representative examples, so the scope/cost is accurately represented.
- **Bad:** Adds optional `IServiceProvider? services = null` to every
`AsAIAgent()` overload across ~10–15 provider packages.
Source-compatible + binary-compatible. Coordinated release needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
ADR 0026 propose convention-aligned OTel auto-instrumentation for Agent Framework. No code change. Only doc.
Why
Today: per-agent
UseOpenTelemetry()wrap. Diverge from .NET OTel ecosystem (AddXxxInstrumentation()on provider). No kill switch.AsAIAgent()factories unreachable by DI wrap.What ADR propose
AddAgentFrameworkInstrumentation()on TracerProviderBuilder + MeterProviderBuilderAddAgentFrameworkWorkflowsInstrumentation()for workflows sourceOpenTelemetry.Api.ProviderBuilderExtensions, 2 net-new transitiveAgentFrameworkInstrumentationOptions= full parity withUseOpenTelemetry()(SourceName + ConfigureAgent)AsAIAgent()factories gain optionalIServiceProvider? servicesparam. Auto-wrap when options registered. Idempotent.Workflow.AsAIAgent()join same pattern (agents marker)OTEL_DOTNET_AGENTFRAMEWORK_INSTRUMENTATION_ENABLEDUseOpenTelemetry()+OpenTelemetryAgentunchanged. ADR-0003 not superseded.Open question for reviewer
Existing
OpenTelemetryAgent,UseOpenTelemetry(),OpenTelemetryConsts:Microsoft.Agents.AI.OpenTelemetry+Microsoft.Agents.AI.Workflows.OpenTelemetrypackages (breaking)Out of scope (deferred)
Experimental.prefix removal (gated on upstream gen-AI semconv stable)Refs