Skip to content
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
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
</dependency>

<dependency>
<groupId>io.opentelemetry</groupId>
<groupId>io.opentelemetry.semconv</groupId>
<artifactId>opentelemetry-semconv</artifactId>
<version>${version.opentelemetry}-alpha</version>
<version>${version.opentelemetry-semconv}</version>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
@@ -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<String> HTTP_URL = getAttribute("HTTP_URL");
public static final AttributeKey<Long> HTTP_STATUS_CODE = getAttribute("HTTP_STATUS_CODE");
public static final AttributeKey<String> HTTP_METHOD = getAttribute("HTTP_METHOD");
public static final AttributeKey<Long> NET_PEER_PORT = getAttribute("NET_PEER_PORT");
public static final AttributeKey<String> NET_PEER_IP = getAttribute("NET_PEER_IP");

@SuppressWarnings("unchecked")
private static <T> AttributeKey<T> 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<T>) attribClass.getField(name).get(null);
}catch (Exception e) {
throw new IllegalStateException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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"
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
3 changes: 2 additions & 1 deletion apm-agent-plugins/apm-opentelemetry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
-->
<version.opentelemetry>1.22.0</version.opentelemetry>
<version.opentelemetry>1.31.0</version.opentelemetry>
<version.opentelemetry-semconv>1.21.0-alpha</version.opentelemetry-semconv>

<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.source>8</maven.compiler.source>
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/external-plugin-otel-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<properties>
<apm-agent-parent.base.dir>${project.basedir}/../..</apm-agent-parent.base.dir>

<otel.version>1.20.0</otel.version>
<otel.version>1.31.0</otel.version>

<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
Expand Down