hypertrace / javaagent

Hypertrace OpenTelemetry Java agent with payload/body and headers data capture.
Apache License 2.0
30 stars 15 forks source link

🐛 gRPC header capture with shaded netty module and body capture without com.google.protobuf.util.JsonFormat #339

Closed ryandens closed 3 years ago

ryandens commented 3 years ago

Description

First, duplicates instrumentation targeting io.grpc.netty.Utls to work properly when users are using io.grpc:grpc-netty-shaded. This is rather inelegant, but this was the fastest solution we could land on.

Second, updates the GrpcSpanDecorator to not need com.google.protobuf.util.JsonFormat on the user's application classpath. Since io.grpc:grpc-protobuf:1.14.0, grpc has not had a transitive dependency on com.google.protobuf:protobuf-java-utils, the dependency which holds com.google.protobuf.util.JsonFormat. In order to work with newer versions of gRPC, we need to shade the dependency and make it eligible for muzzle application classpath injection. This is also rather inelegant, but again we're up against time constraints here.

Testing

Added tests for gRPC 1.30.0 to our test suite, which reproduces the shaded header issue. Unfortunately, due to the nature of these instrumentation tests, com.google.protobuf:protobuf-java-utils is on the test runtime classpath as a transitive dependency from otel, so in order to reproduce that issue I had to write a sample gRPC test app and use the agent against it. In the future, we might want to consider adding a gRPC smoke test

Checklist:

Documentation

Make sure that you have documented corresponding changes in this repository or hypertrace docs repo if required.