Skip to content

Add copilot telemetry cross-correlation id - #12508

Merged
Amaury Levé (Evangelink) merged 3 commits into
mainfrom
dev/jankrivanek/copilot-telemetry-correlation
Nov 18, 2026
Merged

Amaury Levé (Evangelink) merged 3 commits into
mainfrom
dev/jankrivanek/copilot-telemetry-correlation

Conversation

@JanKrivanek

Copy link
Copy Markdown
Member

Motivation

Ability to cross-corelate telemetry with the copilot telemetry

Related

dotnet/sdk#57106

Copilot AI balanced review requested due to automatic review settings November 18, 2026 10:49
@github-actions github-actions Bot added the state/needs-review Awaiting review from the team. label Nov 18, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Nov 18, 2026
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/needs-review Awaiting review from the team. labels Nov 18, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧪 Test quality review — PR #12508

Compared merge base 28c534d9fd47856682e8d1c14f54a10a1b4a08bf with head de5d2bb4b700c74e0bbf1021d00e57ab65a3f22d. Evidence applies to this head, not every intermediate commit.

Test-value evidence

All results are static predictions. No paired execution records were available, and CI status is not counted as proof.

Contract Scenario and expected outcome Test and decisive assertion Counterfactual Evidence
is llm is added to every usage event An AI agent marker yields true; unknown, empty and absent markers yield false. LogEvent_ReportsLLMContext (6 rows), Assert.ContainsEntry("is llm", expected, properties). Dropping the property fails every row. Hard-coding false fails the true rows. Static prediction: detected
CopilotAgentSessionId normalization UUID v1-8 with RFC variant and nil UUID are preserved. Other values become lowercase SHA-256 of the raw UTF-8 bytes. Missing or empty becomes not_present. LogEvent_NormalizesCopilotSessionId (17 rows) covers casing, whitespace, braces, trailing \n, invalid version/variant and non-ASCII; asserts ContainsEntry("CopilotAgentSessionId", expected, ...). Trimming, case-folding, $ instead of \z, or restricting the version range each fail a specific row. Static prediction: detected
Context is snapshotted before queueing, and the caller's dictionary is not mutated The environment changes after each LogEventAsync call; each queued event keeps the context from its own call. LogEvent_SnapshotsContextBeforeQueueingWithoutMutatingCallerProperties asserts the per-event values and HasCount(2, callerProperties). Reading the environment at consume time, or writing into paramsMap, fails. Static prediction: detected
No collection or env read when telemetry is disabled Opt-out, or EnableTelemetry=false: no collector is created and COPILOT_AGENT_SESSION_ID is never read. TelemetryManager_WhenDisabled_DoesNotCreateContextCollector (3 rows), Assert.IsFalse(collectorCreated) and Verify(..., Times.Never). Acceptance opt-out tests assert no Send telemetry event: lines. Reading the env before the opt-out check fails the Times.Never verify. Static prediction: detected
The packaged host emits the fields on every event Four agent/session combinations; every Send telemetry event block carries the expected values. Telemetry_Context_IsIncludedInEveryUsageEvent: per-event AreEqual on is llm and CopilotAgentSessionId. A path that bypasses the snapshot (for example a direct send) fails in the diag output. Static prediction: detected
Docs and the internal API file PACKAGE.md, the decision doc and InternalAPI.Unshipped.txt n/a n/a Not applicable (non-executable)

🧵 Parallel safety

PARALLEL-SAFETY RESULT
STATUS: PARTIAL

The parallel-safety-reviewer specialist task was not run in this session, so coverage is incomplete. This is not a clean result.

Cursory observations from the diff only, not a specialist verdict:

  • The unit tests use per-test Mock<IEnvironment> instances and do not touch process-wide environment state.
  • The acceptance test passes its environment variables per child process and uses a per-iteration TempDirectory.

Per-test assessment

Pseudo-mutation evidence is static prediction, not executed mutation results. The grade-tests and test-gap-analysis skills were not invoked, so the grades below are manual assessments.

