Semconv 1.25.0 migration (#10983)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
SylvainJuge 2024-04-09 20:25:52 +02:00 committed by GitHub
parent 0bc2372d67
commit 955470a63a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
417 changed files with 6410 additions and 5699 deletions

View File

@ -28,6 +28,7 @@ tasks.withType<ShadowJar>().configureEach {
// relocate(OpenTelemetry API) since these classes live in the bootstrap class loader
relocate("io.opentelemetry.api", "io.opentelemetry.javaagent.shaded.io.opentelemetry.api")
relocate("io.opentelemetry.semconv", "io.opentelemetry.javaagent.shaded.io.opentelemetry.semconv")
relocate("io.opentelemetry.semconv.incubating", "io.opentelemetry.javaagent.shaded.io.opentelemetry.semconv.incubating")
relocate("io.opentelemetry.context", "io.opentelemetry.javaagent.shaded.io.opentelemetry.context")
relocate("io.opentelemetry.extension.incubator", "io.opentelemetry.javaagent.shaded.io.opentelemetry.extension.incubator")
}

View File

@ -46,9 +46,11 @@ val asmVersion = "9.7"
val jmhVersion = "1.37"
val mockitoVersion = "4.11.0"
val slf4jVersion = "2.0.12"
val semConvVersion = "1.25.0-alpha"
val CORE_DEPENDENCIES = listOf(
"io.opentelemetry.semconv:opentelemetry-semconv:1.23.1-alpha",
"io.opentelemetry.semconv:opentelemetry-semconv:${semConvVersion}",
"io.opentelemetry.semconv:opentelemetry-semconv-incubating:${semConvVersion}",
"com.google.auto.service:auto-service:${autoServiceVersion}",
"com.google.auto.service:auto-service-annotations:${autoServiceVersion}",
"com.google.auto.value:auto-value:${autoValueVersion}",

View File

@ -12,6 +12,7 @@ ext.relocatePackages = { shadowJar ->
// relocate(OpenTelemetry API) since these classes live in the bootstrap class loader
shadowJar.relocate("io.opentelemetry.api", "io.opentelemetry.javaagent.shaded.io.opentelemetry.api")
shadowJar.relocate("io.opentelemetry.semconv", "io.opentelemetry.javaagent.shaded.io.opentelemetry.semconv")
shadowJar.relocate("io.opentelemetry.semconv.incubating", "io.opentelemetry.javaagent.shaded.io.opentelemetry.semconv.incubating")
shadowJar.relocate("io.opentelemetry.context", "io.opentelemetry.javaagent.shaded.io.opentelemetry.context")
shadowJar.relocate("io.opentelemetry.extension.incubator", "io.opentelemetry.javaagent.shaded.io.opentelemetry.extension.incubator")

View File

@ -7,8 +7,8 @@ package io.opentelemetry.javaagent.instrumentation.otelannotations;
import static io.opentelemetry.api.common.AttributeKey.booleanKey;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
import static io.opentelemetry.semconv.SemanticAttributes.CODE_FUNCTION;
import static io.opentelemetry.semconv.SemanticAttributes.CODE_NAMESPACE;
import static io.opentelemetry.semconv.incubating.CodeIncubatingAttributes.CODE_FUNCTION;
import static io.opentelemetry.semconv.incubating.CodeIncubatingAttributes.CODE_NAMESPACE;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.catchThrowable;

View File

@ -12,6 +12,7 @@ dependencies {
api("io.opentelemetry:opentelemetry-api")
api("io.opentelemetry.semconv:opentelemetry-semconv")
api("io.opentelemetry.semconv:opentelemetry-semconv-incubating")
compileOnly("com.google.auto.value:auto-value-annotations")
annotationProcessor("com.google.auto.value:auto-value")

View File

@ -12,6 +12,7 @@ group = "io.opentelemetry.instrumentation"
dependencies {
api("io.opentelemetry.semconv:opentelemetry-semconv")
api("io.opentelemetry.semconv:opentelemetry-semconv-incubating")
api(project(":instrumentation-api"))
implementation("io.opentelemetry:opentelemetry-extension-incubator")

View File

@ -10,7 +10,7 @@ import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorU
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.CodeIncubatingAttributes;
import javax.annotation.Nullable;
/**
@ -37,9 +37,9 @@ public final class CodeAttributesExtractor<REQUEST, RESPONSE>
public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {
Class<?> cls = getter.getCodeClass(request);
if (cls != null) {
internalSet(attributes, SemanticAttributes.CODE_NAMESPACE, cls.getName());
internalSet(attributes, CodeIncubatingAttributes.CODE_NAMESPACE, cls.getName());
}
internalSet(attributes, SemanticAttributes.CODE_FUNCTION, getter.getMethodName(request));
internalSet(attributes, CodeIncubatingAttributes.CODE_FUNCTION, getter.getMethodName(request));
}
@Override

View File

@ -10,7 +10,7 @@ import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorU
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
/**
* Extractor of <a
@ -38,7 +38,7 @@ public final class DbClientAttributesExtractor<REQUEST, RESPONSE>
public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {
super.onStart(attributes, parentContext, request);
internalSet(attributes, SemanticAttributes.DB_STATEMENT, getter.getStatement(request));
internalSet(attributes, SemanticAttributes.DB_OPERATION, getter.getOperation(request));
internalSet(attributes, DbIncubatingAttributes.DB_STATEMENT, getter.getStatement(request));
internalSet(attributes, DbIncubatingAttributes.DB_OPERATION, getter.getOperation(request));
}
}

View File

@ -12,7 +12,7 @@ import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.internal.SpanKey;
import io.opentelemetry.instrumentation.api.internal.SpanKeyProvider;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
import javax.annotation.Nullable;
abstract class DbClientCommonAttributesExtractor<
@ -25,13 +25,16 @@ abstract class DbClientCommonAttributesExtractor<
this.getter = getter;
}
@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@Override
public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {
internalSet(attributes, SemanticAttributes.DB_SYSTEM, getter.getSystem(request));
internalSet(attributes, SemanticAttributes.DB_USER, getter.getUser(request));
internalSet(attributes, SemanticAttributes.DB_NAME, getter.getName(request));
internalSet(attributes, DbIncubatingAttributes.DB_SYSTEM, getter.getSystem(request));
internalSet(attributes, DbIncubatingAttributes.DB_USER, getter.getUser(request));
internalSet(attributes, DbIncubatingAttributes.DB_NAME, getter.getName(request));
internalSet(
attributes, SemanticAttributes.DB_CONNECTION_STRING, getter.getConnectionString(request));
attributes,
DbIncubatingAttributes.DB_CONNECTION_STRING,
getter.getConnectionString(request));
}
@Override

View File

@ -11,7 +11,7 @@ import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
/**
* Extractor of <a
@ -19,9 +19,9 @@ import io.opentelemetry.semconv.SemanticAttributes;
* attributes</a>. This class is designed with SQL (or SQL-like) database clients in mind.
*
* <p>It sets the same set of attributes as {@link DbClientAttributesExtractor} plus an additional
* <code>{@linkplain SemanticAttributes#DB_SQL_TABLE db.sql.table}</code> attribute. The raw SQL
* statements returned by the {@link SqlClientAttributesGetter#getRawStatement(Object)} method are
* sanitized before use, all statement parameters are removed.
* <code>{@link DbIncubatingAttributes#DB_SQL_TABLE}</code> attribute. The raw SQL statements
* returned by the {@link SqlClientAttributesGetter#getRawStatement(Object)} method are sanitized
* before use, all statement parameters are removed.
*/
public final class SqlClientAttributesExtractor<REQUEST, RESPONSE>
extends DbClientCommonAttributesExtractor<
@ -62,8 +62,9 @@ public final class SqlClientAttributesExtractor<REQUEST, RESPONSE>
SqlStatementInfo sanitizedStatement = sanitizer.sanitize(getter.getRawStatement(request));
String operation = sanitizedStatement.getOperation();
internalSet(attributes, SemanticAttributes.DB_STATEMENT, sanitizedStatement.getFullStatement());
internalSet(attributes, SemanticAttributes.DB_OPERATION, operation);
internalSet(
attributes, DbIncubatingAttributes.DB_STATEMENT, sanitizedStatement.getFullStatement());
internalSet(attributes, DbIncubatingAttributes.DB_OPERATION, operation);
if (!SQL_CALL.equals(operation)) {
internalSet(attributes, dbTableAttribute, sanitizedStatement.getMainIdentifier());
}

View File

@ -10,13 +10,13 @@ import static java.util.Objects.requireNonNull;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
/** A builder of {@link SqlClientAttributesExtractor}. */
public final class SqlClientAttributesExtractorBuilder<REQUEST, RESPONSE> {
final SqlClientAttributesGetter<REQUEST> getter;
AttributeKey<String> dbTableAttribute = SemanticAttributes.DB_SQL_TABLE;
AttributeKey<String> dbTableAttribute = DbIncubatingAttributes.DB_SQL_TABLE;
boolean statementSanitizationEnabled = true;
SqlClientAttributesExtractorBuilder(SqlClientAttributesGetter<REQUEST> getter) {
@ -26,7 +26,7 @@ public final class SqlClientAttributesExtractorBuilder<REQUEST, RESPONSE> {
/**
* Configures the extractor to set the table value extracted by the {@link
* SqlClientAttributesExtractor} under the {@code dbTableAttribute} key. By default, the <code>
* {@linkplain SemanticAttributes#DB_SQL_TABLE db.sql.table}</code> attribute is used.
* {@link DbIncubatingAttributes#DB_SQL_TABLE}</code> attribute is used.
*
* @param dbTableAttribute The {@link AttributeKey} under which the table extracted by the {@link
* SqlClientAttributesExtractor} will be stored.

View File

@ -11,7 +11,7 @@ import io.opentelemetry.instrumentation.api.incubator.semconv.net.PeerServiceRes
import io.opentelemetry.instrumentation.api.incubator.semconv.net.internal.UrlParser;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesGetter;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.PeerIncubatingAttributes;
import java.util.function.Supplier;
import javax.annotation.Nullable;
@ -67,7 +67,7 @@ public final class HttpClientPeerServiceAttributesExtractor<REQUEST, RESPONSE>
Supplier<String> pathSupplier = () -> getUrlPath(attributesGetter, request);
String peerService = mapToPeerService(serverAddress, serverPort, pathSupplier);
if (peerService != null) {
attributes.put(SemanticAttributes.PEER_SERVICE, peerService);
attributes.put(PeerIncubatingAttributes.PEER_SERVICE, peerService);
}
}

View File

@ -13,7 +13,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesGetter;
import io.opentelemetry.instrumentation.api.semconv.http.HttpCommonAttributesGetter;
import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesGetter;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.HttpIncubatingAttributes;
import java.util.List;
import javax.annotation.Nullable;
@ -49,11 +49,11 @@ public final class HttpExperimentalAttributesExtractor<REQUEST, RESPONSE>
@Nullable Throwable error) {
Long requestBodySize = requestBodySize(request);
internalSet(attributes, SemanticAttributes.HTTP_REQUEST_BODY_SIZE, requestBodySize);
internalSet(attributes, HttpIncubatingAttributes.HTTP_REQUEST_BODY_SIZE, requestBodySize);
if (response != null) {
Long responseBodySize = responseBodySize(request, response);
internalSet(attributes, SemanticAttributes.HTTP_RESPONSE_BODY_SIZE, responseBodySize);
internalSet(attributes, HttpIncubatingAttributes.HTTP_RESPONSE_BODY_SIZE, responseBodySize);
}
}

View File

@ -11,7 +11,11 @@ import io.opentelemetry.api.metrics.LongHistogramBuilder;
import io.opentelemetry.api.metrics.LongUpDownCounterBuilder;
import io.opentelemetry.extension.incubator.metrics.ExtendedLongHistogramBuilder;
import io.opentelemetry.extension.incubator.metrics.ExtendedLongUpDownCounterBuilder;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.ErrorAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import io.opentelemetry.semconv.UrlAttributes;
final class HttpExperimentalMetricsAdvice {
@ -22,13 +26,13 @@ final class HttpExperimentalMetricsAdvice {
((ExtendedLongHistogramBuilder) builder)
.setAttributesAdvice(
asList(
SemanticAttributes.HTTP_REQUEST_METHOD,
SemanticAttributes.HTTP_RESPONSE_STATUS_CODE,
SemanticAttributes.ERROR_TYPE,
SemanticAttributes.NETWORK_PROTOCOL_NAME,
SemanticAttributes.NETWORK_PROTOCOL_VERSION,
SemanticAttributes.SERVER_ADDRESS,
SemanticAttributes.SERVER_PORT));
HttpAttributes.HTTP_REQUEST_METHOD,
HttpAttributes.HTTP_RESPONSE_STATUS_CODE,
ErrorAttributes.ERROR_TYPE,
NetworkAttributes.NETWORK_PROTOCOL_NAME,
NetworkAttributes.NETWORK_PROTOCOL_VERSION,
ServerAttributes.SERVER_ADDRESS,
ServerAttributes.SERVER_PORT));
}
static void applyServerRequestSizeAdvice(LongHistogramBuilder builder) {
@ -39,13 +43,13 @@ final class HttpExperimentalMetricsAdvice {
.setAttributesAdvice(
asList(
// stable attributes
SemanticAttributes.HTTP_ROUTE,
SemanticAttributes.HTTP_REQUEST_METHOD,
SemanticAttributes.HTTP_RESPONSE_STATUS_CODE,
SemanticAttributes.ERROR_TYPE,
SemanticAttributes.NETWORK_PROTOCOL_NAME,
SemanticAttributes.NETWORK_PROTOCOL_VERSION,
SemanticAttributes.URL_SCHEME));
HttpAttributes.HTTP_ROUTE,
HttpAttributes.HTTP_REQUEST_METHOD,
HttpAttributes.HTTP_RESPONSE_STATUS_CODE,
ErrorAttributes.ERROR_TYPE,
NetworkAttributes.NETWORK_PROTOCOL_NAME,
NetworkAttributes.NETWORK_PROTOCOL_VERSION,
UrlAttributes.URL_SCHEME));
}
static void applyServerActiveRequestsAdvice(LongUpDownCounterBuilder builder) {
@ -56,7 +60,7 @@ final class HttpExperimentalMetricsAdvice {
.setAttributesAdvice(
asList(
// https://github.com/open-telemetry/semantic-conventions/blob/v1.23.0/docs/http/http-metrics.md#metric-httpserveractive_requests
SemanticAttributes.HTTP_REQUEST_METHOD, SemanticAttributes.URL_SCHEME));
HttpAttributes.HTTP_REQUEST_METHOD, UrlAttributes.URL_SCHEME));
}
private HttpExperimentalMetricsAdvice() {}

View File

@ -7,19 +7,19 @@ package io.opentelemetry.instrumentation.api.incubator.semconv.http;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.HttpIncubatingAttributes;
import javax.annotation.Nullable;
final class HttpMessageBodySizeUtil {
@Nullable
static Long getHttpRequestBodySize(Attributes... attributesList) {
return getAttribute(SemanticAttributes.HTTP_REQUEST_BODY_SIZE, attributesList);
return getAttribute(HttpIncubatingAttributes.HTTP_REQUEST_BODY_SIZE, attributesList);
}
@Nullable
static Long getHttpResponseBodySize(Attributes... attributesList) {
return getAttribute(SemanticAttributes.HTTP_RESPONSE_BODY_SIZE, attributesList);
return getAttribute(HttpIncubatingAttributes.HTTP_RESPONSE_BODY_SIZE, attributesList);
}
@Nullable

View File

@ -12,7 +12,7 @@ import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.internal.SpanKey;
import io.opentelemetry.instrumentation.api.internal.SpanKeyProvider;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
import java.util.List;
import javax.annotation.Nullable;
@ -62,40 +62,46 @@ public final class MessagingAttributesExtractor<REQUEST, RESPONSE>
@Override
public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {
internalSet(attributes, SemanticAttributes.MESSAGING_SYSTEM, getter.getSystem(request));
internalSet(
attributes, MessagingIncubatingAttributes.MESSAGING_SYSTEM, getter.getSystem(request));
boolean isTemporaryDestination = getter.isTemporaryDestination(request);
if (isTemporaryDestination) {
internalSet(attributes, SemanticAttributes.MESSAGING_DESTINATION_TEMPORARY, true);
internalSet(attributes, SemanticAttributes.MESSAGING_DESTINATION_NAME, TEMP_DESTINATION_NAME);
internalSet(attributes, MessagingIncubatingAttributes.MESSAGING_DESTINATION_TEMPORARY, true);
internalSet(
attributes,
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
TEMP_DESTINATION_NAME);
} else {
internalSet(
attributes,
SemanticAttributes.MESSAGING_DESTINATION_NAME,
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
getter.getDestination(request));
internalSet(
attributes,
SemanticAttributes.MESSAGING_DESTINATION_TEMPLATE,
MessagingIncubatingAttributes.MESSAGING_DESTINATION_TEMPLATE,
getter.getDestinationTemplate(request));
}
boolean isAnonymousDestination = getter.isAnonymousDestination(request);
if (isAnonymousDestination) {
internalSet(attributes, SemanticAttributes.MESSAGING_DESTINATION_ANONYMOUS, true);
internalSet(attributes, MessagingIncubatingAttributes.MESSAGING_DESTINATION_ANONYMOUS, true);
}
internalSet(
attributes,
SemanticAttributes.MESSAGING_MESSAGE_CONVERSATION_ID,
MessagingIncubatingAttributes.MESSAGING_MESSAGE_CONVERSATION_ID,
getter.getConversationId(request));
internalSet(
attributes,
SemanticAttributes.MESSAGING_MESSAGE_BODY_SIZE,
MessagingIncubatingAttributes.MESSAGING_MESSAGE_BODY_SIZE,
getter.getMessageBodySize(request));
internalSet(
attributes,
SemanticAttributes.MESSAGING_MESSAGE_ENVELOPE_SIZE,
MessagingIncubatingAttributes.MESSAGING_MESSAGE_ENVELOPE_SIZE,
getter.getMessageEnvelopeSize(request));
internalSet(attributes, SemanticAttributes.MESSAGING_CLIENT_ID, getter.getClientId(request));
internalSet(
attributes, MessagingIncubatingAttributes.MESSAGING_CLIENT_ID, getter.getClientId(request));
if (operation != null) {
internalSet(attributes, SemanticAttributes.MESSAGING_OPERATION, operation.operationName());
internalSet(
attributes, MessagingIncubatingAttributes.MESSAGING_OPERATION, operation.operationName());
}
}
@ -108,11 +114,11 @@ public final class MessagingAttributesExtractor<REQUEST, RESPONSE>
@Nullable Throwable error) {
internalSet(
attributes,
SemanticAttributes.MESSAGING_MESSAGE_ID,
MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID,
getter.getMessageId(request, response));
internalSet(
attributes,
SemanticAttributes.MESSAGING_BATCH_MESSAGE_COUNT,
MessagingIncubatingAttributes.MESSAGING_BATCH_MESSAGE_COUNT,
getter.getBatchMessageCount(request, response));
for (String name : capturedHeaders) {

View File

@ -9,7 +9,7 @@ import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.semconv.network.ServerAttributesGetter;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.PeerIncubatingAttributes;
import javax.annotation.Nullable;
/**
@ -60,7 +60,7 @@ public final class PeerServiceAttributesExtractor<REQUEST, RESPONSE>
Integer serverPort = attributesGetter.getServerPort(request);
String peerService = mapToPeerService(serverAddress, serverPort);
if (peerService != null) {
attributes.put(SemanticAttributes.PEER_SERVICE, peerService);
attributes.put(PeerIncubatingAttributes.PEER_SERVICE, peerService);
}
}

View File

@ -10,7 +10,7 @@ import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorU
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.RpcIncubatingAttributes;
import javax.annotation.Nullable;
abstract class RpcCommonAttributesExtractor<REQUEST, RESPONSE>
@ -24,9 +24,9 @@ abstract class RpcCommonAttributesExtractor<REQUEST, RESPONSE>
@Override
public final void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {
internalSet(attributes, SemanticAttributes.RPC_SYSTEM, getter.getSystem(request));
internalSet(attributes, SemanticAttributes.RPC_SERVICE, getter.getService(request));
internalSet(attributes, SemanticAttributes.RPC_METHOD, getter.getMethod(request));
internalSet(attributes, RpcIncubatingAttributes.RPC_SYSTEM, getter.getSystem(request));
internalSet(attributes, RpcIncubatingAttributes.RPC_SERVICE, getter.getService(request));
internalSet(attributes, RpcIncubatingAttributes.RPC_METHOD, getter.getMethod(request));
}
@Override

View File

@ -7,7 +7,9 @@ package io.opentelemetry.instrumentation.api.incubator.semconv.rpc;
import io.opentelemetry.api.metrics.DoubleHistogramBuilder;
import io.opentelemetry.extension.incubator.metrics.ExtendedDoubleHistogramBuilder;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import io.opentelemetry.semconv.incubating.RpcIncubatingAttributes;
import java.util.Arrays;
final class RpcMetricsAdvice {
@ -21,14 +23,14 @@ final class RpcMetricsAdvice {
((ExtendedDoubleHistogramBuilder) builder)
.setAttributesAdvice(
Arrays.asList(
SemanticAttributes.RPC_SYSTEM,
SemanticAttributes.RPC_SERVICE,
SemanticAttributes.RPC_METHOD,
SemanticAttributes.RPC_GRPC_STATUS_CODE,
SemanticAttributes.NETWORK_TYPE,
SemanticAttributes.NETWORK_TRANSPORT,
SemanticAttributes.SERVER_ADDRESS,
SemanticAttributes.SERVER_PORT));
RpcIncubatingAttributes.RPC_SYSTEM,
RpcIncubatingAttributes.RPC_SERVICE,
RpcIncubatingAttributes.RPC_METHOD,
RpcIncubatingAttributes.RPC_GRPC_STATUS_CODE,
NetworkAttributes.NETWORK_TYPE,
NetworkAttributes.NETWORK_TRANSPORT,
ServerAttributes.SERVER_ADDRESS,
ServerAttributes.SERVER_PORT));
}
static void applyServerDurationAdvice(DoubleHistogramBuilder builder) {
@ -40,14 +42,14 @@ final class RpcMetricsAdvice {
((ExtendedDoubleHistogramBuilder) builder)
.setAttributesAdvice(
Arrays.asList(
SemanticAttributes.RPC_SYSTEM,
SemanticAttributes.RPC_SERVICE,
SemanticAttributes.RPC_METHOD,
SemanticAttributes.RPC_GRPC_STATUS_CODE,
SemanticAttributes.NETWORK_TYPE,
SemanticAttributes.NETWORK_TRANSPORT,
SemanticAttributes.SERVER_ADDRESS,
SemanticAttributes.SERVER_PORT));
RpcIncubatingAttributes.RPC_SYSTEM,
RpcIncubatingAttributes.RPC_SERVICE,
RpcIncubatingAttributes.RPC_METHOD,
RpcIncubatingAttributes.RPC_GRPC_STATUS_CODE,
NetworkAttributes.NETWORK_TYPE,
NetworkAttributes.NETWORK_TRANSPORT,
ServerAttributes.SERVER_ADDRESS,
ServerAttributes.SERVER_PORT));
}
private RpcMetricsAdvice() {}

View File

@ -12,7 +12,7 @@ import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.CodeIncubatingAttributes;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@ -59,8 +59,8 @@ class CodeAttributesExtractorTest {
// then
assertThat(startAttributes.build())
.containsOnly(
entry(SemanticAttributes.CODE_NAMESPACE, TestClass.class.getName()),
entry(SemanticAttributes.CODE_FUNCTION, "doSomething"));
entry(CodeIncubatingAttributes.CODE_NAMESPACE, TestClass.class.getName()),
entry(CodeIncubatingAttributes.CODE_FUNCTION, "doSomething"));
assertThat(endAttributes.build().isEmpty()).isTrue();
}

View File

@ -12,7 +12,7 @@ import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@ -52,6 +52,7 @@ class DbClientAttributesExtractorTest {
}
}
@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@Test
void shouldExtractAllAvailableAttributes() {
// given
@ -78,12 +79,12 @@ class DbClientAttributesExtractorTest {
// then
assertThat(startAttributes.build())
.containsOnly(
entry(SemanticAttributes.DB_SYSTEM, "myDb"),
entry(SemanticAttributes.DB_USER, "username"),
entry(SemanticAttributes.DB_NAME, "potatoes"),
entry(SemanticAttributes.DB_CONNECTION_STRING, "mydb:///potatoes"),
entry(SemanticAttributes.DB_STATEMENT, "SELECT * FROM potato"),
entry(SemanticAttributes.DB_OPERATION, "SELECT"));
entry(DbIncubatingAttributes.DB_SYSTEM, "myDb"),
entry(DbIncubatingAttributes.DB_USER, "username"),
entry(DbIncubatingAttributes.DB_NAME, "potatoes"),
entry(DbIncubatingAttributes.DB_CONNECTION_STRING, "mydb:///potatoes"),
entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT * FROM potato"),
entry(DbIncubatingAttributes.DB_OPERATION, "SELECT"));
assertThat(endAttributes.build().isEmpty()).isTrue();
}

View File

@ -12,7 +12,7 @@ import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@ -49,6 +49,7 @@ class SqlClientAttributesExtractorTest {
}
}
@SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation
@Test
void shouldExtractAllAttributes() {
// given
@ -74,13 +75,13 @@ class SqlClientAttributesExtractorTest {
// then
assertThat(startAttributes.build())
.containsOnly(
entry(SemanticAttributes.DB_SYSTEM, "myDb"),
entry(SemanticAttributes.DB_USER, "username"),
entry(SemanticAttributes.DB_NAME, "potatoes"),
entry(SemanticAttributes.DB_CONNECTION_STRING, "mydb:///potatoes"),
entry(SemanticAttributes.DB_STATEMENT, "SELECT * FROM potato WHERE id=?"),
entry(SemanticAttributes.DB_OPERATION, "SELECT"),
entry(SemanticAttributes.DB_SQL_TABLE, "potato"));
entry(DbIncubatingAttributes.DB_SYSTEM, "myDb"),
entry(DbIncubatingAttributes.DB_USER, "username"),
entry(DbIncubatingAttributes.DB_NAME, "potatoes"),
entry(DbIncubatingAttributes.DB_CONNECTION_STRING, "mydb:///potatoes"),
entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT * FROM potato WHERE id=?"),
entry(DbIncubatingAttributes.DB_OPERATION, "SELECT"),
entry(DbIncubatingAttributes.DB_SQL_TABLE, "potato"));
assertThat(endAttributes.build().isEmpty()).isTrue();
}
@ -103,8 +104,8 @@ class SqlClientAttributesExtractorTest {
// then
assertThat(attributes.build())
.containsOnly(
entry(SemanticAttributes.DB_STATEMENT, "SELECT *"),
entry(SemanticAttributes.DB_OPERATION, "SELECT"));
entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT *"),
entry(DbIncubatingAttributes.DB_OPERATION, "SELECT"));
}
@Test
@ -117,7 +118,7 @@ class SqlClientAttributesExtractorTest {
AttributesExtractor<Map<String, String>, Void> underTest =
SqlClientAttributesExtractor.<Map<String, String>, Void>builder(new TestAttributesGetter())
.setTableAttribute(SemanticAttributes.DB_CASSANDRA_TABLE)
.setTableAttribute(DbIncubatingAttributes.DB_CASSANDRA_TABLE)
.build();
// when
@ -127,9 +128,9 @@ class SqlClientAttributesExtractorTest {
// then
assertThat(attributes.build())
.containsOnly(
entry(SemanticAttributes.DB_STATEMENT, "SELECT * FROM table"),
entry(SemanticAttributes.DB_OPERATION, "SELECT"),
entry(SemanticAttributes.DB_CASSANDRA_TABLE, "table"));
entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT * FROM table"),
entry(DbIncubatingAttributes.DB_OPERATION, "SELECT"),
entry(DbIncubatingAttributes.DB_CASSANDRA_TABLE, "table"));
}
@Test

View File

@ -15,10 +15,14 @@ import io.opentelemetry.api.trace.TraceFlags;
import io.opentelemetry.api.trace.TraceState;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.OperationListener;
import io.opentelemetry.instrumentation.api.semconv.network.internal.NetworkAttributes;
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.ErrorAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import io.opentelemetry.semconv.incubating.HttpIncubatingAttributes;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.Test;
@ -35,22 +39,22 @@ class HttpClientExperimentalMetricsTest {
Attributes requestAttributes =
Attributes.builder()
.put(SemanticAttributes.HTTP_REQUEST_METHOD, "GET")
.put(SemanticAttributes.URL_FULL, "https://localhost:1234/")
.put(SemanticAttributes.URL_PATH, "/")
.put(SemanticAttributes.URL_QUERY, "q=a")
.put(SemanticAttributes.SERVER_ADDRESS, "localhost")
.put(SemanticAttributes.SERVER_PORT, 1234)
.put(HttpAttributes.HTTP_REQUEST_METHOD, "GET")
.put(UrlAttributes.URL_FULL, "https://localhost:1234/")
.put(UrlAttributes.URL_PATH, "/")
.put(UrlAttributes.URL_QUERY, "q=a")
.put(ServerAttributes.SERVER_ADDRESS, "localhost")
.put(ServerAttributes.SERVER_PORT, 1234)
.build();
Attributes responseAttributes =
Attributes.builder()
.put(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200)
.put(SemanticAttributes.ERROR_TYPE, "400")
.put(SemanticAttributes.HTTP_REQUEST_BODY_SIZE, 100)
.put(SemanticAttributes.HTTP_RESPONSE_BODY_SIZE, 200)
.put(SemanticAttributes.NETWORK_PROTOCOL_NAME, "http")
.put(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0")
.put(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200)
.put(ErrorAttributes.ERROR_TYPE, "400")
.put(HttpIncubatingAttributes.HTTP_REQUEST_BODY_SIZE, 100)
.put(HttpIncubatingAttributes.HTTP_RESPONSE_BODY_SIZE, 200)
.put(NetworkAttributes.NETWORK_PROTOCOL_NAME, "http")
.put(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0")
.put(NetworkAttributes.NETWORK_PEER_ADDRESS, "1.2.3.4")
.put(NetworkAttributes.NETWORK_PEER_PORT, 8080)
.build();
@ -89,16 +93,15 @@ class HttpClientExperimentalMetricsTest {
point
.hasSum(100 /* bytes */)
.hasAttributesSatisfying(
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(ErrorAttributes.ERROR_TYPE, "400"),
equalTo(
SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(SemanticAttributes.ERROR_TYPE, "400"),
NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"),
equalTo(
SemanticAttributes.NETWORK_PROTOCOL_NAME, "http"),
equalTo(
SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0"),
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"),
equalTo(SemanticAttributes.SERVER_PORT, 1234))
NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0"),
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
equalTo(ServerAttributes.SERVER_PORT, 1234))
.hasExemplarsSatisfying(
exemplar ->
exemplar
@ -116,16 +119,15 @@ class HttpClientExperimentalMetricsTest {
point
.hasSum(200 /* bytes */)
.hasAttributesSatisfying(
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(ErrorAttributes.ERROR_TYPE, "400"),
equalTo(
SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(SemanticAttributes.ERROR_TYPE, "400"),
NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"),
equalTo(
SemanticAttributes.NETWORK_PROTOCOL_NAME, "http"),
equalTo(
SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0"),
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"),
equalTo(SemanticAttributes.SERVER_PORT, 1234))
NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0"),
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
equalTo(ServerAttributes.SERVER_PORT, 1234))
.hasExemplarsSatisfying(
exemplar ->
exemplar

View File

@ -17,7 +17,7 @@ import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.incubator.semconv.net.PeerServiceResolver;
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesGetter;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.PeerIncubatingAttributes;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
@ -101,6 +101,6 @@ class HttpClientPeerServiceAttributesExtractorTest {
// then
assertThat(startAttributes.build()).isEmpty();
assertThat(endAttributes.build())
.containsOnly(entry(SemanticAttributes.PEER_SERVICE, "myService"));
.containsOnly(entry(PeerIncubatingAttributes.PEER_SERVICE, "myService"));
}
}

View File

@ -17,7 +17,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesGetter;
import io.opentelemetry.instrumentation.api.semconv.http.HttpCommonAttributesGetter;
import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesGetter;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.HttpIncubatingAttributes;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
@ -55,7 +55,7 @@ class HttpExperimentalAttributesExtractorTest {
extractor.onEnd(attributes, Context.root(), "request", "response", null);
assertThat(attributes.build())
.containsOnly(
entry(SemanticAttributes.HTTP_REQUEST_BODY_SIZE, 123L),
entry(SemanticAttributes.HTTP_RESPONSE_BODY_SIZE, 42L));
entry(HttpIncubatingAttributes.HTTP_REQUEST_BODY_SIZE, 123L),
entry(HttpIncubatingAttributes.HTTP_RESPONSE_BODY_SIZE, 42L));
}
}

View File

@ -15,10 +15,14 @@ import io.opentelemetry.api.trace.TraceFlags;
import io.opentelemetry.api.trace.TraceState;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.OperationListener;
import io.opentelemetry.instrumentation.api.semconv.network.internal.NetworkAttributes;
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.ErrorAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import io.opentelemetry.semconv.incubating.HttpIncubatingAttributes;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.Test;
@ -35,24 +39,24 @@ class HttpServerExperimentalMetricsTest {
Attributes requestAttributes =
Attributes.builder()
.put(SemanticAttributes.HTTP_REQUEST_METHOD, "GET")
.put(SemanticAttributes.URL_SCHEME, "https")
.put(SemanticAttributes.URL_PATH, "/")
.put(SemanticAttributes.URL_QUERY, "q=a")
.put(SemanticAttributes.NETWORK_TRANSPORT, "tcp")
.put(SemanticAttributes.NETWORK_TYPE, "ipv4")
.put(SemanticAttributes.NETWORK_PROTOCOL_NAME, "http")
.put(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0")
.put(SemanticAttributes.SERVER_ADDRESS, "localhost")
.put(SemanticAttributes.SERVER_PORT, 1234)
.put(HttpAttributes.HTTP_REQUEST_METHOD, "GET")
.put(UrlAttributes.URL_SCHEME, "https")
.put(UrlAttributes.URL_PATH, "/")
.put(UrlAttributes.URL_QUERY, "q=a")
.put(NetworkAttributes.NETWORK_TRANSPORT, "tcp")
.put(NetworkAttributes.NETWORK_TYPE, "ipv4")
.put(NetworkAttributes.NETWORK_PROTOCOL_NAME, "http")
.put(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0")
.put(ServerAttributes.SERVER_ADDRESS, "localhost")
.put(ServerAttributes.SERVER_PORT, 1234)
.build();
Attributes responseAttributes =
Attributes.builder()
.put(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200)
.put(SemanticAttributes.ERROR_TYPE, "500")
.put(SemanticAttributes.HTTP_REQUEST_BODY_SIZE, 100)
.put(SemanticAttributes.HTTP_RESPONSE_BODY_SIZE, 200)
.put(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200)
.put(ErrorAttributes.ERROR_TYPE, "500")
.put(HttpIncubatingAttributes.HTTP_REQUEST_BODY_SIZE, 100)
.put(HttpIncubatingAttributes.HTTP_RESPONSE_BODY_SIZE, 200)
.put(NetworkAttributes.NETWORK_PEER_ADDRESS, "1.2.3.4")
.put(NetworkAttributes.NETWORK_PEER_PORT, 8080)
.put(NetworkAttributes.NETWORK_LOCAL_ADDRESS, "4.3.2.1")
@ -89,8 +93,8 @@ class HttpServerExperimentalMetricsTest {
point
.hasValue(1)
.hasAttributesSatisfying(
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(SemanticAttributes.URL_SCHEME, "https"))
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(UrlAttributes.URL_SCHEME, "https"))
.hasExemplarsSatisfying(
exemplar ->
exemplar
@ -112,8 +116,8 @@ class HttpServerExperimentalMetricsTest {
point
.hasValue(2)
.hasAttributesSatisfying(
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(SemanticAttributes.URL_SCHEME, "https"))
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(UrlAttributes.URL_SCHEME, "https"))
.hasExemplarsSatisfying(
exemplar ->
exemplar
@ -134,8 +138,8 @@ class HttpServerExperimentalMetricsTest {
point
.hasValue(1)
.hasAttributesSatisfying(
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(SemanticAttributes.URL_SCHEME, "https"))
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(UrlAttributes.URL_SCHEME, "https"))
.hasExemplarsSatisfying(
exemplar ->
exemplar
@ -153,15 +157,14 @@ class HttpServerExperimentalMetricsTest {
point
.hasSum(100 /* bytes */)
.hasAttributesSatisfying(
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(ErrorAttributes.ERROR_TYPE, "500"),
equalTo(
SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(SemanticAttributes.ERROR_TYPE, "500"),
NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"),
equalTo(
SemanticAttributes.NETWORK_PROTOCOL_NAME, "http"),
equalTo(
SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0"),
equalTo(SemanticAttributes.URL_SCHEME, "https"))
NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0"),
equalTo(UrlAttributes.URL_SCHEME, "https"))
.hasExemplarsSatisfying(
exemplar ->
exemplar
@ -179,15 +182,14 @@ class HttpServerExperimentalMetricsTest {
point
.hasSum(200 /* bytes */)
.hasAttributesSatisfying(
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(ErrorAttributes.ERROR_TYPE, "500"),
equalTo(
SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(SemanticAttributes.ERROR_TYPE, "500"),
NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"),
equalTo(
SemanticAttributes.NETWORK_PROTOCOL_NAME, "http"),
equalTo(
SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0"),
equalTo(SemanticAttributes.URL_SCHEME, "https"))
NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0"),
equalTo(UrlAttributes.URL_SCHEME, "https"))
.hasExemplarsSatisfying(
exemplar ->
exemplar

View File

@ -13,7 +13,7 @@ import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@ -70,22 +70,27 @@ class MessagingAttributesExtractorTest {
// then
List<MapEntry<AttributeKey<?>, Object>> expectedEntries = new ArrayList<>();
expectedEntries.add(entry(SemanticAttributes.MESSAGING_SYSTEM, "myQueue"));
expectedEntries.add(entry(SemanticAttributes.MESSAGING_DESTINATION_NAME, expectedDestination));
expectedEntries.add(entry(MessagingIncubatingAttributes.MESSAGING_SYSTEM, "myQueue"));
expectedEntries.add(
entry(MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME, expectedDestination));
if (temporary) {
expectedEntries.add(entry(SemanticAttributes.MESSAGING_DESTINATION_TEMPORARY, true));
expectedEntries.add(
entry(MessagingIncubatingAttributes.MESSAGING_DESTINATION_TEMPORARY, true));
} else {
expectedEntries.add(
entry(SemanticAttributes.MESSAGING_DESTINATION_TEMPLATE, expectedDestination));
entry(MessagingIncubatingAttributes.MESSAGING_DESTINATION_TEMPLATE, expectedDestination));
}
if (anonymous) {
expectedEntries.add(entry(SemanticAttributes.MESSAGING_DESTINATION_ANONYMOUS, true));
expectedEntries.add(
entry(MessagingIncubatingAttributes.MESSAGING_DESTINATION_ANONYMOUS, true));
}
expectedEntries.add(entry(SemanticAttributes.MESSAGING_MESSAGE_CONVERSATION_ID, "42"));
expectedEntries.add(entry(SemanticAttributes.MESSAGING_MESSAGE_BODY_SIZE, 100L));
expectedEntries.add(entry(SemanticAttributes.MESSAGING_MESSAGE_ENVELOPE_SIZE, 120L));
expectedEntries.add(entry(SemanticAttributes.MESSAGING_CLIENT_ID, "43"));
expectedEntries.add(entry(SemanticAttributes.MESSAGING_OPERATION, operation.operationName()));
expectedEntries.add(
entry(MessagingIncubatingAttributes.MESSAGING_MESSAGE_CONVERSATION_ID, "42"));
expectedEntries.add(entry(MessagingIncubatingAttributes.MESSAGING_MESSAGE_BODY_SIZE, 100L));
expectedEntries.add(entry(MessagingIncubatingAttributes.MESSAGING_MESSAGE_ENVELOPE_SIZE, 120L));
expectedEntries.add(entry(MessagingIncubatingAttributes.MESSAGING_CLIENT_ID, "43"));
expectedEntries.add(
entry(MessagingIncubatingAttributes.MESSAGING_OPERATION, operation.operationName()));
@SuppressWarnings({"unchecked", "rawtypes"})
MapEntry<? extends AttributeKey<?>, ?>[] expectedEntriesArr =
@ -94,8 +99,8 @@ class MessagingAttributesExtractorTest {
assertThat(endAttributes.build())
.containsOnly(
entry(SemanticAttributes.MESSAGING_MESSAGE_ID, "42"),
entry(SemanticAttributes.MESSAGING_BATCH_MESSAGE_COUNT, 2L));
entry(MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID, "42"),
entry(MessagingIncubatingAttributes.MESSAGING_BATCH_MESSAGE_COUNT, 2L));
}
static Stream<Arguments> destinations() {

View File

@ -16,7 +16,7 @@ import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.semconv.network.ServerAttributesGetter;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.PeerIncubatingAttributes;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
@ -97,6 +97,6 @@ class PeerServiceAttributesExtractorTest {
// then
assertThat(startAttributes.build()).isEmpty();
assertThat(endAttributes.build())
.containsOnly(entry(SemanticAttributes.PEER_SERVICE, "myService"));
.containsOnly(entry(PeerIncubatingAttributes.PEER_SERVICE, "myService"));
}
}

View File

@ -12,7 +12,7 @@ import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.RpcIncubatingAttributes;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
@ -59,14 +59,14 @@ class RpcAttributesExtractorTest {
extractor.onStart(attributes, context, request);
assertThat(attributes.build())
.containsOnly(
entry(SemanticAttributes.RPC_SYSTEM, "test"),
entry(SemanticAttributes.RPC_SERVICE, "my.Service"),
entry(SemanticAttributes.RPC_METHOD, "Method"));
entry(RpcIncubatingAttributes.RPC_SYSTEM, "test"),
entry(RpcIncubatingAttributes.RPC_SERVICE, "my.Service"),
entry(RpcIncubatingAttributes.RPC_METHOD, "Method"));
extractor.onEnd(attributes, context, request, null, null);
assertThat(attributes.build())
.containsOnly(
entry(SemanticAttributes.RPC_SYSTEM, "test"),
entry(SemanticAttributes.RPC_SERVICE, "my.Service"),
entry(SemanticAttributes.RPC_METHOD, "Method"));
entry(RpcIncubatingAttributes.RPC_SYSTEM, "test"),
entry(RpcIncubatingAttributes.RPC_SERVICE, "my.Service"),
entry(RpcIncubatingAttributes.RPC_METHOD, "Method"));
}
}

View File

@ -17,7 +17,9 @@ import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.OperationListener;
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import io.opentelemetry.semconv.incubating.RpcIncubatingAttributes;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.Test;
@ -33,23 +35,23 @@ class RpcClientMetricsTest {
Attributes requestAttributes =
Attributes.builder()
.put(SemanticAttributes.RPC_SYSTEM, "grpc")
.put(SemanticAttributes.RPC_SERVICE, "myservice.EchoService")
.put(SemanticAttributes.RPC_METHOD, "exampleMethod")
.put(RpcIncubatingAttributes.RPC_SYSTEM, "grpc")
.put(RpcIncubatingAttributes.RPC_SERVICE, "myservice.EchoService")
.put(RpcIncubatingAttributes.RPC_METHOD, "exampleMethod")
.build();
Attributes responseAttributes1 =
Attributes.builder()
.put(SemanticAttributes.SERVER_ADDRESS, "example.com")
.put(SemanticAttributes.SERVER_PORT, 8080)
.put(SemanticAttributes.NETWORK_TRANSPORT, "tcp")
.put(SemanticAttributes.NETWORK_TYPE, "ipv4")
.put(ServerAttributes.SERVER_ADDRESS, "example.com")
.put(ServerAttributes.SERVER_PORT, 8080)
.put(NetworkAttributes.NETWORK_TRANSPORT, "tcp")
.put(NetworkAttributes.NETWORK_TYPE, "ipv4")
.build();
Attributes responseAttributes2 =
Attributes.builder()
.put(SemanticAttributes.SERVER_PORT, 8080)
.put(SemanticAttributes.NETWORK_TRANSPORT, "tcp")
.put(ServerAttributes.SERVER_PORT, 8080)
.put(NetworkAttributes.NETWORK_TRANSPORT, "tcp")
.build();
Context parent =
@ -85,16 +87,17 @@ class RpcClientMetricsTest {
point
.hasSum(150 /* millis */)
.hasAttributesSatisfying(
equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"),
equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "grpc"),
equalTo(
SemanticAttributes.RPC_SERVICE,
RpcIncubatingAttributes.RPC_SERVICE,
"myservice.EchoService"),
equalTo(SemanticAttributes.RPC_METHOD, "exampleMethod"),
equalTo(
SemanticAttributes.SERVER_ADDRESS, "example.com"),
equalTo(SemanticAttributes.SERVER_PORT, 8080),
equalTo(SemanticAttributes.NETWORK_TRANSPORT, "tcp"),
equalTo(SemanticAttributes.NETWORK_TYPE, "ipv4"))
RpcIncubatingAttributes.RPC_METHOD,
"exampleMethod"),
equalTo(ServerAttributes.SERVER_ADDRESS, "example.com"),
equalTo(ServerAttributes.SERVER_PORT, 8080),
equalTo(NetworkAttributes.NETWORK_TRANSPORT, "tcp"),
equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"))
.hasExemplarsSatisfying(
exemplar ->
exemplar
@ -116,14 +119,15 @@ class RpcClientMetricsTest {
point
.hasSum(150 /* millis */)
.hasAttributesSatisfying(
equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"),
equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "grpc"),
equalTo(
SemanticAttributes.RPC_SERVICE,
RpcIncubatingAttributes.RPC_SERVICE,
"myservice.EchoService"),
equalTo(SemanticAttributes.RPC_METHOD, "exampleMethod"),
equalTo(SemanticAttributes.SERVER_PORT, 8080),
equalTo(
SemanticAttributes.NETWORK_TRANSPORT, "tcp")))));
RpcIncubatingAttributes.RPC_METHOD,
"exampleMethod"),
equalTo(ServerAttributes.SERVER_PORT, 8080),
equalTo(NetworkAttributes.NETWORK_TRANSPORT, "tcp")))));
}
private static long nanos(int millis) {

View File

@ -15,10 +15,11 @@ import io.opentelemetry.api.trace.TraceFlags;
import io.opentelemetry.api.trace.TraceState;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.OperationListener;
import io.opentelemetry.instrumentation.api.semconv.network.internal.NetworkAttributes;
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import io.opentelemetry.semconv.incubating.RpcIncubatingAttributes;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.Test;
@ -34,25 +35,25 @@ class RpcServerMetricsTest {
Attributes requestAttributes =
Attributes.builder()
.put(SemanticAttributes.RPC_SYSTEM, "grpc")
.put(SemanticAttributes.RPC_SERVICE, "myservice.EchoService")
.put(SemanticAttributes.RPC_METHOD, "exampleMethod")
.put(RpcIncubatingAttributes.RPC_SYSTEM, "grpc")
.put(RpcIncubatingAttributes.RPC_SERVICE, "myservice.EchoService")
.put(RpcIncubatingAttributes.RPC_METHOD, "exampleMethod")
.build();
Attributes responseAttributes1 =
Attributes.builder()
.put(SemanticAttributes.SERVER_ADDRESS, "example.com")
.put(SemanticAttributes.SERVER_PORT, 8080)
.put(ServerAttributes.SERVER_ADDRESS, "example.com")
.put(ServerAttributes.SERVER_PORT, 8080)
.put(NetworkAttributes.NETWORK_LOCAL_ADDRESS, "127.0.0.1")
.put(SemanticAttributes.NETWORK_TRANSPORT, "tcp")
.put(SemanticAttributes.NETWORK_TYPE, "ipv4")
.put(NetworkAttributes.NETWORK_TRANSPORT, "tcp")
.put(NetworkAttributes.NETWORK_TYPE, "ipv4")
.build();
Attributes responseAttributes2 =
Attributes.builder()
.put(SemanticAttributes.SERVER_PORT, 8080)
.put(ServerAttributes.SERVER_PORT, 8080)
.put(NetworkAttributes.NETWORK_LOCAL_ADDRESS, "127.0.0.1")
.put(SemanticAttributes.NETWORK_TRANSPORT, "tcp")
.put(NetworkAttributes.NETWORK_TRANSPORT, "tcp")
.build();
Context parent =
@ -88,15 +89,16 @@ class RpcServerMetricsTest {
point
.hasSum(150 /* millis */)
.hasAttributesSatisfying(
equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"),
equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "grpc"),
equalTo(
SemanticAttributes.RPC_SERVICE,
RpcIncubatingAttributes.RPC_SERVICE,
"myservice.EchoService"),
equalTo(SemanticAttributes.RPC_METHOD, "exampleMethod"),
equalTo(
SemanticAttributes.SERVER_ADDRESS, "example.com"),
equalTo(SemanticAttributes.NETWORK_TRANSPORT, "tcp"),
equalTo(SemanticAttributes.NETWORK_TYPE, "ipv4"))
RpcIncubatingAttributes.RPC_METHOD,
"exampleMethod"),
equalTo(ServerAttributes.SERVER_ADDRESS, "example.com"),
equalTo(NetworkAttributes.NETWORK_TRANSPORT, "tcp"),
equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"))
.hasExemplarsSatisfying(
exemplar ->
exemplar
@ -118,13 +120,14 @@ class RpcServerMetricsTest {
point
.hasSum(150 /* millis */)
.hasAttributesSatisfying(
equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"),
equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "grpc"),
equalTo(
SemanticAttributes.RPC_SERVICE,
RpcIncubatingAttributes.RPC_SERVICE,
"myservice.EchoService"),
equalTo(SemanticAttributes.RPC_METHOD, "exampleMethod"),
equalTo(
SemanticAttributes.NETWORK_TRANSPORT, "tcp")))));
RpcIncubatingAttributes.RPC_METHOD,
"exampleMethod"),
equalTo(NetworkAttributes.NETWORK_TRANSPORT, "tcp")))));
}
private static long nanos(int millis) {

View File

@ -15,6 +15,7 @@ dependencies {
api("io.opentelemetry:opentelemetry-api")
implementation("io.opentelemetry:opentelemetry-extension-incubator")
implementation("io.opentelemetry.semconv:opentelemetry-semconv")
implementation("io.opentelemetry.semconv:opentelemetry-semconv-incubating")
compileOnly("com.google.auto.value:auto-value-annotations")
annotationProcessor("com.google.auto.value:auto-value")

View File

@ -15,7 +15,8 @@ import io.opentelemetry.instrumentation.api.internal.SpanKey;
import io.opentelemetry.instrumentation.api.internal.SpanKeyProvider;
import io.opentelemetry.instrumentation.api.semconv.network.internal.InternalNetworkAttributesExtractor;
import io.opentelemetry.instrumentation.api.semconv.network.internal.InternalServerAttributesExtractor;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import java.util.function.ToIntFunction;
import javax.annotation.Nullable;
@ -73,11 +74,11 @@ public final class HttpClientAttributesExtractor<REQUEST, RESPONSE>
internalServerExtractor.onStart(attributes, request);
String fullUrl = stripSensitiveData(getter.getUrlFull(request));
internalSet(attributes, SemanticAttributes.URL_FULL, fullUrl);
internalSet(attributes, UrlAttributes.URL_FULL, fullUrl);
int resendCount = resendCountIncrementer.applyAsInt(parentContext);
if (resendCount > 0) {
attributes.put(SemanticAttributes.HTTP_REQUEST_RESEND_COUNT, resendCount);
attributes.put(HttpAttributes.HTTP_REQUEST_RESEND_COUNT, resendCount);
}
}

View File

@ -15,7 +15,9 @@ import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesGetter;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.ErrorAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
@ -58,10 +60,10 @@ abstract class HttpCommonAttributesExtractor<
public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {
String method = getter.getHttpRequestMethod(request);
if (method == null || knownMethods.contains(method)) {
internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD, method);
internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD, method);
} else {
internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD, _OTHER);
internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, method);
internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD, _OTHER);
internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, method);
}
for (String name : capturedRequestHeaders) {
@ -84,7 +86,7 @@ abstract class HttpCommonAttributesExtractor<
if (response != null) {
statusCode = getter.getHttpResponseStatusCode(request, response, error);
if (statusCode != null && statusCode > 0) {
internalSet(attributes, SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, (long) statusCode);
internalSet(attributes, HttpAttributes.HTTP_RESPONSE_STATUS_CODE, (long) statusCode);
}
for (String name : capturedResponseHeaders) {
@ -110,16 +112,16 @@ abstract class HttpCommonAttributesExtractor<
errorType = _OTHER;
}
}
internalSet(attributes, SemanticAttributes.ERROR_TYPE, errorType);
internalSet(attributes, ErrorAttributes.ERROR_TYPE, errorType);
String protocolName = lowercaseStr(getter.getNetworkProtocolName(request, response));
String protocolVersion = lowercaseStr(getter.getNetworkProtocolVersion(request, response));
if (protocolVersion != null) {
if (!"http".equals(protocolName)) {
internalSet(attributes, SemanticAttributes.NETWORK_PROTOCOL_NAME, protocolName);
internalSet(attributes, NetworkAttributes.NETWORK_PROTOCOL_NAME, protocolName);
}
internalSet(attributes, SemanticAttributes.NETWORK_PROTOCOL_VERSION, protocolVersion);
internalSet(attributes, NetworkAttributes.NETWORK_PROTOCOL_VERSION, protocolVersion);
}
}

