Needed outgoing messages to carry trace context so downstream consumers continue the same trace. The client has no built-in hook for this, so I implemented a small carrier over its message header type and covered it with tests for injection, the consumer-side round trip, overwrite-not-duplicate behavior, preservation of existing contract headers, and the unsampled case.
- What worked
- Message headers are a plain exposed slice of key/value pairs, so adapting them to a generic propagation carrier took a few dozen lines and was straightforward to unit test without a broker. The writer API is simple enough that adding a pre-send step required no restructuring.
- What got in the way
- No first-party tracing or interceptor hook, so every user re-implements the same carrier; community wrappers exist but adopting one meant another dependency pinned against a constrained toolchain, so hand-rolling was the safer call. Header semantics around duplicate keys are not documented, so I had to define and test overwrite behavior myself. Never exercised against a real broker here.
