[Shared] Refactor EnvironmentVariableScope#7175
Conversation
Copy from open-telemetry/opentelemetry-dotnet-contrib to support multiple variables without needing to allocator multiple scopes.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7175 +/- ##
==========================================
- Coverage 89.08% 89.06% -0.03%
==========================================
Files 271 271
Lines 13073 13073
==========================================
- Hits 11646 11643 -3
- Misses 1427 1430 +3
Flags with carried forward coverage won't be shown. Click here to find out more. |
There was a problem hiding this comment.
Pull request overview
Refactors the test-only EnvironmentVariableScope helper to support setting/restoring multiple environment variables in a single scope, and updates impacted tests to use the new factory-based API.
Changes:
- Replaced single-variable
EnvironmentVariableScopector usage withEnvironmentVariableScope.Create(...)across several tests. - Refactored
EnvironmentVariableScopeto track and restore multiple variables. - Minor expression-bodied member cleanup in
TracerProviderBuilderBaseTests.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/OpenTelemetry.Tests/EnvironmentVariableScope.cs | Refactors helper to support multiple env vars and adds Create factory overloads. |
| test/OpenTelemetry.Tests/Trace/TracerProviderBuilderBaseTests.cs | Switches env var scoping to Create and simplifies helper methods. |
| test/OpenTelemetry.Tests/Metrics/MeterProviderBuilderBaseTests.cs | Switches env var scoping to Create. |
| test/OpenTelemetry.Tests/Logs/LoggerProviderBuilderBaseTests.cs | Switches env var scoping to Create. |
| test/OpenTelemetry.Extensions.Hosting.Tests/OpenTelemetryMetricsBuilderExtensionsTests.cs | Switches env var scoping to Create for OTEL_SDK_DISABLED test. |
| test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpMetricsExporterTests.cs | Switches env var scoping to Create for env-var-based configuration test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
React to changes from open-telemetry#7175.
Changes
Copy from open-telemetry/opentelemetry-dotnet-contrib to support multiple variables without needing to allocator multiple scopes as I've found that need while working on #7168 and #7174.
Merge requirement checklist
AppropriateCHANGELOG.mdfiles updated for non-trivial changesChanges in public API reviewed (if applicable)