Skip to content

#62 document OpenTelemetry auto discovery NPE's #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

steven-aerts
Copy link

During auto-discovery it is possible that you see NPE's in OpenTelemetry when the VertxContextProvider picked up as the default ContextProvder. This behavior can be prevented with a system property.

During auto-discovery it is possible that you see NPE's in OpenTelemetry when the VertxContextProvider picked up as the default ContextProvder.  This behavior can be prevented with a system property.
@tsegismont
Copy link
Contributor

Thank you @steven-aerts

Can you share the full stack trace please?

@tsegismont
Copy link
Contributor

I guess this comes from current context which is null.

We should update the implementation so that the noop scope is used if the current context is null. And also, log a trace level message.

Can you take care of it?

Copy link
Contributor

@tsegismont tsegismont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment about the doc

@@ -67,3 +67,12 @@ The default sending policy is `PROPAGATE`, you can configure the policy with {@l
----
{@link examples.OpenTelemetryExamples#ex6}
----

== Vert.x tracing and auto-configuration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you agree to modify the code as suggested, I think this part should be re-written to indicate that the VertxContextStorage is fine with pure Vert.x application but it might not be the best choice for mixed apps. And then the user needs to select the appropriate storage via the sysprop

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both we, as the reporter of #62 seem to have seen this in a pure Vert.x applications, but OpenTelemetry itself is also creating traces for the actions it does, and those traces need a ContextStorage which works for them.
I will see if I can try to reword it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then perhaps the Vertx Context Storage can delegate to the default storage when not running on the Vert.x thread?

@steven-aerts
Copy link
Author

I guess this comes from current context which is null.

We should update the implementation so that the noop scope is used if the current context is null. And also, log a trace level message.

Can you take care of it?

Stacktrace and more context in #62.
Yes, the context is null, but that does not mean we can just ignore things, as it still needs to act as a ContextStorage.
I am more wondering if the SPI is necessary for Vert.x as it is more or less saying here is a ContextStorage for everyone to use. Which is of course not the case.
I have the feeling that by just removing the SPI, things might just keep on working, as Vert.x will still attach the correct storage, but it will not be picked up automagically.

This might solve this issue without any need to define a system property.

@tsegismont
Copy link
Contributor

I have the feeling that by just removing the SPI, things might just keep on working, as Vert.x will still attach the correct storage, but it will not be picked up automagically.

If we do this, then it's no longer possible to call Span.current() and retrieve the span created by Vert.x

@steven-aerts
Copy link
Author

That is sad, Span.current() works when the system property is set.

I am not too familiar with the opentelemetry code base, to understand how to best fall back. For example in more complex examples, like how to behave if a third ContextProvider is injected?

Do you think it is still usefull to update the documentation? Or do you think this is something which needs need be addressed in code?

@Traderjoe95
Copy link

I am not too familiar with the opentelemetry code base, to understand how to best fall back. For example in more complex examples, like how to behave if a third ContextProvider is injected?

That's indeed a good question. But I think it's one we can leave up to the application to decide. A good default behavior for the Vert.x Context Storage is to delegate to OpenTelemetry's default context storage. But maybe we can make that configurable. i.e. let the application configure an alternative fallback in OpenTelemetryOptions, if required. But we could run into difficulties with the singleton implementation of VertxContextStorage then. What do you think, @tsegismont?

@tsegismont
Copy link
Contributor

@steven-aerts thank you for bringing this to our attention.

I will close this PR in favor of #72 (which makes the Vert.x context storage provider use the default provider when not invoked on a Vert.x thread).

@tsegismont tsegismont closed this Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants