test: improve unit test coverage to 80%+ across packages#550
Open
bobstrecansky wants to merge 2 commits intoopen-telemetry:mainfrom
Open
test: improve unit test coverage to 80%+ across packages#550bobstrecansky wants to merge 2 commits intoopen-telemetry:mainfrom
bobstrecansky wants to merge 2 commits intoopen-telemetry:mainfrom
Conversation
Add unit tests to reach 100% coverage on 10 packages: - Propagation/ServerTiming, TraceResponse, CloudTrace, Instana - Shims/OpenTracing (new unit tests for Scope, Span, Tracer) - SqlCommenter, ResourceDetectors/Azure, Container, DigitalOcean - Logs/Monolog (already at 100%) Add new test files for Instrumentation/HttpConfig covering HttpConfig, HttpClientConfig, HttpServerConfig, MultiSanitizer, and NoopSanitizer classes. Key test additions: - Singleton getInstance() coverage via reflection reset - Edge case coverage for CloudTrace formatter (invalid headers, missing span/options, invalid base conversion chars) - OpenTracing shim: scope chain restoration through closed scopes, invalid timestamp/exception types, binary format exceptions, flush with SDK vs non-SDK providers - Azure/Container resource detectors: empty env var and HTTP error fallback paths - SqlCommenter: null propagator global fallback, multi-propagator with all-invalid entries
Add unit tests for Psr3, Psr6, Psr14, and Psr16 instrumentation packages to achieve 80%+ line coverage on each. - Psr6: 0% → 97.44% (13 tests covering all cache pool operations) - Psr14: 0% → 81.82% (5 tests covering event dispatch) - Psr16: 0% → 97.30% (12 tests covering all simple cache operations) - Psr3: 36.96% → 92.39% (21 tests covering inject/export modes)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #550 +/- ##
============================================
+ Coverage 82.56% 83.29% +0.72%
+ Complexity 2306 2071 -235
============================================
Files 156 127 -29
Lines 8571 7885 -686
============================================
- Hits 7077 6568 -509
+ Misses 1494 1317 -177 Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Coverage improvements
All other modified packages also brought above the 80% line coverage threshold.
Test plan
PROJECT=Instrumentation/Psr6 make test-unit— verify all tests passPROJECT=Instrumentation/Psr14 make test-unit— verify all tests passPROJECT=Instrumentation/Psr16 make test-unit— verify all tests passPROJECT=Instrumentation/Psr3 make test-unit— verify all tests pass