Skip to content

Adding CorrelationId to track requests#171

Merged
skg-marimuthu merged 2 commits intomainfrom
users/magurusa/trackCorrelationId
Jan 23, 2026
Merged

Adding CorrelationId to track requests#171
skg-marimuthu merged 2 commits intomainfrom
users/magurusa/trackCorrelationId

Conversation

@skg-marimuthu
Copy link
Contributor

Adding CorrelationId to track requests across different interfaces

@skg-marimuthu skg-marimuthu requested review from a team as code owners January 22, 2026 02:38
Copilot AI review requested due to automatic review settings January 22, 2026 02:38
@skg-marimuthu skg-marimuthu enabled auto-merge (squash) January 22, 2026 02:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds correlation ID support to track requests across different interfaces in the Agent365 CLI tool. The implementation introduces a standardized way to generate and propagate correlation IDs throughout HTTP requests for better observability and request tracing.

Changes:

  • Added x-ms-correlation-id header support to HttpClientFactory with automatic GUID generation when not provided
  • Updated all HTTP client creation calls to accept and propagate optional correlation IDs
  • Added correlation ID generation at workflow entry points across commands and services
  • Updated test mocks to accommodate the new optional correlationId parameter

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
HttpClientFactory.cs Added CorrelationIdHeaderName constant, updated CreateAuthenticatedClient to accept optional correlationId parameter, added GenerateCorrelationId helper method
IBotConfigurator.cs Added optional correlationId parameter to both interface methods
BotConfigurator.cs Updated method signatures and passed correlationId to HttpClientFactory
DelegatedConsentService.cs Added correlation ID generation and logging at workflow entry point
Agent365ToolingService.cs Added correlation ID generation for all public API methods
A365CreateInstanceRunner.cs Added correlation ID generation and propagation across multiple Graph API calls
SetupHelpers.cs Added optional correlationId parameter to RegisterBlueprintMessagingEndpointAsync
BlueprintSubcommand.cs Added correlation ID generation in command handler and passed to helper methods
AllSubcommand.cs Added correlation ID generation in command handler
PublishCommand.cs Added correlation ID generation and logging
DevelopCommand.cs Added correlation ID generation in CallDiscoverToolServersAsync
CleanupCommand.cs Added correlation ID generation (with timing issue)
HttpClientFactoryTests.cs Added comprehensive tests for correlation ID functionality
CleanupCommandTests.cs Updated mocks to accept new optional correlationId parameter

Comment on lines +42 to +52
// Generate correlation ID at workflow entry point
var correlationId = HttpClientFactory.GenerateCorrelationId();

// Set default handler for 'a365 cleanup' (without subcommand) - cleans up everything
cleanupCommand.SetHandler(async (configFile, verbose) =>
{
await ExecuteAllCleanupAsync(logger, configService, botConfigurator, executor, agentBlueprintService, confirmationProvider, federatedCredentialService, configFile);
await ExecuteAllCleanupAsync(logger, configService, botConfigurator, executor, agentBlueprintService, confirmationProvider, federatedCredentialService, configFile, correlationId: correlationId);
}, configOption, verboseOption);

// Add subcommands for granular control
cleanupCommand.AddCommand(CreateBlueprintCleanupCommand(logger, configService, botConfigurator, executor, agentBlueprintService, federatedCredentialService));
cleanupCommand.AddCommand(CreateBlueprintCleanupCommand(logger, configService, botConfigurator, executor, agentBlueprintService, federatedCredentialService, correlationId: correlationId));
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

The correlation ID is being generated once at command creation time (when CreateCommand is called) rather than at command execution time. This means all invocations of the cleanup command will share the same correlation ID, defeating the purpose of request tracing.

The correlation ID should be generated inside the SetHandler lambda or at the beginning of ExecuteAllCleanupAsync so that each command invocation gets a unique ID.

Copilot uses AI. Check for mistakes.
@skg-marimuthu skg-marimuthu merged commit c4979b7 into main Jan 23, 2026
6 checks passed
@skg-marimuthu skg-marimuthu deleted the users/magurusa/trackCorrelationId branch January 23, 2026 22:53
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