Skip to content

test: expand coverage for src/tracing/exporters.cpp #1022

Description

@kcenon

Part of #953

What

Raise line coverage of src/tracing/exporters.cpp from 7.4% to >= 70%, and branch coverage to >= 60%.

Current state (pre-Step-1 snapshot, 2026-04-13 measurement from parent epic #953):

  • Lines hit: 25 / 340 (7.4%)
  • File size: 340 LOC

Note: These numbers predate the BUILD_WITH_* workflow fix (#987, #989). A re-measurement on the current develop baseline will be captured in the PR description before merging.

Why

  • Tracing exporters are the egress path for span data; silent failures here mean missing observability in production with no on-host signal.
  • 7.4% line coverage implies exporter error paths (network failures, backend 5xx, serialization errors, shutdown races) are largely unexercised.
  • Observability code is particularly costly to debug in production — regression bugs surface only when tracing is most needed.

Where

  • Source: src/tracing/exporters.cpp
  • Headers: include/kcenon/network/tracing/exporters.hpp (verify exact path)
  • Existing tests to extend: tests/unit/tracing/ — check for existing exporter tests before adding
  • May require: test doubles for exporter sinks (OTLP/HTTP/stdout backends) — inspect existing fixtures first

How

Approach

  1. Enumerate each concrete exporter implementation (OTLP, HTTP, stdout, noop — verify actual set in code).
  2. Write tests covering:
    • Happy-path export of a populated span batch
    • Empty-batch and oversized-batch handling
    • Backend-failure paths (connection refused, timeout, 5xx response, partial write)
    • Serialization edge cases (unicode span names, empty attributes, deeply nested events)
    • Shutdown behavior: pending exports flushed, in-flight exports cancelled safely
  3. Use existing tracing test fixtures if present; otherwise add minimal sink doubles.

Acceptance Criteria

  • src/tracing/exporters.cpp line coverage >= 70%
  • src/tracing/exporters.cpp branch coverage >= 60%
  • New or extended tests in tests/unit/tracing/
  • All tests pass on Ubuntu/macOS/Windows CI
  • ASAN/TSAN/UBSAN all green on the new tests
  • Current develop baseline re-measured in PR description

Dependencies

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions