Added UseOpenTelemetry - #5
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds OpenTelemetry-based instrumentation to the agent and chat-client pipelines so workflow execution and per-model round-trips can be traced via ActivitySource/ActivityListener (and later exported via an OpenTelemetry TracerProvider if desired).
Changes:
- Wrap each
ChatClientAgentwith.AsBuilder().UseOpenTelemetry(...).Build()to emit agent-level spans. - Add
.UseOpenTelemetry(sourceName: "BlogWriter.ChatClient")to the sharedIChatClientpipeline to emit GenAI spans for each model round-trip (model name, token usage, tool calls, latency). - Update
Program.cstracing comments to reflect the new GenAI spans alongside existing agent/workflow spans.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| ReviewerAgent.cs | Wrap agent creation with UseOpenTelemetry and store as AIAgent. |
| ResearcherAgent.cs | Wrap agent creation with UseOpenTelemetry and store as AIAgent. |
| BloggerAgent.cs | Wrap agent creation with UseOpenTelemetry and store as AIAgent. |
| AuthorAgent.cs | Wrap agent creation with UseOpenTelemetry and store as AIAgent. |
| Program.cs | Add UseOpenTelemetry to the IChatClient pipeline and update tracing comments. |
Comment on lines
33
to
37
| // Build the IChatClient pipeline once and share it across all agents. | ||
| // UseFunctionInvocation() adds the middleware that actually *executes* the tool | ||
| // calls the model requests — without it, attaching the Tavily tool to the | ||
| // Researcher agent would let the model ask for a search but nothing would run it. | ||
| // Middleware is applied inner-to-outer, so function invocation wraps the raw |
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.
Added UseOpenTelemetry
#1 captures which agent ran, and agent-level timing
#2 captures the model name, token usage, tool calls and per-round-trip latency