Skip to content
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

[WIP] Mongodb otel refactor #40472

Closed
wants to merge 14 commits into from
Closed

Conversation

vkn
Copy link
Contributor

@vkn vkn commented May 6, 2024

Initially #40191 added mongo db commands to otel traces. This PR moves the implementation from mongodb-client extension to opentelemetry

vkn added 5 commits May 3, 2024 17:18
Instead of storing the full mongo event object,
we only save command name and the command itself
As suggested by @brunobat, moving the implementation
from mongo-client to opentelemetry extension
Otherwise OOM would happen atm
Fixing failing windows tests
The mongo dependency is optional and we must
include mongo tracing only if mongo dependency
is present and mongo tracing is enabled

Also moving the build item to TracerProcessor
Copy link

quarkus-bot bot commented May 6, 2024

/cc @radcortez (opentelemetry)

Copy link

quarkus-bot bot commented May 6, 2024

Thanks for your pull request!

The title of your pull request does not follow our editorial rules. Could you have a look?

  • title should preferably start with an uppercase character (if it makes sense!)

This message is automatically generated by a bot.

vkn added 4 commits May 6, 2024 16:49
The endpoints called from blockingClientError
or reactiveClientError tests will return 500
because of invalid mongo query.

We assert that the invalid query was added to
the traces
Verify that mongo span has parent span id matching
root span id
@vkn
Copy link
Contributor Author

vkn commented May 16, 2024

@brunobat I've added docs and parent-child relationship tests, which shows that in reactive case the mongo span is not added to the parent, as the listener is executed in a separate thread from vert.x event loop thread containing parent span. Any hints how to propagate the parent context to the listener. I've tried a few things but it didn't work
Thanks!

Copy link

github-actions bot commented May 16, 2024

🙈 The PR is closed and the preview is expired.

vkn added 2 commits May 17, 2024 14:44
To correctly implement opentelemetry traces
in mongodb listeners we need to propagate traces
with the help of ReactiveContextProvider, which
will create request context to be used in mongo
command listener implementations
If mongo request context contains trace context
then we must use it as parent, otherwise mongo span
would not be the child of the parent span
@brunobat
Copy link
Contributor

brunobat commented May 17, 2024

Let me think about this... Please park it for a couple days.

Copy link
Contributor

@brunobat brunobat left a comment

Choose a reason for hiding this comment

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

Thanks for your time on this.
Let's keep your original implementation and only add the documentation and tests to this PR.

@@ -659,6 +659,7 @@ Additional exporters will be available in the Quarkiverse https://docs.quarkiver
* https://quarkus.io/guides/scheduler[`quarkus-scheduler`]
* https://quarkus.io/guides/smallrye-graphql[`quarkus-smallrye-graphql`]
* https://quarkus.io/extensions/io.quarkus/quarkus-messaging[`quarkus-messaging`]
* https://quarkus.io/extensions/io.quarkus/quarkus-mongodb-client[`quarkus-mongodb-client`]
Copy link
Contributor

Choose a reason for hiding this comment

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

In needs to be inserted above quarkus-messaging

@@ -26,6 +26,11 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-mongodb-client</artifactId>
Copy link
Contributor

@brunobat brunobat May 17, 2024

Choose a reason for hiding this comment

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

Looking at how messy the de code will be, with many property overrides, I think your original implementation is better and I was wrong when I asked you to move it to the OpenTelemetry extension.
Please ignore that request. Sorry.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@brunobat Ok. I've opened #40714 . Canceling this one

public CompletionStage<List<Book>> getBooksError() {
BsonDocument query = new BsonDocument();
query.put("$invalidop", new BsonDouble(0d));
return getCollection().find(query).collect().asList().subscribeAsCompletionStage();
Copy link
Contributor

Choose a reason for hiding this comment

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

The context propagation will not happen when calling the MongoDB directly.
Please check the injected reactive client, it should provide the required propagation: https://quarkus.io/guides/mongodb#reactive.

Copy link
Contributor Author

@vkn vkn May 18, 2024

Choose a reason for hiding this comment

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

I've fixed reactive context propagation by a registering com.mongodb.reactivestreams.client.ReactiveContextProvider.

@vkn vkn closed this May 18, 2024
@quarkus-bot quarkus-bot bot added the triage/invalid This doesn't seem right label May 18, 2024
@vkn vkn deleted the mongodb-otel-refactor branch May 18, 2024 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

2 participants