View File

@ -10,7 +10,11 @@ import static java.util.Collections.unmodifiableList;
import io.opentelemetry.api.metrics.DoubleHistogramBuilder;
import io.opentelemetry.extension.incubator.metrics.ExtendedDoubleHistogramBuilder;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.ErrorAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import java.util.List;
final class HttpMetricsAdvice {
@ -26,13 +30,13 @@ final class HttpMetricsAdvice {
((ExtendedDoubleHistogramBuilder) builder)
.setAttributesAdvice(
asList(
SemanticAttributes.HTTP_REQUEST_METHOD,
SemanticAttributes.HTTP_RESPONSE_STATUS_CODE,
SemanticAttributes.ERROR_TYPE,
SemanticAttributes.NETWORK_PROTOCOL_NAME,
SemanticAttributes.NETWORK_PROTOCOL_VERSION,
SemanticAttributes.SERVER_ADDRESS,
SemanticAttributes.SERVER_PORT));
HttpAttributes.HTTP_REQUEST_METHOD,
HttpAttributes.HTTP_RESPONSE_STATUS_CODE,
ErrorAttributes.ERROR_TYPE,
NetworkAttributes.NETWORK_PROTOCOL_NAME,
NetworkAttributes.NETWORK_PROTOCOL_VERSION,
ServerAttributes.SERVER_ADDRESS,
ServerAttributes.SERVER_PORT));
}
static void applyServerDurationAdvice(DoubleHistogramBuilder builder) {
@ -42,13 +46,13 @@ final class HttpMetricsAdvice {
((ExtendedDoubleHistogramBuilder) builder)
.setAttributesAdvice(
asList(
SemanticAttributes.HTTP_ROUTE,
SemanticAttributes.HTTP_REQUEST_METHOD,
SemanticAttributes.HTTP_RESPONSE_STATUS_CODE,
SemanticAttributes.ERROR_TYPE,
SemanticAttributes.NETWORK_PROTOCOL_NAME,
SemanticAttributes.NETWORK_PROTOCOL_VERSION,
SemanticAttributes.URL_SCHEME));
HttpAttributes.HTTP_ROUTE,
HttpAttributes.HTTP_REQUEST_METHOD,
HttpAttributes.HTTP_RESPONSE_STATUS_CODE,
ErrorAttributes.ERROR_TYPE,
NetworkAttributes.NETWORK_PROTOCOL_NAME,
NetworkAttributes.NETWORK_PROTOCOL_VERSION,
UrlAttributes.URL_SCHEME));
}
private HttpMetricsAdvice() {}

View File

