Skip to content

Add ActivitySource and Logging - #2

Merged
JesseLiberty merged 1 commit into
mainfrom
ActivitySource
Jul 21, 2026
Merged

Add ActivitySource and Logging#2
JesseLiberty merged 1 commit into
mainfrom
ActivitySource

Conversation

@JesseLiberty

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings July 21, 2026 18:54
@JesseLiberty
JesseLiberty merged commit a1eefb3 into main Jul 21, 2026
1 check passed

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

Adds basic observability to the BlogWriter console workflow by introducing console logging and lightweight distributed tracing spans (via ActivitySource) around agent invocations and workflow runs.

Changes:

  • Inject ILogger<T> into each agent and create a console ILoggerFactory in Program.cs.
  • Add ActivitySource spans to agents, the workflow, and the top-level run in Program.cs, plus a console ActivityListener to print span start/stop.
  • Add Microsoft.Extensions.Logging and Microsoft.Extensions.Logging.Console package references.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
ReviewerAgent.cs Adds ILogger<ReviewerAgent> injection and an ActivitySource span around review invocation.
ResearcherAgent.cs Adds ILogger<ResearcherAgent> injection and an ActivitySource span around research invocation.
Program.cs Creates console logger factory, wires loggers into agents, and registers an ActivityListener + root run activity.
BlogWriter.csproj Adds logging package references to support console logging.
BlogWorkflow.cs Adds a workflow-level ActivitySource and root span for each workflow run.
BloggerAgent.cs Adds ILogger<BloggerAgent> injection and an ActivitySource span around decision invocation.
AuthorAgent.cs Adds ILogger<AuthorAgent> injection and an ActivitySource span around author invocation.

Comment thread Program.cs
Comment on lines +90 to +99
var appActivitySource = new ActivitySource("BlogWriter.Program");

ActivitySource.AddActivityListener(new ActivityListener
{
ShouldListenTo = source => source.Name.StartsWith("BlogWriter", StringComparison.Ordinal),
Sample = (ref ActivityCreationOptions<ActivityContext> _) => ActivitySamplingResult.AllData,
ActivityStarted = activity => Console.WriteLine($"[trace] \u2192 {activity.DisplayName}"),
ActivityStopped = activity =>
Console.WriteLine($"[trace] \u2190 {activity.DisplayName} ({activity.Duration.TotalMilliseconds:F0} ms)")
});
Comment thread ReviewerAgent.cs
MaxOutputTokens = chatOptions.MaxOutputTokens,
},
});
_logger.LogInformation("ReviewerAgent initialized.");
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