Skip to content

.NET: Update OpenTelemetry Agent - Added Demo, AIAgentMetadata and Agent.GetService() - #356

Merged
Roger Barreto (rogerbarreto) merged 28 commits into
microsoft:mainfrom
rogerbarreto:demos/open-telemetry-agent
Aug 15, 2025
Merged

.NET: Update OpenTelemetry Agent - Added Demo, AIAgentMetadata and Agent.GetService() #356
Roger Barreto (rogerbarreto) merged 28 commits into
microsoft:mainfrom
rogerbarreto:demos/open-telemetry-agent

Conversation

@rogerbarreto

Copy link
Copy Markdown
Member

Motivation and Context

This is a second round on the Agent OpenTelemetry implementation expanding the support and behavior of the current implementation.

  • Added Demo Sample using Open Telemetry with Aspire Dashboard
  • To be able to retrieve required OTEL information for the genai.system, there was no option in agents to identify the system and as part of this current limitation I did introduce AIAgentMetadata and Agent.GetService() similar manner as found in MEAI's IChatClient to retrieve Agent specific metadata for OTEL and potentially more usages.
  • Added Loging support for OpenTelemetryAgent with proper duplication prevention (if the agent has a chatclient with OTEL already enabled and logging)
  • Small restructure of Solution folders (Samples/Demos/src/Tests).

CopilotAI review requested due to automatic review settings August 6, 2025 14:17
@eavanvalkenburgEduard van Valkenburg (eavanvalkenburg) added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs .NET Usage: [Issues, PRs], Target: .Net labels Aug 6, 2025
@github-actionsgithub-actionsBot changed the title .Net: Update OpenTelemetry Agent - Added Demo, AIAgentMetadata and Agent.GetService() .NET: Update OpenTelemetry Agent - Added Demo, AIAgentMetadata and Agent.GetService() Aug 6, 2025

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 AIAgentMetadata and Agent.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
FileDescription
OpenTelemetryAgent.csEnhanced with logging support, metadata handling, and deduplication logic
OpenTelemetryConsts.csNew constants file replacing AgentOpenTelemetryConsts with updated naming
AIAgent.csAdded abstract GetService method and generic helper
AIAgentMetadata.csNew metadata class for agent provider information
ChatClientAgent.csImplemented GetService method with metadata support
AgentOpenTelemetry demoComplete demo application with Aspire Dashboard integration
Test filesUpdated to use new constants and test new GetService functionality
Comments suppressed due to low confidence (1)

Comment threaddotnet/demos/AgentOpenTelemetry/Program.cs Outdated
Comment threaddotnet/demos/AgentOpenTelemetry/Program.cs
Comment threaddotnet/demos/AgentOpenTelemetry/README.md Outdated
Comment threaddotnet/demos/AgentOpenTelemetry/README.md
Comment threaddotnet/src/Microsoft.Extensions.AI.Agents/OpenTelemetryAgent.cs Outdated
Merged via the queue into microsoft:main with commit 5311320Aug 15, 2025
14 checks passed
@github-project-automationgithub-project-automationBot moved this from In Review to Done in Agent FrameworkAug 15, 2025
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
AQ-1970 (Arturo-Quiroga-MSFT) pushed a commit to Arturo-Quiroga-MSFT/agent-framework-public that referenced this pull request Nov 23, 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
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentationUsage: [Issues, PRs], Target: documentation in the code base and learn docs.NETUsage: [Issues, PRs], Target: .Net

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants

@rogerbarreto@dmytrostruk@westey-m@eavanvalkenburg