@ -17,7 +17,8 @@ import io.opentelemetry.instrumentation.api.semconv.network.internal.InternalCli
import io.opentelemetry.instrumentation.api.semconv.network.internal.InternalNetworkAttributesExtractor;
import io.opentelemetry.instrumentation.api.semconv.network.internal.InternalServerAttributesExtractor;
import io.opentelemetry.instrumentation.api.semconv.url.internal.InternalUrlAttributesExtractor;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.UserAgentAttributes;
import java.util.function.Function;
import javax.annotation.Nullable;
@ -80,8 +81,8 @@ public final class HttpServerAttributesExtractor<REQUEST, RESPONSE>
internalServerExtractor.onStart(attributes, request);
internalClientExtractor.onStart(attributes, request);
internalSet(attributes, SemanticAttributes.HTTP_ROUTE, getter.getHttpRoute(request));
internalSet(attributes, SemanticAttributes.USER_AGENT_ORIGINAL, userAgent(request));
internalSet(attributes, HttpAttributes.HTTP_ROUTE, getter.getHttpRoute(request));
internalSet(attributes, UserAgentAttributes.USER_AGENT_ORIGINAL, userAgent(request));
}
@Override
@ -96,7 +97,7 @@ public final class HttpServerAttributesExtractor<REQUEST, RESPONSE>
internalNetworkExtractor.onEnd(attributes, request, response);
internalSet(attributes, SemanticAttributes.HTTP_ROUTE, httpRouteGetter.apply(context));
internalSet(attributes, HttpAttributes.HTTP_ROUTE, httpRouteGetter.apply(context));
}
/**

View File

@ -8,7 +8,7 @@ package io.opentelemetry.instrumentation.api.semconv.network.internal;
import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.ClientAttributes;
/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
@ -29,9 +29,9 @@ public final class InternalClientAttributesExtractor<REQUEST> {
AddressAndPort clientAddressAndPort = addressAndPortExtractor.extract(request);
if (clientAddressAndPort.address != null) {
internalSet(attributes, SemanticAttributes.CLIENT_ADDRESS, clientAddressAndPort.address);
internalSet(attributes, ClientAttributes.CLIENT_ADDRESS, clientAddressAndPort.address);
if (capturePort && clientAddressAndPort.port != null && clientAddressAndPort.port > 0) {
internalSet(attributes, SemanticAttributes.CLIENT_PORT, (long) clientAddressAndPort.port);
internalSet(attributes, ClientAttributes.CLIENT_PORT, (long) clientAddressAndPort.port);
}
}
}

View File

@ -9,7 +9,7 @@ import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorU
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesGetter;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import java.util.Locale;
import javax.annotation.Nullable;
@ -38,13 +38,13 @@ public final class InternalNetworkAttributesExtractor<REQUEST, RESPONSE> {
if (captureProtocolAttributes) {
String transport = lowercase(getter.getNetworkTransport(request, response));
internalSet(attributes, SemanticAttributes.NETWORK_TRANSPORT, transport);
internalSet(attributes, NetworkAttributes.NETWORK_TRANSPORT, transport);
internalSet(
attributes,
SemanticAttributes.NETWORK_TYPE,
NetworkAttributes.NETWORK_TYPE,
lowercase(getter.getNetworkType(request, response)));
internalSet(attributes, SemanticAttributes.NETWORK_PROTOCOL_NAME, protocolName);
internalSet(attributes, SemanticAttributes.NETWORK_PROTOCOL_VERSION, protocolVersion);
internalSet(attributes, NetworkAttributes.NETWORK_PROTOCOL_NAME, protocolName);
internalSet(attributes, NetworkAttributes.NETWORK_PROTOCOL_VERSION, protocolVersion);
}
if (captureLocalSocketAttributes) {

View File

@ -8,7 +8,7 @@ package io.opentelemetry.instrumentation.api.semconv.network.internal;
import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.ServerAttributes;
/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
@ -27,10 +27,10 @@ public final class InternalServerAttributesExtractor<REQUEST> {
AddressAndPort serverAddressAndPort = addressAndPortExtractor.extract(request);
if (serverAddressAndPort.address != null) {
internalSet(attributes, SemanticAttributes.SERVER_ADDRESS, serverAddressAndPort.address);
internalSet(attributes, ServerAttributes.SERVER_ADDRESS, serverAddressAndPort.address);
if (serverAddressAndPort.port != null && serverAddressAndPort.port > 0) {
internalSet(attributes, SemanticAttributes.SERVER_PORT, (long) serverAddressAndPort.port);
internalSet(attributes, ServerAttributes.SERVER_PORT, (long) serverAddressAndPort.port);
}
}
}

View File

@ -1,29 +0,0 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.instrumentation.api.semconv.network.internal;
import static io.opentelemetry.api.common.AttributeKey.longKey;
import static io.opentelemetry.api.common.AttributeKey.stringKey;
import io.opentelemetry.api.common.AttributeKey;
/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
* any time.
*/
public final class NetworkAttributes {
public static final AttributeKey<String> NETWORK_LOCAL_ADDRESS =
stringKey("network.local.address");
public static final AttributeKey<Long> NETWORK_LOCAL_PORT = longKey("network.local.port");
public static final AttributeKey<String> NETWORK_PEER_ADDRESS = stringKey("network.peer.address");
public static final AttributeKey<Long> NETWORK_PEER_PORT = longKey("network.peer.port");
private NetworkAttributes() {}
}

View File

@ -9,7 +9,7 @@ import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorU
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.instrumentation.api.semconv.url.UrlAttributesGetter;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import java.util.function.Function;
/**
@ -32,9 +32,9 @@ public final class InternalUrlAttributesExtractor<REQUEST> {
String urlPath = getter.getUrlPath(request);
String urlQuery = getter.getUrlQuery(request);
internalSet(attributes, SemanticAttributes.URL_SCHEME, urlScheme);
internalSet(attributes, SemanticAttributes.URL_PATH, urlPath);
internalSet(attributes, SemanticAttributes.URL_QUERY, urlQuery);
internalSet(attributes, UrlAttributes.URL_SCHEME, urlScheme);
internalSet(attributes, UrlAttributes.URL_PATH, urlPath);
internalSet(attributes, UrlAttributes.URL_QUERY, urlQuery);
}
private String getUrlScheme(REQUEST request) {

View File

@ -18,8 +18,11 @@ import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.internal.HttpConstants;
import io.opentelemetry.instrumentation.api.semconv.network.internal.NetworkAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.ErrorAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import java.net.ConnectException;
import java.util.HashMap;
import java.util.HashSet;
@ -168,24 +171,24 @@ class HttpClientAttributesExtractorTest {
extractor.onStart(startAttributes, Context.root(), request);
assertThat(startAttributes.build())
.containsOnly(
entry(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
entry(SemanticAttributes.URL_FULL, "http://github.com"),
entry(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
entry(UrlAttributes.URL_FULL, "http://github.com"),
entry(
AttributeKey.stringArrayKey("http.request.header.custom-request-header"),
asList("123", "456")),
entry(SemanticAttributes.SERVER_ADDRESS, "github.com"),
entry(SemanticAttributes.SERVER_PORT, 80L),
entry(SemanticAttributes.HTTP_REQUEST_RESEND_COUNT, 2L));
entry(ServerAttributes.SERVER_ADDRESS, "github.com"),
entry(ServerAttributes.SERVER_PORT, 80L),
entry(HttpAttributes.HTTP_REQUEST_RESEND_COUNT, 2L));
AttributesBuilder endAttributes = Attributes.builder();
extractor.onEnd(endAttributes, Context.root(), request, response, null);
assertThat(endAttributes.build())
.containsOnly(
entry(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 202L),
entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 202L),
entry(
AttributeKey.stringArrayKey("http.response.header.custom-response-header"),
asList("654", "321")),
entry(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1"),
entry(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"),
entry(NetworkAttributes.NETWORK_PEER_ADDRESS, "4.3.2.1"),
entry(NetworkAttributes.NETWORK_PEER_PORT, 456L));
}
@ -204,8 +207,8 @@ class HttpClientAttributesExtractorTest {
extractor.onEnd(attributes, Context.root(), request, emptyMap(), null);
assertThat(attributes.build())
.containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD, requestMethod)
.doesNotContainKey(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL);
.containsEntry(HttpAttributes.HTTP_REQUEST_METHOD, requestMethod)
.doesNotContainKey(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL);
}
@ParameterizedTest
@ -222,8 +225,8 @@ class HttpClientAttributesExtractorTest {
extractor.onEnd(attributes, Context.root(), request, emptyMap(), null);
assertThat(attributes.build())
.containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER)
.containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod);
.containsEntry(HttpAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER)
.containsEntry(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod);
}
@ParameterizedTest
@ -240,8 +243,8 @@ class HttpClientAttributesExtractorTest {
extractor.onEnd(attributes, Context.root(), request, emptyMap(), null);
assertThat(attributes.build())
.containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER)
.containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod);
.containsEntry(HttpAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER)
.containsEntry(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod);
}
@ParameterizedTest
@ -260,8 +263,8 @@ class HttpClientAttributesExtractorTest {
extractor.onEnd(attributes, Context.root(), request, emptyMap(), null);
assertThat(attributes.build())
.containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD, requestMethod)
.doesNotContainKey(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL);
.containsEntry(HttpAttributes.HTTP_REQUEST_METHOD, requestMethod)
.doesNotContainKey(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL);
}
@ParameterizedTest
@ -280,8 +283,8 @@ class HttpClientAttributesExtractorTest {
extractor.onEnd(attributes, Context.root(), request, emptyMap(), null);
assertThat(attributes.build())
.containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER)
.containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod);
.containsEntry(HttpAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER)
.containsEntry(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod);
}
@Test
@ -297,8 +300,8 @@ class HttpClientAttributesExtractorTest {
extractor.onEnd(attributes, Context.root(), emptyMap(), response, null);
assertThat(attributes.build())
.containsEntry(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 400)
.containsEntry(SemanticAttributes.ERROR_TYPE, "400");
.containsEntry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 400)
.containsEntry(ErrorAttributes.ERROR_TYPE, "400");
}
@Test
@ -314,8 +317,7 @@ class HttpClientAttributesExtractorTest {
extractor.onStart(attributes, Context.root(), emptyMap());
extractor.onEnd(attributes, Context.root(), request, emptyMap(), null);
assertThat(attributes.build())
.containsEntry(SemanticAttributes.ERROR_TYPE, "custom error type");
assertThat(attributes.build()).containsEntry(ErrorAttributes.ERROR_TYPE, "custom error type");
}
@Test
@ -328,7 +330,7 @@ class HttpClientAttributesExtractorTest {
extractor.onEnd(attributes, Context.root(), emptyMap(), emptyMap(), new ConnectException());
assertThat(attributes.build())
.containsEntry(SemanticAttributes.ERROR_TYPE, "java.net.ConnectException");
.containsEntry(ErrorAttributes.ERROR_TYPE, "java.net.ConnectException");
}
@Test
@ -340,8 +342,7 @@ class HttpClientAttributesExtractorTest {
extractor.onStart(attributes, Context.root(), emptyMap());
extractor.onEnd(attributes, Context.root(), emptyMap(), emptyMap(), null);
assertThat(attributes.build())
.containsEntry(SemanticAttributes.ERROR_TYPE, HttpConstants._OTHER);
assertThat(attributes.build()).containsEntry(ErrorAttributes.ERROR_TYPE, HttpConstants._OTHER);
}
@Test
@ -359,13 +360,13 @@ class HttpClientAttributesExtractorTest {
extractor.onStart(startAttributes, Context.root(), request);
assertThat(startAttributes.build())
.containsOnly(
entry(SemanticAttributes.SERVER_ADDRESS, "github.com"),
entry(SemanticAttributes.SERVER_PORT, 123L));
entry(ServerAttributes.SERVER_ADDRESS, "github.com"),
entry(ServerAttributes.SERVER_PORT, 123L));
AttributesBuilder endAttributes = Attributes.builder();
extractor.onEnd(endAttributes, Context.root(), request, response, null);
assertThat(endAttributes.build())
.containsOnly(entry(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200L));
.containsOnly(entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L));
}
@Test
@ -386,14 +387,14 @@ class HttpClientAttributesExtractorTest {
extractor.onStart(startAttributes, Context.root(), request);
assertThat(startAttributes.build())
.containsOnly(
entry(SemanticAttributes.SERVER_ADDRESS, "1.2.3.4"),
entry(SemanticAttributes.SERVER_PORT, 123L));
entry(ServerAttributes.SERVER_ADDRESS, "1.2.3.4"),
entry(ServerAttributes.SERVER_PORT, 123L));
AttributesBuilder endAttributes = Attributes.builder();
extractor.onEnd(endAttributes, Context.root(), request, response, null);
assertThat(endAttributes.build())
.containsOnly(
entry(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200L),
entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L),
entry(NetworkAttributes.NETWORK_PEER_ADDRESS, "1.2.3.4"),
entry(NetworkAttributes.NETWORK_PEER_PORT, 456L));
}
@ -418,8 +419,8 @@ class HttpClientAttributesExtractorTest {
extractor.onEnd(endAttributes, Context.root(), request, response, null);
assertThat(endAttributes.build())
.containsOnly(
entry(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200L),
entry(SemanticAttributes.NETWORK_PROTOCOL_NAME, "spdy"),
entry(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "3.1"));
entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L),
entry(NetworkAttributes.NETWORK_PROTOCOL_NAME, "spdy"),
entry(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "3.1"));
}
}

View File

@ -15,10 +15,14 @@ import io.opentelemetry.api.trace.TraceFlags;
import io.opentelemetry.api.trace.TraceState;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.OperationListener;
import io.opentelemetry.instrumentation.api.semconv.network.internal.NetworkAttributes;
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.ErrorAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import io.opentelemetry.semconv.incubating.HttpIncubatingAttributes;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.Test;
@ -37,22 +41,22 @@ class HttpClientMetricsTest {
Attributes requestAttributes =
Attributes.builder()
.put(SemanticAttributes.HTTP_REQUEST_METHOD, "GET")
.put(SemanticAttributes.URL_FULL, "https://localhost:1234/")
.put(SemanticAttributes.URL_PATH, "/")
.put(SemanticAttributes.URL_QUERY, "q=a")
.put(SemanticAttributes.SERVER_ADDRESS, "localhost")
.put(SemanticAttributes.SERVER_PORT, 1234)
.put(HttpAttributes.HTTP_REQUEST_METHOD, "GET")
.put(UrlAttributes.URL_FULL, "https://localhost:1234/")
.put(UrlAttributes.URL_PATH, "/")
.put(UrlAttributes.URL_QUERY, "q=a")
.put(ServerAttributes.SERVER_ADDRESS, "localhost")
.put(ServerAttributes.SERVER_PORT, 1234)
.build();
Attributes responseAttributes =
Attributes.builder()
.put(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200)
.put(SemanticAttributes.ERROR_TYPE, "400")
.put(SemanticAttributes.HTTP_REQUEST_BODY_SIZE, 100)
.put(SemanticAttributes.HTTP_RESPONSE_BODY_SIZE, 200)
.put(SemanticAttributes.NETWORK_PROTOCOL_NAME, "http")
.put(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0")
.put(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200)
.put(ErrorAttributes.ERROR_TYPE, "400")
.put(HttpIncubatingAttributes.HTTP_REQUEST_BODY_SIZE, 100)
.put(HttpIncubatingAttributes.HTTP_RESPONSE_BODY_SIZE, 200)
.put(NetworkAttributes.NETWORK_PROTOCOL_NAME, "http")
.put(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0")
.put(NetworkAttributes.NETWORK_PEER_ADDRESS, "1.2.3.4")
.put(NetworkAttributes.NETWORK_PEER_PORT, 8080)
.build();
@ -91,16 +95,15 @@ class HttpClientMetricsTest {
point
.hasSum(0.15 /* seconds */)
.hasAttributesSatisfying(
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(ErrorAttributes.ERROR_TYPE, "400"),
equalTo(
SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(SemanticAttributes.ERROR_TYPE, "400"),
NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"),
equalTo(
SemanticAttributes.NETWORK_PROTOCOL_NAME, "http"),
equalTo(
SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0"),
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"),
equalTo(SemanticAttributes.SERVER_PORT, 1234))
NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0"),
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
equalTo(ServerAttributes.SERVER_PORT, 1234))
.hasExemplarsSatisfying(
exemplar ->
exemplar

View File

@ -18,8 +18,13 @@ import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.internal.HttpConstants;
import io.opentelemetry.instrumentation.api.semconv.network.internal.NetworkAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.ClientAttributes;
import io.opentelemetry.semconv.ErrorAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import io.opentelemetry.semconv.UserAgentAttributes;
import java.net.ConnectException;
import java.util.HashMap;
import java.util.HashSet;
@ -193,15 +198,15 @@ class HttpServerAttributesExtractorTest {
extractor.onStart(startAttributes, Context.root(), request);
assertThat(startAttributes.build())
.containsOnly(
entry(SemanticAttributes.SERVER_ADDRESS, "github.com"),
entry(SemanticAttributes.SERVER_PORT, 443L),
entry(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
entry(SemanticAttributes.URL_SCHEME, "https"),
entry(SemanticAttributes.URL_PATH, "/repositories/1"),
entry(SemanticAttributes.URL_QUERY, "details=true"),
entry(SemanticAttributes.USER_AGENT_ORIGINAL, "okhttp 3.x"),
entry(SemanticAttributes.HTTP_ROUTE, "/repositories/{id}"),
entry(SemanticAttributes.CLIENT_ADDRESS, "1.1.1.1"),
entry(ServerAttributes.SERVER_ADDRESS, "github.com"),
entry(ServerAttributes.SERVER_PORT, 443L),
entry(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
entry(UrlAttributes.URL_SCHEME, "https"),
entry(UrlAttributes.URL_PATH, "/repositories/1"),
entry(UrlAttributes.URL_QUERY, "details=true"),
entry(UserAgentAttributes.USER_AGENT_ORIGINAL, "okhttp 3.x"),
entry(HttpAttributes.HTTP_ROUTE, "/repositories/{id}"),
entry(ClientAttributes.CLIENT_ADDRESS, "1.1.1.1"),
entry(
AttributeKey.stringArrayKey("http.request.header.custom-request-header"),
asList("123", "456")));
@ -210,11 +215,11 @@ class HttpServerAttributesExtractorTest {
extractor.onEnd(endAttributes, Context.root(), request, response, null);
assertThat(endAttributes.build())
.containsOnly(
entry(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0"),
entry(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0"),
entry(NetworkAttributes.NETWORK_PEER_ADDRESS, "4.3.2.1"),
entry(NetworkAttributes.NETWORK_PEER_PORT, 456L),
entry(SemanticAttributes.HTTP_ROUTE, "/repositories/{repoId}"),
entry(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 202L),
entry(HttpAttributes.HTTP_ROUTE, "/repositories/{repoId}"),
entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 202L),
entry(
AttributeKey.stringArrayKey("http.response.header.custom-response-header"),
asList("654", "321")));
@ -234,8 +239,8 @@ class HttpServerAttributesExtractorTest {
extractor.onEnd(attributes, Context.root(), request, emptyMap(), null);
assertThat(attributes.build())
.containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD, requestMethod)
.doesNotContainKey(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL);
.containsEntry(HttpAttributes.HTTP_REQUEST_METHOD, requestMethod)
.doesNotContainKey(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL);
}
@ParameterizedTest
@ -252,8 +257,8 @@ class HttpServerAttributesExtractorTest {
extractor.onEnd(attributes, Context.root(), request, emptyMap(), null);
assertThat(attributes.build())
.containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER)
.containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod);
.containsEntry(HttpAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER)
.containsEntry(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod);
}
@ParameterizedTest
@ -270,8 +275,8 @@ class HttpServerAttributesExtractorTest {
extractor.onEnd(attributes, Context.root(), request, emptyMap(), null);
assertThat(attributes.build())
.containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER)
.containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod);
.containsEntry(HttpAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER)
.containsEntry(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod);
}
@ParameterizedTest
@ -290,8 +295,8 @@ class HttpServerAttributesExtractorTest {
extractor.onEnd(attributes, Context.root(), request, emptyMap(), null);
assertThat(attributes.build())
.containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD, requestMethod)
.doesNotContainKey(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL);
.containsEntry(HttpAttributes.HTTP_REQUEST_METHOD, requestMethod)
.doesNotContainKey(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL);
}
@ParameterizedTest
@ -310,8 +315,8 @@ class HttpServerAttributesExtractorTest {
extractor.onEnd(attributes, Context.root(), request, emptyMap(), null);
assertThat(attributes.build())
.containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER)
.containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod);
.containsEntry(HttpAttributes.HTTP_REQUEST_METHOD, HttpConstants._OTHER)
.containsEntry(HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, requestMethod);
}
@Test
@ -327,8 +332,8 @@ class HttpServerAttributesExtractorTest {
extractor.onEnd(attributes, Context.root(), emptyMap(), response, null);
assertThat(attributes.build())
.containsEntry(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 500)
.containsEntry(SemanticAttributes.ERROR_TYPE, "500");
.containsEntry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 500)
.containsEntry(ErrorAttributes.ERROR_TYPE, "500");
}
@Test
@ -344,8 +349,7 @@ class HttpServerAttributesExtractorTest {
extractor.onStart(attributes, Context.root(), emptyMap());
extractor.onEnd(attributes, Context.root(), request, emptyMap(), null);
assertThat(attributes.build())
.containsEntry(SemanticAttributes.ERROR_TYPE, "custom error type");
assertThat(attributes.build()).containsEntry(ErrorAttributes.ERROR_TYPE, "custom error type");
}
@Test
@ -358,7 +362,7 @@ class HttpServerAttributesExtractorTest {
extractor.onEnd(attributes, Context.root(), emptyMap(), emptyMap(), new ConnectException());
assertThat(attributes.build())
.containsEntry(SemanticAttributes.ERROR_TYPE, "java.net.ConnectException");
.containsEntry(ErrorAttributes.ERROR_TYPE, "java.net.ConnectException");
}
@Test
@ -370,8 +374,7 @@ class HttpServerAttributesExtractorTest {
extractor.onStart(attributes, Context.root(), emptyMap());
extractor.onEnd(attributes, Context.root(), emptyMap(), emptyMap(), null);
assertThat(attributes.build())
.containsEntry(SemanticAttributes.ERROR_TYPE, HttpConstants._OTHER);
assertThat(attributes.build()).containsEntry(ErrorAttributes.ERROR_TYPE, HttpConstants._OTHER);
}
@Test
@ -388,12 +391,12 @@ class HttpServerAttributesExtractorTest {
AttributesBuilder startAttributes = Attributes.builder();
extractor.onStart(startAttributes, Context.root(), request);
assertThat(startAttributes.build()).containsOnly(entry(SemanticAttributes.URL_SCHEME, "https"));
assertThat(startAttributes.build()).containsOnly(entry(UrlAttributes.URL_SCHEME, "https"));
AttributesBuilder endAttributes = Attributes.builder();
extractor.onEnd(endAttributes, Context.root(), request, response, null);
assertThat(endAttributes.build())
.containsOnly(entry(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 202L));
.containsOnly(entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 202L));
}
@Test
@ -415,13 +418,13 @@ class HttpServerAttributesExtractorTest {
assertThat(startAttributes.build())
.containsOnly(
entry(SemanticAttributes.SERVER_ADDRESS, "example.com"),
entry(SemanticAttributes.SERVER_PORT, 42L));
entry(ServerAttributes.SERVER_ADDRESS, "example.com"),
entry(ServerAttributes.SERVER_PORT, 42L));
AttributesBuilder endAttributes = Attributes.builder();
extractor.onEnd(endAttributes, Context.root(), request, response, null);
assertThat(endAttributes.build())
.containsOnly(entry(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200L));
.containsOnly(entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L));
}
@Test
@ -442,13 +445,13 @@ class HttpServerAttributesExtractorTest {
assertThat(startAttributes.build())
.containsOnly(
entry(SemanticAttributes.SERVER_ADDRESS, "opentelemetry.io"),
entry(SemanticAttributes.SERVER_PORT, 987L));
entry(ServerAttributes.SERVER_ADDRESS, "opentelemetry.io"),
entry(ServerAttributes.SERVER_PORT, 987L));
AttributesBuilder endAttributes = Attributes.builder();
extractor.onEnd(endAttributes, Context.root(), request, response, null);
assertThat(endAttributes.build())
.containsOnly(entry(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200L));
.containsOnly(entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L));
}
@Test
@ -468,13 +471,13 @@ class HttpServerAttributesExtractorTest {
assertThat(startAttributes.build())
.containsOnly(
entry(SemanticAttributes.SERVER_ADDRESS, "opentelemetry.io"),
entry(SemanticAttributes.SERVER_PORT, 42L));
entry(ServerAttributes.SERVER_ADDRESS, "opentelemetry.io"),
entry(ServerAttributes.SERVER_PORT, 42L));
AttributesBuilder endAttributes = Attributes.builder();
extractor.onEnd(endAttributes, Context.root(), request, response, null);
assertThat(endAttributes.build())
.containsOnly(entry(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200L));
.containsOnly(entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L));
}
@Test
@ -493,13 +496,13 @@ class HttpServerAttributesExtractorTest {
assertThat(startAttributes.build())
.containsOnly(
entry(SemanticAttributes.SERVER_ADDRESS, "github.com"),
entry(SemanticAttributes.SERVER_PORT, 123L));
entry(ServerAttributes.SERVER_ADDRESS, "github.com"),
entry(ServerAttributes.SERVER_PORT, 123L));
AttributesBuilder endAttributes = Attributes.builder();
extractor.onEnd(endAttributes, Context.root(), request, response, null);
assertThat(endAttributes.build())
.containsOnly(entry(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200L));
.containsOnly(entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L));
}
@Test
@ -518,13 +521,13 @@ class HttpServerAttributesExtractorTest {
AttributesBuilder startAttributes = Attributes.builder();
extractor.onStart(startAttributes, Context.root(), request);
assertThat(startAttributes.build())
.containsOnly(entry(SemanticAttributes.CLIENT_ADDRESS, "1.2.3.4"));
.containsOnly(entry(ClientAttributes.CLIENT_ADDRESS, "1.2.3.4"));
AttributesBuilder endAttributes = Attributes.builder();
extractor.onEnd(endAttributes, Context.root(), request, response, null);
assertThat(endAttributes.build())
.containsOnly(
entry(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200L),
entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L),
entry(NetworkAttributes.NETWORK_PEER_ADDRESS, "1.2.3.4"),
entry(NetworkAttributes.NETWORK_PEER_PORT, 456L));
}
@ -549,8 +552,8 @@ class HttpServerAttributesExtractorTest {
extractor.onEnd(endAttributes, Context.root(), request, response, null);
assertThat(endAttributes.build())
.containsOnly(
entry(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200L),
entry(SemanticAttributes.NETWORK_PROTOCOL_NAME, "spdy"),
entry(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "3.1"));
entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L),
entry(NetworkAttributes.NETWORK_PROTOCOL_NAME, "spdy"),
entry(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "3.1"));
}
}

View File

@ -15,10 +15,14 @@ import io.opentelemetry.api.trace.TraceFlags;
import io.opentelemetry.api.trace.TraceState;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.OperationListener;
import io.opentelemetry.instrumentation.api.semconv.network.internal.NetworkAttributes;
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.ErrorAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import io.opentelemetry.semconv.incubating.HttpIncubatingAttributes;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.Test;
@ -37,24 +41,24 @@ class HttpServerMetricsTest {
Attributes requestAttributes =
Attributes.builder()
.put(SemanticAttributes.HTTP_REQUEST_METHOD, "GET")
.put(SemanticAttributes.URL_SCHEME, "https")
.put(SemanticAttributes.URL_PATH, "/")
.put(SemanticAttributes.URL_QUERY, "q=a")
.put(SemanticAttributes.NETWORK_TRANSPORT, "tcp")
.put(SemanticAttributes.NETWORK_TYPE, "ipv4")
.put(SemanticAttributes.NETWORK_PROTOCOL_NAME, "http")
.put(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0")
.put(SemanticAttributes.SERVER_ADDRESS, "localhost")
.put(SemanticAttributes.SERVER_PORT, 1234)
.put(HttpAttributes.HTTP_REQUEST_METHOD, "GET")
.put(UrlAttributes.URL_SCHEME, "https")
.put(UrlAttributes.URL_PATH, "/")
.put(UrlAttributes.URL_QUERY, "q=a")
.put(NetworkAttributes.NETWORK_TRANSPORT, "tcp")
.put(NetworkAttributes.NETWORK_TYPE, "ipv4")
.put(NetworkAttributes.NETWORK_PROTOCOL_NAME, "http")
.put(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0")
.put(ServerAttributes.SERVER_ADDRESS, "localhost")
.put(ServerAttributes.SERVER_PORT, 1234)
.build();
Attributes responseAttributes =
Attributes.builder()
.put(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200)
.put(SemanticAttributes.ERROR_TYPE, "500")
.put(SemanticAttributes.HTTP_REQUEST_BODY_SIZE, 100)
.put(SemanticAttributes.HTTP_RESPONSE_BODY_SIZE, 200)
.put(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200)
.put(ErrorAttributes.ERROR_TYPE, "500")
.put(HttpIncubatingAttributes.HTTP_REQUEST_BODY_SIZE, 100)
.put(HttpIncubatingAttributes.HTTP_RESPONSE_BODY_SIZE, 200)
.put(NetworkAttributes.NETWORK_PEER_ADDRESS, "1.2.3.4")
.put(NetworkAttributes.NETWORK_PEER_PORT, 8080)
.put(NetworkAttributes.NETWORK_LOCAL_ADDRESS, "4.3.2.1")
@ -96,15 +100,14 @@ class HttpServerMetricsTest {
point
.hasSum(0.15 /* seconds */)
.hasAttributesSatisfying(
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(ErrorAttributes.ERROR_TYPE, "500"),
equalTo(
SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(SemanticAttributes.ERROR_TYPE, "500"),
NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"),
equalTo(
SemanticAttributes.NETWORK_PROTOCOL_NAME, "http"),
equalTo(
SemanticAttributes.NETWORK_PROTOCOL_VERSION, "2.0"),
equalTo(SemanticAttributes.URL_SCHEME, "https"))
NetworkAttributes.NETWORK_PROTOCOL_VERSION, "2.0"),
equalTo(UrlAttributes.URL_SCHEME, "https"))
.hasExemplarsSatisfying(
exemplar ->
exemplar
@ -143,12 +146,12 @@ class HttpServerMetricsTest {
Attributes requestAttributes =
Attributes.builder()
.put(SemanticAttributes.SERVER_ADDRESS, "host")
.put(SemanticAttributes.URL_SCHEME, "https")
.put(ServerAttributes.SERVER_ADDRESS, "host")
.put(UrlAttributes.URL_SCHEME, "https")
.build();
Attributes responseAttributes =
Attributes.builder().put(SemanticAttributes.HTTP_ROUTE, "/test/{id}").build();
Attributes.builder().put(HttpAttributes.HTTP_ROUTE, "/test/{id}").build();
Context parentContext = Context.root();
@ -170,9 +173,8 @@ class HttpServerMetricsTest {
point
.hasSum(0.100 /* seconds */)
.hasAttributesSatisfying(
equalTo(SemanticAttributes.URL_SCHEME, "https"),
equalTo(
SemanticAttributes.HTTP_ROUTE, "/test/{id}")))));
equalTo(UrlAttributes.URL_SCHEME, "https"),
equalTo(HttpAttributes.HTTP_ROUTE, "/test/{id}")))));
}
private static long nanos(int millis) {

View File

@ -13,7 +13,7 @@ import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.ClientAttributes;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
@ -50,8 +50,8 @@ class ClientAttributesExtractorTest {
extractor.onStart(startAttributes, Context.root(), request);
assertThat(startAttributes.build())
.containsOnly(
entry(SemanticAttributes.CLIENT_ADDRESS, "opentelemetry.io"),
entry(SemanticAttributes.CLIENT_PORT, 80L));
entry(ClientAttributes.CLIENT_ADDRESS, "opentelemetry.io"),
entry(ClientAttributes.CLIENT_PORT, 80L));
AttributesBuilder endAttributes = Attributes.builder();
extractor.onEnd(endAttributes, Context.root(), request, null, null);

View File

@ -12,8 +12,7 @@ import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.semconv.network.internal.NetworkAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import java.net.InetSocketAddress;
import javax.annotation.Nullable;
import org.junit.jupiter.api.Test;
@ -54,7 +53,7 @@ class NetworkAttributesExtractorInetSocketAddressTest {
extractor.onEnd(endAttributes, Context.root(), local, peer, null);
assertThat(endAttributes.build())
.containsOnly(
entry(SemanticAttributes.NETWORK_TYPE, "ipv4"),
entry(NetworkAttributes.NETWORK_TYPE, "ipv4"),
entry(NetworkAttributes.NETWORK_LOCAL_ADDRESS, "1.2.3.4"),
entry(NetworkAttributes.NETWORK_LOCAL_PORT, 8080L),
entry(NetworkAttributes.NETWORK_PEER_ADDRESS, "4.3.2.1"),

View File

@ -13,8 +13,7 @@ import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.semconv.network.internal.NetworkAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
@ -99,10 +98,10 @@ class NetworkAttributesExtractorTest {
extractor.onEnd(endAttributes, Context.root(), request, null, null);
assertThat(endAttributes.build())
.containsOnly(
entry(SemanticAttributes.NETWORK_TRANSPORT, "tcp"),
entry(SemanticAttributes.NETWORK_TYPE, "ipv4"),
entry(SemanticAttributes.NETWORK_PROTOCOL_NAME, "http"),
entry(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1"),
entry(NetworkAttributes.NETWORK_TRANSPORT, "tcp"),
entry(NetworkAttributes.NETWORK_TYPE, "ipv4"),
entry(NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"),
entry(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"),
entry(NetworkAttributes.NETWORK_LOCAL_ADDRESS, "1.2.3.4"),
entry(NetworkAttributes.NETWORK_LOCAL_PORT, 8080L),
entry(NetworkAttributes.NETWORK_PEER_ADDRESS, "4.3.2.1"),

View File

@ -13,7 +13,7 @@ import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
@ -50,8 +50,8 @@ class ServerAttributesExtractorTest {
extractor.onStart(startAttributes, Context.root(), request);
assertThat(startAttributes.build())
.containsOnly(
entry(SemanticAttributes.SERVER_ADDRESS, "opentelemetry.io"),
entry(SemanticAttributes.SERVER_PORT, 80L));
entry(ServerAttributes.SERVER_ADDRESS, "opentelemetry.io"),
entry(ServerAttributes.SERVER_PORT, 80L));
AttributesBuilder endAttributes = Attributes.builder();
extractor.onEnd(endAttributes, Context.root(), request, null, null);
@ -84,7 +84,7 @@ class ServerAttributesExtractorTest {
AttributesBuilder startAttributes = Attributes.builder();
extractor.onStart(startAttributes, Context.root(), request);
assertThat(startAttributes.build())
.containsOnly(entry(SemanticAttributes.SERVER_ADDRESS, "opentelemetry.io"));
.containsOnly(entry(ServerAttributes.SERVER_ADDRESS, "opentelemetry.io"));
}
@Test

View File

@ -13,7 +13,7 @@ import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
@ -56,9 +56,9 @@ class UrlAttributesExtractorTest {
extractor.onStart(startAttributes, Context.root(), request);
assertThat(startAttributes.build())
.containsOnly(
entry(SemanticAttributes.URL_SCHEME, "https"),
entry(SemanticAttributes.URL_PATH, "/test"),
entry(SemanticAttributes.URL_QUERY, "q=Java"));
entry(UrlAttributes.URL_SCHEME, "https"),
entry(UrlAttributes.URL_PATH, "/test"),
entry(UrlAttributes.URL_QUERY, "q=Java"));
AttributesBuilder endAttributes = Attributes.builder();
extractor.onEnd(endAttributes, Context.root(), request, null, null);

View File

@ -11,7 +11,7 @@ import io.opentelemetry.instrumentation.testing.junit.http.{
HttpServerTestOptions,
ServerEndpoint
}
import io.opentelemetry.semconv.SemanticAttributes
import io.opentelemetry.semconv.HttpAttributes
import java.util
import java.util.function.{Function, Predicate}
@ -29,7 +29,7 @@ abstract class AbstractHttpServerInstrumentationTest
val set = new util.HashSet[AttributeKey[_]](
HttpServerTestOptions.DEFAULT_HTTP_ATTRIBUTES
)
set.remove(SemanticAttributes.HTTP_ROUTE)
set.remove(HttpAttributes.HTTP_ROUTE)
set
}
}

View File

@ -17,7 +17,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor;
import io.opentelemetry.instrumentation.api.semconv.network.ServerAttributesExtractor;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.PeerIncubatingAttributes;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
@ -82,7 +82,7 @@ public final class DubboTelemetryBuilder {
if (peerService != null) {
clientInstrumenterBuilder.addAttributesExtractor(
AttributesExtractor.constant(SemanticAttributes.PEER_SERVICE, peerService));
AttributesExtractor.constant(PeerIncubatingAttributes.PEER_SERVICE, peerService));
}
return new DubboTelemetry(

View File

@ -8,10 +8,11 @@ package io.opentelemetry.instrumentation.apachedubbo.v2_7
import io.opentelemetry.api.trace.SpanKind
import io.opentelemetry.instrumentation.apachedubbo.v2_7.api.HelloService
import io.opentelemetry.instrumentation.apachedubbo.v2_7.impl.HelloServiceImpl
import io.opentelemetry.instrumentation.api.semconv.network.internal.NetworkAttributes
import io.opentelemetry.instrumentation.test.InstrumentationSpecification
import io.opentelemetry.instrumentation.test.utils.PortUtils
import io.opentelemetry.semconv.SemanticAttributes
import io.opentelemetry.semconv.incubating.RpcIncubatingAttributes
import io.opentelemetry.semconv.ServerAttributes
import io.opentelemetry.semconv.NetworkAttributes
import org.apache.dubbo.common.utils.NetUtils
import org.apache.dubbo.config.ApplicationConfig
import org.apache.dubbo.config.ProtocolConfig
@ -100,14 +101,14 @@ abstract class AbstractDubboTest extends InstrumentationSpecification {
kind CLIENT
childOf span(0)
attributes {
"$SemanticAttributes.RPC_SYSTEM" "apache_dubbo"
"$SemanticAttributes.RPC_SERVICE" "org.apache.dubbo.rpc.service.GenericService"
"$SemanticAttributes.RPC_METHOD" "\$invoke"
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.SERVER_PORT" Long
"$RpcIncubatingAttributes.RPC_SYSTEM" "apache_dubbo"
"$RpcIncubatingAttributes.RPC_SERVICE" "org.apache.dubbo.rpc.service.GenericService"
"$RpcIncubatingAttributes.RPC_METHOD" "\$invoke"
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$ServerAttributes.SERVER_PORT" Long
"$NetworkAttributes.NETWORK_PEER_ADDRESS" { it == null || it instanceof String}
"$NetworkAttributes.NETWORK_PEER_PORT" { it == null || it instanceof Long}
"$SemanticAttributes.NETWORK_TYPE" { it == "ipv4" || it == "ipv6" || it == null }
"$NetworkAttributes.NETWORK_TYPE" { it == "ipv4" || it == "ipv6" || it == null }
}
}
span(2) {
@ -115,12 +116,12 @@ abstract class AbstractDubboTest extends InstrumentationSpecification {
kind SERVER
childOf span(1)
attributes {
"$SemanticAttributes.RPC_SYSTEM" "apache_dubbo"
"$SemanticAttributes.RPC_SERVICE" "io.opentelemetry.instrumentation.apachedubbo.v2_7.api.HelloService"
"$SemanticAttributes.RPC_METHOD" "hello"
"$RpcIncubatingAttributes.RPC_SYSTEM" "apache_dubbo"
"$RpcIncubatingAttributes.RPC_SERVICE" "io.opentelemetry.instrumentation.apachedubbo.v2_7.api.HelloService"
"$RpcIncubatingAttributes.RPC_METHOD" "hello"
"$NetworkAttributes.NETWORK_PEER_ADDRESS" String
"$NetworkAttributes.NETWORK_PEER_PORT" Long
"$SemanticAttributes.NETWORK_TYPE" { it == "ipv4" || it == "ipv6" || it == null }
"$NetworkAttributes.NETWORK_TYPE" { it == "ipv4" || it == "ipv6" || it == null }
}
}
}
@ -176,14 +177,14 @@ abstract class AbstractDubboTest extends InstrumentationSpecification {
kind CLIENT
childOf span(0)
attributes {
"$SemanticAttributes.RPC_SYSTEM" "apache_dubbo"
"$SemanticAttributes.RPC_SERVICE" "org.apache.dubbo.rpc.service.GenericService"
"$SemanticAttributes.RPC_METHOD" "\$invokeAsync"
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.SERVER_PORT" Long
"$RpcIncubatingAttributes.RPC_SYSTEM" "apache_dubbo"
"$RpcIncubatingAttributes.RPC_SERVICE" "org.apache.dubbo.rpc.service.GenericService"
"$RpcIncubatingAttributes.RPC_METHOD" "\$invokeAsync"
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$ServerAttributes.SERVER_PORT" Long
"$NetworkAttributes.NETWORK_PEER_ADDRESS" { it == null || it instanceof String}
"$NetworkAttributes.NETWORK_PEER_PORT" { it == null || it instanceof Long}
"$SemanticAttributes.NETWORK_TYPE" { it == "ipv4" || it == "ipv6" || it == null }
"$NetworkAttributes.NETWORK_TYPE" { it == "ipv4" || it == "ipv6" || it == null }
}
}
span(2) {
@ -191,12 +192,12 @@ abstract class AbstractDubboTest extends InstrumentationSpecification {
kind SERVER
childOf span(1)
attributes {
"$SemanticAttributes.RPC_SYSTEM" "apache_dubbo"
"$SemanticAttributes.RPC_SERVICE" "io.opentelemetry.instrumentation.apachedubbo.v2_7.api.HelloService"
"$SemanticAttributes.RPC_METHOD" "hello"
"$RpcIncubatingAttributes.RPC_SYSTEM" "apache_dubbo"
"$RpcIncubatingAttributes.RPC_SERVICE" "io.opentelemetry.instrumentation.apachedubbo.v2_7.api.HelloService"
"$RpcIncubatingAttributes.RPC_METHOD" "hello"
"$NetworkAttributes.NETWORK_PEER_ADDRESS" String
"$NetworkAttributes.NETWORK_PEER_PORT" Long
"$SemanticAttributes.NETWORK_TYPE" { it == "ipv4" || it == "ipv6" || it == null }
"$NetworkAttributes.NETWORK_TYPE" { it == "ipv4" || it == "ipv6" || it == null }
}
}
}

View File

@ -10,10 +10,11 @@ import io.opentelemetry.instrumentation.apachedubbo.v2_7.api.HelloService
import io.opentelemetry.instrumentation.apachedubbo.v2_7.api.MiddleService
import io.opentelemetry.instrumentation.apachedubbo.v2_7.impl.HelloServiceImpl
import io.opentelemetry.instrumentation.apachedubbo.v2_7.impl.MiddleServiceImpl
import io.opentelemetry.instrumentation.api.semconv.network.internal.NetworkAttributes
import io.opentelemetry.instrumentation.test.InstrumentationSpecification
import io.opentelemetry.instrumentation.test.utils.PortUtils
import io.opentelemetry.semconv.SemanticAttributes
import io.opentelemetry.semconv.incubating.RpcIncubatingAttributes
import io.opentelemetry.semconv.ServerAttributes
import io.opentelemetry.semconv.NetworkAttributes
import org.apache.dubbo.common.utils.NetUtils
import org.apache.dubbo.config.ApplicationConfig
import org.apache.dubbo.config.ProtocolConfig
@ -136,14 +137,14 @@ abstract class AbstractDubboTraceChainTest extends InstrumentationSpecification
kind CLIENT
childOf span(0)
attributes {
"$SemanticAttributes.RPC_SYSTEM" "apache_dubbo"
"$SemanticAttributes.RPC_SERVICE" "org.apache.dubbo.rpc.service.GenericService"
"$SemanticAttributes.RPC_METHOD" "\$invoke"
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.SERVER_PORT" Long
"$RpcIncubatingAttributes.RPC_SYSTEM" "apache_dubbo"
"$RpcIncubatingAttributes.RPC_SERVICE" "org.apache.dubbo.rpc.service.GenericService"
"$RpcIncubatingAttributes.RPC_METHOD" "\$invoke"
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$ServerAttributes.SERVER_PORT" Long
"$NetworkAttributes.NETWORK_PEER_ADDRESS" { it == null || it instanceof String}
"$NetworkAttributes.NETWORK_PEER_PORT" { it == null || it instanceof Long}
"$SemanticAttributes.NETWORK_TYPE" { it == "ipv4" || it == "ipv6" || it == null }
"$NetworkAttributes.NETWORK_TYPE" { it == "ipv4" || it == "ipv6" || it == null }
}
}
span(2) {
@ -151,12 +152,12 @@ abstract class AbstractDubboTraceChainTest extends InstrumentationSpecification
kind SERVER
childOf span(1)
attributes {
"$SemanticAttributes.RPC_SYSTEM" "apache_dubbo"
"$SemanticAttributes.RPC_SERVICE" "io.opentelemetry.instrumentation.apachedubbo.v2_7.api.MiddleService"
"$SemanticAttributes.RPC_METHOD" "hello"
"$RpcIncubatingAttributes.RPC_SYSTEM" "apache_dubbo"
"$RpcIncubatingAttributes.RPC_SERVICE" "io.opentelemetry.instrumentation.apachedubbo.v2_7.api.MiddleService"
"$RpcIncubatingAttributes.RPC_METHOD" "hello"
"$NetworkAttributes.NETWORK_PEER_ADDRESS" String
"$NetworkAttributes.NETWORK_PEER_PORT" Long
"$SemanticAttributes.NETWORK_TYPE" { it == "ipv4" || it == "ipv6" || it == null }
"$NetworkAttributes.NETWORK_TYPE" { it == "ipv4" || it == "ipv6" || it == null }
}
}
span(3) {
@ -164,14 +165,14 @@ abstract class AbstractDubboTraceChainTest extends InstrumentationSpecification
kind CLIENT
childOf span(2)
attributes {
"$SemanticAttributes.RPC_SYSTEM" "apache_dubbo"
"$SemanticAttributes.RPC_SERVICE" "org.apache.dubbo.rpc.service.GenericService"
"$SemanticAttributes.RPC_METHOD" "\$invoke"
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.SERVER_PORT" Long
"$RpcIncubatingAttributes.RPC_SYSTEM" "apache_dubbo"
"$RpcIncubatingAttributes.RPC_SERVICE" "org.apache.dubbo.rpc.service.GenericService"
"$RpcIncubatingAttributes.RPC_METHOD" "\$invoke"
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$ServerAttributes.SERVER_PORT" Long
"$NetworkAttributes.NETWORK_PEER_ADDRESS" { it == null || it instanceof String }
"$NetworkAttributes.NETWORK_PEER_PORT" { it == null || it instanceof Long }
"$SemanticAttributes.NETWORK_TYPE" { it == "ipv4" || it == "ipv6" || it == null }
"$NetworkAttributes.NETWORK_TYPE" { it == "ipv4" || it == "ipv6" || it == null }
}
}
span(4) {
@ -179,12 +180,12 @@ abstract class AbstractDubboTraceChainTest extends InstrumentationSpecification
kind SERVER
childOf span(3)
attributes {
"$SemanticAttributes.RPC_SYSTEM" "apache_dubbo"
"$SemanticAttributes.RPC_SERVICE" "io.opentelemetry.instrumentation.apachedubbo.v2_7.api.HelloService"
"$SemanticAttributes.RPC_METHOD" "hello"
"$RpcIncubatingAttributes.RPC_SYSTEM" "apache_dubbo"
"$RpcIncubatingAttributes.RPC_SERVICE" "io.opentelemetry.instrumentation.apachedubbo.v2_7.api.HelloService"
"$RpcIncubatingAttributes.RPC_METHOD" "hello"
"$NetworkAttributes.NETWORK_PEER_ADDRESS" String
"$NetworkAttributes.NETWORK_PEER_PORT" Long
"$SemanticAttributes.NETWORK_TYPE" { it == "ipv4" || it == "ipv6" || it == null }
"$NetworkAttributes.NETWORK_TYPE" { it == "ipv4" || it == "ipv6" || it == null }
}
}
}
@ -252,14 +253,14 @@ abstract class AbstractDubboTraceChainTest extends InstrumentationSpecification
kind CLIENT
childOf span(0)
attributes {
"$SemanticAttributes.RPC_SYSTEM" "apache_dubbo"
"$SemanticAttributes.RPC_SERVICE" "org.apache.dubbo.rpc.service.GenericService"
"$SemanticAttributes.RPC_METHOD" "\$invoke"
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.SERVER_PORT" Long
"$RpcIncubatingAttributes.RPC_SYSTEM" "apache_dubbo"
"$RpcIncubatingAttributes.RPC_SERVICE" "org.apache.dubbo.rpc.service.GenericService"
"$RpcIncubatingAttributes.RPC_METHOD" "\$invoke"
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$ServerAttributes.SERVER_PORT" Long
"$NetworkAttributes.NETWORK_PEER_ADDRESS" { it == null || it instanceof String}
"$NetworkAttributes.NETWORK_PEER_PORT" { it == null || it instanceof Long}
"$SemanticAttributes.NETWORK_TYPE" { it == "ipv4" || it == "ipv6" || it == null }
"$NetworkAttributes.NETWORK_TYPE" { it == "ipv4" || it == "ipv6" || it == null }
}
}
span(2) {
@ -267,12 +268,12 @@ abstract class AbstractDubboTraceChainTest extends InstrumentationSpecification
kind SERVER
childOf span(1)
attributes {
"$SemanticAttributes.RPC_SYSTEM" "apache_dubbo"
"$SemanticAttributes.RPC_SERVICE" "io.opentelemetry.instrumentation.apachedubbo.v2_7.api.MiddleService"
"$SemanticAttributes.RPC_METHOD" "hello"
"$RpcIncubatingAttributes.RPC_SYSTEM" "apache_dubbo"
"$RpcIncubatingAttributes.RPC_SERVICE" "io.opentelemetry.instrumentation.apachedubbo.v2_7.api.MiddleService"
"$RpcIncubatingAttributes.RPC_METHOD" "hello"
"$NetworkAttributes.NETWORK_PEER_ADDRESS" String
"$NetworkAttributes.NETWORK_PEER_PORT" Long
"$SemanticAttributes.NETWORK_TYPE" { it == "ipv4" || it == "ipv6" || it == null }
"$NetworkAttributes.NETWORK_TYPE" { it == "ipv4" || it == "ipv6" || it == null }
}
}
}

View File

@ -9,7 +9,7 @@ import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpClientTest;
import io.opentelemetry.instrumentation.testing.junit.http.HttpClientResult;
import io.opentelemetry.instrumentation.testing.junit.http.HttpClientTestOptions;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import java.net.URI;
import java.time.Duration;
import java.util.HashSet;
@ -40,7 +40,7 @@ abstract class AbstractApacheHttpClientTest<T extends HttpRequest>
|| "https://192.0.2.1/".equals(uri.toString())
|| uri.toString().contains("/read-timeout")
|| uri.toString().contains("/circular-redirect")) {
attributes.remove(SemanticAttributes.NETWORK_PROTOCOL_VERSION);
attributes.remove(NetworkAttributes.NETWORK_PROTOCOL_VERSION);
}
return attributes;
}

View File

@ -30,7 +30,7 @@ import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractor;
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractorBuilder;
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanStatusExtractor;
import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaHttpClientAttributesGetter;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.PeerIncubatingAttributes;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@ -243,7 +243,7 @@ public final class ArmeriaTelemetryBuilder {
if (peerService != null) {
clientInstrumenterBuilder.addAttributesExtractor(
AttributesExtractor.constant(SemanticAttributes.PEER_SERVICE, peerService));
AttributesExtractor.constant(PeerIncubatingAttributes.PEER_SERVICE, peerService));
}
if (emitExperimentalHttpClientMetrics) {
clientInstrumenterBuilder

View File

@ -18,7 +18,7 @@ import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpClientTes
import io.opentelemetry.instrumentation.testing.junit.http.HttpClientInstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.http.HttpClientResult;
import io.opentelemetry.instrumentation.testing.junit.http.HttpClientTestOptions;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import java.net.URI;
import java.util.HashSet;
import java.util.Map;
@ -93,7 +93,7 @@ class AsyncHttpClientTest extends AbstractHttpClientTest<Request> {
endpoint -> {
Set<AttributeKey<?>> attributes =
new HashSet<>(HttpClientTestOptions.DEFAULT_HTTP_ATTRIBUTES);
attributes.remove(SemanticAttributes.NETWORK_PROTOCOL_VERSION);
attributes.remove(NetworkAttributes.NETWORK_PROTOCOL_VERSION);
return attributes;
});
}

View File

@ -15,7 +15,7 @@ import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.awslambdacore.v1_0.AbstractAwsLambdaTest;
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.FaasIncubatingAttributes;
import lambdainternal.AwsLambdaLegacyInternalRequestHandler;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
@ -55,7 +55,7 @@ public class AwsLambdaTest extends AbstractAwsLambdaTest {
span.hasName("my_function")
.hasKind(SpanKind.SERVER)
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
equalTo(FaasIncubatingAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
}
@Test
@ -72,7 +72,7 @@ public class AwsLambdaTest extends AbstractAwsLambdaTest {
span.hasName("my_function")
.hasKind(SpanKind.SERVER)
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
equalTo(FaasIncubatingAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
}
private static final class TestRequestHandler implements RequestHandler<String, String> {

View File

@ -5,14 +5,12 @@
package io.opentelemetry.instrumentation.awslambdacore.v1_0.internal;
import static io.opentelemetry.semconv.ResourceAttributes.CLOUD_ACCOUNT_ID;
import static io.opentelemetry.semconv.ResourceAttributes.CLOUD_RESOURCE_ID;
import static io.opentelemetry.semconv.SemanticAttributes.FAAS_INVOCATION_ID;
import com.amazonaws.services.lambda.runtime.Context;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.awslambdacore.v1_0.AwsLambdaRequest;
import io.opentelemetry.semconv.incubating.CloudIncubatingAttributes;
import io.opentelemetry.semconv.incubating.FaasIncubatingAttributes;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
@ -49,11 +47,11 @@ public final class AwsLambdaFunctionAttributesExtractor
io.opentelemetry.context.Context parentContext,
AwsLambdaRequest request) {
Context awsContext = request.getAwsContext();
attributes.put(FAAS_INVOCATION_ID, awsContext.getAwsRequestId());
attributes.put(FaasIncubatingAttributes.FAAS_INVOCATION_ID, awsContext.getAwsRequestId());
String arn = getFunctionArn(awsContext);
if (arn != null) {
attributes.put(CLOUD_RESOURCE_ID, arn);
attributes.put(CLOUD_ACCOUNT_ID, getAccountId(arn));
attributes.put(CloudIncubatingAttributes.CLOUD_RESOURCE_ID, arn);
attributes.put(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID, getAccountId(arn));
}
}

View File

@ -20,8 +20,8 @@ import io.opentelemetry.instrumentation.awslambdacore.v1_0.internal.WrappedLambd
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.LibraryInstrumentationExtension;
import io.opentelemetry.sdk.trace.data.StatusData;
import io.opentelemetry.semconv.ResourceAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.CloudIncubatingAttributes;
import io.opentelemetry.semconv.incubating.FaasIncubatingAttributes;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@ -91,10 +91,10 @@ public class AwsLambdaStreamWrapperHttpPropagationTest {
.hasParentSpanId("0000000000000456")
.hasAttributesSatisfyingExactly(
equalTo(
ResourceAttributes.CLOUD_RESOURCE_ID,
CloudIncubatingAttributes.CLOUD_RESOURCE_ID,
"arn:aws:lambda:us-east-1:123456789:function:test"),
equalTo(ResourceAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
equalTo(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(FaasIncubatingAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
}
@Test
@ -128,10 +128,10 @@ public class AwsLambdaStreamWrapperHttpPropagationTest {
.hasException(thrown)
.hasAttributesSatisfyingExactly(
equalTo(
ResourceAttributes.CLOUD_RESOURCE_ID,
CloudIncubatingAttributes.CLOUD_RESOURCE_ID,
"arn:aws:lambda:us-east-1:123456789:function:test"),
equalTo(ResourceAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
equalTo(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(FaasIncubatingAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
}
public static final class TestRequestHandler implements RequestStreamHandler {

View File

@ -17,8 +17,8 @@ import io.opentelemetry.instrumentation.awslambdacore.v1_0.internal.WrappedLambd
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.LibraryInstrumentationExtension;
import io.opentelemetry.sdk.trace.data.StatusData;
import io.opentelemetry.semconv.ResourceAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.CloudIncubatingAttributes;
import io.opentelemetry.semconv.incubating.FaasIncubatingAttributes;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
@ -81,10 +81,10 @@ public class AwsLambdaStreamWrapperTest {
.hasKind(SpanKind.SERVER)
.hasAttributesSatisfyingExactly(
equalTo(
ResourceAttributes.CLOUD_RESOURCE_ID,
CloudIncubatingAttributes.CLOUD_RESOURCE_ID,
"arn:aws:lambda:us-east-1:123456789:function:test"),
equalTo(ResourceAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
equalTo(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(FaasIncubatingAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
}
@Test
@ -109,10 +109,10 @@ public class AwsLambdaStreamWrapperTest {
.hasException(thrown)
.hasAttributesSatisfyingExactly(
equalTo(
ResourceAttributes.CLOUD_RESOURCE_ID,
CloudIncubatingAttributes.CLOUD_RESOURCE_ID,
"arn:aws:lambda:us-east-1:123456789:function:test"),
equalTo(ResourceAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
equalTo(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(FaasIncubatingAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
}
public static final class TestRequestHandler implements RequestStreamHandler {

View File

@ -15,7 +15,7 @@ import com.amazonaws.services.lambda.runtime.RequestHandler;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.sdk.trace.data.StatusData;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.FaasIncubatingAttributes;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -68,7 +68,7 @@ public abstract class AbstractAwsLambdaTest {
span.hasName("my_function")
.hasKind(SpanKind.SERVER)
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
equalTo(FaasIncubatingAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
}
@Test
@ -86,7 +86,7 @@ public abstract class AbstractAwsLambdaTest {
.hasStatus(StatusData.error())
.hasException(thrown)
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
equalTo(FaasIncubatingAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
}
/**
@ -111,6 +111,6 @@ public abstract class AbstractAwsLambdaTest {
.hasNoParent()
.hasLinks()
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
equalTo(FaasIncubatingAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
}
}

View File

@ -9,9 +9,8 @@ import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorU
import static io.opentelemetry.instrumentation.api.internal.HttpConstants._OTHER;
import static io.opentelemetry.instrumentation.awslambdacore.v1_0.internal.MapUtils.emptyIfNull;
import static io.opentelemetry.instrumentation.awslambdacore.v1_0.internal.MapUtils.lowercaseMap;
import static io.opentelemetry.semconv.SemanticAttributes.FAAS_TRIGGER;
import static io.opentelemetry.semconv.SemanticAttributes.HTTP_RESPONSE_STATUS_CODE;
import static io.opentelemetry.semconv.SemanticAttributes.USER_AGENT_ORIGINAL;
import static io.opentelemetry.semconv.HttpAttributes.HTTP_RESPONSE_STATUS_CODE;
import static io.opentelemetry.semconv.UserAgentAttributes.USER_AGENT_ORIGINAL;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
@ -19,7 +18,9 @@ import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.awslambdacore.v1_0.AwsLambdaRequest;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import io.opentelemetry.semconv.incubating.FaasIncubatingAttributes;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
@ -40,7 +41,8 @@ final class ApiGatewayProxyAttributesExtractor
public void onStart(
AttributesBuilder attributes, Context parentContext, AwsLambdaRequest request) {
if (request.getInput() instanceof APIGatewayProxyRequestEvent) {
attributes.put(FAAS_TRIGGER, SemanticAttributes.FaasTriggerValues.HTTP);
attributes.put(
FaasIncubatingAttributes.FAAS_TRIGGER, FaasIncubatingAttributes.FaasTriggerValues.HTTP);
onRequest(attributes, (APIGatewayProxyRequestEvent) request.getInput());
}
}
@ -48,10 +50,10 @@ final class ApiGatewayProxyAttributesExtractor
void onRequest(AttributesBuilder attributes, APIGatewayProxyRequestEvent request) {
String method = request.getHttpMethod();
if (method == null || knownMethods.contains(method)) {
internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD, method);
internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD, method);
} else {
internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD, _OTHER);
internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, method);
internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD, _OTHER);
internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, method);
}
Map<String, String> headers = lowercaseMap(request.getHeaders());
@ -60,7 +62,7 @@ final class ApiGatewayProxyAttributesExtractor
attributes.put(USER_AGENT_ORIGINAL, userAgent);
}
internalSet(attributes, SemanticAttributes.URL_FULL, getHttpUrl(request, headers));
internalSet(attributes, UrlAttributes.URL_FULL, getHttpUrl(request, headers));
}
private static String getHttpUrl(

View File

@ -9,14 +9,14 @@ import com.amazonaws.services.lambda.runtime.events.SQSEvent;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
import javax.annotation.Nullable;
class SqsEventAttributesExtractor implements AttributesExtractor<SQSEvent, Void> {
@Override
public void onStart(AttributesBuilder attributes, Context parentContext, SQSEvent event) {
attributes.put(SemanticAttributes.MESSAGING_SYSTEM, "AmazonSQS");
attributes.put(SemanticAttributes.MESSAGING_OPERATION, "process");
attributes.put(MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS");
attributes.put(MessagingIncubatingAttributes.MESSAGING_OPERATION, "process");
}
@Override

View File

@ -9,16 +9,17 @@ import com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
import javax.annotation.Nullable;
class SqsMessageAttributesExtractor implements AttributesExtractor<SQSMessage, Void> {
@Override
public void onStart(AttributesBuilder attributes, Context parentContext, SQSMessage message) {
attributes.put(SemanticAttributes.MESSAGING_SYSTEM, "AmazonSQS");
attributes.put(SemanticAttributes.MESSAGING_OPERATION, "process");
attributes.put(SemanticAttributes.MESSAGING_MESSAGE_ID, message.getMessageId());
attributes.put(SemanticAttributes.MESSAGING_DESTINATION_NAME, message.getEventSource());
attributes.put(MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS");
attributes.put(MessagingIncubatingAttributes.MESSAGING_OPERATION, "process");
attributes.put(MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID, message.getMessageId());
attributes.put(
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME, message.getEventSource());
}
@Override

View File

@ -17,8 +17,11 @@ import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.awslambdacore.v1_0.internal.WrappedLambda;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.LibraryInstrumentationExtension;
import io.opentelemetry.semconv.ResourceAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import io.opentelemetry.semconv.UserAgentAttributes;
import io.opentelemetry.semconv.incubating.CloudIncubatingAttributes;
import io.opentelemetry.semconv.incubating.FaasIncubatingAttributes;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.AfterEach;
@ -97,17 +100,16 @@ public class AwsLambdaApiGatewayWrapperTest {
.hasParentSpanId("0000000000000456")
.hasAttributesSatisfyingExactly(
equalTo(
ResourceAttributes.CLOUD_RESOURCE_ID,
CloudIncubatingAttributes.CLOUD_RESOURCE_ID,
"arn:aws:lambda:us-east-1:123456789:function:test"),
equalTo(ResourceAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333"),
equalTo(SemanticAttributes.FAAS_TRIGGER, "http"),
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(SemanticAttributes.USER_AGENT_ORIGINAL, "Test Client"),
equalTo(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(FaasIncubatingAttributes.FAAS_INVOCATION_ID, "1-22-333"),
equalTo(FaasIncubatingAttributes.FAAS_TRIGGER, "http"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(UserAgentAttributes.USER_AGENT_ORIGINAL, "Test Client"),
equalTo(
SemanticAttributes.URL_FULL,
"http://localhost:123/hello/world?a=b&c=d"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200L))));
UrlAttributes.URL_FULL, "http://localhost:123/hello/world?a=b&c=d"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L))));
}
@Test
@ -134,11 +136,11 @@ public class AwsLambdaApiGatewayWrapperTest {
.hasKind(SpanKind.SERVER)
.hasAttributesSatisfyingExactly(
equalTo(
ResourceAttributes.CLOUD_RESOURCE_ID,
CloudIncubatingAttributes.CLOUD_RESOURCE_ID,
"arn:aws:lambda:us-east-1:123456789:function:test"),
equalTo(ResourceAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333"),
equalTo(SemanticAttributes.FAAS_TRIGGER, "http"))));
equalTo(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(FaasIncubatingAttributes.FAAS_INVOCATION_ID, "1-22-333"),
equalTo(FaasIncubatingAttributes.FAAS_TRIGGER, "http"))));
}
@Test
@ -165,11 +167,11 @@ public class AwsLambdaApiGatewayWrapperTest {
.hasKind(SpanKind.SERVER)
.hasAttributesSatisfyingExactly(
equalTo(
ResourceAttributes.CLOUD_RESOURCE_ID,
CloudIncubatingAttributes.CLOUD_RESOURCE_ID,
"arn:aws:lambda:us-east-1:123456789:function:test"),
equalTo(ResourceAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333"),
equalTo(SemanticAttributes.FAAS_TRIGGER, "http"))));
equalTo(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(FaasIncubatingAttributes.FAAS_INVOCATION_ID, "1-22-333"),
equalTo(FaasIncubatingAttributes.FAAS_TRIGGER, "http"))));
}
@Test
@ -196,11 +198,11 @@ public class AwsLambdaApiGatewayWrapperTest {
.hasKind(SpanKind.SERVER)
.hasAttributesSatisfyingExactly(
equalTo(
ResourceAttributes.CLOUD_RESOURCE_ID,
CloudIncubatingAttributes.CLOUD_RESOURCE_ID,
"arn:aws:lambda:us-east-1:123456789:function:test"),
equalTo(ResourceAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333"),
equalTo(SemanticAttributes.FAAS_TRIGGER, "http"))));
equalTo(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(FaasIncubatingAttributes.FAAS_INVOCATION_ID, "1-22-333"),
equalTo(FaasIncubatingAttributes.FAAS_TRIGGER, "http"))));
}
@Test
@ -230,11 +232,11 @@ public class AwsLambdaApiGatewayWrapperTest {
.hasKind(SpanKind.SERVER)
.hasAttributesSatisfyingExactly(
equalTo(
ResourceAttributes.CLOUD_RESOURCE_ID,
CloudIncubatingAttributes.CLOUD_RESOURCE_ID,
"arn:aws:lambda:us-east-1:123456789:function:test"),
equalTo(ResourceAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333"),
equalTo(SemanticAttributes.FAAS_TRIGGER, "http"))));
equalTo(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(FaasIncubatingAttributes.FAAS_INVOCATION_ID, "1-22-333"),
equalTo(FaasIncubatingAttributes.FAAS_TRIGGER, "http"))));
}
public static class TestRequestHandlerApiGateway

View File

@ -16,8 +16,9 @@ import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.awslambdacore.v1_0.internal.WrappedLambda;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.LibraryInstrumentationExtension;
import io.opentelemetry.semconv.ResourceAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.CloudIncubatingAttributes;
import io.opentelemetry.semconv.incubating.FaasIncubatingAttributes;
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
import java.lang.reflect.Constructor;
import java.util.Collections;
import org.junit.jupiter.api.AfterEach;
@ -75,16 +76,17 @@ public class AwsLambdaSqsEventWrapperTest {
.hasKind(SpanKind.SERVER)
.hasAttributesSatisfyingExactly(
equalTo(
ResourceAttributes.CLOUD_RESOURCE_ID,
CloudIncubatingAttributes.CLOUD_RESOURCE_ID,
"arn:aws:lambda:us-east-1:123456789:function:test"),
equalTo(ResourceAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333")),
equalTo(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(FaasIncubatingAttributes.FAAS_INVOCATION_ID, "1-22-333")),
span ->
span.hasName("otel process")
.hasKind(SpanKind.CONSUMER)
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(SemanticAttributes.MESSAGING_OPERATION, "process"))));
equalTo(MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(
MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"))));
}
public static final class TestRequestHandler implements RequestHandler<SQSEvent, Void> {

View File

@ -19,7 +19,8 @@ import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.LibraryInstrumentationExtension;
import io.opentelemetry.sdk.OpenTelemetrySdk;
import io.opentelemetry.sdk.trace.data.LinkData;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.FaasIncubatingAttributes;
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
import java.lang.reflect.Constructor;
import java.util.Arrays;
import java.util.Collections;
@ -79,14 +80,14 @@ public class AwsLambdaSqsMessageHandlerTest {
span.hasName("my_function")
.hasKind(SpanKind.SERVER)
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333")),
equalTo(FaasIncubatingAttributes.FAAS_INVOCATION_ID, "1-22-333")),
span ->
span.hasName("queue1 process")
.hasKind(SpanKind.CONSUMER)
.hasParentSpanId(trace.getSpan(0).getSpanId())
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(SemanticAttributes.MESSAGING_OPERATION, "process"))
equalTo(MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"))
.hasLinks(
LinkData.create(
SpanContext.createFromRemoteParent(
@ -105,10 +106,11 @@ public class AwsLambdaSqsMessageHandlerTest {
.hasKind(SpanKind.CONSUMER)
.hasParentSpanId(trace.getSpan(1).getSpanId())
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(SemanticAttributes.MESSAGING_OPERATION, "process"),
equalTo(SemanticAttributes.MESSAGING_MESSAGE_ID, "message1"),
equalTo(SemanticAttributes.MESSAGING_DESTINATION_NAME, "queue1"))
equalTo(MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"),
equalTo(MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID, "message1"),
equalTo(
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME, "queue1"))
.hasLinks(
LinkData.create(
SpanContext.createFromRemoteParent(
@ -121,10 +123,11 @@ public class AwsLambdaSqsMessageHandlerTest {
.hasKind(SpanKind.CONSUMER)
.hasParentSpanId(trace.getSpan(1).getSpanId())
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(SemanticAttributes.MESSAGING_OPERATION, "process"),
equalTo(SemanticAttributes.MESSAGING_MESSAGE_ID, "message2"),
equalTo(SemanticAttributes.MESSAGING_DESTINATION_NAME, "queue1"))
equalTo(MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"),
equalTo(MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID, "message2"),
equalTo(
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME, "queue1"))
.hasLinks(
LinkData.create(
SpanContext.createFromRemoteParent(

View File

@ -17,8 +17,8 @@ import io.opentelemetry.instrumentation.awslambdacore.v1_0.internal.WrappedLambd
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.LibraryInstrumentationExtension;
import io.opentelemetry.sdk.trace.data.StatusData;
import io.opentelemetry.semconv.ResourceAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.CloudIncubatingAttributes;
import io.opentelemetry.semconv.incubating.FaasIncubatingAttributes;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -71,10 +71,10 @@ public class AwsLambdaWrapperTest {
.hasKind(SpanKind.SERVER)
.hasAttributesSatisfyingExactly(
equalTo(
ResourceAttributes.CLOUD_RESOURCE_ID,
CloudIncubatingAttributes.CLOUD_RESOURCE_ID,
"arn:aws:lambda:us-east-1:123456789:function:test"),
equalTo(ResourceAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
equalTo(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(FaasIncubatingAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
}
@Test
@ -101,10 +101,10 @@ public class AwsLambdaWrapperTest {
.hasException(thrown)
.hasAttributesSatisfyingExactly(
equalTo(
ResourceAttributes.CLOUD_RESOURCE_ID,
CloudIncubatingAttributes.CLOUD_RESOURCE_ID,
"arn:aws:lambda:us-east-1:123456789:function:test"),
equalTo(ResourceAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
equalTo(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(FaasIncubatingAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
}
@Test
@ -129,10 +129,10 @@ public class AwsLambdaWrapperTest {
.hasKind(SpanKind.SERVER)
.hasAttributesSatisfyingExactly(
equalTo(
ResourceAttributes.CLOUD_RESOURCE_ID,
CloudIncubatingAttributes.CLOUD_RESOURCE_ID,
"arn:aws:lambda:us-east-1:123456789:function:test"),
equalTo(ResourceAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
equalTo(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(FaasIncubatingAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
}
@Test
@ -160,10 +160,10 @@ public class AwsLambdaWrapperTest {
.hasKind(SpanKind.SERVER)
.hasAttributesSatisfyingExactly(
equalTo(
ResourceAttributes.CLOUD_RESOURCE_ID,
CloudIncubatingAttributes.CLOUD_RESOURCE_ID,
"arn:aws:lambda:us-east-1:123456789:function:test"),
equalTo(ResourceAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
equalTo(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID, "123456789"),
equalTo(FaasIncubatingAttributes.FAAS_INVOCATION_ID, "1-22-333"))));
}
public static final class TestRequestHandlerString implements RequestHandler<String, String> {

View File

@ -14,7 +14,8 @@ import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.SQSEvent;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.FaasIncubatingAttributes;
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
import java.lang.reflect.Constructor;
import java.util.Arrays;
import java.util.Collections;
@ -73,14 +74,16 @@ public abstract class AbstractAwsLambdaSqsEventHandlerTest {
span.hasName("my_function")
.hasKind(SpanKind.SERVER)
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333")),
equalTo(FaasIncubatingAttributes.FAAS_INVOCATION_ID, "1-22-333")),
span ->
span.hasName("queue1 process")
.hasKind(SpanKind.CONSUMER)
.hasParentSpanId(trace.getSpan(0).getSpanId())
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(SemanticAttributes.MESSAGING_OPERATION, "process"))
equalTo(
MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(
MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"))
.hasLinksSatisfying(
links ->
assertThat(links)
@ -119,14 +122,16 @@ public abstract class AbstractAwsLambdaSqsEventHandlerTest {
span.hasName("my_function")
.hasKind(SpanKind.SERVER)
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.FAAS_INVOCATION_ID, "1-22-333")),
equalTo(FaasIncubatingAttributes.FAAS_INVOCATION_ID, "1-22-333")),
span ->
span.hasName("multiple_sources process")
.hasKind(SpanKind.CONSUMER)
.hasParentSpanId(trace.getSpan(0).getSpanId())
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(SemanticAttributes.MESSAGING_OPERATION, "process"))
equalTo(
MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(
MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"))
.hasLinksSatisfying(
links ->
assertThat(links)

View File

@ -4,7 +4,11 @@
*/
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import io.opentelemetry.semconv.SemanticAttributes
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes
import io.opentelemetry.semconv.ServerAttributes
import io.opentelemetry.semconv.HttpAttributes
import io.opentelemetry.semconv.NetworkAttributes
import io.opentelemetry.semconv.UrlAttributes
import spock.lang.Shared
import static io.opentelemetry.api.trace.SpanKind.CLIENT
@ -60,12 +64,12 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"aws.queue.name" queueName
"rpc.system" "aws-api"
"rpc.service" "AmazonSQS"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -82,12 +86,12 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"rpc.system" "aws-api"
"rpc.service" "Amazon S3"
"aws.bucket.name" bucketName
"$SemanticAttributes.HTTP_REQUEST_METHOD" "PUT"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "PUT"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -104,12 +108,12 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"aws.queue.url" queueUrl
"rpc.system" "aws-api"
"rpc.service" "AmazonSQS"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -126,12 +130,12 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"aws.queue.url" queueUrl
"rpc.system" "aws-api"
"rpc.service" "AmazonSQS"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -148,12 +152,12 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"rpc.system" "aws-api"
"rpc.service" "Amazon S3"
"aws.bucket.name" bucketName
"$SemanticAttributes.HTTP_REQUEST_METHOD" "PUT"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "PUT"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -169,12 +173,12 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"rpc.system" "aws-api"
"rpc.service" "Amazon S3"
"aws.bucket.name" bucketName
"$SemanticAttributes.HTTP_REQUEST_METHOD" "PUT"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "PUT"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
span(1) {
@ -188,16 +192,16 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"aws.queue.url" queueUrl
"rpc.system" "aws-api"
"rpc.service" "AmazonSQS"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$SemanticAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" "s3ToSqsTestQueue"
"$SemanticAttributes.MESSAGING_OPERATION" "process"
"$SemanticAttributes.MESSAGING_MESSAGE_ID" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$ServerAttributes.SERVER_PORT" { it == null || Number }
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "s3ToSqsTestQueue"
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "process"
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
}
}
span(2) {
@ -219,12 +223,12 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"rpc.system" "aws-api"
"rpc.service" "Amazon S3"
"aws.bucket.name" bucketName
"$SemanticAttributes.HTTP_REQUEST_METHOD" "GET"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "GET"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -240,12 +244,12 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"rpc.system" "aws-api"
"rpc.service" "Amazon S3"
"aws.bucket.name" bucketName
"$SemanticAttributes.HTTP_REQUEST_METHOD" "DELETE"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 204
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "DELETE"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 204
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -261,12 +265,12 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"rpc.system" "aws-api"
"rpc.service" "Amazon S3"
"aws.bucket.name" bucketName
"$SemanticAttributes.HTTP_REQUEST_METHOD" "DELETE"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 204
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "DELETE"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 204
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -282,12 +286,12 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"aws.queue.url" queueUrl
"rpc.system" "aws-api"
"rpc.service" "AmazonSQS"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -336,12 +340,12 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"aws.queue.name" queueName
"rpc.system" "aws-api"
"rpc.service" "AmazonSQS"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -357,12 +361,12 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"aws.queue.url" queueUrl
"rpc.system" "aws-api"
"rpc.service" "AmazonSQS"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -378,12 +382,12 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"rpc.system" "aws-api"
"rpc.service" "Amazon S3"
"aws.bucket.name" bucketName
"$SemanticAttributes.HTTP_REQUEST_METHOD" "PUT"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "PUT"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -398,12 +402,12 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"rpc.method" "CreateTopic"
"rpc.system" "aws-api"
"rpc.service" "AmazonSNS"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -418,13 +422,13 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"rpc.method" "Subscribe"
"rpc.system" "aws-api"
"rpc.service" "AmazonSNS"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" topicArn
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" topicArn
}
}
}
@ -440,12 +444,12 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"aws.queue.url" queueUrl
"rpc.system" "aws-api"
"rpc.service" "AmazonSQS"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -460,13 +464,13 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"rpc.method" "SetTopicAttributes"
"rpc.system" "aws-api"
"rpc.service" "AmazonSNS"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" topicArn
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" topicArn
}
}
}
@ -482,12 +486,12 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"rpc.system" "aws-api"
"rpc.service" "Amazon S3"
"aws.bucket.name" bucketName
"$SemanticAttributes.HTTP_REQUEST_METHOD" "PUT"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "PUT"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -503,12 +507,12 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"rpc.system" "aws-api"
"rpc.service" "Amazon S3"
"aws.bucket.name" bucketName
"$SemanticAttributes.HTTP_REQUEST_METHOD" "PUT"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "PUT"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -524,16 +528,16 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"aws.queue.url" queueUrl
"rpc.system" "aws-api"
"rpc.service" "AmazonSQS"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$SemanticAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" "s3ToSnsToSqsTestQueue"
"$SemanticAttributes.MESSAGING_OPERATION" "process"
"$SemanticAttributes.MESSAGING_MESSAGE_ID" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$ServerAttributes.SERVER_PORT" { it == null || Number }
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "s3ToSnsToSqsTestQueue"
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "process"
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
}
}
span(1) {
@ -555,12 +559,12 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"rpc.system" "aws-api"
"rpc.service" "Amazon S3"
"aws.bucket.name" bucketName
"$SemanticAttributes.HTTP_REQUEST_METHOD" "GET"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "GET"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -576,12 +580,12 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"rpc.system" "aws-api"
"rpc.service" "Amazon S3"
"aws.bucket.name" bucketName
"$SemanticAttributes.HTTP_REQUEST_METHOD" "DELETE"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 204
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "DELETE"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 204
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -597,12 +601,12 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"rpc.system" "aws-api"
"rpc.service" "Amazon S3"
"aws.bucket.name" bucketName
"$SemanticAttributes.HTTP_REQUEST_METHOD" "DELETE"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 204
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "DELETE"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 204
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -618,12 +622,12 @@ class S3TracingTest extends AgentInstrumentationSpecification {
"aws.queue.url" queueUrl
"rpc.system" "aws-api"
"rpc.service" "AmazonSQS"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://") }
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}

View File

@ -4,7 +4,11 @@
*/
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import io.opentelemetry.semconv.SemanticAttributes
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes
import io.opentelemetry.semconv.ServerAttributes
import io.opentelemetry.semconv.HttpAttributes
import io.opentelemetry.semconv.NetworkAttributes
import io.opentelemetry.semconv.UrlAttributes
import spock.lang.Shared
import static io.opentelemetry.api.trace.SpanKind.CLIENT
@ -52,12 +56,12 @@ class SnsTracingTest extends AgentInstrumentationSpecification {
"aws.queue.name" queueName
"rpc.system" "aws-api"
"rpc.service" "AmazonSQS"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" String
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" String
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -74,12 +78,12 @@ class SnsTracingTest extends AgentInstrumentationSpecification {
"aws.queue.url" queueUrl
"rpc.system" "aws-api"
"rpc.service" "AmazonSQS"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" String
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" String
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -96,12 +100,12 @@ class SnsTracingTest extends AgentInstrumentationSpecification {
"aws.queue.url" queueUrl
"rpc.system" "aws-api"
"rpc.service" "AmazonSQS"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" String
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" String
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -117,12 +121,12 @@ class SnsTracingTest extends AgentInstrumentationSpecification {
"rpc.method" "CreateTopic"
"rpc.system" "aws-api"
"rpc.service" "AmazonSNS"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" String
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" String
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
}
}
}
@ -138,13 +142,13 @@ class SnsTracingTest extends AgentInstrumentationSpecification {
"rpc.method" "Subscribe"
"rpc.system" "aws-api"
"rpc.service" "AmazonSNS"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" String
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" topicArn
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" String
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" topicArn
}
}
}
@ -159,13 +163,13 @@ class SnsTracingTest extends AgentInstrumentationSpecification {
"rpc.method" "Publish"
"rpc.system" "aws-api"
"rpc.service" "AmazonSNS"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" String
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" topicArn
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" String
"$ServerAttributes.SERVER_ADDRESS" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" { it == null || Number }
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" topicArn
}
}
span(1) {
@ -179,16 +183,16 @@ class SnsTracingTest extends AgentInstrumentationSpecification {
"rpc.system" "aws-api"
"rpc.service" "AmazonSQS"
"rpc.method" "ReceiveMessage"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" String
"$SemanticAttributes.SERVER_ADDRESS" String
"$SemanticAttributes.SERVER_PORT" { it == null || Number }
"$SemanticAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" "snsToSqsTestQueue"
"$SemanticAttributes.MESSAGING_OPERATION" "process"
"$SemanticAttributes.MESSAGING_MESSAGE_ID" String
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" String
"$ServerAttributes.SERVER_ADDRESS" String
"$ServerAttributes.SERVER_PORT" { it == null || Number }
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "snsToSqsTestQueue"
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "process"
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
}
}
span(2) {

View File

@ -19,7 +19,11 @@ import io.opentelemetry.api.trace.Span
import io.opentelemetry.api.trace.SpanKind
import io.opentelemetry.instrumentation.awssdk.v1_11.AbstractAws1ClientTest
import io.opentelemetry.instrumentation.test.AgentTestTrait
import io.opentelemetry.semconv.SemanticAttributes
import io.opentelemetry.semconv.incubating.RpcIncubatingAttributes
import io.opentelemetry.semconv.ServerAttributes
import io.opentelemetry.semconv.ErrorAttributes
import io.opentelemetry.semconv.HttpAttributes
import io.opentelemetry.semconv.UrlAttributes
import static io.opentelemetry.api.trace.StatusCode.ERROR
@ -99,16 +103,16 @@ class Aws1ClientTest extends AbstractAws1ClientTest implements AgentTestTrait {
errorEvent IllegalStateException, "bad handler"
hasNoParent()
attributes {
"$SemanticAttributes.URL_FULL" "https://s3.amazonaws.com"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "HEAD"
"$SemanticAttributes.SERVER_ADDRESS" "s3.amazonaws.com"
"$SemanticAttributes.RPC_SYSTEM" "aws-api"
"$SemanticAttributes.RPC_SERVICE" "Amazon S3"
"$SemanticAttributes.RPC_METHOD" "HeadBucket"
"$UrlAttributes.URL_FULL" "https://s3.amazonaws.com"
"$HttpAttributes.HTTP_REQUEST_METHOD" "HEAD"
"$ServerAttributes.SERVER_ADDRESS" "s3.amazonaws.com"
"$RpcIncubatingAttributes.RPC_SYSTEM" "aws-api"
"$RpcIncubatingAttributes.RPC_SERVICE" "Amazon S3"
"$RpcIncubatingAttributes.RPC_METHOD" "HeadBucket"
"aws.endpoint" "https://s3.amazonaws.com"
"aws.agent" "java-aws-sdk"
"aws.bucket.name" "someBucket"
"$SemanticAttributes.ERROR_TYPE" IllegalStateException.name
"$ErrorAttributes.ERROR_TYPE" IllegalStateException.name
}
}
}

View File

@ -24,7 +24,12 @@ import com.amazonaws.services.s3.AmazonS3Client
import com.amazonaws.services.s3.S3ClientOptions
import io.opentelemetry.api.trace.Span
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import io.opentelemetry.semconv.SemanticAttributes
import io.opentelemetry.semconv.incubating.RpcIncubatingAttributes
import io.opentelemetry.semconv.ServerAttributes
import io.opentelemetry.semconv.ErrorAttributes
import io.opentelemetry.semconv.HttpAttributes
import io.opentelemetry.semconv.NetworkAttributes
import io.opentelemetry.semconv.UrlAttributes
import io.opentelemetry.testing.internal.armeria.common.HttpResponse
import io.opentelemetry.testing.internal.armeria.common.HttpStatus
import io.opentelemetry.testing.internal.armeria.common.MediaType
@ -106,15 +111,15 @@ class Aws0ClientTest extends AgentInstrumentationSpecification {
kind CLIENT
hasNoParent()
attributes {
"$SemanticAttributes.URL_FULL" "${server.httpUri()}"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "$method"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" server.httpPort()
"$SemanticAttributes.SERVER_ADDRESS" "127.0.0.1"
"$SemanticAttributes.RPC_SYSTEM" "aws-api"
"$SemanticAttributes.RPC_SERVICE" { it.contains(service) }
"$SemanticAttributes.RPC_METHOD" "${operation}"
"$UrlAttributes.URL_FULL" "${server.httpUri()}"
"$HttpAttributes.HTTP_REQUEST_METHOD" "$method"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" server.httpPort()
"$ServerAttributes.SERVER_ADDRESS" "127.0.0.1"
"$RpcIncubatingAttributes.RPC_SYSTEM" "aws-api"
"$RpcIncubatingAttributes.RPC_SERVICE" { it.contains(service) }
"$RpcIncubatingAttributes.RPC_METHOD" "${operation}"
"aws.endpoint" "${server.httpUri()}"
"aws.agent" "java-aws-sdk"
for (def addedTag : additionalAttributes) {
@ -168,19 +173,19 @@ class Aws0ClientTest extends AgentInstrumentationSpecification {
errorEvent AmazonClientException, ~/Unable to execute HTTP request/
hasNoParent()
attributes {
"$SemanticAttributes.URL_FULL" "http://localhost:${UNUSABLE_PORT}"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "$method"
"$SemanticAttributes.SERVER_PORT" 61
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.RPC_SYSTEM" "aws-api"
"$SemanticAttributes.RPC_SERVICE" { it.contains(service) }
"$SemanticAttributes.RPC_METHOD" "${operation}"
"$UrlAttributes.URL_FULL" "http://localhost:${UNUSABLE_PORT}"
"$HttpAttributes.HTTP_REQUEST_METHOD" "$method"
"$ServerAttributes.SERVER_PORT" 61
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$RpcIncubatingAttributes.RPC_SYSTEM" "aws-api"
"$RpcIncubatingAttributes.RPC_SERVICE" { it.contains(service) }
"$RpcIncubatingAttributes.RPC_METHOD" "${operation}"
"aws.endpoint" "http://localhost:${UNUSABLE_PORT}"
"aws.agent" "java-aws-sdk"
for (def addedTag : additionalAttributes) {
"$addedTag.key" "$addedTag.value"
}
"$SemanticAttributes.ERROR_TYPE" AmazonClientException.name
"$ErrorAttributes.ERROR_TYPE" AmazonClientException.name
}
}
}
@ -216,16 +221,16 @@ class Aws0ClientTest extends AgentInstrumentationSpecification {
errorEvent IllegalStateException, "bad handler"
hasNoParent()
attributes {
"$SemanticAttributes.URL_FULL" "https://s3.amazonaws.com"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "GET"
"$SemanticAttributes.SERVER_ADDRESS" "s3.amazonaws.com"
"$SemanticAttributes.RPC_SYSTEM" "aws-api"
"$SemanticAttributes.RPC_SERVICE" "Amazon S3"
"$SemanticAttributes.RPC_METHOD" "GetObject"
"$UrlAttributes.URL_FULL" "https://s3.amazonaws.com"
"$HttpAttributes.HTTP_REQUEST_METHOD" "GET"
"$ServerAttributes.SERVER_ADDRESS" "s3.amazonaws.com"
"$RpcIncubatingAttributes.RPC_SYSTEM" "aws-api"
"$RpcIncubatingAttributes.RPC_SERVICE" "Amazon S3"
"$RpcIncubatingAttributes.RPC_METHOD" "GetObject"
"aws.endpoint" "https://s3.amazonaws.com"
"aws.agent" "java-aws-sdk"
"aws.bucket.name" "someBucket"
"$SemanticAttributes.ERROR_TYPE" IllegalStateException.name
"$ErrorAttributes.ERROR_TYPE" IllegalStateException.name
}
}
}
@ -259,17 +264,17 @@ class Aws0ClientTest extends AgentInstrumentationSpecification {
errorEvent AmazonClientException, ~/Unable to execute HTTP request/
hasNoParent()
attributes {
"$SemanticAttributes.URL_FULL" "${server.httpUri()}"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "GET"
"$SemanticAttributes.SERVER_PORT" server.httpPort()
"$SemanticAttributes.SERVER_ADDRESS" "127.0.0.1"
"$SemanticAttributes.RPC_SYSTEM" "aws-api"
"$SemanticAttributes.RPC_SERVICE" "Amazon S3"
"$SemanticAttributes.RPC_METHOD" "GetObject"
"$UrlAttributes.URL_FULL" "${server.httpUri()}"
"$HttpAttributes.HTTP_REQUEST_METHOD" "GET"
"$ServerAttributes.SERVER_PORT" server.httpPort()
"$ServerAttributes.SERVER_ADDRESS" "127.0.0.1"
"$RpcIncubatingAttributes.RPC_SYSTEM" "aws-api"
"$RpcIncubatingAttributes.RPC_SERVICE" "Amazon S3"
"$RpcIncubatingAttributes.RPC_METHOD" "GetObject"
"aws.endpoint" "${server.httpUri()}"
"aws.agent" "java-aws-sdk"
"aws.bucket.name" "someBucket"
"$SemanticAttributes.ERROR_TYPE" AmazonClientException.name
"$ErrorAttributes.ERROR_TYPE" AmazonClientException.name
}
}
}

View File

@ -12,7 +12,7 @@ import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
import javax.annotation.Nullable;
public class SnsAttributesExtractor implements AttributesExtractor<Request<?>, Response<?>> {
@ -20,7 +20,7 @@ public class SnsAttributesExtractor implements AttributesExtractor<Request<?>, R
public void onStart(AttributesBuilder attributes, Context parentContext, Request<?> request) {
String destination = findMessageDestination(request.getOriginalRequest());
AttributesExtractorUtil.internalSet(
attributes, SemanticAttributes.MESSAGING_DESTINATION_NAME, destination);
attributes, MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME, destination);
}
/*

View File

@ -31,7 +31,13 @@ import com.amazonaws.services.sns.AmazonSNSClientBuilder
import com.amazonaws.services.sns.model.PublishRequest
import io.opentelemetry.api.trace.Span
import io.opentelemetry.instrumentation.test.InstrumentationSpecification
import io.opentelemetry.semconv.SemanticAttributes
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes
import io.opentelemetry.semconv.incubating.RpcIncubatingAttributes
import io.opentelemetry.semconv.ServerAttributes
import io.opentelemetry.semconv.ErrorAttributes
import io.opentelemetry.semconv.HttpAttributes
import io.opentelemetry.semconv.NetworkAttributes
import io.opentelemetry.semconv.UrlAttributes
import io.opentelemetry.testing.internal.armeria.common.HttpResponse
import io.opentelemetry.testing.internal.armeria.common.HttpStatus
import io.opentelemetry.testing.internal.armeria.common.MediaType
@ -104,15 +110,15 @@ abstract class AbstractAws1ClientTest extends InstrumentationSpecification {
kind operation == "SendMessage" ? PRODUCER : CLIENT
hasNoParent()
attributes {
"$SemanticAttributes.URL_FULL" "${server.httpUri()}"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "$method"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$SemanticAttributes.SERVER_PORT" server.httpPort()
"$SemanticAttributes.SERVER_ADDRESS" "127.0.0.1"
"$SemanticAttributes.RPC_SYSTEM" "aws-api"
"$SemanticAttributes.RPC_SERVICE" { it.contains(service) }
"$SemanticAttributes.RPC_METHOD" "${operation}"
"$UrlAttributes.URL_FULL" "${server.httpUri()}"
"$HttpAttributes.HTTP_REQUEST_METHOD" "$method"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$NetworkAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
"$ServerAttributes.SERVER_PORT" server.httpPort()
"$ServerAttributes.SERVER_ADDRESS" "127.0.0.1"
"$RpcIncubatingAttributes.RPC_SYSTEM" "aws-api"
"$RpcIncubatingAttributes.RPC_SERVICE" { it.contains(service) }
"$RpcIncubatingAttributes.RPC_METHOD" "${operation}"
"aws.endpoint" "${server.httpUri()}"
"aws.agent" "java-aws-sdk"
for (def addedTag : additionalAttributes) {
@ -155,7 +161,7 @@ abstract class AbstractAws1ClientTest extends InstrumentationSpecification {
</ResponseMetadata>
</DeleteOptionGroupResponse>
"""
"SNS" | "Publish" | "POST" | "d74b8436-ae13-5ab4-a9ff-ce54dfea72a0" | AmazonSNSClientBuilder.standard() | { c -> c.publish(new PublishRequest().withMessage("somemessage").withTopicArn("somearn")) } | ["$SemanticAttributes.MESSAGING_DESTINATION_NAME": "somearn"] | """
"SNS" | "Publish" | "POST" | "d74b8436-ae13-5ab4-a9ff-ce54dfea72a0" | AmazonSNSClientBuilder.standard() | { c -> c.publish(new PublishRequest().withMessage("somemessage").withTopicArn("somearn")) } | ["$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME": "somearn"] | """
<PublishResponse xmlns="https://sns.amazonaws.com/doc/2010-03-31/">
<PublishResult>
<MessageId>567910cd-659e-55d4-8ccb-5aaf14679dc0</MessageId>
@ -165,7 +171,7 @@ abstract class AbstractAws1ClientTest extends InstrumentationSpecification {
</ResponseMetadata>
</PublishResponse>
"""
"SNS" | "Publish" | "POST" | "d74b8436-ae13-5ab4-a9ff-ce54dfea72a0" | AmazonSNSClientBuilder.standard() | { c -> c.publish(new PublishRequest().withMessage("somemessage").withTargetArn("somearn")) } | ["$SemanticAttributes.MESSAGING_DESTINATION_NAME": "somearn"] | """
"SNS" | "Publish" | "POST" | "d74b8436-ae13-5ab4-a9ff-ce54dfea72a0" | AmazonSNSClientBuilder.standard() | { c -> c.publish(new PublishRequest().withMessage("somemessage").withTargetArn("somearn")) } | ["$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME": "somearn"] | """
<PublishResponse xmlns="https://sns.amazonaws.com/doc/2010-03-31/">
<PublishResult>
<MessageId>567910cd-659e-55d4-8ccb-5aaf14679dc0</MessageId>
@ -201,19 +207,19 @@ abstract class AbstractAws1ClientTest extends InstrumentationSpecification {
errorEvent SdkClientException, ~/Unable to execute HTTP request/
hasNoParent()
attributes {
"$SemanticAttributes.URL_FULL" "http://127.0.0.1:${UNUSABLE_PORT}"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "$method"
"$SemanticAttributes.SERVER_ADDRESS" "127.0.0.1"
"$SemanticAttributes.SERVER_PORT" 61
"$SemanticAttributes.RPC_SYSTEM" "aws-api"
"$SemanticAttributes.RPC_SERVICE" { it.contains(service) }
"$SemanticAttributes.RPC_METHOD" "${operation}"
"$UrlAttributes.URL_FULL" "http://127.0.0.1:${UNUSABLE_PORT}"
"$HttpAttributes.HTTP_REQUEST_METHOD" "$method"
"$ServerAttributes.SERVER_ADDRESS" "127.0.0.1"
"$ServerAttributes.SERVER_PORT" 61
"$RpcIncubatingAttributes.RPC_SYSTEM" "aws-api"
"$RpcIncubatingAttributes.RPC_SERVICE" { it.contains(service) }
"$RpcIncubatingAttributes.RPC_METHOD" "${operation}"
"aws.endpoint" "http://127.0.0.1:${UNUSABLE_PORT}"
"aws.agent" "java-aws-sdk"
for (def addedTag : additionalAttributes) {
"$addedTag.key" "$addedTag.value"
}
"$SemanticAttributes.ERROR_TYPE" SdkClientException.name
"$ErrorAttributes.ERROR_TYPE" SdkClientException.name
}
}
}
@ -257,17 +263,17 @@ abstract class AbstractAws1ClientTest extends InstrumentationSpecification {
}
hasNoParent()
attributes {
"$SemanticAttributes.URL_FULL" "${server.httpUri()}"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "GET"
"$SemanticAttributes.SERVER_PORT" server.httpPort()
"$SemanticAttributes.SERVER_ADDRESS" "127.0.0.1"
"$SemanticAttributes.RPC_SYSTEM" "aws-api"
"$SemanticAttributes.RPC_SERVICE" "Amazon S3"
"$SemanticAttributes.RPC_METHOD" "GetObject"
"$UrlAttributes.URL_FULL" "${server.httpUri()}"
"$HttpAttributes.HTTP_REQUEST_METHOD" "GET"
"$ServerAttributes.SERVER_PORT" server.httpPort()
"$ServerAttributes.SERVER_ADDRESS" "127.0.0.1"
"$RpcIncubatingAttributes.RPC_SYSTEM" "aws-api"
"$RpcIncubatingAttributes.RPC_SERVICE" "Amazon S3"
"$RpcIncubatingAttributes.RPC_METHOD" "GetObject"
"aws.endpoint" "${server.httpUri()}"
"aws.agent" "java-aws-sdk"
"aws.bucket.name" "someBucket"
"$SemanticAttributes.ERROR_TYPE" {it == SdkClientException.name || it == AmazonClientException.name }
"$ErrorAttributes.ERROR_TYPE" {it == SdkClientException.name || it == AmazonClientException.name }
}
}
}

View File

@ -24,7 +24,12 @@ import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.test.utils.PortUtils;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
import io.opentelemetry.semconv.incubating.RpcIncubatingAttributes;
import org.elasticmq.rest.sqs.SQSRestServer;
import org.elasticmq.rest.sqs.SQSRestServerBuilder;
import org.junit.jupiter.api.AfterEach;
@ -92,15 +97,15 @@ public abstract class AbstractSqsSuppressReceiveSpansTest {
equalTo(stringKey("aws.agent"), "java-aws-sdk"),
equalTo(stringKey("aws.endpoint"), "http://localhost:" + sqsPort),
equalTo(stringKey("aws.queue.name"), "testSdkSqs"),
equalTo(SemanticAttributes.RPC_SYSTEM, "aws-api"),
equalTo(SemanticAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(SemanticAttributes.RPC_METHOD, "CreateQueue"),
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(SemanticAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"),
equalTo(SemanticAttributes.SERVER_PORT, sqsPort),
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1"))),
equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "aws-api"),
equalTo(RpcIncubatingAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(RpcIncubatingAttributes.RPC_METHOD, "CreateQueue"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(UrlAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
equalTo(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"))),
trace ->
trace.hasSpansSatisfyingExactly(
span ->
@ -113,22 +118,25 @@ public abstract class AbstractSqsSuppressReceiveSpansTest {
equalTo(
stringKey("aws.queue.url"),
"http://localhost:" + sqsPort + "/000000000000/testSdkSqs"),
equalTo(SemanticAttributes.RPC_SYSTEM, "aws-api"),
equalTo(SemanticAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(SemanticAttributes.RPC_METHOD, "SendMessage"),
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(SemanticAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"),
equalTo(SemanticAttributes.SERVER_PORT, sqsPort),
equalTo(SemanticAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "aws-api"),
equalTo(RpcIncubatingAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(RpcIncubatingAttributes.RPC_METHOD, "SendMessage"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(UrlAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
equalTo(
SemanticAttributes.MESSAGING_DESTINATION_NAME, "testSdkSqs"),
equalTo(SemanticAttributes.MESSAGING_OPERATION, "publish"),
MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
"testSdkSqs"),
equalTo(
MessagingIncubatingAttributes.MESSAGING_OPERATION, "publish"),
satisfies(
SemanticAttributes.MESSAGING_MESSAGE_ID,
MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID,
val -> val.isInstanceOf(String.class)),
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1")),
equalTo(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1")),
span ->
span.hasName("testSdkSqs process")
.hasKind(SpanKind.CONSUMER)
@ -139,22 +147,25 @@ public abstract class AbstractSqsSuppressReceiveSpansTest {
equalTo(
stringKey("aws.queue.url"),
"http://localhost:" + sqsPort + "/000000000000/testSdkSqs"),
equalTo(SemanticAttributes.RPC_SYSTEM, "aws-api"),
equalTo(SemanticAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(SemanticAttributes.RPC_METHOD, "ReceiveMessage"),
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(SemanticAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"),
equalTo(SemanticAttributes.SERVER_PORT, sqsPort),
equalTo(SemanticAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "aws-api"),
equalTo(RpcIncubatingAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(RpcIncubatingAttributes.RPC_METHOD, "ReceiveMessage"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(UrlAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
equalTo(
SemanticAttributes.MESSAGING_DESTINATION_NAME, "testSdkSqs"),
equalTo(SemanticAttributes.MESSAGING_OPERATION, "process"),
MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
"testSdkSqs"),
equalTo(
MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"),
satisfies(
SemanticAttributes.MESSAGING_MESSAGE_ID,
MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID,
val -> val.isInstanceOf(String.class)),
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1")),
equalTo(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1")),
span ->
span.hasName("process child")
.hasParent(trace.getSpan(1))
@ -193,15 +204,15 @@ public abstract class AbstractSqsSuppressReceiveSpansTest {
equalTo(stringKey("aws.agent"), "java-aws-sdk"),
equalTo(stringKey("aws.endpoint"), "http://localhost:" + sqsPort),
equalTo(stringKey("aws.queue.name"), "testSdkSqs"),
equalTo(SemanticAttributes.RPC_SYSTEM, "aws-api"),
equalTo(SemanticAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(SemanticAttributes.RPC_METHOD, "CreateQueue"),
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(SemanticAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"),
equalTo(SemanticAttributes.SERVER_PORT, sqsPort),
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1"))),
equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "aws-api"),
equalTo(RpcIncubatingAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(RpcIncubatingAttributes.RPC_METHOD, "CreateQueue"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(UrlAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
equalTo(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"))),
trace ->
trace.hasSpansSatisfyingExactly(
span ->
@ -214,22 +225,25 @@ public abstract class AbstractSqsSuppressReceiveSpansTest {
equalTo(
stringKey("aws.queue.url"),
"http://localhost:" + sqsPort + "/000000000000/testSdkSqs"),
equalTo(SemanticAttributes.RPC_SYSTEM, "aws-api"),
equalTo(SemanticAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(SemanticAttributes.RPC_METHOD, "SendMessage"),
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(SemanticAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"),
equalTo(SemanticAttributes.SERVER_PORT, sqsPort),
equalTo(SemanticAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "aws-api"),
equalTo(RpcIncubatingAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(RpcIncubatingAttributes.RPC_METHOD, "SendMessage"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(UrlAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
equalTo(
SemanticAttributes.MESSAGING_DESTINATION_NAME, "testSdkSqs"),
equalTo(SemanticAttributes.MESSAGING_OPERATION, "publish"),
MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
"testSdkSqs"),
equalTo(
MessagingIncubatingAttributes.MESSAGING_OPERATION, "publish"),
satisfies(
SemanticAttributes.MESSAGING_MESSAGE_ID,
MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID,
val -> val.isInstanceOf(String.class)),
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1")),
equalTo(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1")),
span ->
span.hasName("testSdkSqs process")
.hasKind(SpanKind.CONSUMER)
@ -240,22 +254,25 @@ public abstract class AbstractSqsSuppressReceiveSpansTest {
equalTo(
stringKey("aws.queue.url"),
"http://localhost:" + sqsPort + "/000000000000/testSdkSqs"),
equalTo(SemanticAttributes.RPC_SYSTEM, "aws-api"),
equalTo(SemanticAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(SemanticAttributes.RPC_METHOD, "ReceiveMessage"),
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(SemanticAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"),
equalTo(SemanticAttributes.SERVER_PORT, sqsPort),
equalTo(SemanticAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "aws-api"),
equalTo(RpcIncubatingAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(RpcIncubatingAttributes.RPC_METHOD, "ReceiveMessage"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(UrlAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
equalTo(
SemanticAttributes.MESSAGING_DESTINATION_NAME, "testSdkSqs"),
equalTo(SemanticAttributes.MESSAGING_OPERATION, "process"),
MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
"testSdkSqs"),
equalTo(
MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"),
satisfies(
SemanticAttributes.MESSAGING_MESSAGE_ID,
MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID,
val -> val.isInstanceOf(String.class)),
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1")),
equalTo(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1")),
span ->
span.hasName("process child")
.hasParent(trace.getSpan(1))
@ -277,15 +294,15 @@ public abstract class AbstractSqsSuppressReceiveSpansTest {
equalTo(
stringKey("aws.queue.url"),
"http://localhost:" + sqsPort + "/000000000000/testSdkSqs"),
equalTo(SemanticAttributes.RPC_SYSTEM, "aws-api"),
equalTo(SemanticAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(SemanticAttributes.RPC_METHOD, "ReceiveMessage"),
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(SemanticAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"),
equalTo(SemanticAttributes.SERVER_PORT, sqsPort),
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1"))));
equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "aws-api"),
equalTo(RpcIncubatingAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(RpcIncubatingAttributes.RPC_METHOD, "ReceiveMessage"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(UrlAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
equalTo(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"))));
}
@Test

View File

@ -30,7 +30,12 @@ import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.sdk.testing.assertj.AttributeAssertion;
import io.opentelemetry.sdk.testing.assertj.SpanDataAssert;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
import io.opentelemetry.semconv.incubating.RpcIncubatingAttributes;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -125,15 +130,15 @@ public abstract class AbstractSqsTracingTest {
equalTo(stringKey("aws.agent"), "java-aws-sdk"),
equalTo(stringKey("aws.endpoint"), "http://localhost:" + sqsPort),
equalTo(stringKey("aws.queue.name"), "testSdkSqs"),
equalTo(SemanticAttributes.RPC_SYSTEM, "aws-api"),
equalTo(SemanticAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(SemanticAttributes.RPC_METHOD, "CreateQueue"),
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(SemanticAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"),
equalTo(SemanticAttributes.SERVER_PORT, sqsPort),
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1"))),
equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "aws-api"),
equalTo(RpcIncubatingAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(RpcIncubatingAttributes.RPC_METHOD, "CreateQueue"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(UrlAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
equalTo(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"))),
trace ->
trace.hasSpansSatisfyingExactly(
span -> {
@ -145,23 +150,25 @@ public abstract class AbstractSqsTracingTest {
equalTo(
stringKey("aws.queue.url"),
"http://localhost:" + sqsPort + "/000000000000/testSdkSqs"),
equalTo(SemanticAttributes.RPC_SYSTEM, "aws-api"),
equalTo(SemanticAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(SemanticAttributes.RPC_METHOD, "SendMessage"),
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "aws-api"),
equalTo(RpcIncubatingAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(RpcIncubatingAttributes.RPC_METHOD, "SendMessage"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(UrlAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
equalTo(
SemanticAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"),
equalTo(SemanticAttributes.SERVER_PORT, sqsPort),
equalTo(SemanticAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(
SemanticAttributes.MESSAGING_DESTINATION_NAME, "testSdkSqs"),
equalTo(SemanticAttributes.MESSAGING_OPERATION, "publish"),
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
"testSdkSqs"),
equalTo(
MessagingIncubatingAttributes.MESSAGING_OPERATION, "publish"),
satisfies(
SemanticAttributes.MESSAGING_MESSAGE_ID,
MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID,
val -> val.isInstanceOf(String.class)),
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1")));
equalTo(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1")));
if (testCaptureHeaders) {
attributes.add(
@ -186,21 +193,25 @@ public abstract class AbstractSqsTracingTest {
equalTo(
stringKey("aws.queue.url"),
"http://localhost:" + sqsPort + "/000000000000/testSdkSqs"),
equalTo(SemanticAttributes.RPC_SYSTEM, "aws-api"),
equalTo(SemanticAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(SemanticAttributes.RPC_METHOD, "ReceiveMessage"),
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "aws-api"),
equalTo(RpcIncubatingAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(RpcIncubatingAttributes.RPC_METHOD, "ReceiveMessage"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(UrlAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
equalTo(
SemanticAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"),
equalTo(SemanticAttributes.SERVER_PORT, sqsPort),
equalTo(SemanticAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(
SemanticAttributes.MESSAGING_DESTINATION_NAME, "testSdkSqs"),
equalTo(SemanticAttributes.MESSAGING_OPERATION, "receive"),
equalTo(SemanticAttributes.MESSAGING_BATCH_MESSAGE_COUNT, 1),
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1")));
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
"testSdkSqs"),
equalTo(
MessagingIncubatingAttributes.MESSAGING_OPERATION, "receive"),
equalTo(
MessagingIncubatingAttributes.MESSAGING_BATCH_MESSAGE_COUNT,
1),
equalTo(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1")));
if (testCaptureHeaders) {
attributes.add(
@ -223,23 +234,25 @@ public abstract class AbstractSqsTracingTest {
equalTo(
stringKey("aws.queue.url"),
"http://localhost:" + sqsPort + "/000000000000/testSdkSqs"),
equalTo(SemanticAttributes.RPC_SYSTEM, "aws-api"),
equalTo(SemanticAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(SemanticAttributes.RPC_METHOD, "ReceiveMessage"),
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "aws-api"),
equalTo(RpcIncubatingAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(RpcIncubatingAttributes.RPC_METHOD, "ReceiveMessage"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(UrlAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
equalTo(
SemanticAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"),
equalTo(SemanticAttributes.SERVER_PORT, sqsPort),
equalTo(SemanticAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(
SemanticAttributes.MESSAGING_DESTINATION_NAME, "testSdkSqs"),
equalTo(SemanticAttributes.MESSAGING_OPERATION, "process"),
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
"testSdkSqs"),
equalTo(
MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"),
satisfies(
SemanticAttributes.MESSAGING_MESSAGE_ID,
MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID,
val -> val.isInstanceOf(String.class)),
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1")));
equalTo(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1")));
if (testCaptureHeaders) {
attributes.add(
@ -290,15 +303,15 @@ public abstract class AbstractSqsTracingTest {
equalTo(stringKey("aws.agent"), "java-aws-sdk"),
equalTo(stringKey("aws.endpoint"), "http://localhost:" + sqsPort),
equalTo(stringKey("aws.queue.name"), "testSdkSqs"),
equalTo(SemanticAttributes.RPC_SYSTEM, "aws-api"),
equalTo(SemanticAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(SemanticAttributes.RPC_METHOD, "CreateQueue"),
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(SemanticAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"),
equalTo(SemanticAttributes.SERVER_PORT, sqsPort),
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1"))),
equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "aws-api"),
equalTo(RpcIncubatingAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(RpcIncubatingAttributes.RPC_METHOD, "CreateQueue"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(UrlAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
equalTo(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"))),
trace ->
trace.hasSpansSatisfyingExactly(
span ->
@ -311,22 +324,25 @@ public abstract class AbstractSqsTracingTest {
equalTo(
stringKey("aws.queue.url"),
"http://localhost:" + sqsPort + "/000000000000/testSdkSqs"),
equalTo(SemanticAttributes.RPC_SYSTEM, "aws-api"),
equalTo(SemanticAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(SemanticAttributes.RPC_METHOD, "SendMessage"),
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(SemanticAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"),
equalTo(SemanticAttributes.SERVER_PORT, sqsPort),
equalTo(SemanticAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "aws-api"),
equalTo(RpcIncubatingAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(RpcIncubatingAttributes.RPC_METHOD, "SendMessage"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(UrlAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
equalTo(
SemanticAttributes.MESSAGING_DESTINATION_NAME, "testSdkSqs"),
equalTo(SemanticAttributes.MESSAGING_OPERATION, "publish"),
MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
equalTo(
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
"testSdkSqs"),
equalTo(
MessagingIncubatingAttributes.MESSAGING_OPERATION, "publish"),
satisfies(
SemanticAttributes.MESSAGING_MESSAGE_ID,
MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID,
val -> val.isInstanceOf(String.class)),
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1"))),
equalTo(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"))),
trace -> {
AtomicReference<SpanData> receiveSpan = new AtomicReference<>();
AtomicReference<SpanData> processSpan = new AtomicReference<>();
@ -351,17 +367,16 @@ public abstract class AbstractSqsTracingTest {
"http://localhost:"
+ sqsPort
+ "/000000000000/testSdkSqs"),
equalTo(SemanticAttributes.RPC_SYSTEM, "aws-api"),
equalTo(SemanticAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(SemanticAttributes.RPC_METHOD, "ReceiveMessage"),
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "aws-api"),
equalTo(RpcIncubatingAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(RpcIncubatingAttributes.RPC_METHOD, "ReceiveMessage"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(
SemanticAttributes.URL_FULL,
"http://localhost:" + sqsPort),
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"),
equalTo(SemanticAttributes.SERVER_PORT, sqsPort),
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1")),
UrlAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
equalTo(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1")),
span ->
span.hasName("testSdkSqs receive")
.hasKind(SpanKind.CONSUMER)
@ -375,23 +390,29 @@ public abstract class AbstractSqsTracingTest {
"http://localhost:"
+ sqsPort
+ "/000000000000/testSdkSqs"),
equalTo(SemanticAttributes.RPC_SYSTEM, "aws-api"),
equalTo(SemanticAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(SemanticAttributes.RPC_METHOD, "ReceiveMessage"),
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "aws-api"),
equalTo(RpcIncubatingAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(RpcIncubatingAttributes.RPC_METHOD, "ReceiveMessage"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(
SemanticAttributes.URL_FULL,
"http://localhost:" + sqsPort),
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"),
equalTo(SemanticAttributes.SERVER_PORT, sqsPort),
equalTo(SemanticAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
UrlAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
equalTo(
SemanticAttributes.MESSAGING_DESTINATION_NAME,
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
"AmazonSQS"),
equalTo(
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
"testSdkSqs"),
equalTo(SemanticAttributes.MESSAGING_OPERATION, "receive"),
equalTo(SemanticAttributes.MESSAGING_BATCH_MESSAGE_COUNT, 1),
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1")),
equalTo(
MessagingIncubatingAttributes.MESSAGING_OPERATION,
"receive"),
equalTo(
MessagingIncubatingAttributes
.MESSAGING_BATCH_MESSAGE_COUNT,
1),
equalTo(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1")),
span ->
span.hasName("testSdkSqs process")
.hasKind(SpanKind.CONSUMER)
@ -405,25 +426,28 @@ public abstract class AbstractSqsTracingTest {
"http://localhost:"
+ sqsPort
+ "/000000000000/testSdkSqs"),
equalTo(SemanticAttributes.RPC_SYSTEM, "aws-api"),
equalTo(SemanticAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(SemanticAttributes.RPC_METHOD, "ReceiveMessage"),
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "aws-api"),
equalTo(RpcIncubatingAttributes.RPC_SERVICE, "AmazonSQS"),
equalTo(RpcIncubatingAttributes.RPC_METHOD, "ReceiveMessage"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
equalTo(
SemanticAttributes.URL_FULL,
"http://localhost:" + sqsPort),
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"),
equalTo(SemanticAttributes.SERVER_PORT, sqsPort),
equalTo(SemanticAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
UrlAttributes.URL_FULL, "http://localhost:" + sqsPort),
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
equalTo(
SemanticAttributes.MESSAGING_DESTINATION_NAME,
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
"AmazonSQS"),
equalTo(
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
"testSdkSqs"),
equalTo(SemanticAttributes.MESSAGING_OPERATION, "process"),
equalTo(
MessagingIncubatingAttributes.MESSAGING_OPERATION,
"process"),
satisfies(
SemanticAttributes.MESSAGING_MESSAGE_ID,
MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID,
val -> val.isInstanceOf(String.class)),
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1")),
equalTo(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1")),
span ->
span.hasName("process child")
.hasParent(processSpan.get())

View File

@ -7,7 +7,7 @@ package io.opentelemetry.instrumentation.awssdk.v2_2;
import static io.opentelemetry.instrumentation.awssdk.v2_2.FieldMapping.request;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -21,8 +21,8 @@ enum AwsSdkRequestType {
/*
* Only one of TopicArn and TargetArn are permitted on an SNS request.
*/
request(SemanticAttributes.MESSAGING_DESTINATION_NAME.getKey(), "TargetArn"),
request(SemanticAttributes.MESSAGING_DESTINATION_NAME.getKey(), "TopicArn"));
request(MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME.getKey(), "TargetArn"),
request(MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME.getKey(), "TopicArn"));
// Wrapping in unmodifiableMap
@SuppressWarnings("ImmutableEnumChecker")

View File

@ -17,7 +17,8 @@ import io.opentelemetry.contrib.awsxray.propagator.AwsXrayPropagator;
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.internal.InstrumenterUtil;
import io.opentelemetry.instrumentation.api.internal.Timer;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@ -311,10 +312,10 @@ final class TracingExecutionInterceptor implements ExecutionInterceptor {
fieldMapper.mapToAttributes(sdkRequest, awsSdkRequest, span);
if (awsSdkRequest.type() == DYNAMODB) {
span.setAttribute(SemanticAttributes.DB_SYSTEM, "dynamodb");
span.setAttribute(DbIncubatingAttributes.DB_SYSTEM, "dynamodb");
String operation = attributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME);
if (operation != null) {
span.setAttribute(SemanticAttributes.DB_OPERATION, operation);
span.setAttribute(DbIncubatingAttributes.DB_OPERATION, operation);
}
}
}
@ -381,7 +382,7 @@ final class TracingExecutionInterceptor implements ExecutionInterceptor {
.collect(Collectors.joining("\n"));
Attributes attributes =
Attributes.of(
SemanticAttributes.HTTP_RESPONSE_STATUS_CODE,
HttpAttributes.HTTP_RESPONSE_STATUS_CODE,
Long.valueOf(errorCode),
HTTP_ERROR_MSG,
errorMsg);

View File

@ -7,7 +7,11 @@ package io.opentelemetry.instrumentation.awssdk.v2_2
import io.opentelemetry.instrumentation.api.internal.ConfigPropertiesUtil
import io.opentelemetry.instrumentation.test.InstrumentationSpecification
import io.opentelemetry.semconv.SemanticAttributes
import io.opentelemetry.semconv.incubating.RpcIncubatingAttributes
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes
import io.opentelemetry.semconv.ServerAttributes
import io.opentelemetry.semconv.HttpAttributes
import io.opentelemetry.semconv.UrlAttributes
import io.opentelemetry.testing.internal.armeria.common.HttpResponse
import io.opentelemetry.testing.internal.armeria.common.HttpStatus
import io.opentelemetry.testing.internal.armeria.common.MediaType
@ -133,19 +137,19 @@ abstract class AbstractAws2ClientCoreTest extends InstrumentationSpecification {
kind CLIENT
hasNoParent()
attributes {
"$SemanticAttributes.SERVER_ADDRESS" "127.0.0.1"
"$SemanticAttributes.SERVER_PORT" server.httpPort()
"$SemanticAttributes.URL_FULL" { it.startsWith("${server.httpUri()}${path}") }
"$SemanticAttributes.HTTP_REQUEST_METHOD" "$method"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.RPC_SYSTEM" "aws-api"
"$SemanticAttributes.RPC_SERVICE" "DynamoDb"
"$SemanticAttributes.RPC_METHOD" "CreateTable"
"$ServerAttributes.SERVER_ADDRESS" "127.0.0.1"
"$ServerAttributes.SERVER_PORT" server.httpPort()
"$UrlAttributes.URL_FULL" { it.startsWith("${server.httpUri()}${path}") }
"$HttpAttributes.HTTP_REQUEST_METHOD" "$method"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$RpcIncubatingAttributes.RPC_SYSTEM" "aws-api"
"$RpcIncubatingAttributes.RPC_SERVICE" "DynamoDb"
"$RpcIncubatingAttributes.RPC_METHOD" "CreateTable"
"aws.agent" "java-aws-sdk"
"aws.requestId" "$requestId"
"aws.table.name" "sometable"
"$SemanticAttributes.DB_SYSTEM" "dynamodb"
"$SemanticAttributes.DB_OPERATION" "CreateTable"
"$DbIncubatingAttributes.DB_SYSTEM" "dynamodb"
"$DbIncubatingAttributes.DB_OPERATION" "CreateTable"
"aws.dynamodb.global_secondary_indexes" "[{\"IndexName\":\"globalIndex\",\"KeySchema\":[{\"AttributeName\":\"attribute\"}],\"ProvisionedThroughput\":{\"ReadCapacityUnits\":10,\"WriteCapacityUnits\":12}},{\"IndexName\":\"globalIndexSecondary\",\"KeySchema\":[{\"AttributeName\":\"attributeSecondary\"}],\"ProvisionedThroughput\":{\"ReadCapacityUnits\":7,\"WriteCapacityUnits\":8}}]"
"aws.dynamodb.provisioned_throughput.read_capacity_units" "1"
"aws.dynamodb.provisioned_throughput.write_capacity_units" "1"
@ -166,19 +170,19 @@ abstract class AbstractAws2ClientCoreTest extends InstrumentationSpecification {
kind CLIENT
hasNoParent()
attributes {
"$SemanticAttributes.SERVER_ADDRESS" "127.0.0.1"
"$SemanticAttributes.SERVER_PORT" server.httpPort()
"$SemanticAttributes.URL_FULL" { it.startsWith("${server.httpUri()}${path}") }
"$SemanticAttributes.HTTP_REQUEST_METHOD" "$method"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.RPC_SYSTEM" "aws-api"
"$SemanticAttributes.RPC_SERVICE" "DynamoDb"
"$SemanticAttributes.RPC_METHOD" "Query"
"$ServerAttributes.SERVER_ADDRESS" "127.0.0.1"
"$ServerAttributes.SERVER_PORT" server.httpPort()
"$UrlAttributes.URL_FULL" { it.startsWith("${server.httpUri()}${path}") }
"$HttpAttributes.HTTP_REQUEST_METHOD" "$method"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$RpcIncubatingAttributes.RPC_SYSTEM" "aws-api"
"$RpcIncubatingAttributes.RPC_SERVICE" "DynamoDb"
"$RpcIncubatingAttributes.RPC_METHOD" "Query"
"aws.agent" "java-aws-sdk"
"aws.requestId" "$requestId"
"aws.table.name" "sometable"
"$SemanticAttributes.DB_SYSTEM" "dynamodb"
"$SemanticAttributes.DB_OPERATION" "Query"
"$DbIncubatingAttributes.DB_SYSTEM" "dynamodb"
"$DbIncubatingAttributes.DB_OPERATION" "Query"
"aws.dynamodb.limit" "10"
"aws.dynamodb.select" "ALL_ATTRIBUTES"
}
@ -198,19 +202,19 @@ abstract class AbstractAws2ClientCoreTest extends InstrumentationSpecification {
kind CLIENT
hasNoParent()
attributes {
"$SemanticAttributes.SERVER_ADDRESS" "127.0.0.1"
"$SemanticAttributes.SERVER_PORT" server.httpPort()
"$SemanticAttributes.URL_FULL" { it.startsWith("${server.httpUri()}${path}") }
"$SemanticAttributes.HTTP_REQUEST_METHOD" "$method"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.RPC_SYSTEM" "aws-api"
"$SemanticAttributes.RPC_SERVICE" "$service"
"$SemanticAttributes.RPC_METHOD" "${operation}"
"$ServerAttributes.SERVER_ADDRESS" "127.0.0.1"
"$ServerAttributes.SERVER_PORT" server.httpPort()
"$UrlAttributes.URL_FULL" { it.startsWith("${server.httpUri()}${path}") }
"$HttpAttributes.HTTP_REQUEST_METHOD" "$method"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$RpcIncubatingAttributes.RPC_SYSTEM" "aws-api"
"$RpcIncubatingAttributes.RPC_SERVICE" "$service"
"$RpcIncubatingAttributes.RPC_METHOD" "${operation}"
"aws.agent" "java-aws-sdk"
"aws.requestId" "$requestId"
"aws.table.name" "sometable"
"$SemanticAttributes.DB_SYSTEM" "dynamodb"
"$SemanticAttributes.DB_OPERATION" "${operation}"
"$DbIncubatingAttributes.DB_SYSTEM" "dynamodb"
"$DbIncubatingAttributes.DB_OPERATION" "${operation}"
}
}
}

View File

@ -6,7 +6,11 @@
package io.opentelemetry.instrumentation.awssdk.v2_2
import io.opentelemetry.semconv.SemanticAttributes
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes
import io.opentelemetry.semconv.incubating.RpcIncubatingAttributes
import io.opentelemetry.semconv.ServerAttributes
import io.opentelemetry.semconv.HttpAttributes
import io.opentelemetry.semconv.UrlAttributes
import io.opentelemetry.testing.internal.armeria.common.HttpData
import io.opentelemetry.testing.internal.armeria.common.HttpResponse
import io.opentelemetry.testing.internal.armeria.common.HttpStatus
@ -118,18 +122,18 @@ abstract class AbstractAws2ClientTest extends AbstractAws2ClientCoreTest {
// the bucket name is a valid DNS label, even in the case that we are using an endpoint override.
// Previously the sdk was only doing that if endpoint had "s3" as label in the FQDN.
// Our test assert both cases so that we don't need to know what version is being tested.
"$SemanticAttributes.SERVER_ADDRESS" { it == "somebucket.localhost" || it == "localhost" }
"$SemanticAttributes.URL_FULL" { it.startsWith("http://somebucket.localhost:${server.httpPort()}") || it.startsWith("http://localhost:${server.httpPort()}/somebucket") }
"$ServerAttributes.SERVER_ADDRESS" { it == "somebucket.localhost" || it == "localhost" }
"$UrlAttributes.URL_FULL" { it.startsWith("http://somebucket.localhost:${server.httpPort()}") || it.startsWith("http://localhost:${server.httpPort()}/somebucket") }
} else {
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.URL_FULL" { it.startsWith("http://localhost:${server.httpPort()}") }
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:${server.httpPort()}") }
}
"$SemanticAttributes.SERVER_PORT" server.httpPort()
"$SemanticAttributes.HTTP_REQUEST_METHOD" "$method"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.RPC_SYSTEM" "aws-api"
"$SemanticAttributes.RPC_SERVICE" "$service"
"$SemanticAttributes.RPC_METHOD" "${operation}"
"$ServerAttributes.SERVER_PORT" server.httpPort()
"$HttpAttributes.HTTP_REQUEST_METHOD" "$method"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$RpcIncubatingAttributes.RPC_SYSTEM" "aws-api"
"$RpcIncubatingAttributes.RPC_SERVICE" "$service"
"$RpcIncubatingAttributes.RPC_METHOD" "${operation}"
"aws.agent" "java-aws-sdk"
"aws.requestId" "$requestId"
if (service == "S3") {
@ -138,14 +142,14 @@ abstract class AbstractAws2ClientTest extends AbstractAws2ClientCoreTest {
"aws.queue.name" "somequeue"
} else if (service == "Sqs" && operation == "SendMessage") {
"aws.queue.url" QUEUE_URL
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" "somequeue"
"$SemanticAttributes.MESSAGING_OPERATION" "publish"
"$SemanticAttributes.MESSAGING_MESSAGE_ID" String
"$SemanticAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "somequeue"
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "publish"
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
} else if (service == "Kinesis") {
"aws.stream.name" "somestream"
} else if (service == "Sns") {
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" "somearn"
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "somearn"
}
}
}
@ -278,18 +282,18 @@ abstract class AbstractAws2ClientTest extends AbstractAws2ClientCoreTest {
// the bucket name is a valid DNS label, even in the case that we are using an endpoint override.
// Previously the sdk was only doing that if endpoint had "s3" as label in the FQDN.
// Our test assert both cases so that we don't need to know what version is being tested.
"$SemanticAttributes.SERVER_ADDRESS" { it == "somebucket.localhost" || it == "localhost" }
"$SemanticAttributes.URL_FULL" { it.startsWith("http://somebucket.localhost:${server.httpPort()}") || it.startsWith("http://localhost:${server.httpPort()}") }
"$ServerAttributes.SERVER_ADDRESS" { it == "somebucket.localhost" || it == "localhost" }
"$UrlAttributes.URL_FULL" { it.startsWith("http://somebucket.localhost:${server.httpPort()}") || it.startsWith("http://localhost:${server.httpPort()}") }
} else {
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.URL_FULL" { it == "http://localhost:${server.httpPort()}" || it == "http://localhost:${server.httpPort()}/" }
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$UrlAttributes.URL_FULL" { it == "http://localhost:${server.httpPort()}" || it == "http://localhost:${server.httpPort()}/" }
}
"$SemanticAttributes.SERVER_PORT" server.httpPort()
"$SemanticAttributes.HTTP_REQUEST_METHOD" "$method"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.RPC_SYSTEM" "aws-api"
"$SemanticAttributes.RPC_SERVICE" "$service"
"$SemanticAttributes.RPC_METHOD" "${operation}"
"$ServerAttributes.SERVER_PORT" server.httpPort()
"$HttpAttributes.HTTP_REQUEST_METHOD" "$method"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$RpcIncubatingAttributes.RPC_SYSTEM" "aws-api"
"$RpcIncubatingAttributes.RPC_SERVICE" "$service"
"$RpcIncubatingAttributes.RPC_METHOD" "${operation}"
"aws.agent" "java-aws-sdk"
"aws.requestId" "$requestId"
if (service == "S3") {
@ -298,14 +302,14 @@ abstract class AbstractAws2ClientTest extends AbstractAws2ClientCoreTest {
"aws.queue.name" "somequeue"
} else if (service == "Sqs" && operation == "SendMessage") {
"aws.queue.url" QUEUE_URL
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" "somequeue"
"$SemanticAttributes.MESSAGING_OPERATION" "publish"
"$SemanticAttributes.MESSAGING_MESSAGE_ID" String
"$SemanticAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "somequeue"
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "publish"
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
} else if (service == "Kinesis") {
"aws.stream.name" "somestream"
} else if (service == "Sns") {
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" "somearn"
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "somearn"
}
}
}
@ -446,13 +450,13 @@ abstract class AbstractAws2ClientTest extends AbstractAws2ClientCoreTest {
// the bucket name is a valid DNS label, even in the case that we are using an endpoint override.
// Previously the sdk was only doing that if endpoint had "s3" as label in the FQDN.
// Our test assert both cases so that we don't need to know what version is being tested.
"$SemanticAttributes.SERVER_ADDRESS" { it == "somebucket.localhost" || it == "localhost" }
"$SemanticAttributes.URL_FULL" { it == "http://somebucket.localhost:${server.httpPort()}/somekey" || it == "http://localhost:${server.httpPort()}/somebucket/somekey" }
"$SemanticAttributes.SERVER_PORT" server.httpPort()
"$SemanticAttributes.HTTP_REQUEST_METHOD" "GET"
"$SemanticAttributes.RPC_SYSTEM" "aws-api"
"$SemanticAttributes.RPC_SERVICE" "S3"
"$SemanticAttributes.RPC_METHOD" "GetObject"
"$ServerAttributes.SERVER_ADDRESS" { it == "somebucket.localhost" || it == "localhost" }
"$UrlAttributes.URL_FULL" { it == "http://somebucket.localhost:${server.httpPort()}/somekey" || it == "http://localhost:${server.httpPort()}/somebucket/somekey" }
"$ServerAttributes.SERVER_PORT" server.httpPort()
"$HttpAttributes.HTTP_REQUEST_METHOD" "GET"
"$RpcIncubatingAttributes.RPC_SYSTEM" "aws-api"
"$RpcIncubatingAttributes.RPC_SERVICE" "S3"
"$RpcIncubatingAttributes.RPC_METHOD" "GetObject"
"aws.agent" "java-aws-sdk"
"aws.bucket.name" "somebucket"
}

View File

@ -6,7 +6,10 @@
package io.opentelemetry.instrumentation.awssdk.v2_2
import io.opentelemetry.instrumentation.test.InstrumentationSpecification
import io.opentelemetry.semconv.SemanticAttributes
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes
import io.opentelemetry.semconv.ServerAttributes
import io.opentelemetry.semconv.HttpAttributes
import io.opentelemetry.semconv.UrlAttributes
import org.elasticmq.rest.sqs.SQSRestServerBuilder
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider
@ -129,11 +132,11 @@ abstract class AbstractAws2SqsSuppressReceiveSpansTest extends InstrumentationSp
"rpc.system" "aws-api"
"rpc.service" "Sqs"
"rpc.method" "CreateQueue"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.SERVER_PORT" sqsPort
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$ServerAttributes.SERVER_PORT" sqsPort
}
}
}
@ -149,15 +152,15 @@ abstract class AbstractAws2SqsSuppressReceiveSpansTest extends InstrumentationSp
"rpc.system" "aws-api"
"rpc.method" "SendMessage"
"rpc.service" "Sqs"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.SERVER_PORT" sqsPort
"$SemanticAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
"$SemanticAttributes.MESSAGING_OPERATION" "publish"
"$SemanticAttributes.MESSAGING_MESSAGE_ID" String
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$ServerAttributes.SERVER_PORT" sqsPort
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "publish"
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
}
}
span(1) {
@ -170,15 +173,15 @@ abstract class AbstractAws2SqsSuppressReceiveSpansTest extends InstrumentationSp
"rpc.method" "ReceiveMessage"
"rpc.system" "aws-api"
"rpc.service" "Sqs"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.SERVER_PORT" sqsPort
"$SemanticAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
"$SemanticAttributes.MESSAGING_OPERATION" "process"
"$SemanticAttributes.MESSAGING_MESSAGE_ID" String
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$ServerAttributes.SERVER_PORT" sqsPort
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "process"
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
}
}
span(2) {
@ -210,11 +213,11 @@ abstract class AbstractAws2SqsSuppressReceiveSpansTest extends InstrumentationSp
"aws.queue.url" "http://localhost:$sqsPort/000000000000/testSdkSqs"
"rpc.system" "aws-api"
"rpc.service" "Sqs"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.SERVER_PORT" sqsPort
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$ServerAttributes.SERVER_PORT" sqsPort
}
}
}
@ -321,14 +324,14 @@ abstract class AbstractAws2SqsSuppressReceiveSpansTest extends InstrumentationSp
"rpc.system" "aws-api"
"rpc.method" "SendMessageBatch"
"rpc.service" "Sqs"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.SERVER_PORT" sqsPort
"$SemanticAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
"$SemanticAttributes.MESSAGING_OPERATION" "publish"
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$ServerAttributes.SERVER_PORT" sqsPort
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "publish"
}
}
for (int i: 1..(xrayInjectionEnabled ? 3 : 2)) {
@ -343,15 +346,15 @@ abstract class AbstractAws2SqsSuppressReceiveSpansTest extends InstrumentationSp
"rpc.method" "ReceiveMessage"
"rpc.system" "aws-api"
"rpc.service" "Sqs"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.SERVER_PORT" sqsPort
"$SemanticAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
"$SemanticAttributes.MESSAGING_OPERATION" "process"
"$SemanticAttributes.MESSAGING_MESSAGE_ID" String
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$ServerAttributes.SERVER_PORT" sqsPort
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "process"
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
}
}
}
@ -371,15 +374,15 @@ abstract class AbstractAws2SqsSuppressReceiveSpansTest extends InstrumentationSp
"rpc.method" "ReceiveMessage"
"rpc.system" "aws-api"
"rpc.service" "Sqs"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.SERVER_PORT" sqsPort
"$SemanticAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
"$SemanticAttributes.MESSAGING_OPERATION" "process"
"$SemanticAttributes.MESSAGING_MESSAGE_ID" String
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$ServerAttributes.SERVER_PORT" sqsPort
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "process"
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
}
}
}

View File

@ -7,7 +7,10 @@ package io.opentelemetry.instrumentation.awssdk.v2_2
import io.opentelemetry.instrumentation.test.InstrumentationSpecification
import io.opentelemetry.sdk.trace.data.SpanData
import io.opentelemetry.semconv.SemanticAttributes
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes
import io.opentelemetry.semconv.ServerAttributes
import io.opentelemetry.semconv.HttpAttributes
import io.opentelemetry.semconv.UrlAttributes
import org.elasticmq.rest.sqs.SQSRestServerBuilder
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider
@ -131,11 +134,11 @@ abstract class AbstractAws2SqsTracingTest extends InstrumentationSpecification {
"rpc.system" "aws-api"
"rpc.service" "Sqs"
"rpc.method" "CreateQueue"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.SERVER_PORT" sqsPort
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$ServerAttributes.SERVER_PORT" sqsPort
}
}
}
@ -151,15 +154,15 @@ abstract class AbstractAws2SqsTracingTest extends InstrumentationSpecification {
"rpc.system" "aws-api"
"rpc.method" "SendMessage"
"rpc.service" "Sqs"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.SERVER_PORT" sqsPort
"$SemanticAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
"$SemanticAttributes.MESSAGING_OPERATION" "publish"
"$SemanticAttributes.MESSAGING_MESSAGE_ID" String
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$ServerAttributes.SERVER_PORT" sqsPort
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "publish"
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
if (captureHeaders) {
"messaging.header.test_message_header" { it == ["test"] }
}
@ -190,11 +193,11 @@ abstract class AbstractAws2SqsTracingTest extends InstrumentationSpecification {
"aws.queue.url" "http://localhost:$sqsPort/000000000000/testSdkSqs"
"rpc.system" "aws-api"
"rpc.service" "Sqs"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.SERVER_PORT" sqsPort
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$ServerAttributes.SERVER_PORT" sqsPort
}
}
}
@ -212,15 +215,15 @@ abstract class AbstractAws2SqsTracingTest extends InstrumentationSpecification {
"rpc.method" "ReceiveMessage"
"rpc.system" "aws-api"
"rpc.service" "Sqs"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.SERVER_PORT" sqsPort
"$SemanticAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
"$SemanticAttributes.MESSAGING_OPERATION" "receive"
"$SemanticAttributes.MESSAGING_BATCH_MESSAGE_COUNT" 1
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$ServerAttributes.SERVER_PORT" sqsPort
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "receive"
"$MessagingIncubatingAttributes.MESSAGING_BATCH_MESSAGE_COUNT" 1
if (captureHeaders) {
"messaging.header.test_message_header" { it == ["test"] }
}
@ -236,15 +239,15 @@ abstract class AbstractAws2SqsTracingTest extends InstrumentationSpecification {
"rpc.method" "ReceiveMessage"
"rpc.system" "aws-api"
"rpc.service" "Sqs"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.SERVER_PORT" sqsPort
"$SemanticAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
"$SemanticAttributes.MESSAGING_OPERATION" "process"
"$SemanticAttributes.MESSAGING_MESSAGE_ID" String
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$ServerAttributes.SERVER_PORT" sqsPort
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "process"
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
if (captureHeaders) {
"messaging.header.test_message_header" { it == ["test"] }
}
@ -387,14 +390,14 @@ abstract class AbstractAws2SqsTracingTest extends InstrumentationSpecification {
"rpc.system" "aws-api"
"rpc.method" "SendMessageBatch"
"rpc.service" "Sqs"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.SERVER_PORT" sqsPort
"$SemanticAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
"$SemanticAttributes.MESSAGING_OPERATION" "publish"
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$ServerAttributes.SERVER_PORT" sqsPort
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "publish"
}
}
publishSpan = span(0)
@ -411,15 +414,15 @@ abstract class AbstractAws2SqsTracingTest extends InstrumentationSpecification {
"rpc.method" "ReceiveMessage"
"rpc.system" "aws-api"
"rpc.service" "Sqs"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.SERVER_PORT" sqsPort
"$SemanticAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
"$SemanticAttributes.MESSAGING_OPERATION" "receive"
"$SemanticAttributes.MESSAGING_BATCH_MESSAGE_COUNT" 3
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$ServerAttributes.SERVER_PORT" sqsPort
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "receive"
"$MessagingIncubatingAttributes.MESSAGING_BATCH_MESSAGE_COUNT" 3
}
}
if (!xrayInjectionEnabled) {
@ -450,15 +453,15 @@ abstract class AbstractAws2SqsTracingTest extends InstrumentationSpecification {
"rpc.method" "ReceiveMessage"
"rpc.system" "aws-api"
"rpc.service" "Sqs"
"$SemanticAttributes.HTTP_REQUEST_METHOD" "POST"
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$SemanticAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
"$SemanticAttributes.SERVER_PORT" sqsPort
"$SemanticAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$SemanticAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
"$SemanticAttributes.MESSAGING_OPERATION" "process"
"$SemanticAttributes.MESSAGING_MESSAGE_ID" String
"$HttpAttributes.HTTP_REQUEST_METHOD" "POST"
"$HttpAttributes.HTTP_RESPONSE_STATUS_CODE" 200
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
"$ServerAttributes.SERVER_ADDRESS" "localhost"
"$ServerAttributes.SERVER_PORT" sqsPort
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "process"
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
}
}
span(1 + 2*i + 1) {

View File

@ -12,7 +12,10 @@ import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.api.internal.ConfigPropertiesUtil;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
import io.opentelemetry.semconv.incubating.RpcIncubatingAttributes;
import io.opentelemetry.testing.internal.armeria.common.HttpResponse;
import io.opentelemetry.testing.internal.armeria.common.HttpStatus;
import io.opentelemetry.testing.internal.armeria.common.MediaType;
@ -163,18 +166,18 @@ public abstract class AbstractAws2ClientRecordHttpErrorTest {
span.hasAttributesSatisfying(
attributes -> {
assertThat(attributes)
.containsEntry(SemanticAttributes.SERVER_ADDRESS, "127.0.0.1")
.containsEntry(SemanticAttributes.SERVER_PORT, server.httpPort())
.containsEntry(SemanticAttributes.HTTP_REQUEST_METHOD, method)
.containsEntry(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200)
.containsEntry(SemanticAttributes.RPC_SYSTEM, "aws-api")
.containsEntry(SemanticAttributes.RPC_SERVICE, service)
.containsEntry(SemanticAttributes.RPC_METHOD, operation)
.containsEntry(ServerAttributes.SERVER_ADDRESS, "127.0.0.1")
.containsEntry(ServerAttributes.SERVER_PORT, server.httpPort())
.containsEntry(HttpAttributes.HTTP_REQUEST_METHOD, method)
.containsEntry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200)
.containsEntry(RpcIncubatingAttributes.RPC_SYSTEM, "aws-api")
.containsEntry(RpcIncubatingAttributes.RPC_SERVICE, service)
.containsEntry(RpcIncubatingAttributes.RPC_METHOD, operation)
.containsEntry("aws.agent", "java-aws-sdk")
.containsEntry("aws.requestId", requestId)
.containsEntry("aws.table.name", "sometable")
.containsEntry(SemanticAttributes.DB_SYSTEM, "dynamodb")
.containsEntry(SemanticAttributes.DB_OPERATION, operation);
.containsEntry(DbIncubatingAttributes.DB_SYSTEM, "dynamodb")
.containsEntry(DbIncubatingAttributes.DB_OPERATION, operation);
});
if (isRecordIndividualHttpErrorEnabled()) {
span.hasEventsSatisfyingExactly(
@ -182,7 +185,7 @@ public abstract class AbstractAws2ClientRecordHttpErrorTest {
event
.hasName("HTTP request failure")
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 500),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 500),
equalTo(
AttributeKey.stringKey("aws.http.error_message"),
"DynamoDB could not process your request")),
@ -190,7 +193,7 @@ public abstract class AbstractAws2ClientRecordHttpErrorTest {
event
.hasName("HTTP request failure")
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 503),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 503),
equalTo(
AttributeKey.stringKey("aws.http.error_message"),
"DynamoDB is currently unavailable")));

View File

@ -6,7 +6,7 @@
package io.opentelemetry.instrumentation.awssdk.v2_2;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
import static io.opentelemetry.semconv.SemanticAttributes.URL_FULL;
import static io.opentelemetry.semconv.UrlAttributes.URL_FULL;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;

View File

@ -27,7 +27,7 @@ import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlStatementSanitizer;
import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig;
import io.opentelemetry.javaagent.instrumentation.apachecamel.CamelDirection;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
import java.net.URI;
import java.util.Map;
import org.apache.camel.Endpoint;
@ -122,14 +122,14 @@ class DbSpanDecorator extends BaseSpanDecorator {
CamelDirection camelDirection) {
super.pre(attributes, exchange, endpoint, camelDirection);
attributes.put(SemanticAttributes.DB_SYSTEM, system);
attributes.put(DbIncubatingAttributes.DB_SYSTEM, system);
String statement = getStatement(exchange, endpoint);
if (statement != null) {
attributes.put(SemanticAttributes.DB_STATEMENT, statement);
attributes.put(DbIncubatingAttributes.DB_STATEMENT, statement);
}
String dbName = getDbName(endpoint);
if (dbName != null) {
attributes.put(SemanticAttributes.DB_NAME, dbName);
attributes.put(DbIncubatingAttributes.DB_NAME, dbName);
}
}
}

