hivemq / hivemq-mqtt-client

HiveMQ MQTT Client is an MQTT 5.0 and MQTT 3.1.1 compatible and feature-rich high-performance Java client library with different API flavours and backpressure support
https://hivemq.github.io/hivemq-mqtt-client/
Apache License 2.0
855 stars 158 forks source link

W3C trace context propagation and OpenTracing / OpenTelemetry support #384

Open frittentheke opened 4 years ago

frittentheke commented 4 years ago

Problem or use case

While distributed systems are already a pain to debug, adding asynchronicity as with MQTT makes things even harder. More and more tools add OpenTracing (or later OpenTelemetry) capabilities to their code. While this comes quite natural to HTTP with its headers, it is not limited to be used via HTTP.

The W3C trying to standardize the way the context is propagated via MQTT in https://github.com/w3c/trace-context-mqtt

Would you kindly consider adding

Initially: Context Propagation (receive, forward and emit a new trace context - to NOT be a blackhole to tracing)

Later: Native support to add a spans / metadata to traces.

Preferred solution or suggestions

W3C is already working on a standard: https://github.com/w3c/trace-context-mqtt

fischerman commented 4 years ago

With OpenTelemetry going beta we could make use of this new standard. It supports W3C headers out of the box. We would only have to add the OpenTelementry API as a dependency and set two user properties, given that MQTT 5 is used. No API change is required. It will also work if the application does not use OpenTelemetry.

fischerman commented 4 years ago

I had a quick browse through the code and the change seems to be more complicated than anticipated due to the different API flavors and the enormous level of indirectness (builders, many layers of inheritance, ...), which I guess is in the nature of Java.

Any pointers w.r.t. the right place to inject / extract the context is appreciated. I might be able to piece up a pull request.

frittentheke commented 3 years ago

@SgtSilvio @dobermai The W3C has now moved this to a draft status (https://w3c.github.io/trace-context-mqtt/) with Sergey Kanzhelev (Google) and Clemens Vasters (Microsoft) as editors.

cforce commented 10 months ago

Any update here?