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

Can't use TracedSubscriber with r2dbc #14

Open
pe4enko opened this issue Jun 7, 2021 · 2 comments
Open

Can't use TracedSubscriber with r2dbc #14

pe4enko opened this issue Jun 7, 2021 · 2 comments

Comments

@pe4enko
Copy link

pe4enko commented Jun 7, 2021

We are using ProjectReactor and grpc, as well as using reactive drivers for postgres r2dbc-postgresql.
There are 3 microservices.
A grpc request is made from the pvi-adapter application, to the ed-server application, then a transaction is opened, some kind of business logic is executed, then a grpc call to the dicts server is made.
When you start the application for the first time and receive the first grpc request from pvi-adapter, all spans are appended in the correct sequence and to the correct trace.
But all subsequent requests received via grpc from pvi-adpater are also bound to the span that was formed at the first request.
To pass the span in the reactor, we use
Hooks.onEachOperator (TracedSubscriber.asOperator (tracer));
Hooks.onLastOperator (TracedSubscriber.asOperator (tracer));
as you have written about it https://github.com/opentracing-contrib/java-reactor

To pass the span through grpc, we use
TracingServerInterceptor and TracingClientInterceptor from repository
https://github.com/opentracing-contrib/java-grpc

After a long debugging, I came to the conclusion that the problem is that the postgres r2dbc driver keeps the context passed through TracedSubscriber until the connection to the database is interrupted io.r2dbc.postgresql.client.ReactorNettyClient

https://github.com/pgjdbc/r2dbc-postgresql/blob/main/src/main/java/io/r2dbc/postgresql/client/ReactorNettyClient.java

The question is who faced such a problem and how to get around it? Now it turns out that using TracedSubscriber in a fully reactive environment with reactive drivers for postgres is not possible.

@jam01
Copy link
Collaborator

jam01 commented Jun 7, 2021

The fact that the library uses the same first span sideways that the library's chain is not really part of the request handling chain in the way that is expected, otherwise the right context span would be used.

Perhaps there's an instrumentation for that specific library...?

@pe4enko
Copy link
Author

pe4enko commented Jun 7, 2021

Library is PostgreSQL R2DBC Driver https://github.com/pgjdbc/r2dbc-postgresql
Is it part of request handling chain? Is it possible to skip this library from tracing, then i use TracedSubscriber?

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

No branches or pull requests

2 participants