Skip to content

Improve App Insights telemetry enrichment for MCP failures#129

Open
TomProkop wants to merge 2 commits into
masterfrom
feat/telemetry-appinsights-failures
Open

Improve App Insights telemetry enrichment for MCP failures#129
TomProkop wants to merge 2 commits into
masterfrom
feat/telemetry-appinsights-failures

Conversation

@TomProkop
Copy link
Copy Markdown
Member

@TomProkop TomProkop commented May 27, 2026

Summary

  • share resolver-based identity tagging between CLI and MCP telemetry
  • enrich MCP request, subprocess, and background-task spans with profile context
  • promote root error messages and copy key identity/environment fields onto exception events
  • add unit tests for the shared tagger, MCP enricher, and telemetry log provider

- 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>
Copy link
Copy Markdown
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 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 ActivityIdentityTagger to tag from the same resolver fallback chain used by the CLI (explicit profile → env/workspace/global).
  • Adds MCP-side McpTelemetryEnricher and 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>
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.

2 participants