Currently grpc client instrumentation unreliably fills `net.sock.peer.addr` which makes tests flaky https://ge.opentelemetry.io/s/nni57d5zryafk/tests/:instrumentation:grpc-1.6:javaagent:test/io.opentelemetry.javaagent.instrumentation.grpc.v1_6.GrpcStreamingTest/conversation(int,%20int)%5B8%5D?expanded-stacktrace=WyIwIl0&top-execution=1 This pr moves capturing `net.sock.peer.addr` to a later point where it seems to work reliably. |
||
---|---|---|
.. | ||
src | ||
README.md | ||
build.gradle.kts |
README.md
Library Instrumentation for gRPC 1.6.0+
Provides OpenTelemetry instrumentation for gRPC.
Quickstart
Add the following dependencies to your project
Replace OPENTELEMETRY_VERSION
with the latest release.
For Maven, add the following to your pom.xml
dependencies:
<dependencies>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-grpc-1.6</artifactId>
<version>OPENTELEMETRY_VERSION</version>
</dependency>
</dependencies>
For Gradle, add the following to your dependencies:
implementation("io.opentelemetry.instrumentation:opentelemetry-grpc-1.6:OPENTELEMETRY_VERSION")
Usage
The instrumentation library provides the implementation of ClientInterceptor
and ServerInterceptor
to provide OpenTelemetry-based spans and context propagation.
// For client-side, attach the interceptor to your channel builder.
void configureClientInterceptor(Opentelemetry opentelemetry, NettyChannelBuilder nettyChannelBuilder) {
GrpcTelemetry grpcTelemetry = GrpcTelemetry.create(opentelemetry);
nettyChannelBuilder.intercept(grpcTelemetry.newClientInterceptor());
}
// For server-side, attatch the interceptor to your service.
ServerServiceDefinition configureServerInterceptor(Opentelemetry opentelemetry, ServerServiceDefinition serviceDefinition) {
GrpcTelemetry grpcTelemetry = GrpcTelemetry.create(opentelemetry);
return ServiceInterceptors.intercept(serviceDefinition, grpcTelemetry.newServerInterceptor());
}