View File

@ -6,7 +6,7 @@
package io.opentelemetry.javaagent.instrumentation.apachecamel.decorators;
import io.opentelemetry.javaagent.instrumentation.apachecamel.SpanDecorator;
import io.opentelemetry.semconv.SemanticAttributes.DbSystemValues;
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
import java.util.HashMap;
import java.util.Map;
@ -25,7 +25,7 @@ public class DecoratorRegistry {
result.put("aws-sqs", new MessagingSpanDecorator("aws-sqs"));
result.put("cometd", new MessagingSpanDecorator("cometd"));
result.put("cometds", new MessagingSpanDecorator("cometds"));
result.put("cql", new DbSpanDecorator("cql", DbSystemValues.CASSANDRA));
result.put("cql", new DbSpanDecorator("cql", DbIncubatingAttributes.DbSystemValues.CASSANDRA));
result.put("direct", new InternalSpanDecorator());
result.put("direct-vm", new InternalSpanDecorator());
result.put("disruptor", new InternalSpanDecorator());
@ -36,12 +36,14 @@ public class DecoratorRegistry {
result.put("https4", new Https4SpanDecorator());
result.put("http", new HttpSpanDecorator());
result.put("ironmq", new MessagingSpanDecorator("ironmq"));
result.put("jdbc", new DbSpanDecorator("jdbc", DbSystemValues.OTHER_SQL));
result.put(
"jdbc", new DbSpanDecorator("jdbc", DbIncubatingAttributes.DbSystemValues.OTHER_SQL));
result.put("jetty", new HttpSpanDecorator());
result.put("jms", new MessagingSpanDecorator("jms"));
result.put("kafka", new KafkaSpanDecorator());
result.put("log", new LogSpanDecorator());
result.put("mongodb", new DbSpanDecorator("mongodb", DbSystemValues.MONGODB));
result.put(
"mongodb", new DbSpanDecorator("mongodb", DbIncubatingAttributes.DbSystemValues.MONGODB));
result.put("mqtt", new MessagingSpanDecorator("mqtt"));
result.put("netty-http4", new HttpSpanDecorator());
result.put("netty-http", new HttpSpanDecorator());
@ -52,7 +54,7 @@ public class DecoratorRegistry {
result.put("seda", new InternalSpanDecorator());
result.put("servlet", new HttpSpanDecorator());
result.put("sjms", new MessagingSpanDecorator("sjms"));
result.put("sql", new DbSpanDecorator("sql", DbSystemValues.OTHER_SQL));
result.put("sql", new DbSpanDecorator("sql", DbIncubatingAttributes.DbSystemValues.OTHER_SQL));
result.put("stomp", new MessagingSpanDecorator("stomp"));
result.put("timer", new TimerSpanDecorator());
result.put("undertow", new HttpSpanDecorator());

View File

@ -32,7 +32,8 @@ import io.opentelemetry.instrumentation.api.semconv.http.HttpServerRoute;
import io.opentelemetry.instrumentation.api.semconv.http.HttpServerRouteSource;
import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig;
import io.opentelemetry.javaagent.instrumentation.apachecamel.CamelDirection;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Set;
@ -95,14 +96,14 @@ class HttpSpanDecorator extends BaseSpanDecorator {
CamelDirection camelDirection) {
super.pre(attributes, exchange, endpoint, camelDirection);
internalSet(attributes, SemanticAttributes.URL_FULL, getHttpUrl(exchange, endpoint));
internalSet(attributes, UrlAttributes.URL_FULL, getHttpUrl(exchange, endpoint));
String method = getHttpMethod(exchange, endpoint);
if (method == null || knownMethods.contains(method)) {
internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD, method);
internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD, method);
} else {
internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD, _OTHER);
internalSet(attributes, SemanticAttributes.HTTP_REQUEST_METHOD_ORIGINAL, method);
internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD, _OTHER);
internalSet(attributes, HttpAttributes.HTTP_REQUEST_METHOD_ORIGINAL, method);
}
}
@ -165,7 +166,7 @@ class HttpSpanDecorator extends BaseSpanDecorator {
if (exchange.hasOut()) {
Object responseCode = exchange.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE);
if (responseCode instanceof Integer) {
attributes.put(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, (Integer) responseCode);
attributes.put(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, (Integer) responseCode);
}
}
}

