You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make OpenTelemetry resource enrichment composable - #11526
Applications using Aspire ServiceDefaults or another application-owned OpenTelemetry setup already define their service, host, OS, and process identity. The existing aggregate MTP resource helper also defines those attributes, making it difficult to add only test and CI provenance without relying on resource ordering.
This follow-up to #11521 adds two focused composition paths:
AddTestingPlatformTestResource() adds test-specific resource identity, currently test.assembly.name.
AddTestingPlatformCiResource() adds the existing cicd.* and vcs.* provider mappings, including repository URL credential stripping.
Neither focused helper changes service.*, host.*, os.*, or process.*. The shipped AddTestingPlatformResource() remains the standalone aggregate convenience path and preserves its existing service identity, generated instance ID, host/OS/process, test assembly, and CI/VCS behavior.
The package documentation now recommends the focused helpers for Aspire ServiceDefaults, HostApplicationBuilder, and other application-owned resource configurations. Public/internal API baselines and direct regression, isolation, mapping, and precedence tests are included.
coverable once the parallel-safety analyzers ship (attribute-based opt-in)
Findings: A (global-state) 0 · B (paths) 0 · C (declaration) 0 · D (over-serialization) 0 — by severity: Critical 0 · High 0 · Warning 0 · Info 0.
The only changed test file is test/UnitTests/Microsoft.Testing.Extensions.UnitTests/OpenTelemetryProviderExtensionsTests.cs, which adds several new [TestMethod]s exercising the new AddTestingPlatformTestResource() / AddTestingPlatformCiResource() composition helpers, plus a new synchronous WithEnvironment(Dictionary<string, string?>, Action) helper mirroring the pre-existing WithEnvironmentAsync.
Reviewed for parallel-safety under MethodLevel:
Category A (env var mutation). Every new test that mutates real environment variables (AddTestingPlatformResource_PreservesAggregateResourceBehavior, AddTestingPlatformTestResource_AddsOnlyTestSpecificAttributes, AddTestingPlatformCiResource_EmitsExistingProviderMappingsWithoutApplicationOrTestIdentity, FocusedResourceHelpers_PreserveApplicationOwnedIdentity) carries a method-level [ResourceLock(WellKnownResources.EnvironmentVariables)], consistent with the existing pattern used elsewhere in this class and in AzureFoundryChatClientProviderTests / TestingPlatformResourceDetectorTests.
Restoration paired with the lock. The new WithEnvironment helper snapshots every name in ObservedEnvironmentVariables (which the PR correctly extends with the new CI/service env-var names the detector now reads), clears them, runs the body, and restores the snapshot in a finally — matching the async twin. No leaked mutation across serialized tests.
Category C (declaration reconciliation). The production code these tests exercise (TestingPlatformResourceDetector.cs, OpenTelemetryProviderExtensions.cs) only reads via Environment.GetEnvironmentVariable/Environment.MachineName/Environment.ProcessId — all covered by the single WellKnownResources.EnvironmentVariables key used consistently across the file and the rest of the assembly. No under-declaration, no key near-miss (no custom string keys were introduced).
Category D. No [DoNotParallelize] was added by this PR (the pre-existing one on the end-to-end TracerProvider test is untouched), and no class-level lock over-serializes — everything is method-level and narrowly scoped.
Nothing in this diff introduces a parallel-safety hazard. No findings to report.
Advisory only — heuristic, non-blocking. Re-run with /parallel-audit. This audit answers "is it parallel-safe?"; for testability, smells, or flakiness see the detect-static-dependencies / test-smell-detection / test-anti-patterns analyses.
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
github.com
To allow these domains, add them to the network.allowed list in your workflow frontmatter:
The repository consistently spells the two-letter CI acronym in identifiers (CIConditionAttribute, CIEnvironmentDetector, TryGetCIConditionMode). Shipping AddTestingPlatformCiResource would permanently add an inconsistent public API name; rename it to AddTestingPlatformCIResource and update its baseline, tests, and documentation before release.
PACKAGE.md is rendered as the NuGet package readme, so this repository-relative target resolves under nuget.org rather than GitHub and the published sample link will be broken. Use an absolute GitHub URL, consistent with the other package readmes.
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
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
Applications using Aspire ServiceDefaults or another application-owned OpenTelemetry setup already define their service, host, OS, and process identity. The existing aggregate MTP resource helper also defines those attributes, making it difficult to add only test and CI provenance without relying on resource ordering.
This follow-up to #11521 adds two focused composition paths:
AddTestingPlatformTestResource()adds test-specific resource identity, currentlytest.assembly.name.AddTestingPlatformCiResource()adds the existingcicd.*andvcs.*provider mappings, including repository URL credential stripping.Neither focused helper changes
service.*,host.*,os.*, orprocess.*. The shippedAddTestingPlatformResource()remains the standalone aggregate convenience path and preserves its existing service identity, generated instance ID, host/OS/process, test assembly, and CI/VCS behavior.The package documentation now recommends the focused helpers for Aspire ServiceDefaults,
HostApplicationBuilder, and other application-owned resource configurations. Public/internal API baselines and direct regression, isolation, mapping, and precedence tests are included.Related to #11505.
Validation
.\build.cmd -bl -projects test\UnitTests\Microsoft.Testing.Extensions.UnitTests\Microsoft.Testing.Extensions.UnitTests.csprojOpenTelemetryProviderExtensionsTestsandTestingPlatformResourceDetectorTests: 50/50 passed onnet8.0OpenTelemetryProviderExtensionsTestsandTestingPlatformResourceDetectorTests: 50/50 passed onnet9.0.\build.cmd -bl -projects src\Platform\Microsoft.Testing.Extensions.OpenTelemetry\Microsoft.Testing.Extensions.OpenTelemetry.csproj(netstandard2.0,net8.0,net9.0)