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

Update OTel to 1.29 #259

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

<version.weld.core>5.1.0.Final</version.weld.core>
<version.resteasy>6.2.2.Final</version.resteasy>
<version.smallrye.config>3.1.1</version.smallrye.config>
<version.smallrye.config>3.3.4</version.smallrye.config>

<version.opentelemetry>1.26.0</version.opentelemetry>
<version.opentelemetry>1.29.0</version.opentelemetry>
</properties>

<build>
Expand Down
6 changes: 3 additions & 3 deletions examples/library/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

<version.weld.core>5.1.0.Final</version.weld.core>
<version.resteasy>6.2.2.Final</version.resteasy>
<version.smallrye.config>3.1.1</version.smallrye.config>
<version.smallrye.config>3.3.4</version.smallrye.config>

<version.opentelemetry>1.26.0</version.opentelemetry>
<version.opentelemetry.exporter>1.26.0</version.opentelemetry.exporter>
<version.opentelemetry>1.29.0</version.opentelemetry>
<version.opentelemetry.exporter>1.29.0</version.opentelemetry.exporter>
</properties>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public OpenTelemetry getOpenTelemetry() {
}

return builder
.setResultAsGlobal(false)
.registerShutdownHook(false)
.disableShutdownHook()
.addPropertiesSupplier(() -> config.properties())
.build()
.getOpenTelemetrySdk();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# We don't support metrics yet. Only Tracing.
# We don't support metrics or logging yet. Only Tracing.
otel.metrics.exporter=none
otel.logs.exporter=none
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.logs.GlobalLoggerProvider;
import io.opentelemetry.instrumentation.annotations.SpanAttribute;
import io.opentelemetry.instrumentation.annotations.WithSpan;
import io.opentelemetry.sdk.trace.data.SpanData;
Expand All @@ -37,7 +36,6 @@ class WithSpanInterceptorTest {
void setUp() {
spanExporter.reset();
GlobalOpenTelemetry.resetForTest();
GlobalLoggerProvider.resetForTest();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,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;

@Provider
public class OpenTelemetryClientFilter implements ClientRequestFilter, ClientResponseFilter {
Expand All @@ -48,8 +46,7 @@ public OpenTelemetryClientFilter(final OpenTelemetry openTelemetry) {

this.instrumenter = builder
.setSpanStatusExtractor(HttpSpanStatusExtractor.create(clientAttributesExtractor))
.addAttributesExtractor(
HttpClientAttributesExtractor.create(clientAttributesExtractor, new NetClientAttributesExtractor()))
.addAttributesExtractor(HttpClientAttributesExtractor.create(clientAttributesExtractor))
.buildClientInstrumenter(new ClientRequestContextTextMapSetter());
}

Expand Down Expand Up @@ -103,68 +100,40 @@ private static class ClientAttributesExtractor
implements HttpClientAttributesGetter<ClientRequestContext, ClientResponseContext> {

@Override
public String getUrl(final ClientRequestContext request) {
public String getUrlFull(final ClientRequestContext request) {
return request.getUri().toString();
}

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

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

@Override
public Integer getStatusCode(final ClientRequestContext request, final ClientResponseContext response,
final Throwable throwable) {
return response.getStatus();
}

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

private static class NetClientAttributesExtractor
implements NetClientAttributesGetter<ClientRequestContext, ClientResponseContext> {
@Override
public String getTransport(final ClientRequestContext request, final ClientResponseContext response) {
return SemanticAttributes.NetTransportValues.IP_TCP;
}

@Override
public String getPeerName(final ClientRequestContext request) {
public String getServerAddress(final ClientRequestContext request) {
return request.getUri().getHost();
}

@Override
public Integer getPeerPort(final ClientRequestContext request) {
public Integer getServerPort(final ClientRequestContext request) {
return request.getUri().getPort();
}

@Override
public String getSockFamily(final ClientRequestContext request, final ClientResponseContext response) {
return null;
public String getHttpRequestMethod(final ClientRequestContext request) {
return request.getMethod();
}

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

@Override
public String getSockPeerName(final ClientRequestContext request, final ClientResponseContext response) {
return null;
public Integer getHttpResponseStatusCode(final ClientRequestContext request, final ClientResponseContext response,
final Throwable throwable) {
return response.getStatus();
}

@Override
public Integer getSockPeerPort(final ClientRequestContext request, final ClientResponseContext response) {
return null;
public List<String> getHttpResponseHeader(final ClientRequestContext request, final ClientResponseContext response,
final String name) {
return response.getHeaders().getOrDefault(name, emptyList());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesGetter;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetServerAttributesGetter;
import io.opentelemetry.instrumentation.api.instrumenter.net.internal.NetAttributes;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;

@Provider
Expand All @@ -58,7 +56,7 @@ public OpenTelemetryServerFilter(final OpenTelemetry openTelemetry) {
this.instrumenter = builder
.setSpanStatusExtractor(HttpSpanStatusExtractor.create(serverAttributesExtractor))
.addAttributesExtractor(io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesExtractor
.create(serverAttributesExtractor, new NetServerAttributesExtractor()))
.create(serverAttributesExtractor, new NetServerAttributesGetter()))
.buildServerInstrumenter(new ContainerRequestContextTextMapGetter());
}

Expand Down Expand Up @@ -119,30 +117,31 @@ public String get(final ContainerRequestContext carrier, final String key) {
}
}

private static class NetServerAttributesExtractor
extends InetSocketAddressNetServerAttributesGetter<ContainerRequestContext> {
private static class NetServerAttributesGetter implements
io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesGetter<ContainerRequestContext, ContainerResponseContext> {
@Override
public String getTransport(final ContainerRequestContext request) {
return SemanticAttributes.NetTransportValues.IP_TCP;
}

@Override
public String getProtocolName(final ContainerRequestContext request) {
return (String) request.getProperty(NetAttributes.NET_PROTOCOL_NAME.getKey());
public String getNetworkProtocolName(final ContainerRequestContext request, final ContainerResponseContext response) {
return (String) request.getProperty(SemanticAttributes.NET_PROTOCOL_NAME.getKey());
}

@Override
public String getProtocolVersion(final ContainerRequestContext request) {
return (String) request.getProperty(NetAttributes.NET_PROTOCOL_VERSION.getKey());
public String getNetworkProtocolVersion(final ContainerRequestContext request,
final ContainerResponseContext response) {
return (String) request.getProperty(SemanticAttributes.NET_PROTOCOL_VERSION.getKey());
}

@Override
public String getHostName(final ContainerRequestContext request) {
public String getServerAddress(final ContainerRequestContext request) {
return request.getUriInfo().getRequestUri().getHost();
}

@Override
public Integer getHostPort(final ContainerRequestContext request) {
public Integer getServerPort(final ContainerRequestContext request) {
URI uri = request.getUriInfo().getRequestUri();
if (uri.getPort() > 0) {
return uri.getPort();
Expand All @@ -155,32 +154,32 @@ public Integer getHostPort(final ContainerRequestContext request) {
}

@Override
protected InetSocketAddress getPeerSocketAddress(final ContainerRequestContext request) {
public InetSocketAddress getServerInetSocketAddress(final ContainerRequestContext request,
final ContainerResponseContext response) {
String serverAddress = getServerAddress(request);
Integer serverPort = getServerPort(request);
if (serverAddress != null && serverPort != null) {
return new InetSocketAddress(serverAddress, serverPort);
}
return null;
}

@Override
protected InetSocketAddress getHostSocketAddress(final ContainerRequestContext request) {
return new InetSocketAddress(getHostName(request), getHostPort(request));
}
}

private static class HttpServerAttributesExtractor
implements HttpServerAttributesGetter<ContainerRequestContext, ContainerResponseContext> {

@Override
public String getTarget(final ContainerRequestContext request) {
URI requestUri = request.getUriInfo().getRequestUri();
String path = requestUri.getPath();
String query = requestUri.getQuery();
if (path != null && query != null && !query.isEmpty()) {
return path + "?" + query;
}
return path;
public String getUrlPath(final ContainerRequestContext request) {
return request.getUriInfo().getRequestUri().getPath();
}

@Override
public String getUrlQuery(final ContainerRequestContext request) {
return request.getUriInfo().getRequestUri().getQuery();
}

@Override
public String getRoute(final ContainerRequestContext request) {
public String getHttpRoute(final ContainerRequestContext request) {
try {
// This can throw an IllegalArgumentException when determining the route for a subresource
Class<?> resource = (Class<?>) request.getProperty("rest.resource.class");
Expand All @@ -203,28 +202,29 @@ public String getRoute(final ContainerRequestContext request) {
}

@Override
public String getScheme(final ContainerRequestContext request) {
public String getUrlScheme(final ContainerRequestContext request) {
return request.getUriInfo().getRequestUri().getScheme();
}

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

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

@Override
public Integer getStatusCode(final ContainerRequestContext request, final ContainerResponseContext response,
public Integer getHttpResponseStatusCode(final ContainerRequestContext request, final ContainerResponseContext response,
final Throwable throwable) {
return response.getStatus();
}

@Override
public List<String> getResponseHeader(final ContainerRequestContext request, final ContainerResponseContext response,
public List<String> getHttpResponseHeader(final ContainerRequestContext request,
final ContainerResponseContext response,
final String name) {
return response.getStringHeaders().getOrDefault(name, emptyList());
}
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
<url>http://smallrye.io</url>

<properties>
<version.opentelemetry>1.26.0</version.opentelemetry>
<version.opentelemetry>1.29.0</version.opentelemetry>
<version.microprofile.opentelemetry>1.0</version.microprofile.opentelemetry>
<version.microprofile.config>3.0.2</version.microprofile.config>
<version.microprofile.config>3.0.3</version.microprofile.config>

<!-- Test -->
<version.smallrye.testing>2.3.0</version.smallrye.testing>
<version.smallrye.config>3.1.3</version.smallrye.config>
<version.smallrye.config>3.3.4</version.smallrye.config>
</properties>

<licenses>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@
import org.jboss.arquillian.test.spi.TestClass;

import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.logs.GlobalLoggerProvider;
import io.restassured.RestAssured;

public class ArquillianLifecycle {
public void beforeDeploy(@Observes BeforeDeploy event, TestClass testClass) {
GlobalOpenTelemetry.resetForTest();
GlobalLoggerProvider.resetForTest();
}

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.ext.Provider;

import io.opentelemetry.instrumentation.api.instrumenter.net.internal.NetAttributes;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;

@Provider
@PreMatching
Expand All @@ -20,8 +20,8 @@ public class HttpServerAttributesFilter implements ContainerRequestFilter, Conta
@Override
public void filter(final ContainerRequestContext request) {
String[] nameAndVersion = httpServletRequest.getProtocol().split("/");
request.setProperty(NetAttributes.NET_PROTOCOL_NAME.getKey(), nameAndVersion[0]);
request.setProperty(NetAttributes.NET_PROTOCOL_VERSION.getKey(), nameAndVersion[1]);
request.setProperty(SemanticAttributes.NET_PROTOCOL_NAME.getKey(), nameAndVersion[0]);
request.setProperty(SemanticAttributes.NET_PROTOCOL_VERSION.getKey(), nameAndVersion[1]);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion testsuite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

<modules>
<module>extra</module>
<!-- Requires updates to the TCK due to OTel breaking changes
<!--
<module>tck</module>
-->
</modules>
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.smallrye.opentelemetry</groupId>
<artifactId>smallrye-opentelemetry-testsuite</artifactId>
<version>2.3.1-SNAPSHOT</version>
<version>2.4.1-SNAPSHOT</version>
</parent>

<artifactId>smallrye-opentelemetry-tck</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
import org.jboss.arquillian.test.spi.TestClass;

import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.logs.GlobalLoggerProvider;

public class ArquillianLifecycle {
public void beforeDeploy(@Observes BeforeDeploy event, TestClass testClass) {
GlobalOpenTelemetry.resetForTest();
GlobalLoggerProvider.resetForTest();
}
}
Loading