diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 65525c4e40..95d3ce2935 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -36,6 +36,8 @@ updates: - dependency-name: "io.vertx:*" - dependency-name: "org.apache.logging.log4j:*" - dependency-name: "org.springframework.boot:*" + - dependency-name: "io.opentelemetry:*" + - dependency-name: "io.opentelemetry.semconv:*" ignore: - dependency-name: "net.bytebuddy:byte-buddy-agent" # We deliberately want to keep this older version of Byte Buddy for our runtime attach test diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/pom.xml b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/pom.xml index 8f890f3f34..46544a723f 100644 --- a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/pom.xml +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/pom.xml @@ -23,9 +23,9 @@ - io.opentelemetry + io.opentelemetry.semconv opentelemetry-semconv - ${version.opentelemetry}-alpha + ${version.opentelemetry-semconv} test diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/src/test/java/co/elastic/apm/agent/opentelemetry/SemAttributes.java b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/src/test/java/co/elastic/apm/agent/opentelemetry/SemAttributes.java new file mode 100644 index 0000000000..7077c599ec --- /dev/null +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/src/test/java/co/elastic/apm/agent/opentelemetry/SemAttributes.java @@ -0,0 +1,49 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package co.elastic.apm.agent.opentelemetry; + +import io.opentelemetry.api.common.AttributeKey; + +/** + * Bridge for integration tests which use {@link io.opentelemetry.semconv.SemanticAttributes} + * which has been moved from {@code io.opentelemetry.semconv.trace.attributes.SemanticAttributes}. + */ +public class SemAttributes { + + public static final AttributeKey HTTP_URL = getAttribute("HTTP_URL"); + public static final AttributeKey HTTP_STATUS_CODE = getAttribute("HTTP_STATUS_CODE"); + public static final AttributeKey HTTP_METHOD = getAttribute("HTTP_METHOD"); + public static final AttributeKey NET_PEER_PORT = getAttribute("NET_PEER_PORT"); + public static final AttributeKey NET_PEER_IP = getAttribute("NET_PEER_IP"); + + @SuppressWarnings("unchecked") + private static AttributeKey getAttribute(String name) { + try { + Class attribClass; + try { + attribClass = Class.forName("io.opentelemetry.semconv.SemanticAttributes"); + } catch (ClassNotFoundException cnf) { + attribClass = Class.forName("io.opentelemetry.semconv.trace.attributes.SemanticAttributes"); + } + return (AttributeKey) attribClass.getField(name).get(null); + }catch (Exception e) { + throw new IllegalStateException(e); + } + } +} diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/src/test/java/co/elastic/apm/agent/opentelemetry/tracing/ElasticOpenTelemetryTest.java b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/src/test/java/co/elastic/apm/agent/opentelemetry/tracing/ElasticOpenTelemetryTest.java index aa2084f246..08e43d5a4a 100644 --- a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/src/test/java/co/elastic/apm/agent/opentelemetry/tracing/ElasticOpenTelemetryTest.java +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/src/test/java/co/elastic/apm/agent/opentelemetry/tracing/ElasticOpenTelemetryTest.java @@ -22,6 +22,7 @@ import co.elastic.apm.agent.impl.transaction.ElasticContext; import co.elastic.apm.agent.impl.transaction.OTelSpanKind; import co.elastic.apm.agent.impl.transaction.Transaction; +import co.elastic.apm.agent.opentelemetry.SemAttributes; import co.elastic.apm.agent.tracer.Outcome; import co.elastic.apm.agent.tracer.dispatch.TextHeaderSetter; import io.opentelemetry.api.baggage.Baggage; @@ -33,7 +34,6 @@ import io.opentelemetry.context.ContextKey; import io.opentelemetry.context.Scope; import io.opentelemetry.context.propagation.TextMapGetter; -import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -571,20 +571,20 @@ public void elasticSpanOverOtelSpan() { public void testOTelSpanAttributesCopiedAsIs() { otelTracer.spanBuilder("transaction").setSpanKind(SpanKind.SERVER) .startSpan() - .setAttribute(SemanticAttributes.HTTP_METHOD, "GET") - .setAttribute(SemanticAttributes.HTTP_URL, "http://example.com:8080/foo?bar") - .setAttribute(SemanticAttributes.HTTP_STATUS_CODE, 200L) - .setAttribute(SemanticAttributes.NET_PEER_PORT, 123456) - .setAttribute(SemanticAttributes.NET_PEER_IP, "192.168.178.1") + .setAttribute(SemAttributes.HTTP_METHOD, "GET") + .setAttribute(SemAttributes.HTTP_URL, "http://example.com:8080/foo?bar") + .setAttribute(SemAttributes.HTTP_STATUS_CODE, 200L) + .setAttribute(SemAttributes.NET_PEER_PORT, 123456) + .setAttribute(SemAttributes.NET_PEER_IP, "192.168.178.1") .end(); assertThat(reporter.getTransactions()).hasSize(1); checkOTelAttributes(reporter.getFirstTransaction(), Map.of( - SemanticAttributes.HTTP_METHOD.getKey(), "GET", - SemanticAttributes.HTTP_URL.getKey(), "http://example.com:8080/foo?bar", - SemanticAttributes.HTTP_STATUS_CODE.getKey(), 200L, - SemanticAttributes.NET_PEER_PORT.getKey(), 123456L, - SemanticAttributes.NET_PEER_IP.getKey(), "192.168.178.1" + SemAttributes.HTTP_METHOD.getKey(), "GET", + SemAttributes.HTTP_URL.getKey(), "http://example.com:8080/foo?bar", + SemAttributes.HTTP_STATUS_CODE.getKey(), 200L, + SemAttributes.NET_PEER_PORT.getKey(), 123456L, + SemAttributes.NET_PEER_IP.getKey(), "192.168.178.1" )); } diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/src/test/java/specs/OTelBridgeStepsDefinitions.java b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/src/test/java/specs/OTelBridgeStepsDefinitions.java index f951862788..c1d00c1029 100644 --- a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/src/test/java/specs/OTelBridgeStepsDefinitions.java +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/src/test/java/specs/OTelBridgeStepsDefinitions.java @@ -37,7 +37,7 @@ import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.api.trace.StatusCode; import io.opentelemetry.context.Context; -import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; +import io.opentelemetry.semconv.SemanticAttributes; import javax.annotation.Nullable; import java.util.HashMap; diff --git a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-test/src/test/java/co/elastic/apm/agent/opentelemetry/OpenTelemetryVersionIT.java b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-test/src/test/java/co/elastic/apm/agent/opentelemetry/OpenTelemetryVersionIT.java index fa4f0098a7..17c8fffb8e 100644 --- a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-test/src/test/java/co/elastic/apm/agent/opentelemetry/OpenTelemetryVersionIT.java +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-test/src/test/java/co/elastic/apm/agent/opentelemetry/OpenTelemetryVersionIT.java @@ -59,6 +59,7 @@ void testTracingVersion(String version) throws Exception { TestClassWithDependencyRunner runner = new TestClassWithDependencyRunner(dependencies, "co.elastic.apm.agent.opentelemetry.tracing.ElasticOpenTelemetryTest", "co.elastic.apm.agent.opentelemetry.tracing.AbstractOpenTelemetryTest", + "co.elastic.apm.agent.opentelemetry.SemAttributes", "co.elastic.apm.agent.opentelemetry.tracing.ElasticOpenTelemetryTest$MapGetter"); runner.run(); } diff --git a/apm-agent-plugins/apm-opentelemetry/pom.xml b/apm-agent-plugins/apm-opentelemetry/pom.xml index cd5a609d10..cae3ef6876 100644 --- a/apm-agent-plugins/apm-opentelemetry/pom.xml +++ b/apm-agent-plugins/apm-opentelemetry/pom.xml @@ -19,7 +19,8 @@ When updating the version, add the old version to OpenTelemetryVersionIT to make sure that in the future we stay compatible with the previous version. --> - 1.22.0 + 1.31.0 + 1.21.0-alpha 8 8 diff --git a/integration-tests/external-plugin-otel-test/pom.xml b/integration-tests/external-plugin-otel-test/pom.xml index a4e51cd926..3b15c90b26 100644 --- a/integration-tests/external-plugin-otel-test/pom.xml +++ b/integration-tests/external-plugin-otel-test/pom.xml @@ -14,7 +14,7 @@ ${project.basedir}/../.. - 1.20.0 + 1.31.0 8 8