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

chore(deps): Bump opentelemetry-instrumentation to 2.7.0 #615

Open
wants to merge 1 commit into
base: 7.0.x
Choose a base branch
from
Open
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
14 changes: 8 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ groovy = "4.0.17"
spock = "2.3-groovy-4.0"

managed-brave-instrumentation = '6.0.2'
managed-opentelemetry = '1.36.0'
managed-opentelemetry-alpha = '1.36.0-alpha'
managed-opentelemetry-instrumentation = '1.33.1'
managed-opentelemetry-instrumentation-alpha = '1.33.1-alpha'
managed-opentelemetry = '1.41.0'
managed-opentelemetry-alpha = '1.41.0-alpha'
managed-opentelemetry-instrumentation = '2.7.0'
managed-opentelemetry-instrumentation-alpha = '2.7.0-alpha'
managed-opentelemetry-contrib-aws-xray = '1.34.0'
managed-opentelemetry-contrib-aws-xray-propagation = '1.34.0-alpha'
managed-opentelemetry-contrib-aws-resources = '1.31.0-alpha'
managed-opentelemetry-gcp-trace = '0.27.0-alpha'
managed-opentelemetry-semconv = '1.21.0-alpha'
Expand Down Expand Up @@ -44,6 +45,7 @@ micronaut-gradle-plugin = "4.3.6"
micronaut-core = { module = 'io.micronaut:micronaut-core-bom', version.ref = 'micronaut' }

managed-opentelemetry-contrib-aws-xray = { module = 'io.opentelemetry.contrib:opentelemetry-aws-xray', version.ref = 'managed-opentelemetry-contrib-aws-xray'}
managed-opentelemetry-contrib-aws-xray-propagator = { module = 'io.opentelemetry.contrib:opentelemetry-aws-xray-propagator', version.ref = 'managed-opentelemetry-contrib-aws-xray-propagation'}
managed-opentelemetry-contrib-aws-resources = { module = 'io.opentelemetry.contrib:opentelemetry-aws-resources', version.ref = 'managed-opentelemetry-contrib-aws-resources'}
managed-opentelemetry-gcp-trace = { module = 'com.google.cloud.opentelemetry:exporter-auto', version.ref = 'managed-opentelemetry-gcp-trace'}

Expand Down Expand Up @@ -75,16 +77,16 @@ zipkin-reporter = { module = 'io.zipkin.reporter2:zipkin-reporter' }
zipkin-reporter-brave = { module = 'io.zipkin.reporter2:zipkin-reporter-brave' }

opentelemetry-api = { module = 'io.opentelemetry:opentelemetry-api' }
opentelemetry-api-events = { module = 'io.opentelemetry:opentelemetry-api-events' }
opentelemetry-api-incubator = { module = 'io.opentelemetry:opentelemetry-api-incubator' }
opentelemetry-sdk = { module = 'io.opentelemetry:opentelemetry-sdk' }
opentelemetry-sdk-testing = { module = 'io.opentelemetry:opentelemetry-sdk-testing' }
opentelemetry-autoconfigure = { module = 'io.opentelemetry:opentelemetry-sdk-extension-autoconfigure' }
opentelemetry-exporter-zipkin = { module = 'io.opentelemetry:opentelemetry-exporter-zipkin', version.ref = 'managed-opentelemetry' }

