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

GRPC: Adds peer socket address when the client call is ready #7451

Conversation

anuragagarwal561994
Copy link
Contributor

Closes #7445

@anuragagarwal561994 anuragagarwal561994 requested a review from a team December 19, 2022 22:31
@anuragagarwal561994
Copy link
Contributor Author

Verified the changes to work with grpc-xds setup

[otel.javaagent 2022-12-19 22:53:17:631 +0000] [grpc-default-executor-3] INFO io.opentelemetry.exporter.logging.LoggingSpanExporter - 'ipservice.IPService/GetIPInfo' : 6783b44a39675cf7cf127fbd297515a2 5366b7dedd31904c CLIENT [tracer: io.opentelemetry.grpc-1.6:1.22.0-alpha-SNAPSHOT] AttributesMap{data={net.peer.name=grpc-server, net.transport=ip_tcp, thread.id=39, rpc.service=ipservice.IPService, rpc.grpc.status_code=0, rpc.method=GetIPInfo, net.peer.port=9090, rpc.system=grpc, thread.name=http-nio-8080-exec-6}, capacity=128, totalAddedValues=9}

[otel.javaagent 2022-12-19 22:53:17:632 +0000] [http-nio-8080-exec-6] INFO io.opentelemetry.exporter.logging.LoggingSpanExporter - 'HTTP GET' : 6783b44a39675cf7cf127fbd297515a2 0f3a55d67a1f558c SERVER [tracer: io.opentelemetry.tomcat-7.0:1.22.0-alpha-SNAPSHOT] AttributesMap{data={net.transport=ip_tcp, net.sock.peer.port=37384, net.host.name=grpc-client, thread.id=39, http.target=/ipservice/grpc, net.sock.peer.addr=127.0.0.1, http.flavor=1.1, http.response_content_length=104, net.host.port=8080, thread.name=http-nio-8080-exec-6, http.status_code=200, net.sock.host.addr=127.0.0.1, http.request.header.accept=[*/*], http.user_agent=curl/7.85.0, http.method=GET, http.scheme=http}, capacity=128, totalAddedValues=16}

Copy link
Member

@mateuszrzeszutek mateuszrzeszutek left a comment

Choose a reason for hiding this comment

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

Thanks! 🚀

@mateuszrzeszutek mateuszrzeszutek merged commit 390803d into open-telemetry:main Jan 2, 2023
@trask
Copy link
Member

trask commented Jan 3, 2023

thanks @anuragagarwal561994!

If we check the above code snippet, when there is a simple RPC, which means configSelector.get() == null then we get the delegate() assigned before the start of the rpc and hence we are able to fetch the results.

But in case when we are using grpc-xds in that case, we will be doing new ConfigSelectingClientCall and if you observe the implementation.

https://github.com/grpc/grpc-java/blob/43bc578f20ffe54ba45a43f282a7e87757179bf1/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java#L1168-L1190

The delegate is assigned when the rpc is starting.

Now the getAttributes() is using the delegate() method when the attributes are fetched. Since this is done before the RPC has started, hence we are getting NPE.

do you think it's possible to add a test that does something similar to the xds case above, which would fail if someone ever tries to move the call to setPeerSocketAddress() around again?

@anuragagarwal561994
Copy link
Contributor Author

@trask I tried checking this, seems like setting up a test case of grpc-xds is not easy moreover it is present in later versions of grpc. I guess with a comment one can indicate this if you think that is a good idea.

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.

GRPC Instrumentation doesn't work post 1.17.0
3 participants