View File

@ -25,7 +25,7 @@ package io.opentelemetry.javaagent.instrumentation.apachecamel.decorators;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.javaagent.instrumentation.apachecamel.CamelDirection;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
import java.util.Map;
import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
@ -52,6 +52,8 @@ class KafkaSpanDecorator extends MessagingSpanDecorator {
return topic != null ? topic : super.getDestination(exchange, endpoint);
}
@SuppressWarnings("deprecation") // TODO
// MessagingIncubatingAttributes.MESSAGING_KAFKA_DESTINATION_PARTITION deprecation
@Override
public void pre(
AttributesBuilder attributes,
@ -60,11 +62,12 @@ class KafkaSpanDecorator extends MessagingSpanDecorator {
CamelDirection camelDirection) {
super.pre(attributes, exchange, endpoint, camelDirection);
attributes.put(SemanticAttributes.MESSAGING_OPERATION, "process");
attributes.put(MessagingIncubatingAttributes.MESSAGING_OPERATION, "process");
Integer partition = exchange.getIn().getHeader(PARTITION, Integer.class);
if (partition != null) {
attributes.put(SemanticAttributes.MESSAGING_KAFKA_DESTINATION_PARTITION, partition);
attributes.put(
MessagingIncubatingAttributes.MESSAGING_KAFKA_DESTINATION_PARTITION, partition);
}
if (CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES) {

View File

@ -26,7 +26,7 @@ package io.opentelemetry.javaagent.instrumentation.apachecamel.decorators;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.javaagent.instrumentation.apachecamel.CamelDirection;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
import java.net.URI;
import java.util.Map;
import org.apache.camel.Endpoint;
@ -59,11 +59,12 @@ class MessagingSpanDecorator extends BaseSpanDecorator {
super.pre(attributes, exchange, endpoint, camelDirection);
attributes.put(
SemanticAttributes.MESSAGING_DESTINATION_NAME, getDestination(exchange, endpoint));
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
getDestination(exchange, endpoint));
String messageId = getMessageId(exchange);
if (messageId != null) {
attributes.put(SemanticAttributes.MESSAGING_MESSAGE_ID, messageId);
attributes.put(MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID, messageId);
}
}

View File

@ -11,11 +11,15 @@ import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satis
import com.google.common.collect.ImmutableMap;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.api.semconv.network.internal.NetworkAttributes;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerUsingTest;
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerInstrumentationExtension;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.ClientAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import io.opentelemetry.semconv.UserAgentAttributes;
import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
import org.junit.jupiter.api.AfterAll;
@ -91,25 +95,25 @@ class RestCamelTest extends AbstractHttpServerUsingTest<ConfigurableApplicationC
equalTo(
stringKey("camel.uri"),
"rest://get:api/%7Bmodule%7D/unit/%7BunitId%7D"),
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200L)),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L)),
span ->
span.hasName("GET /api/{module}/unit/{unitId}")
.hasKind(SpanKind.SERVER)
.hasParent(trace.getSpan(1))
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.URL_SCHEME, "http"),
equalTo(SemanticAttributes.URL_PATH, "/api/firstModule/unit/unitOne"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200L),
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(SemanticAttributes.HTTP_ROUTE, "/api/{module}/unit/{unitId}"),
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1"),
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"),
equalTo(SemanticAttributes.SERVER_PORT, Long.valueOf(port)),
equalTo(SemanticAttributes.CLIENT_ADDRESS, "127.0.0.1"),
equalTo(UrlAttributes.URL_SCHEME, "http"),
equalTo(UrlAttributes.URL_PATH, "/api/firstModule/unit/unitOne"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(HttpAttributes.HTTP_ROUTE, "/api/{module}/unit/{unitId}"),
equalTo(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"),
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
equalTo(ServerAttributes.SERVER_PORT, Long.valueOf(port)),
equalTo(ClientAttributes.CLIENT_ADDRESS, "127.0.0.1"),
equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, "127.0.0.1"),
satisfies(
SemanticAttributes.USER_AGENT_ORIGINAL,
UserAgentAttributes.USER_AGENT_ORIGINAL,
val -> val.isInstanceOf(String.class)),
satisfies(
NetworkAttributes.NETWORK_PEER_PORT,
@ -119,9 +123,9 @@ class RestCamelTest extends AbstractHttpServerUsingTest<ConfigurableApplicationC
.hasKind(SpanKind.INTERNAL)
.hasParent(trace.getSpan(2))
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "GET"),
equalTo(
SemanticAttributes.URL_FULL,
UrlAttributes.URL_FULL,
"http://localhost:" + port + "/api/firstModule/unit/unitOne"),
satisfies(
stringKey("camel.uri"), val -> val.isInstanceOf(String.class))),

View File

@ -13,7 +13,8 @@ import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerUsingTest;
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerInstrumentationExtension;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import java.net.URI;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
@ -68,8 +69,8 @@ class SingleServiceCamelTest extends AbstractHttpServerUsingTest<ConfigurableApp
span.hasName("POST /camelService")
.hasKind(SpanKind.SERVER)
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(SemanticAttributes.URL_FULL, requestUrl.toString()),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(UrlAttributes.URL_FULL, requestUrl.toString()),
equalTo(
stringKey("camel.uri"),
requestUrl.toString().replace("localhost", "0.0.0.0")))));

View File

@ -11,12 +11,16 @@ import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satis
import com.google.common.collect.ImmutableMap;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.api.semconv.network.internal.NetworkAttributes;
import io.opentelemetry.instrumentation.test.utils.PortUtils;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerUsingTest;
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerInstrumentationExtension;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.ClientAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import io.opentelemetry.semconv.UserAgentAttributes;
import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
@ -107,11 +111,11 @@ class TwoServicesWithDirectClientCamelTest
.hasKind(SpanKind.CLIENT)
.hasParent(trace.getSpan(0))
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(
SemanticAttributes.URL_FULL,
UrlAttributes.URL_FULL,
"http://localhost:" + portOne + "/serviceOne"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200L),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L),
equalTo(
stringKey("camel.uri"),
"http://localhost:" + portOne + "/serviceOne")),
@ -120,11 +124,11 @@ class TwoServicesWithDirectClientCamelTest
.hasKind(SpanKind.SERVER)
.hasParent(trace.getSpan(1))
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(
SemanticAttributes.URL_FULL,
UrlAttributes.URL_FULL,
"http://localhost:" + portOne + "/serviceOne"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200L),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L),
equalTo(
stringKey("camel.uri"),
"http://0.0.0.0:" + portOne + "/serviceOne")),
@ -133,11 +137,11 @@ class TwoServicesWithDirectClientCamelTest
.hasKind(SpanKind.CLIENT)
.hasParent(trace.getSpan(2))
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(
SemanticAttributes.URL_FULL,
UrlAttributes.URL_FULL,
"http://127.0.0.1:" + portTwo + "/serviceTwo"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200L),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L),
equalTo(
stringKey("camel.uri"),
"http://127.0.0.1:" + portTwo + "/serviceTwo")),
@ -146,18 +150,18 @@ class TwoServicesWithDirectClientCamelTest
.hasKind(SpanKind.SERVER)
.hasParent(trace.getSpan(3))
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200L),
equalTo(SemanticAttributes.URL_SCHEME, "http"),
equalTo(SemanticAttributes.URL_PATH, "/serviceTwo"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200L),
equalTo(UrlAttributes.URL_SCHEME, "http"),
equalTo(UrlAttributes.URL_PATH, "/serviceTwo"),
equalTo(
SemanticAttributes.USER_AGENT_ORIGINAL,
UserAgentAttributes.USER_AGENT_ORIGINAL,
"Jakarta Commons-HttpClient/3.1"),
equalTo(SemanticAttributes.HTTP_ROUTE, "/serviceTwo"),
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1"),
equalTo(SemanticAttributes.SERVER_ADDRESS, "127.0.0.1"),
equalTo(SemanticAttributes.SERVER_PORT, portTwo),
equalTo(SemanticAttributes.CLIENT_ADDRESS, "127.0.0.1"),
equalTo(HttpAttributes.HTTP_ROUTE, "/serviceTwo"),
equalTo(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"),
equalTo(ServerAttributes.SERVER_ADDRESS, "127.0.0.1"),
equalTo(ServerAttributes.SERVER_PORT, portTwo),
equalTo(ClientAttributes.CLIENT_ADDRESS, "127.0.0.1"),
equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, "127.0.0.1"),
satisfies(
NetworkAttributes.NETWORK_PEER_PORT,
@ -167,9 +171,9 @@ class TwoServicesWithDirectClientCamelTest
.hasKind(SpanKind.INTERNAL)
.hasParent(trace.getSpan(4))
.hasAttributesSatisfyingExactly(
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(
SemanticAttributes.URL_FULL,
UrlAttributes.URL_FULL,
"http://127.0.0.1:" + portTwo + "/serviceTwo"),
equalTo(
stringKey("camel.uri"),

View File

@ -14,7 +14,11 @@ import static org.assertj.core.api.Assertions.assertThat;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.sdk.testing.assertj.AttributeAssertion;
import io.opentelemetry.sdk.testing.assertj.SpanDataAssert;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -65,19 +69,19 @@ class AwsSpanAssertions {
val ->
val.satisfiesAnyOf(
v -> assertThat(v).isEqualTo(queueUrl), v -> assertThat(v).isNull())),
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
satisfies(SemanticAttributes.URL_FULL, val -> val.isInstanceOf(String.class)),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
satisfies(UrlAttributes.URL_FULL, val -> val.isInstanceOf(String.class)),
satisfies(
SemanticAttributes.SERVER_ADDRESS,
ServerAttributes.SERVER_ADDRESS,
stringAssert -> stringAssert.isInstanceOf(String.class)),
satisfies(
SemanticAttributes.SERVER_PORT,
ServerAttributes.SERVER_PORT,
val ->
val.satisfiesAnyOf(
v -> assertThat(v).isNull(),
v -> assertThat(v).isInstanceOf(Number.class))),
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1"),
equalTo(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"),
equalTo(stringKey("rpc.system"), "aws-api"),
satisfies(stringKey("rpc.method"), stringAssert -> stringAssert.isEqualTo(rpcMethod)),
equalTo(stringKey("rpc.service"), "AmazonSQS")));
@ -87,18 +91,25 @@ class AwsSpanAssertions {
|| spanName.endsWith("publish")) {
attributeAssertions.addAll(
Arrays.asList(
equalTo(SemanticAttributes.MESSAGING_DESTINATION_NAME, queueName),
equalTo(SemanticAttributes.MESSAGING_SYSTEM, "AmazonSQS")));
equalTo(MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME, queueName),
equalTo(MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS")));
if (spanName.endsWith("receive")) {
attributeAssertions.add(equalTo(SemanticAttributes.MESSAGING_OPERATION, "receive"));
attributeAssertions.add(
equalTo(MessagingIncubatingAttributes.MESSAGING_OPERATION, "receive"));
} else if (spanName.endsWith("process")) {
attributeAssertions.add(equalTo(SemanticAttributes.MESSAGING_OPERATION, "process"));
attributeAssertions.add(
satisfies(SemanticAttributes.MESSAGING_MESSAGE_ID, val -> assertThat(val).isNotNull()));
equalTo(MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"));
attributeAssertions.add(
satisfies(
MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID,
val -> assertThat(val).isNotNull()));
} else if (spanName.endsWith("publish")) {
attributeAssertions.add(equalTo(SemanticAttributes.MESSAGING_OPERATION, "publish"));
attributeAssertions.add(
satisfies(SemanticAttributes.MESSAGING_MESSAGE_ID, val -> assertThat(val).isNotNull()));
equalTo(MessagingIncubatingAttributes.MESSAGING_OPERATION, "publish"));
attributeAssertions.add(
satisfies(
MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID,
val -> assertThat(val).isNotNull()));
}
}
@ -116,13 +127,13 @@ class AwsSpanAssertions {
equalTo(stringKey("rpc.method"), spanName.substring(3)),
equalTo(stringKey("rpc.service"), "Amazon S3"),
equalTo(stringKey("aws.bucket.name"), bucketName),
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, method),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
satisfies(SemanticAttributes.URL_FULL, val -> val.isInstanceOf(String.class)),
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1"),
satisfies(SemanticAttributes.SERVER_ADDRESS, val -> val.isInstanceOf(String.class)),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, method),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
satisfies(UrlAttributes.URL_FULL, val -> val.isInstanceOf(String.class)),
equalTo(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"),
satisfies(ServerAttributes.SERVER_ADDRESS, val -> val.isInstanceOf(String.class)),
satisfies(
SemanticAttributes.SERVER_PORT,
ServerAttributes.SERVER_PORT,
val ->
val.satisfiesAnyOf(
v -> val.isInstanceOf(Number.class), v -> assertThat(v).isNull())));
@ -137,14 +148,14 @@ class AwsSpanAssertions {
equalTo(stringKey("rpc.system"), "aws-api"),
equalTo(stringKey("rpc.method"), spanName.substring(4)),
equalTo(stringKey("rpc.service"), "AmazonSNS"),
equalTo(SemanticAttributes.MESSAGING_DESTINATION_NAME, topicArn),
equalTo(SemanticAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
satisfies(SemanticAttributes.URL_FULL, val -> val.isInstanceOf(String.class)),
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1"),
satisfies(SemanticAttributes.SERVER_ADDRESS, val -> val.isInstanceOf(String.class)),
equalTo(MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME, topicArn),
equalTo(HttpAttributes.HTTP_REQUEST_METHOD, "POST"),
equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200),
satisfies(UrlAttributes.URL_FULL, val -> val.isInstanceOf(String.class)),
equalTo(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"),
satisfies(ServerAttributes.SERVER_ADDRESS, val -> val.isInstanceOf(String.class)),
satisfies(
SemanticAttributes.SERVER_PORT,
ServerAttributes.SERVER_PORT,
val ->
val.satisfiesAnyOf(
v -> val.isInstanceOf(Number.class), v -> assertThat(v).isNull())));

View File

@ -11,7 +11,7 @@ import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satis
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.sdk.testing.assertj.SpanDataAssert;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
class CamelSpanAssertions {
@ -31,7 +31,7 @@ class CamelSpanAssertions {
equalTo(
stringKey("camel.uri"),
"aws-sqs://" + queueName + "?amazonSQSClient=%23sqsClient&delay=1000"),
equalTo(SemanticAttributes.MESSAGING_DESTINATION_NAME, queueName));
equalTo(MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME, queueName));
}
static SpanDataAssert sqsConsume(SpanDataAssert span, String queueName) {
@ -45,9 +45,9 @@ class CamelSpanAssertions {
equalTo(
stringKey("camel.uri"),
"aws-sqs://" + queueName + "?amazonSQSClient=%23sqsClient&delay=" + delay),
equalTo(SemanticAttributes.MESSAGING_DESTINATION_NAME, queueName),
equalTo(MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME, queueName),
satisfies(
SemanticAttributes.MESSAGING_MESSAGE_ID,
MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID,
stringAssert -> stringAssert.isInstanceOf(String.class)));
}
@ -57,7 +57,7 @@ class CamelSpanAssertions {
.hasAttributesSatisfying(
equalTo(
stringKey("camel.uri"), "aws-sns://" + topicName + "?amazonSNSClient=%23snsClient"),
equalTo(SemanticAttributes.MESSAGING_DESTINATION_NAME, topicName));
equalTo(MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME, topicName));
}
static SpanDataAssert s3(SpanDataAssert span, String bucketName) {

View File

@ -14,7 +14,7 @@ import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerUsingTest;
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerInstrumentationExtension;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
import org.junit.jupiter.api.AfterAll;
@ -116,10 +116,10 @@ class CassandraTest extends AbstractHttpServerUsingTest<ConfigurableApplicationC
equalTo(
stringKey("camel.uri"),
"cql://" + host + ":" + cassandraPort + "/test"),
equalTo(SemanticAttributes.DB_NAME, "test"),
equalTo(DbIncubatingAttributes.DB_NAME, "test"),
equalTo(
SemanticAttributes.DB_STATEMENT,
DbIncubatingAttributes.DB_STATEMENT,
"select * from test.users where id=? ALLOW FILTERING"),
equalTo(SemanticAttributes.DB_SYSTEM, "cassandra"))));
equalTo(DbIncubatingAttributes.DB_SYSTEM, "cassandra"))));
}
}

View File

@ -9,7 +9,7 @@ import com.datastax.driver.core.ExecutionInfo;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import javax.annotation.Nullable;
public class CassandraAttributesExtractor
@ -28,10 +28,9 @@ public class CassandraAttributesExtractor
return;
}
attributes.put(
SemanticAttributes.SERVER_ADDRESS,
ServerAttributes.SERVER_ADDRESS,
executionInfo.getQueriedHost().getSocketAddress().getHostString());
attributes.put(
SemanticAttributes.SERVER_PORT,
executionInfo.getQueriedHost().getSocketAddress().getPort());
ServerAttributes.SERVER_PORT, executionInfo.getQueriedHost().getSocketAddress().getPort());
}
}

View File

@ -13,7 +13,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor;
import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor;
import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
public final class CassandraSingletons {
private static final String INSTRUMENTATION_NAME = "io.opentelemetry.cassandra-3.0";
@ -32,7 +32,7 @@ public final class CassandraSingletons {
DbClientSpanNameExtractor.create(attributesGetter))
.addAttributesExtractor(
SqlClientAttributesExtractor.builder(attributesGetter)
.setTableAttribute(SemanticAttributes.DB_CASSANDRA_TABLE)
.setTableAttribute(DbIncubatingAttributes.DB_CASSANDRA_TABLE)
.setStatementSanitizationEnabled(
CommonConfig.get().isStatementSanitizationEnabled())
.build())

View File

@ -6,14 +6,14 @@
package io.opentelemetry.javaagent.instrumentation.cassandra.v3_0;
import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesGetter;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
import javax.annotation.Nullable;
final class CassandraSqlAttributesGetter implements SqlClientAttributesGetter<CassandraRequest> {
@Override
public String getSystem(CassandraRequest request) {
return SemanticAttributes.DbSystemValues.CASSANDRA;
return DbIncubatingAttributes.DbSystemValues.CASSANDRA;
}
@Override

Some files were not shown because too many files have changed in this diff Show More