Result Quality Test Notes How to improve
Pass A (90–100) new AppInsightsProviderTests.LogEvent_NormalizesCopilotSessionId Exact expected hashes and UUID edge cases cover the normalization contract. None
Pass A (90–100) new AppInsightsProviderTests.LogEvent_SnapshotsContextBeforeQueueingWithoutMutatingCallerProperties Deterministic gating via TCS; asserts per-event context and an unmutated caller dictionary. None
Pass B (80–89) new AppInsightsProviderTests.LogEvent_ReportsLLMContext Covers detector true/false rows and the default session ID. None
Pass B (80–89) new TelemetryManagerTests.TelemetryManager_WhenDisabled_DoesNotCreateContextCollector Asserts no collector, disabled state and no env read. None
Pass B (80–89) new TelemetryTests.Telemetry_Context_IsIncludedInEveryUsageEvent End-to-end per-event assertions over 4 contexts; long process-level body is acceptable here. None
Pass B (80–89) mod TelemetryTests.Telemetry_WhenOptingOutTelemetry_WithEnvironmentVariable_TelemetryIsDisabled Now also asserts no events are sent while the session ID env var is set. None
Pass B (80–89) mod TelemetryTests.Telemetry_WhenOptingOutTelemetry_With_DOTNET_CLI_EnvironmentVariable_TelemetryIsDisabled Same strengthening as the sibling opt-out test. None
Pass B (80–89) mod TelemetryDisabledTests.Telemetry_WhenEnableTelemetryIsFalse_WithTestApplicationOptions_TelemetryIsDisabled Now also asserts no events are sent. None

No inline findings were published. A few changed lines (the non-ASCII café row, Regex.Matches(...).Count as the expected count) are rubric-level nits that do not hide a wrong behavior.

<sub>This advisory review is heuristic and non-blocking.

Re-run the combined review with /review-tests, or only the parallel-safety specialist with /parallel-audit.</sub>

🤖 Automated content by GitHub Copilot. Generated by the Test Quality Review on PR (on open / sync) workflow. · copilot · auto · ~34 AIC · ⌖ ~1 AIC · ⊞ 8.1K

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note

🤖 Automated review by GitHub Copilot. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

No blocking issues found in the changes I reviewed. I did not see the rest of the test diff (the unit tests and the end of TelemetryTests.cs), and I did not build or run anything.

Reviewer actions

  • Recommended: docs/decisions/llm-context-telemetry.md cites evidence that lives only in session artifacts (validate.ps1, comparison-provenance.json, patch and DLL hashes). Done when: the decision record includes the exact commands and result counts, or links to a stable location where a reviewer can check them.

Change classification

  • Microsoft.Testing.Extensions.Telemetry: adds is llm and CopilotAgentSessionId to every usage event.
  • Internal telemetry constants, PACKAGE.md, and a decision record.
  • Acceptance tests: the telemetry opt-out assets now register the real provider.

Confidence at a glance

🟢 Product code (AppInsightsProvider)
  • The payload is copied into a new dictionary before it is queued. This keeps the caller's dictionary unmodified and stops callers from overriding the new keys, because the new keys are set last. The provider's own later paramsMap.Add(...) calls now only touch the copy.
  • The !NETCOREAPP cancellation check now runs before the payload is built, and the early return on single-threaded wasm is unchanged.
  • The UUID regex is anchored with \A...\z, so trailing newlines do not match. It is case-insensitive and culture-invariant, and it preserves the original casing as the contract states.
  • The hash uses UTF-8 bytes, lowercase hex, and no trimming. Both the NET9_0_OR_GREATER branch and the fallback produce the same output.
  • Adding CopilotAgentSessionId to KnownUnhashedProperties is correct, because the value is either a UUID or a 64-character lowercase hash. The is llm value is a bool and passes through the bool case.
  • No public API is added. The two new internal constants are listed in InternalAPI.Unshipped.txt.
🟡 Tests and validation
  • The new opt-out assertion Assert.DoesNotContain("Send telemetry event:", ...) and the registration of the real provider make the disabled-telemetry tests meaningful.
  • The acceptance test covers four contexts per target framework and checks event counts, names and fields.
  • Gap: the decision record states "222 unit and 15 acceptance cases passed" and a red/green check, but a reader cannot reproduce these from the PR alone (see Reviewer actions).
🟢 Docs and localization

PACKAGE.md describes the new fields and their independence from the OpenTelemetry traces. No resource or localization changes are involved.

The decision record leaves two items open: backend ingestion has not been verified, and the telemetry governance review still has to happen before release. Both are already noted in the PR.

@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. labels Nov 18, 2026
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/needs-review Awaiting review from the team. state/approved Proposal approved; ready for implementation. labels Nov 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block the Copilot session-correlation telemetry change.

No open issues 🎉

What changed in this PR

Adds Copilot session correlation to Microsoft.Testing.Platform’s optional telemetry extension, enabling cross-product correlation with Copilot and the .NET SDK.

