Improve App Insights telemetry enrichment for MCP failures#129
Open
TomProkop wants to merge 2 commits into
Open
Improve App Insights telemetry enrichment for MCP failures#129TomProkop wants to merge 2 commits into
TomProkop wants to merge 2 commits into
Conversation
- share resolver-based identity tagging between CLI and MCP\n- enrich MCP request, subprocess, and task telemetry with profile context\n- promote root error messages and copy key context onto exception events\n- add unit tests for tagger, MCP enricher, and telemetry log provider\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves txc Application Insights telemetry quality for MCP-hosted executions by sharing identity tagging logic with the CLI, enriching MCP spans (request/subprocess/background tasks) with profile/workspace context, and promoting key context onto exception events for better failure triage.
Changes:
- Refactors
ActivityIdentityTaggerto tag from the same resolver fallback chain used by the CLI (explicit profile → env/workspace/global). - Adds MCP-side
McpTelemetryEnricherand wires it into the MCP server’s request, subprocess, and background-task activities. - Enhances telemetry error logging to promote root error messages and copy key identity/environment tags onto exception events; adds unit tests for the new/shared behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/TALXIS.CLI.Tests/Telemetry/ActivityIdentityTaggerTests.cs | Adds unit coverage for resolver-driven identity tagging behavior. |
| tests/TALXIS.CLI.Tests/MCP/McpTelemetryEnricherTests.cs | Adds tests validating MCP telemetry enrichment behavior (explicit profile + workspace-based resolution). |
| tests/TALXIS.CLI.Tests/Logging/TxcTelemetryLogProviderTests.cs | Updates tests for exception enrichment + error message promotion behavior. |
| src/TALXIS.CLI.MCP/Program.cs | Tags MCP request/subprocess/background-task spans with profile/workspace identity context. |
| src/TALXIS.CLI.MCP/McpTelemetryEnricher.cs | New component that enriches activities using profile arguments and/or workspace resolution. |
| src/TALXIS.CLI.Logging/TxcTelemetryLogProvider.cs | Copies key activity tags onto exception events and promotes innermost error message. |
| src/TALXIS.CLI.Core/Telemetry/ActivityIdentityTagger.cs | Simplifies to resolver-based tagging and exposes TagFromProfileAsync API. |
| src/TALXIS.CLI.Core/Shared/TxcLeafCommand.cs | Updates CLI identity tagging call site to use the new tagger API. |
Comment on lines
494
to
+497
| try | ||
| { | ||
| await mcpTelemetryEnricher.TagActivityAsync(taskActivity, arguments, workingDirectory, CancellationToken.None); | ||
|
|
Comment on lines
+518
to
+521
| dispatchActivity?.SetTag("peer.service", "talxis-cli"); | ||
| dispatchActivity?.SetTag(TALXIS.CLI.Core.Telemetry.TxcTelemetryTags.Tool, toolName); | ||
| await mcpTelemetryEnricher.TagActivityAsync(dispatchActivity, cliArguments, workingDirectory, CancellationToken.None); | ||
| result = await CliSubprocessRunner.RunAsync(cliArgs, logForwarder, taskCts.Token, workingDirectory); |
Comment on lines
+71
to
+76
| if (!string.IsNullOrWhiteSpace(profileName)) | ||
| { | ||
| if (_tagger != null) | ||
| await _tagger.TagFromProfileAsync(activity, profileName, ct).ConfigureAwait(false); | ||
| return; | ||
| } |
- honor task cancellation during background telemetry enrichment\n- fall back to store-based explicit profile resolution when tagger is unavailable\n- add test coverage for explicit-profile fallback\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary