Skip to content

test(producer): pin Tracer header injection through DLQ#191

Merged
eschizoid merged 1 commit into
mainfrom
test/tracer-injection-through-dlq
Jun 18, 2026
Merged

test(producer): pin Tracer header injection through DLQ#191
eschizoid merged 1 commit into
mainfrom
test/tracer-injection-through-dlq

Conversation

@eschizoid

Copy link
Copy Markdown
Owner

Summary

Closes a criticality-5 coverage gap: a future refactor that drops the tracer.injectContextInto(headers) call in KPipeProducer.sendToDlq would silently strip trace context from DLQ records without any existing test failing.

  • Adds dlqRecordCarriesTracerInjectedHeaders to KPipeProducerTest.
  • Wires a tiny anonymous Tracer stub (not Mockito) that stamps x-tracer-stamp: yes during injectContextInto.
  • Asserts the stamp lands on the captured outbound ProducerRecord's headers after a sendToDlq call.

Existing shouldSendDlqRecordWithAllHeaders covers the static x-dlq-* enrichment headers but never exercises the tracer injection branch; using a hand-written stub keeps the contract enforced by behaviour rather than by Mockito argument matching.

No production-code change. Production already invokes the tracer correctly at KPipeProducer.java:183 — this PR just pins that invariant under test.

Test plan

  • ./gradlew :lib:kpipe-producer:test — green (24 tests in KPipeProducerTest, was 23).
  • New test exercises a real anonymous Tracer implementation, not a mock.
  • No production code touched.

Existing shouldSendDlqRecordWithAllHeaders covers the static x-dlq-*
headers but does NOT verify that a custom Tracer's injectContextInto
runs against the outbound record. A future refactor that drops the
tracer.injectContextInto(headers) call would silently strip trace
context from DLQ records without any test failure.

New test dlqRecordCarriesTracerInjectedHeaders wires a tiny anonymous
Tracer stub that stamps x-tracer-stamp: yes during injection, sends a
record through sendToDlq, and asserts the stamp lands on the captured
ProducerRecord. Uses a hand-written stub (not Mockito) so the contract
is enforced by behaviour, not by argument matching.
@eschizoid

Copy link
Copy Markdown
Owner Author

@copilot please review

@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.60%. Comparing base (eb21492) to head (4d46452).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #191      +/-   ##
============================================
- Coverage     77.64%   77.60%   -0.04%     
+ Complexity      732      731       -1     
============================================
  Files            68       68              
  Lines          2800     2800              
  Branches        346      346              
============================================
- Hits           2174     2173       -1     
  Misses          465      465              
- Partials        161      162       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@eschizoid eschizoid merged commit b5943b1 into main Jun 18, 2026
3 of 4 checks passed
@eschizoid eschizoid deleted the test/tracer-injection-through-dlq branch June 22, 2026 04:02
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