From 0217722c83ff0fed0b815a4262beecda787b9379 Mon Sep 17 00:00:00 2001 From: Idel Pivnitskiy Date: Tue, 18 Jun 2024 11:15:27 -0700 Subject: [PATCH] Update OpenTelemetry and Instrumentation 1.28.0 -> 1.31.0 --- gradle.properties | 4 ++-- .../http/OpenTelemetryHttpRequestFilter.java | 2 +- .../http/ServiceTalkHttpAttributesGetter.java | 21 +++++++++++++++++++ .../OpenTelemetryHttpRequestFilterTest.java | 2 +- .../OpenTelemetryHttpServerFilterTest.java | 2 +- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index 584b38bc5f..ac1ce44a93 100644 --- a/gradle.properties +++ b/gradle.properties @@ -69,8 +69,8 @@ jacksonVersion=2.15.4 openTracingVersion=0.33.0 zipkinReporterVersion=2.17.2 -opentelemetryVersion=1.28.0 -opentelemetryInstrumentationVersion=1.28.0-alpha +opentelemetryVersion=1.31.0 +opentelemetryInstrumentationVersion=1.31.0-alpha # gRPC protobufGradlePluginVersion=0.9.4 diff --git a/servicetalk-opentelemetry-http/src/main/java/io/servicetalk/opentelemetry/http/OpenTelemetryHttpRequestFilter.java b/servicetalk-opentelemetry-http/src/main/java/io/servicetalk/opentelemetry/http/OpenTelemetryHttpRequestFilter.java index 91ac89cd8f..c37055f752 100755 --- a/servicetalk-opentelemetry-http/src/main/java/io/servicetalk/opentelemetry/http/OpenTelemetryHttpRequestFilter.java +++ b/servicetalk-opentelemetry-http/src/main/java/io/servicetalk/opentelemetry/http/OpenTelemetryHttpRequestFilter.java @@ -44,7 +44,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor; -import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; +import io.opentelemetry.semconv.SemanticAttributes; import java.util.function.UnaryOperator; diff --git a/servicetalk-opentelemetry-http/src/main/java/io/servicetalk/opentelemetry/http/ServiceTalkHttpAttributesGetter.java b/servicetalk-opentelemetry-http/src/main/java/io/servicetalk/opentelemetry/http/ServiceTalkHttpAttributesGetter.java index 26548bda76..71a75ed1d8 100644 --- a/servicetalk-opentelemetry-http/src/main/java/io/servicetalk/opentelemetry/http/ServiceTalkHttpAttributesGetter.java +++ b/servicetalk-opentelemetry-http/src/main/java/io/servicetalk/opentelemetry/http/ServiceTalkHttpAttributesGetter.java @@ -78,6 +78,20 @@ public String getUrlFull(final HttpRequestMetaData request) { return requestScheme + "://" + hostAndPort + '/' + request.requestTarget(); } + @Nullable + @Override + public String getServerAddress(final HttpRequestMetaData requestMetaData) { + final HostAndPort hostAndPort = requestMetaData.effectiveHostAndPort(); + return hostAndPort != null ? hostAndPort.hostName() : null; + } + + @Nullable + @Override + public Integer getServerPort(final HttpRequestMetaData requestMetaData) { + final HostAndPort hostAndPort = requestMetaData.effectiveHostAndPort(); + return hostAndPort != null ? hostAndPort.port() : null; + } + @Override public String getUrlScheme(final HttpRequestMetaData httpRequestMetaData) { final String scheme = httpRequestMetaData.scheme(); @@ -111,4 +125,11 @@ private static List getHeaderValues(final HttpHeaders headers, final Str } return unmodifiableList(result); } + + @Nullable + @Override + public String getNetworkType(final HttpRequestMetaData requestMetaData, + @Nullable final HttpResponseMetaData responseMetaData) { + return null; + } } diff --git a/servicetalk-opentelemetry-http/src/test/java/io/servicetalk/opentelemetry/http/OpenTelemetryHttpRequestFilterTest.java b/servicetalk-opentelemetry-http/src/test/java/io/servicetalk/opentelemetry/http/OpenTelemetryHttpRequestFilterTest.java index cd332e0b88..bf937ecfed 100755 --- a/servicetalk-opentelemetry-http/src/test/java/io/servicetalk/opentelemetry/http/OpenTelemetryHttpRequestFilterTest.java +++ b/servicetalk-opentelemetry-http/src/test/java/io/servicetalk/opentelemetry/http/OpenTelemetryHttpRequestFilterTest.java @@ -32,7 +32,7 @@ import io.opentelemetry.context.propagation.ContextPropagators; import io.opentelemetry.sdk.testing.junit5.OpenTelemetryExtension; import io.opentelemetry.sdk.trace.data.SpanData; -import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; +import io.opentelemetry.semconv.SemanticAttributes; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/servicetalk-opentelemetry-http/src/test/java/io/servicetalk/opentelemetry/http/OpenTelemetryHttpServerFilterTest.java b/servicetalk-opentelemetry-http/src/test/java/io/servicetalk/opentelemetry/http/OpenTelemetryHttpServerFilterTest.java index 39c8583a75..eee51e2b4d 100644 --- a/servicetalk-opentelemetry-http/src/test/java/io/servicetalk/opentelemetry/http/OpenTelemetryHttpServerFilterTest.java +++ b/servicetalk-opentelemetry-http/src/test/java/io/servicetalk/opentelemetry/http/OpenTelemetryHttpServerFilterTest.java @@ -34,7 +34,7 @@ import io.opentelemetry.context.propagation.TextMapSetter; import io.opentelemetry.sdk.testing.junit5.OpenTelemetryExtension; import io.opentelemetry.sdk.trace.data.SpanData; -import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; +import io.opentelemetry.semconv.SemanticAttributes; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test;