Changes:

  • Adds per-event is llm and CopilotAgentSessionId properties, preserving canonical UUIDs and hashing other session IDs.
  • Snapshots context before queueing without modifying caller properties, while retaining existing telemetry opt-outs.
  • Adds unit and packaged acceptance coverage, environment isolation, and contract documentation.

Test-value evidence: The decision record reports 222 passing unit cases, 15 passing acceptance cases, and a 17-case failing/passing comparison for correlation-key alignment. These execution results were not independently verified here.

File Description
test/​Utilities/​Microsoft.Testing.TestInfrastructure/​WellKnownEnvironmentVariables.cs Isolates inherited Copilot session IDs in tests.
test/​UnitTests/​Microsoft.Testing.Platform.UnitTests/​Telemetry/​TelemetryManagerTests.cs Verifies disabled telemetry avoids collector creation and session-ID reads.
test/​UnitTests/​Microsoft.Testing.Extensions.UnitTests/​AppInsightsProviderTests.cs Covers detection, normalization, snapshots, and caller-property ownership.
test/​IntegrationTests/​Microsoft.Testing.Platform.Acceptance.IntegrationTests/​TelemetryTests.cs Checks packaged event context and environment-variable opt-outs.
test/​IntegrationTests/​Microsoft.Testing.Platform.Acceptance.IntegrationTests/​TelemetryDisabledTests.cs Checks application-level disabling with the telemetry provider registered.
src/​Platform/​Microsoft.Testing.Platform/​Telemetry/​TelemetryProperties.cs Defines the two telemetry property names.
src/​Platform/​Microsoft.Testing.Platform/​InternalAPI/​InternalAPI.Unshipped.txt Tracks the new internal constants.
src/​Platform/​Microsoft.Testing.Extensions.Telemetry/​PACKAGE.md Documents context fields and normalization behavior.
src/​Platform/​Microsoft.Testing.Extensions.Telemetry/​AppInsightsProvider.cs Normalizes and captures context before event queueing.
docs/​decisions/​llm-context-telemetry.md Records the contract, design decisions, and reported validation.

Review effort: Balanced

@microsoft-github-policy-service microsoft-github-policy-service Bot added the state/needs-review Awaiting review from the team. label Nov 18, 2026
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/needs-review Awaiting review from the team. state/approved Proposal approved; ready for implementation. labels Nov 18, 2026
Import Microsoft.Testing.Platform in all configurations so RoslynString resolves during Release builds. Verified Release packing and 190 provider test cases.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 18, 2026 11:18
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/approved Proposal approved; ready for implementation. labels Nov 18, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧪 Test quality review — PR #12508

Compared merge base 28c534d9fd47856682e8d1c14f54a10a1b4a08bf with head 692f9011f32db541b4cf46fb0fe0eb4293fb25ff. Evidence applies to this head only. No tests were executed and the review was abbreviated: the per-test rubric skills were not run, so the scorecard has no letter grades.

Test-value evidence

All entries are static predictions. No paired execution records were available.

Contract Test and decisive assertion Counterfactual Evidence
is llm is attached to each telemetry event AppInsightsProviderTests.LogEvent_ReportsLLMContext (6 data rows): Assert.ContainsEntry("is llm", expected, ...) Dropping the property, or ignoring the detector, fails the true rows. Static prediction: likely detects.
CopilotAgentSessionId is normalized: UUID v1-8 with RFC variant, or nil, is kept; anything else is SHA-256 hashed; empty is not_present AppInsightsProviderTests.LogEvent_NormalizesCopilotSessionId (17 data rows, covering UUID versions 0 and 9, a bad variant, braces, a trailing newline, case sensitivity and non-ASCII) Hashing every value, hashing none, or a regex without \z fails specific rows. Static prediction: likely detects.
Context is captured before queueing, and the caller's dictionary is not mutated AppInsightsProviderTests.LogEvent_SnapshotsContextBeforeQueueingWithoutMutatingCallerProperties: the consumer is gated, the environment changes between events, and the caller's dictionary has 2 entries after the calls Reading the environment at consume time, or writing into paramsMap, fails. Static prediction: likely detects.
No context collector is created when telemetry is disabled TelemetryManagerTests.TelemetryManager_WhenDisabled_DoesNotCreateContextCollector: Assert.IsFalse(collectorCreated), plus environment.Verify(... Times.Never) Reading the environment variable regardless of opt-out fails the Verify. Static prediction: likely detects.
COPILOT_AGENT_SESSION_ID is cleared for child test hosts in acceptance tests WellKnownEnvironmentVariables change, used by TelemetryTests Not assessed in depth. Unverified.
Docs, PACKAGE.md, InternalAPI.Unshipped.txt Not executable Not applicable Not applicable.

