Replies: 6 comments 7 replies
-
Provide a minimal application that shows what you are attempting to do. |
Beta Was this translation helpful? Give feedback.
-
It's just an app that receives a message from NATS and uses Vert.x for it's processing, including Vert.x Postgres Client. The agent intrumentation takes care of the Vert.x Postgres Client. But because NATS is not on the supported list, we need to do manual instrumentation for incoming messages (as described in https://opentelemetry.io/docs/instrumentation/java/manual/). But we cannot used the usual static calls in the OpenTelemetry SDK, like span makeCurrent or get current, because all those use ThreadLocal internally, which won't work for Vert.x that processes multiple requests in the same context. I guess we need to store the OTEL context in the Vert.x request context, and I saw such logic in the agent Vert.x Postgres Client. But did not manage to get that logic to find our OTEL context to use it as parent. |
Beta Was this translation helpful? Give feedback.
-
The code is just the sample code from https://opentelemetry.io/docs/instrumentation/java/manual/. But span.makeCurrent() is not safe with Vert.x as it will activate that span for ALL requests being processed by that verticle. As for "pass otel context along in some framework specific context like vetrt.x context", exactly what I am trying to ask here. What are those assumptions built into the otel java agent that handles the Vert.x SQL Client instrumentation? An user needs to know that in order to align any manual intrumentation with that. But I do not see that documented anywhere here. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Ok, I think I found my problem. Seems Vert.x SQL Client instrumentation does not work well with transactions. If I only do a query then the query span is tied to my manual instrumentation span. If I run a query in a transaction the query span does not use my parent span anymore. Simplified example below.
|
Beta Was this translation helpful? Give feedback.
-
I did the same test with a Vert.x HttpServer and without any manual instrumentation. Meaning all features supported by the OTEL agent. And same behavior. When I only use a query the query span ties to the http span. When I add a transaction the two spans are not tied anymore, and presented as independent spans. Seems SQL transactions break the instrumentation logic. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I need to do manual instrumentation for messages received over NATS, which is not supported by the agent. Also we use Vert.x in our application. The agent provides Vert.x SQL Client auto-instrumentation. But we cannot seem to correlate our spans with the sql spans. They do not inherit. The main problem is Vert.x's threading model is not thread per request, so thread-local context storing does not work (the same context will bleed to other requests). So, we are not sure how to make a span current in a Vert.x application. Using span.makeCurrent() will cause the same span to be set for all requests processed on that verticle thread. Reading through the agent code for Vert.x SQL Client, I noticed it stores the OTEL context it in the Vert.x context under the "otel.context" key. I tried to do that in our manual instrumentation too, but still the sql trace does not use our span as parent. Any guidance on how to integrate Integrating manual instrumentation with Vert.x SQL Client auto-instrumentation?
Thanks,
Adrian
Beta Was this translation helpful? Give feedback.
All reactions