opentelemetry-instrumentation-api = { module = 'io.opentelemetry.instrumentation:opentelemetry-instrumentation-api' }
opentelemetry-instrumentation-api-incubator = { module = 'io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-incubator' }
opentelemetry-instrumentation-grpc = { module = 'io.opentelemetry.instrumentation:opentelemetry-grpc-1.6'}
opentelemetry-instrumentation-kafka-common = { module = 'io.opentelemetry.instrumentation:opentelemetry-kafka-clients-common'}
opentelemetry-instrumentation-api-semconv = { module = 'io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-semconv' }
opentelemetry-instrumentation-semconv = { module = 'io.opentelemetry.semconv:opentelemetry-semconv', version.ref ='managed-opentelemetry-semconv' }
opentelemetry-instrumentation-annotations = { module = 'io.opentelemetry.instrumentation: opentelemetry-instrumentation-annotations' }
opentelemetry-aws-sdk = { module = 'io.opentelemetry.instrumentation:opentelemetry-aws-sdk-2.2' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.sdk.testing.exporter.InMemorySpanExporter;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.semconv.HttpAttributes;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
Expand All @@ -29,7 +30,7 @@ public class HttpTracingTest {
private HttpClient client;

public static final String TRACING_ID = "X-TrackingId";
public static final String TRACING_ID_IN_SPAN = "http.request.header.x_trackingid";
public static final String TRACING_ID_IN_SPAN = HttpAttributes.HTTP_REQUEST_HEADER.getAttributeKey(TRACING_ID.toLowerCase()).getKey();

@Inject
ReactorHttpClient reactorHttpClient;
Expand Down
8 changes: 4 additions & 4 deletions tracing-bom/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ micronautBom {
"io.zipkin.proto3"
] as Set
)
dependencies.add("io.opentelemetry:opentelemetry-bom:1.36.0")
dependencies.add("io.opentelemetry:opentelemetry-bom-alpha:1.36.0-alpha")
dependencies.add("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:1.33.1")
dependencies.add("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.33.1-alpha")
dependencies.add("io.opentelemetry:opentelemetry-bom:1.41.0")
dependencies.add("io.opentelemetry:opentelemetry-bom-alpha:1.41.0-alpha")
dependencies.add("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:2.7.0")
dependencies.add("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:2.7.0-alpha")
dependencies.add("io.zipkin.brave:brave-instrumentation-benchmarks:6.0.2")
dependencies.add("io.zipkin.reporter2:zipkin-reporter-bom:3.3.0")
}
Expand Down
3 changes: 1 addition & 2 deletions tracing-opentelemetry-http/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ dependencies {
api libs.opentelemetry.api
api libs.opentelemetry.instrumentation.annotations
api libs.opentelemetry.instrumentation.api
api libs.opentelemetry.instrumentation.api.semconv
api libs.opentelemetry.instrumentation.semconv
api libs.opentelemetry.instrumentation.api.incubator

compileOnly mn.kotlinx.coroutines.core
compileOnly mn.kotlinx.coroutines.reactor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import io.micronaut.http.HttpResponse;
import io.micronaut.http.HttpVersion;
import io.micronaut.http.MutableHttpRequest;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesGetter;
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesGetter;

import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@
import io.micronaut.http.HttpResponse;
import io.micronaut.http.MutableHttpRequest;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.instrumentation.api.incubator.semconv.net.PeerServiceAttributesExtractor;
import io.opentelemetry.instrumentation.api.incubator.semconv.net.PeerServiceResolver;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractorBuilder;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractor;
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder;
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientMetrics;
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractor;
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanStatusExtractor;

import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceResolver;
import jakarta.inject.Named;
import jakarta.inject.Qualifier;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import io.micronaut.http.HttpVersion;
import io.micronaut.http.uri.UriMatchTemplate;
import io.micronaut.web.router.UriRouteInfo;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesGetter;
import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesGetter;

import static io.micronaut.http.HttpVersion.HTTP_1_0;
import static io.micronaut.http.HttpVersion.HTTP_1_1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesExtractorBuilder;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerMetrics;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerRoute;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractor;
import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder;
import io.opentelemetry.instrumentation.api.semconv.http.HttpServerMetrics;
import io.opentelemetry.instrumentation.api.semconv.http.HttpServerRoute;
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractor;
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanStatusExtractor;
import jakarta.inject.Named;
import jakarta.inject.Qualifier;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ import io.opentelemetry.api.trace.StatusCode
import io.opentelemetry.instrumentation.annotations.SpanAttribute
import io.opentelemetry.instrumentation.annotations.WithSpan
import io.opentelemetry.sdk.testing.exporter.InMemorySpanExporter
import io.opentelemetry.semconv.SemanticAttributes
import io.opentelemetry.semconv.HttpAttributes
import io.opentelemetry.semconv.ServerAttributes
import io.reactivex.Single
import jakarta.inject.Inject
import org.reactivestreams.Publisher
Expand All @@ -55,7 +56,7 @@ import static io.micronaut.scheduling.TaskExecutors.IO
class OpenTelemetryHttpSpec extends Specification {

String TRACING_ID = "X-TrackingId"
String TRACING_ID_IN_SPAN = "http.request.header.x_trackingid"
String TRACING_ID_IN_SPAN = HttpAttributes.HTTP_REQUEST_HEADER.getAttributeKey(TRACING_ID.toLowerCase()).getKey()

@AutoCleanup
private ApplicationContext context
Expand Down Expand Up @@ -102,10 +103,11 @@ class OpenTelemetryHttpSpec extends Specification {
}

void hasHttpSemanticAttributes(HttpStatus httpStatus, boolean hasRoute = true) {

def serverSpans = exporter.finishedSpanItems.findAll { it -> it.kind == SpanKind.SERVER }
assert serverSpans.every {it.attributes.stream().any { it.get(SemanticAttributes.HTTP_METHOD) }}
assert !hasRoute || serverSpans.every {it.attributes.stream().any { it.get(SemanticAttributes.HTTP_ROUTE) }}
assert serverSpans.every {it.attributes.stream().any {x -> Optional.ofNullable(x.get(SemanticAttributes.HTTP_STATUS_CODE)).map { it.intValue() == httpStatus.code }.orElse(false) }}
assert serverSpans.every {it.attributes.stream().any { it.get(HttpAttributes.HTTP_REQUEST_METHOD) }}
assert !hasRoute || serverSpans.every {it.attributes.stream().any { it.get(HttpAttributes.HTTP_ROUTE) }}
assert serverSpans.every {it.attributes.stream().any {x -> Optional.ofNullable(x.get(HttpAttributes.HTTP_RESPONSE_STATUS_CODE)).map { it.intValue() == httpStatus.code }.orElse(false) }}
}

void 'test map WithSpan annotation'() {
Expand Down Expand Up @@ -245,7 +247,7 @@ class OpenTelemetryHttpSpec extends Specification {
exporter.finishedSpanItems.name.contains("WarehouseClient.order")
exporter.finishedSpanItems.attributes.stream().anyMatch(x -> x.get(AttributeKey.stringKey("warehouse.order")) == "{testOrderKey=testOrderValue}")
exporter.finishedSpanItems.attributes.stream().anyMatch(x -> x.get(AttributeKey.stringKey("upc")) == "10")
exporter.finishedSpanItems.attributes.stream().anyMatch(x -> x.get(SemanticAttributes.NET_PEER_NAME) == "localhost")
exporter.finishedSpanItems.attributes.stream().anyMatch(x -> x.get(ServerAttributes.SERVER_ADDRESS) == "localhost")
hasHttpSemanticAttributes(HttpStatus.OK)
}

Expand All @@ -266,7 +268,7 @@ class OpenTelemetryHttpSpec extends Specification {
conditions.eventually {
hasSpans(internalSpanCount, serverSpanCount, clientSpanCount)
exporter.finishedSpanItems.attributes.stream().anyMatch(x -> x.get(AttributeKey.stringKey("warehouse.order")) == "{testOrderKey=testOrderValue}")
exporter.finishedSpanItems.attributes.stream().anyMatch(x -> x.get(SemanticAttributes.NET_PEER_NAME) == "correctspanname")
exporter.finishedSpanItems.attributes.stream().anyMatch(x -> x.get(ServerAttributes.SERVER_ADDRESS) == "correctspanname")
}

cleanup:
Expand Down Expand Up @@ -332,7 +334,7 @@ class OpenTelemetryHttpSpec extends Specification {
then:
conditions.eventually {
hasSpans(internalSpanCount, serverSpanCount, clientSpanCount)
exporter.finishedSpanItems.attributes.stream().anyMatch(x -> x.get(SemanticAttributes.HTTP_ROUTE) == "/client/order/{orderId}")
exporter.finishedSpanItems.attributes.stream().anyMatch(x -> x.get(HttpAttributes.HTTP_ROUTE) == "/client/order/{orderId}")
hasHttpSemanticAttributes(HttpStatus.OK)
}

Expand All @@ -353,7 +355,7 @@ class OpenTelemetryHttpSpec extends Specification {
then:
conditions.eventually {
hasSpans(internalSpanCount, serverSpanCount, clientSpanCount)
exporter.finishedSpanItems.attributes.stream().anyMatch(x -> x.get(SemanticAttributes.HTTP_ROUTE) == "/client/order/{orderId}")
exporter.finishedSpanItems.attributes.stream().anyMatch(x -> x.get(HttpAttributes.HTTP_ROUTE) == "/client/order/{orderId}")
hasHttpSemanticAttributes(HttpStatus.OK)
}

Expand Down
1 change: 0 additions & 1 deletion tracing-opentelemetry-kafka/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ dependencies {
api projects.micronautTracingOpentelemetry
api libs.opentelemetry.api
api(mnKafka.micronaut.kafka)
api libs.opentelemetry.instrumentation.semconv
api libs.opentelemetry.instrumentation.kafka.common

testImplementation mnSerde.micronaut.serde.jackson
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import io.micronaut.scheduling.TaskExecutors
import io.micronaut.scheduling.annotation.ExecuteOn
import io.micronaut.tracing.zipkin.http.client.HttpClientSender
import io.opentelemetry.api.trace.Span
import io.opentelemetry.semconv.HttpAttributes
import io.opentelemetry.semconv.UrlAttributes
import jakarta.inject.Inject
import jakarta.inject.Singleton
import org.reactivestreams.Publisher
Expand Down Expand Up @@ -90,21 +92,21 @@ class HttpClientSenderSpec extends Specification {
spanController.receivedSpans.size() == 4

spanController.receivedSpans[0].tags.get('foo') == 'bar'
spanController.receivedSpans[0].tags.get('http.target') == '/traced/hello/John'
spanController.receivedSpans[0].tags.get(UrlAttributes.URL_PATH.key) == '/traced/hello/John'
spanController.receivedSpans[0].name == 'get /traced/hello/{name}'
spanController.receivedSpans[0].kind == SERVER.name()

spanController.receivedSpans[1].tags.get('http.url').contains("/traced/hello/John")
spanController.receivedSpans[1].tags.get(UrlAttributes.URL_FULL.key).contains("/traced/hello/John")
spanController.receivedSpans[1].name == 'get'
spanController.receivedSpans[1].kind == CLIENT.name()

spanController.receivedSpans[2].name == 'get /traced/nested/{name}'
spanController.receivedSpans[2].kind == SERVER.name()
spanController.receivedSpans[2].tags.get('http.method') == 'GET'
spanController.receivedSpans[2].tags.get('http.target') == '/traced/nested/John'
spanController.receivedSpans[2].tags.get(HttpAttributes.HTTP_REQUEST_METHOD.key) == 'GET'
spanController.receivedSpans[2].tags.get(UrlAttributes.URL_PATH.key) == '/traced/nested/John'

spanController.receivedSpans[3].tags.get('foo') == null
spanController.receivedSpans[3].tags.get('http.url').contains('/traced/nested/John')
spanController.receivedSpans[3].tags.get(UrlAttributes.URL_FULL.key).contains('/traced/nested/John')
spanController.receivedSpans[3].name == 'get'
spanController.receivedSpans[3].kind == CLIENT.name()
}
Expand Down Expand Up @@ -154,21 +156,21 @@ class HttpClientSenderSpec extends Specification {
customPathSpanController.receivedSpans.size() == 4

customPathSpanController.receivedSpans[0].tags.get('foo') == 'bar'
customPathSpanController.receivedSpans[0].tags.get('http.target') == '/traced/hello/John'
customPathSpanController.receivedSpans[0].tags.get(UrlAttributes.URL_PATH.key) == '/traced/hello/John'
customPathSpanController.receivedSpans[0].name == 'get /traced/hello/{name}'
customPathSpanController.receivedSpans[0].kind == SERVER.name()

customPathSpanController.receivedSpans[1].tags.get('http.url').contains("/traced/hello/John")
customPathSpanController.receivedSpans[1].tags.get(UrlAttributes.URL_FULL.key).contains("/traced/hello/John")
customPathSpanController.receivedSpans[1].name == 'get'
customPathSpanController.receivedSpans[1].kind == CLIENT.name()

customPathSpanController.receivedSpans[2].name == 'get /traced/nested/{name}'
customPathSpanController.receivedSpans[2].kind == SERVER.name()
customPathSpanController.receivedSpans[2].tags.get('http.method') == 'GET'
customPathSpanController.receivedSpans[2].tags.get('http.target') == '/traced/nested/John'
customPathSpanController.receivedSpans[2].tags.get(HttpAttributes.HTTP_REQUEST_METHOD.key) == 'GET'
customPathSpanController.receivedSpans[2].tags.get(UrlAttributes.URL_PATH.key) == '/traced/nested/John'

customPathSpanController.receivedSpans[3].tags.get('foo') == null
customPathSpanController.receivedSpans[3].tags.get('http.url').contains("/traced/nested/John")
customPathSpanController.receivedSpans[3].tags.get(UrlAttributes.URL_FULL.key).contains("/traced/nested/John")
customPathSpanController.receivedSpans[3].name == 'get'
customPathSpanController.receivedSpans[3].kind == CLIENT.name()
}
Expand Down
3 changes: 1 addition & 2 deletions tracing-opentelemetry/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ dependencies {
api projects.micronautTracingAnnotation
api projects.micronautTracingOpentelemetryAnnotation
api libs.opentelemetry.api
api libs.opentelemetry.api.events
api libs.opentelemetry.api.incubator
api libs.opentelemetry.instrumentation.annotations
api libs.opentelemetry.instrumentation.api
api libs.opentelemetry.instrumentation.semconv
api libs.opentelemetry.autoconfigure

implementation(platform(libs.micronaut.aws))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import io.micronaut.runtime.ApplicationConfiguration;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.events.GlobalEventEmitterProvider;
import io.opentelemetry.api.incubator.events.GlobalEventLoggerProvider;
import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder;
import io.opentelemetry.sdk.trace.IdGenerator;
Expand Down Expand Up @@ -121,7 +121,7 @@ protected OpenTelemetry defaultOpenTelemetry(ApplicationConfiguration applicatio
void resetForTest(Environment environment) {
if (environment.getActiveNames().contains(Environment.TEST)) {
GlobalOpenTelemetry.resetForTest();
GlobalEventEmitterProvider.resetForTest();
GlobalEventLoggerProvider.resetForTest();
}
}

Expand Down
Loading