.NET: Update OpenTelemetry Agent - Added Demo, AIAgentMetadata and Agent.GetService() - #356
Merged
Roger Barreto (rogerbarreto) merged 28 commits intoAug 15, 2025
Conversation
…nto demos/open-telemetry-agent
…nto demos/open-telemetry-agent
Roger Barreto (rogerbarreto)
had a problem deploying
to
integration
August 6, 2025 14:18 — with
GitHub Actions
Failure
Roger Barreto (rogerbarreto)
had a problem deploying
to
integration
August 6, 2025 14:18 — with
GitHub Actions
Failure
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR updates the OpenTelemetry Agent implementation with expanded support and behavior, including a new demo sample, AIAgentMetadata for agent-specific metadata retrieval, and Agent.GetService() method similar to MEAI's IChatClient. The update also adds logging support with deduplication prevention and reorganizes solution folders.
- Added comprehensive OpenTelemetry Agent demo with Aspire Dashboard integration
- Introduced
AIAgentMetadataandAgent.GetService()method for retrieving agent metadata and services - Enhanced OpenTelemetry logging with deduplication logic when agents already have OTEL-enabled chat clients
Reviewed Changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| OpenTelemetryAgent.cs | Enhanced with logging support, metadata handling, and deduplication logic |
| OpenTelemetryConsts.cs | New constants file replacing AgentOpenTelemetryConsts with updated naming |
| AIAgent.cs | Added abstract GetService method and generic helper |
| AIAgentMetadata.cs | New metadata class for agent provider information |
| ChatClientAgent.cs | Implemented GetService method with metadata support |
| AgentOpenTelemetry demo | Complete demo application with Aspire Dashboard integration |
| Test files | Updated to use new constants and test new GetService functionality |
Comments suppressed due to low confidence (1)
Roger Barreto (rogerbarreto)
had a problem deploying
to
integration
August 6, 2025 14:42 — with
GitHub Actions
Failure
Roger Barreto (rogerbarreto)
had a problem deploying
to
integration
August 6, 2025 14:42 — with
GitHub Actions
Failure
Roger Barreto (rogerbarreto)
temporarily deployed
to
integration
August 6, 2025 18:21 — with
GitHub Actions
Inactive
Roger Barreto (rogerbarreto)
temporarily deployed
to
integration
August 6, 2025 18:21 — with
GitHub Actions
Inactive
Roger Barreto (rogerbarreto)
had a problem deploying
to
integration
August 8, 2025 08:17 — with
GitHub Actions
Failure
Roger Barreto (rogerbarreto)
had a problem deploying
to
integration
August 11, 2025 15:02 — with
GitHub Actions
Error
Roger Barreto (rogerbarreto)
had a problem deploying
to
integration
August 11, 2025 15:02 — with
GitHub Actions
Error
Roger Barreto (rogerbarreto)
temporarily deployed
to
integration
August 11, 2025 15:03 — with
GitHub Actions
Inactive
Roger Barreto (rogerbarreto)
temporarily deployed
to
integration
August 11, 2025 15:03 — with
GitHub Actions
Inactive
Roger Barreto (rogerbarreto)
had a problem deploying
to
integration
August 11, 2025 16:13 — with
GitHub Actions
Error
Roger Barreto (rogerbarreto)
had a problem deploying
to
integration
August 11, 2025 16:13 — with
GitHub Actions
Error
Roger Barreto (rogerbarreto)
temporarily deployed
to
integration
August 11, 2025 16:16 — with
GitHub Actions
Inactive
Roger Barreto (rogerbarreto)
temporarily deployed
to
integration
August 11, 2025 16:16 — with
GitHub Actions
Inactive
westey (westey-m)
approved these changes
Aug 12, 2025
Dmytro Struk (dmytrostruk)
approved these changes
Aug 15, 2025
Roger Barreto (rogerbarreto)
temporarily deployed
to
integration
August 15, 2025 15:34 — with
GitHub Actions
Inactive
Roger Barreto (rogerbarreto)
temporarily deployed
to
integration
August 15, 2025 15:34 — with
GitHub Actions
Inactive
Roger Barreto (rogerbarreto)
enabled auto-merge
August 15, 2025 15:35
4 tasks
Reuben Bond (ReubenBond)
pushed a commit
to ReubenBond/agent-framework
that referenced
this pull request
Oct 28, 2025
…ent.GetService() (microsoft#356) * OTEL Demo * updating telemetry sample * OTEL updates * WIP * Adding GetService and Agent Metadata for Telemetry * WIP * Add UT for OTEL System behavior * Address Unicode problem * Add logging * Adjust for new extensions * Change Logger to LoggerFactory for the extension method * Address AI Feedback * Simplify script and readme just for Azure OpenAI * Increase code converage * Address merge conflict * Another slnx fix * Address PR comments * Address PR feedback + Add UT * Added Hosting UT to the solution * Address PR comments * Address missing sensitivity tests * Remove unecessary override * Address PR comments
5 tasks
leilei3167
pushed a commit
to leilei3167/agent-framework
that referenced
this pull request
Sep 14, 2026
* .NET: expose OpenTelemetryAgent.DefaultSourceName 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. * .NET: read DefaultSourceName at run time instead of inlining it 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. * .NET: document that AddSource and the agent source name must match The tracing pipeline only receives agent spans when the name registered with TracerProviderBuilder.AddSource matches the source name the agent emits under; a mismatch fails silently. Spell that pairing out in the sourceName XML docs on UseOpenTelemetry and the OpenTelemetryAgent constructors, and in the ADR usage example, which now also shows the custom-source case and uses the AsBuilder().UseOpenTelemetry() API that actually exists. * .NET: mark OpenTelemetryAgent.DefaultSourceName experimental DefaultSourceName is a new public API, so gate it behind MAAI001 and graduate it later if it proves useful. The ADR usage section notes that the diagnostic has to be suppressed to use the property. * .NET: declare DefaultSourceName in the public API baseline The public API analyzers added in microsoft#7935 require every public member of a released package to be listed in that package's PublicAPI baseline for each target framework. DefaultSourceName was added before those analyzers landed, so this branch built clean on its own but failed RS0016 once merged with main. Add the entry to all five Microsoft.Agents.AI baselines. Unshipped rather than Shipped, since the member has not been released yet; the promotion workflow moves it across after a release. --------- Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com>
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 and Context
This is a second round on the Agent OpenTelemetry implementation expanding the support and behavior of the current implementation.
genai.system, there was no option in agents to identify the system and as part of this current limitation I did introduceAIAgentMetadataandAgent.GetService()similar manner as found in MEAI's IChatClient to retrieve Agent specific metadata for OTEL and potentially more usages.Logingsupport for OpenTelemetryAgent with proper duplication prevention (if the agent has a chatclient with OTEL already enabled and logging)