Skip to content

test: improve unit test coverage to 80%+ across packages#550

Open
bobstrecansky wants to merge 2 commits intoopen-telemetry:mainfrom
bobstrecansky:coverage-improvements-2026-04-02
Open

test: improve unit test coverage to 80%+ across packages#550
bobstrecansky wants to merge 2 commits intoopen-telemetry:mainfrom
bobstrecansky:coverage-improvements-2026-04-02

Conversation

@bobstrecansky
Copy link
Copy Markdown
Contributor

Summary

  • Add unit tests for PSR instrumentation packages (Psr3, Psr6, Psr14, Psr16) that previously had 0-37% coverage
  • Add additional unit tests for HttpConfig, Propagation (CloudTrace, Instana, ServerTiming, TraceResponse), ResourceDetectors (Azure, Container), OpenTracing shim, and SqlCommenter

Coverage improvements

Package Before After
Instrumentation/Psr6 0% 97.44%
Instrumentation/Psr14 0% 81.82%
Instrumentation/Psr16 0% 97.30%
Instrumentation/Psr3 36.96% 92.39%

All other modified packages also brought above the 80% line coverage threshold.

Test plan

  • Run PROJECT=Instrumentation/Psr6 make test-unit — verify all tests pass
  • Run PROJECT=Instrumentation/Psr14 make test-unit — verify all tests pass
  • Run PROJECT=Instrumentation/Psr16 make test-unit — verify all tests pass
  • Run PROJECT=Instrumentation/Psr3 make test-unit — verify all tests pass
  • CI passes for all modified packages

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)
@bobstrecansky bobstrecansky requested a review from a team as a code owner April 6, 2026 12:37
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.29%. Comparing base (9c73e84) to head (7ea9873).

Additional details and impacted files

Impacted file tree graph

@@             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     
Flag Coverage Δ
Aws 93.37% <ø> (ø)
Context/Swoole 0.00% <ø> (ø)
Exporter/Instana 49.80% <ø> (ø)
Instrumentation/AwsSdk 82.14% <ø> (ø)
Instrumentation/CakePHP 20.42% <ø> (ø)
Instrumentation/CodeIgniter 79.31% <ø> (ø)
Instrumentation/Curl 86.88% <ø> (ø)
Instrumentation/Doctrine 92.82% <ø> (ø)
Instrumentation/ExtAmqp 88.80% <ø> (ø)
Instrumentation/Guzzle 76.25% <ø> (ø)
Instrumentation/HttpAsyncClient 78.94% <ø> (ø)
Instrumentation/HttpConfig ?
Instrumentation/IO 0.00% <ø> (ø)
Instrumentation/Laravel 76.03% <ø> (ø)
Instrumentation/MongoDB 76.84% <ø> (ø)
Instrumentation/MySqli 93.39% <ø> (ø)
Instrumentation/OpenAIPHP 86.71% <ø> (ø)
Instrumentation/PDO 85.67% <ø> (ø)
Instrumentation/PostgreSql 91.36% <ø> (ø)
Instrumentation/Psr14 ?
Instrumentation/Psr15 89.74% <ø> (ø)
Instrumentation/Psr16 ?
Instrumentation/Psr18 79.41% <ø> (ø)
Instrumentation/Psr3 ?
Instrumentation/Psr6 ?
Instrumentation/Session 94.28% <ø> (ø)
Instrumentation/Slim 84.21% <ø> (ø)
Logs/Monolog 100.00% <ø> (ø)
Propagation/CloudTrace ?
Propagation/Instana ?
Propagation/ServerTiming ?
Propagation/TraceResponse ?
ResourceDetectors/Azure 100.00% <ø> (+8.33%) ⬆️
ResourceDetectors/Container 100.00% <ø> (+6.97%) ⬆️
ResourceDetectors/DigitalOcean 100.00% <ø> (ø)
Sampler/Xray 78.38% <ø> (ø)
Shims/OpenTracing ?
SqlCommenter 100.00% <ø> (+4.41%) ⬆️
Symfony 88.14% <ø> (ø)
Utils/Test 87.79% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 35 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9c73e84...7ea9873. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant