Add ActivitySource and Logging - #2
Merged
Merged
Conversation
There was a problem hiding this comment.
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 consoleILoggerFactoryinProgram.cs. - Add
ActivitySourcespans to agents, the workflow, and the top-level run inProgram.cs, plus a consoleActivityListenerto print span start/stop. - Add
Microsoft.Extensions.LoggingandMicrosoft.Extensions.Logging.Consolepackage 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 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)") | ||
| }); |
| MaxOutputTokens = chatOptions.MaxOutputTokens, | ||
| }, | ||
| }); | ||
| _logger.LogInformation("ReviewerAgent initialized."); |
Merged
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.
No description provided.