Skip to content

Commit

Permalink
Merge pull request quarkusio#35733 from brunobat/bump-otel-1-29
Browse files Browse the repository at this point in the history
Bump OTel to 1.29.0
  • Loading branch information
geoand authored Sep 19, 2023
2 parents 8a0d070 + 7148730 commit 7903aa7
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 136 deletions.
4 changes: 2 additions & 2 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
<opentracing-jdbc.version>0.2.4</opentracing-jdbc.version>
<opentracing-kafka.version>0.1.15</opentracing-kafka.version>
<opentracing-mongo.version>0.1.5</opentracing-mongo.version>
<opentelemetry.version>1.28.0</opentelemetry.version>
<opentelemetry-alpha.version>1.28.0-alpha</opentelemetry-alpha.version>
<opentelemetry.version>1.29.0</opentelemetry.version>
<opentelemetry-alpha.version>1.29.0-alpha</opentelemetry-alpha.version>
<jaeger.version>1.8.1</jaeger.version>
<quarkus-http.version>5.0.3.Final</quarkus-http.version>
<micrometer.version>1.11.1</micrometer.version><!-- keep in sync with hdrhistogram -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import static io.opentelemetry.api.trace.SpanKind.CLIENT;
import static io.opentelemetry.api.trace.SpanKind.INTERNAL;
import static io.opentelemetry.api.trace.SpanKind.SERVER;
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NET_TRANSPORT;
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NET_HOST_PORT;
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NET_SOCK_HOST_ADDR;
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.RPC_GRPC_STATUS_CODE;
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.RPC_METHOD;
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.RPC_SERVICE;
Expand All @@ -13,6 +14,7 @@
import static io.quarkus.opentelemetry.runtime.config.build.OTelBuildConfig.INSTRUMENTATION_NAME;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

