.NET: expose OpenTelemetryAgent.DefaultSourceName - #7815
Open
Yashvant Mahadev Hange (YashvantHange) wants to merge 2 commits into
Open
.NET: expose OpenTelemetryAgent.DefaultSourceName#7815Yashvant Mahadev Hange (YashvantHange) wants to merge 2 commits into
Yashvant Mahadev Hange (YashvantHange) wants to merge 2 commits into
Conversation
The default ActivitySource name lives on the internal OpenTelemetryConsts class, so consumers cannot reference it when configuring a TracerProvider and must hardcode the literal "Experimental.Microsoft.Agents.AI" instead. ADR 0003 documents AgentOpenTelemetryConsts.DefaultSourceName for this, a type that no longer exists after the rename in microsoft#356. Expose the source name as a public const on OpenTelemetryAgent, the type that emits the spans, rather than making the whole constants class public. That keeps the gen_ai.* attribute keys internal, matching the Microsoft.Extensions.AI precedent, while making the documented AddSource call compile. Update the ADR snippet to the constant that now exists.
Yashvant Mahadev Hange (YashvantHange)
deployed
to
github-app-auth
August 22, 2026 07:33 — with
GitHub Actions
Active
Yashvant Mahadev Hange (YashvantHange)
deployed
to
github-app-auth
August 22, 2026 07:33 — with
GitHub Actions
Active
Yashvant Mahadev Hange (YashvantHange)
deployed
to
github-app-auth
August 22, 2026 07:33 — with
GitHub Actions
Active
Copilot started reviewing on behalf of
Yashvant Mahadev Hange (YashvantHange)
August 22, 2026 07:33
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Exposes the default OpenTelemetry activity source name for external subscribers and updates guidance and tests accordingly.
Changes:
- Adds
OpenTelemetryAgent.DefaultSourceName. - Updates the ADR usage example.
- Tests the exposed source name.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
dotnet/src/Microsoft.Agents.AI/OpenTelemetryAgent.cs |
Exposes the default telemetry source name. |
dotnet/tests/Microsoft.Agents.AI.UnitTests/OpenTelemetryAgentTests.cs |
Verifies the exposed value. |
docs/decisions/0003-agent-opentelemetry-instrumentation.md |
Uses the public API in the example. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Author
|
@microsoft-github-policy-service agree |
A public const is baked into each consumer assembly at compile time, so a consumer built against one package version would keep subscribing to the old literal after upgrading to a version that changed the source name, and would silently stop receiving spans. That is the exact failure this API is meant to remove, so expose the value as a static property that is read at run time. Rename the test to describe what it actually asserts and point at the test that verifies emitted activities use the same source name.
Yashvant Mahadev Hange (YashvantHange)
deployed
to
github-app-auth
August 22, 2026 07:45 — with
GitHub Actions
Active
Yashvant Mahadev Hange (YashvantHange)
marked this pull request as ready for review
August 22, 2026 08:14
Yashvant Mahadev Hange (YashvantHange)
requested review from
SergeyMenshykh,
Tao Chen (TaoChenOSU),
chetantoshniwal,
Eduard van Valkenburg (eavanvalkenburg),
Giles Odigwe (giles17),
Evan Mattson (moonbox3),
Peter Ibekwe (peibekwe),
Roger Barreto (rogerbarreto) and
westey (westey-m)
as code owners
August 22, 2026 08:14
Yashvant Mahadev Hange (YashvantHange)
deployed
to
github-app-auth
August 22, 2026 08:14 — with
GitHub Actions
Active
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.
Motivation & Context
ADR 0003 documents how to subscribe to agent telemetry:
That snippet does not compile against the shipped package.
AgentOpenTelemetryConstswas renamed toOpenTelemetryConstsin #356, and the type isinternal, soDefaultSourceNameis unreachable from outside the assembly. Consumers who want to receiveinvoke_agentspans under the default source have to hardcode the literal"Experimental.Microsoft.Agents.AI", which fails silently if that name ever changes. The repository's own tests hardcode the same literal.Description & Review Guide
What are the major changes?
OpenTelemetryAgentgains apublic const string DefaultSourceNamethat forwards to the existing internalOpenTelemetryConsts.DefaultSourceName. The constant is placed on the type that emits the spans, soOpenTelemetryConstsand thegen_ai.*attribute keys remain internal, preserving the Microsoft.Extensions.AI symmetry that ADR 0003 lists as a design goal. The ADR usage snippet is corrected to reference the constant that now exists. A unit test pins the constant to the literal source name so a rename cannot silently break subscribers.What is the impact of these changes?
Purely additive. Release builds of
Microsoft.Agents.AIsucceed across all five target frameworks with no warnings, and Package Validation reports no compatibility diagnostics against the published baseline. No existing behavior changes.What do you want reviewers to focus on?
Whether
OpenTelemetryAgentis the placement you want for the constant. Moving it is a one-line change if you would prefer it elsewhere. The narrower question of whether to also make thegen_ai.*attribute keys public is deliberately left out of this change, since it is a larger API commitment.Related Issue
Fixes #6452
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.