Hi,
I’m trying to use OpenTelemetry in a project which heavily uses flows.
I have flows with incoming messages, each message comes together with a Span
and I would like to propagate Span
through the flow
so all loggers and other processing functions can access current span
via thread local Context.current()
.
For example
source.map { msg ->
logger.info("...") // <--- logger here has access to current span which is span from msg
msg.size
}.map { size ->
logger.info("...") // <--- even logger here has access to current span
}
It would be even better if all flow operators could work with spans reasonably well.
Eg. flat map operator could create child spans and end original span.
Is this possible without rewriting every flow operator?
(I believe can replace original flow with flow of pairs where first component is carrying the original message and second component carries span and then redefine all operators to correctly propagate span or create child spans and configure current context in thread local storage. But this doesn’t seem very elegant because I have to replace original operators with custom versions and maintain custom versions. And all my operators must work with span too - which seems distracting from their main purpose)