Integration with existing trace libraries #1062
Replies: 3 comments 5 replies
-
The Moleculer built-in tracing feature is a complete solution like the OpenTelemetry lib. Yeah, Moleculer Tracer doesn't have instrumentation for external libs and I don't plan to add it because it's a big "hacking" job, a lot of time, and doesn't give extra to the framework itself. Instead, my suggestion is to create a Moleculer instrumentation for OpenTelemetry. Similar to what dd-trace does. It can be a middleware (based on the built-in tracing middleware) which wraps the |
Beta Was this translation helpful? Give feedback.
-
I made an OpenTelemetry middleware and a demo Moleculer project which demonstrates my suggestion. It uses B3 propagator which pushes tracing info into https://github.com/icebob/moleculer-opentelemetry-demo The main things are in:
My experiences with OT:
|
Beta Was this translation helpful? Give feedback.
-
Nice example! btw. you could use the standard OTLP exporter and run e.g. https://raw.githubusercontent.com/grafana/docker-otel-lgtm/refs/heads/main/run-lgtm.sh locally. Same topic with 1 process 1 service but one less component in the mix. by the way one of the reasons why you see a single span rather than multiple ones is described well here https://stackoverflow.com/questions/72867313/opentelemetry-open-span-in-one-process-and-close-it-in-another. and this is partially just because how moleculer works. And at some point profiling will allow more detailed insight into the different spans https://opentelemetry.io/blog/2024/profiling/ |
Beta Was this translation helpful? Give feedback.
-
Projects like opentelmetry provide prebuilt instrumentation adapters for a whole range of libraries like MySQL, express, cloud SDKs, socket.io etc. It would convenient to use these tools in Moleculer without having to abandon the built-in tracing API provided by the framework.
Perhaps there's a way to share the current trace and span context between Moleculer and another library like OpenTelemetry and allow both to update the trace context.
A better idea might be to have a configurable
SpanFactory
that can create span instances that follow the existing Moleculer API but can use delegate span objects from other frameworks.Beta Was this translation helpful? Give feedback.
All reactions