🧵 Parallel safety

PARTIAL. The parallel-safety specialist was not run in this abbreviated pass, so there is no clean result. The unit tests use per-test mocks and local state, and I found no shared mutable state. TelemetryTests and TelemetryDisabledTests were not assessed.

Per-test assessment

The five changed test files were not graded. Static reading of the three new unit tests found no verified defects, so there are no inline comments.

Result Quality Test Notes How to improve
Uncertain — new AppInsightsProviderTests.LogEvent_ReportsLLMContext Not graded; reading found exact assertions on is llm. Run the grade-tests rubric on this test.
Uncertain — new AppInsightsProviderTests.LogEvent_NormalizesCopilotSessionId Not graded; boundary rows and exact hash values look thorough. Run the grade-tests rubric on this test.
Uncertain — new AppInsightsProviderTests.LogEvent_SnapshotsContextBeforeQueueingWithoutMutatingCallerProperties Not graded; ordering and snapshot assertions look sound. Run the grade-tests rubric on this test.
Uncertain — new TelemetryManagerTests.TelemetryManager_WhenDisabled_DoesNotCreateContextCollector Not graded; the assertions cover the disabled path. Run the grade-tests rubric on this test.
Uncertain — mod TelemetryTests and TelemetryDisabledTests methods Not graded; the acceptance tests were not inspected in depth. Run the grade-tests rubric on these tests.

<sub>This advisory review is heuristic and non-blocking.

Re-run the combined review with /review-tests, or only the parallel-safety specialist with /parallel-audit.</sub>

🤖 Automated content by GitHub Copilot. Generated by the Test Quality Review on PR (on open / sync) workflow. · copilot · auto · ~23 AIC · ⌖ ~1 AIC · ⊞ 8.1K

@microsoft-github-policy-service microsoft-github-policy-service Bot added the state/needs-review Awaiting review from the team. label Nov 18, 2026
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/needs-review Awaiting review from the team. state/approved Proposal approved; ready for implementation. labels Nov 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the Copilot session-correlation telemetry changes.

No open issues 🎉

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Final test-triage resolution — Azure Pipelines build 1687682

Resolution: inconclusive, with no actionable defect found. The build result is succeeded. No issue is warranted.

  • Evidence gap: collection was incomplete. One artifact download failed and the history window is incomplete, so I can't claim the tests are clean.

  • Failed-status records: the evidence has 8 failed-status records, and none looks like a product regression. They come from the Windows and Linux legs (TestResults_Windows_* / TestResults_Linux_*), as shown below.

    • NativeTests.Outcome failed four times with expected host failure.
    • RetryFailsFirstAttempt (WinUI) and RetryTestMethod_PassesOnSecondAppContainerHost (PackagedWinUI) failed on the first attempt, as their names indicate.
    • InheritedMethodDeployment and InheritedClassDeployment (ModernUwp) failed with the DeploymentItemAttribute is not supported by UWP or WinUI test hosts message.
    • These look like deliberate probe assets run inside acceptance tests that assert on the failure. I didn't confirm that from the acceptance assertions in this run.
  • Flaky and retried tests: the evidence has no proven fail-then-pass recovery, no CTRF flaky flags and no retry attempts, so there is nothing to classify as flaky.

  • Crashes and hangs: none (diagnosticCount 0).

  • Slowness: there are no slow regressions (slowRegressionCount 0).

  • Pipeline timeline: the only signals are two DX0065 BuildXL warnings.

Next step: if you want certainty, re-run the leg whose artifact failed to download. Other tests could be affected, but nothing in the collected evidence points to a durable defect.

🤖 Automated content by GitHub Copilot. Generated by the Pipeline Test Triage workflow. · copilot · auto · ~35 AIC · ⌖ ~1 AIC · ⊞ 10.1K

@microsoft-github-policy-service microsoft-github-policy-service Bot added the state/needs-review Awaiting review from the team. label Nov 18, 2026
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/needs-review Awaiting review from the team. state/approved Proposal approved; ready for implementation. labels Nov 18, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added the state/needs-review Awaiting review from the team. label Nov 18, 2026
@Evangelink
Amaury Levé (Evangelink) merged commit 1893237 into main Nov 18, 2026
46 of 47 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/jankrivanek/copilot-telemetry-correlation branch November 18, 2026 13:46
@github-actions github-actions Bot removed state/needs-review Awaiting review from the team. state/approved Proposal approved; ready for implementation. labels Nov 18, 2026
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