MultiplexInstrument can hold multiple Tracers, but only sends traces to one of them — is this expected?
The asymmetry is that inject/extract fan out to every member of the multiplex, but span creation doesn't: InstrumentationSystem.tracer/legacyTracer and the free-function withSpan/startSpan resolve to the first Tracer in the
multiplex and ignore the rest. So context is propagated through all members, but only one of them ever receives spans.
import Tracing
import InMemoryTracing
let tracerA = InMemoryTracer()
let tracerB = InMemoryTracer()
InstrumentationSystem.bootstrap(MultiplexInstrument([tracerA, tracerB]))
withSpan("request") { _ in }
print(tracerA.finishedSpans.count) // 1
print(tracerB.finishedSpans.count) // 0 ← tracerB never sees the span
So my questions:
Is "only the first Tracer receives spans" the intended contract? If so, it would be worth documenting on MultiplexInstrument, since "use multiple instruments" reads as though all of them are active. If not, should span creation fan out to every Tracer in the multiplex?
MultiplexInstrumentcan hold multipleTracers, but only sends traces to one of them — is this expected?The asymmetry is that
inject/extractfan out to every member of the multiplex, but span creation doesn't:InstrumentationSystem.tracer/legacyTracerand the free-functionwithSpan/startSpanresolve to the firstTracerin themultiplex and ignore the rest. So context is propagated through all members, but only one of them ever receives spans.
So my questions:
Is "only the first
Tracerreceives spans" the intended contract? If so, it would be worth documenting onMultiplexInstrument, since "use multiple instruments" reads as though all of them are active. If not, should span creation fan out to everyTracerin the multiplex?