Skip to content

Added UseOpenTelemetry - #5

Merged
JesseLiberty merged 1 commit into
mainfrom
autofix
Jul 31, 2026
Merged

Added UseOpenTelemetry#5
JesseLiberty merged 1 commit into
mainfrom
autofix

Conversation

@JesseLiberty

Copy link
Copy Markdown
Owner

Added UseOpenTelemetry

  1. Instrument each agent -- wrap the ChatClientAgent via .AsBuilder
  2. Instrument the model calls in program.cs

#1 captures which agent ran, and agent-level timing
#2 captures the model name, token usage, tool calls and per-round-trip latency

Copilot AI review requested due to automatic review settings July 31, 2026 15:10
@JesseLiberty
JesseLiberty merged commit 50f5ae1 into main Jul 31, 2026

Copilot AI left a comment

Copy link
Copy Markdown

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 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 ChatClientAgent with .AsBuilder().UseOpenTelemetry(...).Build() to emit agent-level spans.
  • Add .UseOpenTelemetry(sourceName: "BlogWriter.ChatClient") to the shared IChatClient pipeline to emit GenAI spans for each model round-trip (model name, token usage, tool calls, latency).
  • Update Program.cs tracing 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 thread Program.cs
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants