Repository navigation
Create canonical MSTest execution spans - #11596
Amaury Levé (Evangelink) merged 9 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Canonical spans currently include potentially unbounded message-publication latency before test execution starts.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Introduces canonical MSTest execution spans so user instrumentation is naturally parented and results are correlated across asynchronous processing.
Changes:
- Adds an execution-activity broker and reservation lifecycle.
- Makes canonical activities ambient during MSTest execution.
- Adds telemetry topology, aggregation, concurrency, and integration coverage.
Confidence at a glance
🟡 Execution and telemetry lifecycle
One duration-boundary defect was identified: activity timing currently includes in-progress message publication latency.
| File | Description |
|---|---|
test/UnitTests/MSTestAdapter.UnitTests/MSTestTestNodeConverterTests.cs |
Tests multi-result reservation propagation. |
test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Execution/TestMethodRunnerTests.cs |
Tests lease entry with restored context. |
test/UnitTests/Microsoft.Testing.Platform.UnitTests/Telemetry/TestExecutionActivityBrokerTests.cs |
Covers broker lifecycle and aggregation. |
test/UnitTests/Microsoft.Testing.Platform.UnitTests/Telemetry/OpenTelemetryResultHandlerTests.cs |
Covers canonical result enrichment. |
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/OpenTelemetryPlatformServiceTests.cs |
Tests non-ambient activity behavior. |
test/IntegrationTests/MSTest.Acceptance.IntegrationTests/OpenTelemetryActivityTopologyTests.cs |
Validates end-to-end span topology. |
src/Platform/Microsoft.Testing.Platform/Telemetry/TestExecutionActivityProperty.cs |
Carries reservations through test updates. |
src/Platform/Microsoft.Testing.Platform/Telemetry/TestExecutionActivityBroker.cs |
Manages canonical activity lifecycles. |
src/Platform/Microsoft.Testing.Platform/Telemetry/OpenTelemetryResultHandler.Tags.cs |
Shares activity naming and initial tags. |
src/Platform/Microsoft.Testing.Platform/Telemetry/OpenTelemetryResultHandler.ResultHandling.cs |
Enriches canonical activities with results. |
src/Platform/Microsoft.Testing.Platform/Telemetry/OpenTelemetryResultHandler.Notifications.cs |
Tracks canonical activity notifications. |
src/Platform/Microsoft.Testing.Platform/Telemetry/OpenTelemetryResultHandler.cs |
Tracks active canonical reservations. |
src/Platform/Microsoft.Testing.Platform/Telemetry/IPlatformTestExecutionActivity.cs |
Defines execution activity operations. |
src/Platform/Microsoft.Testing.Platform/Telemetry/IPlatformOpenTelemetryServiceWithTestExecutionActivities.cs |
Defines canonical activity creation. |
src/Platform/Microsoft.Testing.Platform/Services/TestApplicationResult.cs |
Owns and disposes activity brokers. |
src/Platform/Microsoft.Testing.Platform/InternalAPI/InternalAPI.Unshipped.txt |
Tracks new platform internal APIs. |
src/Platform/Microsoft.Testing.Extensions.OpenTelemetry/PACKAGE.md |
Documents canonical topology behavior. |
src/Platform/Microsoft.Testing.Extensions.OpenTelemetry/OpenTelemetryPlatformService.cs |
Creates non-ambient execution activities. |
src/Platform/Microsoft.Testing.Extensions.OpenTelemetry/InternalAPI/InternalAPI.Unshipped.txt |
Tracks extension internal APIs. |
src/Platform/Microsoft.Testing.Extensions.OpenTelemetry/ActivityWrapper.cs |
Adds activity scopes and explicit stopping. |
src/Adapter/MSTestAdapter.PlatformServices/Telemetry/MSTestInstrumentation.cs |
Documents canonical fixture parenting. |
src/Adapter/MSTestAdapter.PlatformServices/ObjectModel/UnitTestElement.cs |
Stores process-local execution leases. |
src/Adapter/MSTestAdapter.PlatformServices/InternalAPI/InternalAPI.Unshipped.txt |
Tracks platform-services internal APIs. |
src/Adapter/MSTestAdapter.PlatformServices/Interfaces/ITestExecutionActivityLease.cs |
Defines MSTest’s lease contract. |
src/Adapter/MSTestAdapter.PlatformServices/Execution/UnitTestRunner.RunSingleTest.cs |
Passes leases into method execution. |
src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodRunner.Execution.cs |
Makes activities ambient around user code. |
src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodRunner.cs |
Suppresses duplicate method spans. |
src/Adapter/MSTestAdapter.PlatformServices/Execution/TestExecutionManager.Runner.cs |
Records canonical execution completion. |
src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MtpTestResultRecorder.cs |
Reserves and correlates execution activities. |
src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestTestFramework.cs |
Connects the broker to MSTest recording. |
src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestPlatformActivity.cs |
Parents fixture spans to ambient tests. |
src/Adapter/MSTest.TestAdapter/InternalAPI/uwp/InternalAPI.Unshipped.txt |
Tracks the UWP internal constructor. |
src/Adapter/MSTest.TestAdapter/InternalAPI/InternalAPI.Unshipped.txt |
Tracks the adapter internal constructor. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
One or more custom setup steps configured for this repository failed during this Copilot code review run: Setup steps run before each review. If the review above is missing context, or no review was posted at all, the failing step above may be the cause. See the workflow run for failure details, fix your setup steps configuration, and re-request a review. Note You can configure setup steps for Copilot code review separately from Copilot cloud agent with a |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Pre-activation end timestamps can produce invalid durations, and canonical activity propagation fails across default .NET Framework AppDomains.
Review effort: Balanced
Findings: 1
Open (2)
Resolved since last review (1)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…cal-mstest-execution-spans
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>


Summary
MSTest user code currently runs outside the MTP test-result activity, so automatic HTTP, SQL, EF, WCF, and custom activities cannot naturally become children of the test span. The separate execution and result activities can also represent one logical test twice in the trace.
This change creates one MTP-owned canonical activity per participating native MSTest execution. MSTest publishes the in-progress update before activating the canonical activity, enters it only after restoring its fixture
ExecutionContext, and restores the previous ambient activity without stopping it. The MTP result pipeline enriches and stops that same activity exactly once using the producer execution-end timestamp, so message-publication and asynchronous result-queue delays do not inflate test duration.The package-consuming topology acceptance verifies parallel HTTP and custom activities are naturally parented to the correct canonical test span, parallel tests remain isolated, retries and folded/unfolded data rows retain distinct occurrence identity, skipped results are enriched, and no duplicate
MSTest.TestMethodactivity is exported. Standard ambientActivity.Currentbehavior provides the same parentage mechanism for SQL, EF, WCF, and other compliant instrumentation.Architecture decisions
Activity.Currentstate.IPlatformOpenTelemetryService.StartActivitysignature or adding OpenTelemetry SDK ownership to the dependency-free platform core.ActivityLinkcorrelation from Correlate test result spans with execution activities #11529.Validation
build.cmd -pack -blcompleted successfully and produced shipping packages before publication and after each lifecycle review fix.Microsoft.Testing.Platform,Microsoft.Testing.Extensions.OpenTelemetry,MSTestAdapter.PlatformServices, andMSTest.TestAdapter, including .NET Framework, Windows, and UAP targets where applicable.ActivityLinkfallback acceptance.git diff --check, changed-C# UTF-8 BOM verification, focused-scope inspection, and TestFx code-review passes were clean.Bounded limitations
ActivitySourceandHttpClientinstrumentation. SQL, EF, WCF, and similar integrations rely on the same standard ambientActivity.Currentcontract but are not each package-integrated in this PR.TracerProvider,MeterProvider, exporter, or hosted entrypoint; application/provider ownership remains unchanged.Related to #11505