From 334349bfc649fbde6155f4e0b2134f9190eca657 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Feb 2025 17:17:01 +0000 Subject: [PATCH 1/5] build: bump io.opentelemetry.semconv:opentelemetry-semconv Bumps [io.opentelemetry.semconv:opentelemetry-semconv](https://github.com/open-telemetry/semantic-conventions-java) from 1.29.0-alpha to 1.30.0-rc.1. - [Release notes](https://github.com/open-telemetry/semantic-conventions-java/releases) - [Changelog](https://github.com/open-telemetry/semantic-conventions-java/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/semantic-conventions-java/commits/v1.30.0-rc.1) --- updated-dependencies: - dependency-name: io.opentelemetry.semconv:opentelemetry-semconv dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- apm-agent-plugins/apm-opentelemetry/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apm-agent-plugins/apm-opentelemetry/pom.xml b/apm-agent-plugins/apm-opentelemetry/pom.xml index ac1fb530fb..5f7673ab98 100644 --- a/apm-agent-plugins/apm-opentelemetry/pom.xml +++ b/apm-agent-plugins/apm-opentelemetry/pom.xml @@ -20,7 +20,7 @@ to make sure that in the future we stay compatible with the previous version. --> 1.32.0 - 1.29.0-alpha + 1.30.0-rc.1 8 8 From 7edb4dbda30cd5611f4dfcd3f02848c19ebd99e6 Mon Sep 17 00:00:00 2001 From: Sylvain Juge <763082+SylvainJuge@users.noreply.github.com> Date: Wed, 19 Feb 2025 13:38:36 +0100 Subject: [PATCH 2/5] remove usage of now stale semconv attributes --- .../specs/OTelBridgeStepsDefinitions.java | 32 +++---------------- 1 file changed, 5 insertions(+), 27 deletions(-) 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 dea9a4cb24..aa881e0cf1 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 @@ -34,7 +34,6 @@ import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.api.trace.StatusCode; import io.opentelemetry.context.Context; -import io.opentelemetry.semconv.SemanticAttributes; import javax.annotation.Nullable; import java.util.HashMap; @@ -205,35 +204,14 @@ public void otelSpanAttributes(io.cucumber.datatable.DataTable table) { } private static AttributeKey lookupKey(String name) { + // only doing a simple type mapping to cover existing test cases + // this is not meant to be exhaustive nor to cover up-to-date semconv definitions switch (name) { - case "http.url": - return SemanticAttributes.HTTP_URL; - case "http.scheme": - return SemanticAttributes.HTTP_SCHEME; - case "http.host": - return SemanticAttributes.HTTP_HOST; - case "net.peer.name": - return SemanticAttributes.NET_PEER_NAME; - case "net.peer.ip": - return SemanticAttributes.NET_PEER_IP; case "net.peer.port": - return SemanticAttributes.NET_PEER_PORT; - case "db.system": - return SemanticAttributes.DB_SYSTEM; - case "db.name": - return SemanticAttributes.DB_NAME; - case "messaging.system": - return SemanticAttributes.MESSAGING_SYSTEM; - case "messaging.url": - return SemanticAttributes.MESSAGING_URL; - case "messaging.destination": - return SemanticAttributes.MESSAGING_DESTINATION; - case "rpc.system": - return SemanticAttributes.RPC_SYSTEM; - case "rpc.service": - return SemanticAttributes.RPC_SERVICE; + return AttributeKey.longKey(name); default: - throw new IllegalArgumentException("unknown key for name " + name); + return AttributeKey.stringKey(name); + } } From fc9f0b4c9032e66f77e13a033869429dd1ac012e Mon Sep 17 00:00:00 2001 From: Sylvain Juge <763082+SylvainJuge@users.noreply.github.com> Date: Wed, 19 Feb 2025 13:40:32 +0100 Subject: [PATCH 3/5] remove semconv dependency --- .../apm-opentelemetry/apm-opentelemetry-plugin/pom.xml | 7 ------- 1 file changed, 7 deletions(-) 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 40c6a12e54..64442e2074 100644 --- a/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/pom.xml +++ b/apm-agent-plugins/apm-opentelemetry/apm-opentelemetry-plugin/pom.xml @@ -29,13 +29,6 @@ provided - - io.opentelemetry.semconv - opentelemetry-semconv - ${version.opentelemetry-semconv} - test - - ${project.groupId} apm-opentelemetry-embedded-metrics-sdk From acfb34b28522db16a08c8fba77ca15782b861eda Mon Sep 17 00:00:00 2001 From: Sylvain Juge <763082+SylvainJuge@users.noreply.github.com> Date: Wed, 19 Feb 2025 13:40:44 +0100 Subject: [PATCH 4/5] code cleanup --- .../test/java/specs/OTelBridgeStepsDefinitions.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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 aa881e0cf1..40ae523a3e 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 @@ -20,7 +20,6 @@ import co.elastic.apm.agent.impl.context.ServiceTargetImpl; import co.elastic.apm.agent.impl.transaction.*; -import co.elastic.apm.agent.impl.transaction.TransactionImpl; import co.elastic.apm.agent.opentelemetry.global.ElasticOpenTelemetry; import co.elastic.apm.agent.opentelemetry.tracing.ElasticOpenTelemetryTest; import co.elastic.apm.agent.opentelemetry.tracing.OTelSpan; @@ -102,7 +101,7 @@ public void bridgedTransactionWithRemoteContextParent() { assertThat(traceContext.getTraceId().toString()).isEqualTo(REMOTE_PARENT_TRACE_ID); } - private Context getRemoteContext(){ + private Context getRemoteContext() { return getOtel().getPropagators() .getTextMapPropagator() .extract(Context.current(), @@ -112,7 +111,7 @@ private Context getRemoteContext(){ } @Given("OTel span is created without parent") - public void createOTelSpanWithoutParent(){ + public void createOTelSpanWithoutParent() { otelSpan = (OTelSpan) getOtel().getTracer("") .spanBuilder("otel span") .setNoParent() // redundant, but makes it explicit @@ -155,14 +154,14 @@ public void otelSpanIsCreatedWithKind(String kind) { // the parent transaction is created by another step definition, thus we reuse the existing state TransactionImpl parentTransaction = state.getTransaction(); - Function createSpanWithKind = k -> { + Function createSpanWithKind = k -> { SpanBuilder spanBuilder = getOtel().getTracer("") .spanBuilder("span") .setSpanKind(SpanKind.valueOf(k)); return (OTelSpan) spanBuilder.startSpan(); }; - if( parentTransaction != null){ + if (parentTransaction != null) { // creating a span as a child of existing transaction try (Scope scope = parentTransaction.activateInScope()) { this.otelSpan = createSpanWithKind.apply(kind); @@ -216,7 +215,7 @@ private static AttributeKey lookupKey(String name) { } @Then("Elastic bridged (transaction|span) OTel kind is {string}") - public void bridgeObjectKind(String kind){ + public void bridgeObjectKind(String kind) { assertThat(getBridgedAbstractSpan().getOtelKind()) .isEqualTo(OTelSpanKind.valueOf(kind)); } @@ -303,7 +302,7 @@ public void bridgedSpanTargetServiceType(String type, String name) { } @Then("OTel span status set to {string}") - public void setOtelSpanStatus(String status){ + public void setOtelSpanStatus(String status) { otelSpan.setStatus(StatusCode.valueOf(status.toUpperCase(Locale.ROOT))); } From 7c785cb95d77dfa87a9c45b9a78ec020a7d7370a Mon Sep 17 00:00:00 2001 From: Sylvain Juge <763082+SylvainJuge@users.noreply.github.com> Date: Wed, 19 Feb 2025 15:55:32 +0100 Subject: [PATCH 5/5] remove leftovers references --- .../agent/opentelemetry/SemAttributes.java | 27 +++++-------------- 1 file changed, 6 insertions(+), 21 deletions(-) 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 index 7077c599ec..a06ecc1d0c 100644 --- 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 @@ -21,29 +21,14 @@ import io.opentelemetry.api.common.AttributeKey; /** - * Bridge for integration tests which use {@link io.opentelemetry.semconv.SemanticAttributes} + * Bridge for integration tests which use semconv attributes * 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); - } - } + public static final AttributeKey HTTP_URL = AttributeKey.stringKey("HTTP_URL"); + public static final AttributeKey HTTP_STATUS_CODE = AttributeKey.longKey("HTTP_STATUS_CODE"); + public static final AttributeKey HTTP_METHOD = AttributeKey.stringKey("HTTP_METHOD"); + public static final AttributeKey NET_PEER_PORT = AttributeKey.longKey("NET_PEER_PORT"); + public static final AttributeKey NET_PEER_IP = AttributeKey.stringKey("NET_PEER_IP"); }