Expand Down Expand Up @@ -122,9 +124,8 @@ void grpc() {
assertEquals("helloworld.Greeter", server.getAttributes().get(RPC_SERVICE));
assertEquals("SayHello", server.getAttributes().get(RPC_METHOD));
assertEquals(Status.Code.OK.value(), server.getAttributes().get(RPC_GRPC_STATUS_CODE));
// assertNotNull(server.getAttributes().get(NET_PEER_IP));
// assertNotNull(server.getAttributes().get(NET_PEER_PORT));
assertEquals("ip_tcp", server.getAttributes().get(NET_TRANSPORT));
assertNotNull(server.getAttributes().get(NET_HOST_PORT));
assertNotNull(server.getAttributes().get(NET_SOCK_HOST_ADDR));

final SpanData internal = getSpanByKindAndParentId(spans, INTERNAL, server.getSpanId());
assertEquals("span.internal", internal.getName());
Expand Down Expand Up @@ -161,9 +162,8 @@ void error() {
assertEquals("helloworld.Greeter", server.getAttributes().get(RPC_SERVICE));
assertEquals("SayHello", server.getAttributes().get(RPC_METHOD));
assertEquals(Status.Code.UNKNOWN.value(), server.getAttributes().get(RPC_GRPC_STATUS_CODE));
// assertNotNull(server.getAttributes().get(NET_PEER_IP));
// assertNotNull(server.getAttributes().get(NET_PEER_PORT));
assertEquals("ip_tcp", server.getAttributes().get(NET_TRANSPORT));
assertNotNull(server.getAttributes().get(NET_HOST_PORT));
assertNotNull(server.getAttributes().get(NET_SOCK_HOST_ADDR));
assertEquals(Status.Code.UNKNOWN.value(), server.getAttributes().get(RPC_GRPC_STATUS_CODE));

assertEquals(server.getTraceId(), client.getTraceId());
Expand Down Expand Up @@ -213,9 +213,8 @@ void streaming() {
assertEquals("streaming.Streaming", server.getAttributes().get(RPC_SERVICE));
assertEquals("Pipe", server.getAttributes().get(RPC_METHOD));
assertEquals(Status.Code.OK.value(), server.getAttributes().get(RPC_GRPC_STATUS_CODE));
// assertNotNull(server.getAttributes().get(NET_PEER_IP));
// assertNotNull(server.getAttributes().get(NET_PEER_PORT));
assertEquals("ip_tcp", server.getAttributes().get(NET_TRANSPORT));
assertNotNull(server.getAttributes().get(NET_HOST_PORT));
assertNotNull(server.getAttributes().get(NET_SOCK_HOST_ADDR));
assertEquals("true", server.getAttributes().get(stringKey("grpc.service.propagated")));

assertEquals(server.getTraceId(), client.getTraceId());
Expand Down Expand Up @@ -250,9 +249,8 @@ void streamingBlocking() {
assertEquals("streaming.Streaming", server.getAttributes().get(RPC_SERVICE));
assertEquals("PipeBlocking", server.getAttributes().get(RPC_METHOD));
assertEquals(Status.Code.OK.value(), server.getAttributes().get(RPC_GRPC_STATUS_CODE));
// assertNotNull(server.getAttributes().get(NET_PEER_IP));//now shows up on net.sock.peer.addr. Not available on attributes yet. FIXME
// assertNotNull(server.getAttributes().get(NET_PEER_PORT)); // same for port. FIXME
assertEquals("ip_tcp", server.getAttributes().get(NET_TRANSPORT));
assertNotNull(server.getAttributes().get(NET_HOST_PORT));
assertNotNull(server.getAttributes().get(NET_SOCK_HOST_ADDR));
assertEquals("true", server.getAttributes().get(stringKey("grpc.service.propagated.blocking")));

assertEquals(server.getTraceId(), client.getTraceId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import io.opentelemetry.api.events.EventEmitterProvider;
import io.opentelemetry.api.metrics.MeterProvider;
import io.opentelemetry.sdk.autoconfigure.internal.SpiHelper;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.logs.SdkLoggerProviderBuilder;
import io.opentelemetry.sdk.logs.export.LogRecordExporter;
Expand All @@ -24,7 +25,7 @@ static final class Target_MeterProviderConfiguration {
@Substitute
static List<MetricReader> configureMetricReaders(
ConfigProperties config,
ClassLoader serviceClassLoader,
SpiHelper spiHelper,
BiFunction<? super MetricExporter, ConfigProperties, ? extends MetricExporter> metricExporterCustomizer,
List<Closeable> closeables) {
// OTel metrics not supported and there is no need to call
Expand All @@ -40,7 +41,7 @@ static final class Target_LoggerProviderConfiguration {
static void configureLoggerProvider(
SdkLoggerProviderBuilder loggerProviderBuilder,
ConfigProperties config,
ClassLoader serviceClassLoader,
SpiHelper spiHelper,
MeterProvider meterProvider,
BiFunction<? super LogRecordExporter, ConfigProperties, ? extends LogRecordExporter> logRecordExporterCustomizer,
List<Closeable> closeables) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
import io.opentelemetry.context.propagation.TextMapGetter;
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesGetter;
import io.opentelemetry.instrumentation.api.instrumenter.network.ClientAttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.network.ClientAttributesGetter;
import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesGetter;
import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesGetter;
import io.opentelemetry.instrumentation.api.instrumenter.rpc.RpcServerAttributesExtractor;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.quarkus.grpc.GlobalInterceptor;

@Singleton
Expand All @@ -39,8 +41,12 @@ public GrpcTracingServerInterceptor(final OpenTelemetry openTelemetry) {
INSTRUMENTATION_NAME,
new GrpcSpanNameExtractor());

GrpcServerNetworkAttributesGetter getter = new GrpcServerNetworkAttributesGetter();

builder.addAttributesExtractor(RpcServerAttributesExtractor.create(GrpcAttributesGetter.INSTANCE))
.addAttributesExtractor(NetServerAttributesExtractor.create(new GrpcServerNetServerAttributesGetter()))
.addAttributesExtractor(
ServerAttributesExtractor.createForServerSide(getter))
.addAttributesExtractor(ClientAttributesExtractor.create(getter))
.addAttributesExtractor(new GrpcStatusCodeExtractor())
.setSpanStatusExtractor(new GrpcSpanStatusExtractor());

Expand All @@ -65,11 +71,9 @@ public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
return next.startCall(call, headers);
}

private static class GrpcServerNetServerAttributesGetter implements NetServerAttributesGetter<GrpcRequest, Status> {
@Override
public String getTransport(final GrpcRequest grpcRequest) {
return SemanticAttributes.NetTransportValues.IP_TCP;
}
static class GrpcServerNetworkAttributesGetter implements NetworkAttributesGetter<GrpcRequest, Status>,
ServerAttributesGetter<GrpcRequest, Status>,
ClientAttributesGetter<GrpcRequest, Status> {

@Override
public String getServerAddress(GrpcRequest grpcRequest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesGetter;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.quarkus.arc.Unremovable;
import io.quarkus.opentelemetry.runtime.QuarkusContextStorage;
Expand Down Expand Up @@ -62,7 +61,6 @@ public OpenTelemetryClientFilter() {
@Inject
public OpenTelemetryClientFilter(final OpenTelemetry openTelemetry) {
ClientAttributesExtractor clientAttributesExtractor = new ClientAttributesExtractor();
ClientNetAttributesGetter clientNetAttributesExtractor = new ClientNetAttributesGetter();

InstrumenterBuilder<ClientRequestContext, ClientResponseContext> builder = Instrumenter.builder(
openTelemetry,
Expand All @@ -72,7 +70,7 @@ public OpenTelemetryClientFilter(final OpenTelemetry openTelemetry) {
this.instrumenter = builder
.setSpanStatusExtractor(HttpSpanStatusExtractor.create(clientAttributesExtractor))
.addAttributesExtractor(HttpClientAttributesExtractor.create(
clientAttributesExtractor, clientNetAttributesExtractor))
clientAttributesExtractor))
.buildClientInstrumenter(new ClientRequestContextTextMapSetter());
}

Expand Down Expand Up @@ -155,32 +153,6 @@ public String getUrlFull(final ClientRequestContext request) {
return uri.toString();
}

@Override
public String getHttpRequestMethod(final ClientRequestContext request) {
return request.getMethod();
}

@Override
public List<String> getHttpRequestHeader(final ClientRequestContext request, final String name) {
return request.getStringHeaders().getOrDefault(name, emptyList());
}

@Override
public Integer getHttpResponseStatusCode(ClientRequestContext clientRequestContext,
ClientResponseContext clientResponseContext, Throwable error) {
return clientResponseContext.getStatus();
}

@Override
public List<String> getHttpResponseHeader(final ClientRequestContext request, final ClientResponseContext response,
final String name) {
return response.getHeaders().getOrDefault(name, emptyList());
}
}

private static class ClientNetAttributesGetter
implements NetClientAttributesGetter<ClientRequestContext, ClientResponseContext> {

@Override
public String getTransport(ClientRequestContext clientRequestContext, ClientResponseContext clientResponseContext) {
return SemanticAttributes.NetTransportValues.IP_TCP;
Expand All @@ -207,5 +179,27 @@ public String getNetworkProtocolVersion(ClientRequestContext clientRequestContex
ClientResponseContext clientResponseContext) {
return null;
}

@Override
public String getHttpRequestMethod(final ClientRequestContext request) {
return request.getMethod();
}

@Override
public List<String> getHttpRequestHeader(final ClientRequestContext request, final String name) {
return request.getStringHeaders().getOrDefault(name, emptyList());
}

@Override
public Integer getHttpResponseStatusCode(ClientRequestContext clientRequestContext,
ClientResponseContext clientResponseContext, Throwable error) {
return clientResponseContext.getStatus();
}

@Override
public List<String> getHttpResponseHeader(final ClientRequestContext request, final ClientResponseContext response,
final String name) {
return response.getHeaders().getOrDefault(name, emptyList());
}
}
}
Loading

0 comments on commit 7903aa7

Please sign in to comment.