Remove incubating semconv dependency from library instrumentation (#11324)
This commit is contained in:
parent
c78277e5a2
commit
3a9972b16f
|
@ -22,3 +22,7 @@ configurations {
|
||||||
extendsFrom(bootstrap)
|
extendsFrom(bootstrap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
api("io.opentelemetry.semconv:opentelemetry-semconv-incubating")
|
||||||
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ group = "io.opentelemetry.instrumentation"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api("io.opentelemetry.semconv:opentelemetry-semconv")
|
api("io.opentelemetry.semconv:opentelemetry-semconv")
|
||||||
api("io.opentelemetry.semconv:opentelemetry-semconv-incubating")
|
|
||||||
api(project(":instrumentation-api"))
|
api(project(":instrumentation-api"))
|
||||||
implementation("io.opentelemetry:opentelemetry-api-incubator")
|
implementation("io.opentelemetry:opentelemetry-api-incubator")
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,10 @@ package io.opentelemetry.instrumentation.api.incubator.semconv.code;
|
||||||
|
|
||||||
import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet;
|
import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet;
|
||||||
|
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.incubating.CodeIncubatingAttributes;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +21,11 @@ import javax.annotation.Nullable;
|
||||||
public final class CodeAttributesExtractor<REQUEST, RESPONSE>
|
public final class CodeAttributesExtractor<REQUEST, RESPONSE>
|
||||||
implements AttributesExtractor<REQUEST, RESPONSE> {
|
implements AttributesExtractor<REQUEST, RESPONSE> {
|
||||||
|
|
||||||
|
// copied from CodeIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> CODE_FUNCTION = AttributeKey.stringKey("code.function");
|
||||||
|
private static final AttributeKey<String> CODE_NAMESPACE =
|
||||||
|
AttributeKey.stringKey("code.namespace");
|
||||||
|
|
||||||
/** Creates the code attributes extractor. */
|
/** Creates the code attributes extractor. */
|
||||||
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
|
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
|
||||||
CodeAttributesGetter<REQUEST> getter) {
|
CodeAttributesGetter<REQUEST> getter) {
|
||||||
|
@ -37,9 +42,9 @@ public final class CodeAttributesExtractor<REQUEST, RESPONSE>
|
||||||
public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {
|
public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {
|
||||||
Class<?> cls = getter.getCodeClass(request);
|
Class<?> cls = getter.getCodeClass(request);
|
||||||
if (cls != null) {
|
if (cls != null) {
|
||||||
internalSet(attributes, CodeIncubatingAttributes.CODE_NAMESPACE, cls.getName());
|
internalSet(attributes, CODE_NAMESPACE, cls.getName());
|
||||||
}
|
}
|
||||||
internalSet(attributes, CodeIncubatingAttributes.CODE_FUNCTION, getter.getMethodName(request));
|
internalSet(attributes, CODE_FUNCTION, getter.getMethodName(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -7,10 +7,10 @@ package io.opentelemetry.instrumentation.api.incubator.semconv.db;
|
||||||
|
|
||||||
import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet;
|
import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet;
|
||||||
|
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extractor of <a
|
* Extractor of <a
|
||||||
|
@ -24,6 +24,10 @@ public final class DbClientAttributesExtractor<REQUEST, RESPONSE>
|
||||||
extends DbClientCommonAttributesExtractor<
|
extends DbClientCommonAttributesExtractor<
|
||||||
REQUEST, RESPONSE, DbClientAttributesGetter<REQUEST>> {
|
REQUEST, RESPONSE, DbClientAttributesGetter<REQUEST>> {
|
||||||
|
|
||||||
|
// copied from DbIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> DB_STATEMENT = AttributeKey.stringKey("db.statement");
|
||||||
|
private static final AttributeKey<String> DB_OPERATION = AttributeKey.stringKey("db.operation");
|
||||||
|
|
||||||
/** Creates the database client attributes extractor with default configuration. */
|
/** Creates the database client attributes extractor with default configuration. */
|
||||||
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
|
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
|
||||||
DbClientAttributesGetter<REQUEST> getter) {
|
DbClientAttributesGetter<REQUEST> getter) {
|
||||||
|
@ -38,7 +42,7 @@ public final class DbClientAttributesExtractor<REQUEST, RESPONSE>
|
||||||
public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {
|
public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {
|
||||||
super.onStart(attributes, parentContext, request);
|
super.onStart(attributes, parentContext, request);
|
||||||
|
|
||||||
internalSet(attributes, DbIncubatingAttributes.DB_STATEMENT, getter.getStatement(request));
|
internalSet(attributes, DB_STATEMENT, getter.getStatement(request));
|
||||||
internalSet(attributes, DbIncubatingAttributes.DB_OPERATION, getter.getOperation(request));
|
internalSet(attributes, DB_OPERATION, getter.getOperation(request));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,18 +7,23 @@ package io.opentelemetry.instrumentation.api.incubator.semconv.db;
|
||||||
|
|
||||||
import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet;
|
import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet;
|
||||||
|
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.internal.SpanKey;
|
import io.opentelemetry.instrumentation.api.internal.SpanKey;
|
||||||
import io.opentelemetry.instrumentation.api.internal.SpanKeyProvider;
|
import io.opentelemetry.instrumentation.api.internal.SpanKeyProvider;
|
||||||
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
abstract class DbClientCommonAttributesExtractor<
|
abstract class DbClientCommonAttributesExtractor<
|
||||||
REQUEST, RESPONSE, GETTER extends DbClientCommonAttributesGetter<REQUEST>>
|
REQUEST, RESPONSE, GETTER extends DbClientCommonAttributesGetter<REQUEST>>
|
||||||
implements AttributesExtractor<REQUEST, RESPONSE>, SpanKeyProvider {
|
implements AttributesExtractor<REQUEST, RESPONSE>, SpanKeyProvider {
|
||||||
|
|
||||||
|
// copied from DbIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> DB_NAME = AttributeKey.stringKey("db.name");
|
||||||
|
private static final AttributeKey<String> DB_SYSTEM = AttributeKey.stringKey("db.system");
|
||||||
|
private static final AttributeKey<String> DB_USER = AttributeKey.stringKey("db.user");
|
||||||
|
|
||||||
final GETTER getter;
|
final GETTER getter;
|
||||||
|
|
||||||
DbClientCommonAttributesExtractor(GETTER getter) {
|
DbClientCommonAttributesExtractor(GETTER getter) {
|
||||||
|
@ -27,9 +32,9 @@ abstract class DbClientCommonAttributesExtractor<
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {
|
public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {
|
||||||
internalSet(attributes, DbIncubatingAttributes.DB_SYSTEM, getter.getSystem(request));
|
internalSet(attributes, DB_SYSTEM, getter.getSystem(request));
|
||||||
internalSet(attributes, DbIncubatingAttributes.DB_USER, getter.getUser(request));
|
internalSet(attributes, DB_USER, getter.getUser(request));
|
||||||
internalSet(attributes, DbIncubatingAttributes.DB_NAME, getter.getName(request));
|
internalSet(attributes, DB_NAME, getter.getName(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -11,7 +11,6 @@ import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extractor of <a
|
* Extractor of <a
|
||||||
|
@ -19,14 +18,18 @@ import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
|
||||||
* attributes</a>. This class is designed with SQL (or SQL-like) database clients in mind.
|
* 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
|
* <p>It sets the same set of attributes as {@link DbClientAttributesExtractor} plus an additional
|
||||||
* <code>{@link DbIncubatingAttributes#DB_SQL_TABLE}</code> attribute. The raw SQL statements
|
* <code>db.sql.table</code> attribute. The raw SQL statements returned by the {@link
|
||||||
* returned by the {@link SqlClientAttributesGetter#getRawStatement(Object)} method are sanitized
|
* SqlClientAttributesGetter#getRawStatement(Object)} method are sanitized before use, all statement
|
||||||
* before use, all statement parameters are removed.
|
* parameters are removed.
|
||||||
*/
|
*/
|
||||||
public final class SqlClientAttributesExtractor<REQUEST, RESPONSE>
|
public final class SqlClientAttributesExtractor<REQUEST, RESPONSE>
|
||||||
extends DbClientCommonAttributesExtractor<
|
extends DbClientCommonAttributesExtractor<
|
||||||
REQUEST, RESPONSE, SqlClientAttributesGetter<REQUEST>> {
|
REQUEST, RESPONSE, SqlClientAttributesGetter<REQUEST>> {
|
||||||
|
|
||||||
|
// copied from DbIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> DB_OPERATION = AttributeKey.stringKey("db.operation");
|
||||||
|
private static final AttributeKey<String> DB_STATEMENT = AttributeKey.stringKey("db.statement");
|
||||||
|
|
||||||
/** Creates the SQL client attributes extractor with default configuration. */
|
/** Creates the SQL client attributes extractor with default configuration. */
|
||||||
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
|
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
|
||||||
SqlClientAttributesGetter<REQUEST> getter) {
|
SqlClientAttributesGetter<REQUEST> getter) {
|
||||||
|
@ -62,9 +65,8 @@ public final class SqlClientAttributesExtractor<REQUEST, RESPONSE>
|
||||||
|
|
||||||
SqlStatementInfo sanitizedStatement = sanitizer.sanitize(getter.getRawStatement(request));
|
SqlStatementInfo sanitizedStatement = sanitizer.sanitize(getter.getRawStatement(request));
|
||||||
String operation = sanitizedStatement.getOperation();
|
String operation = sanitizedStatement.getOperation();
|
||||||
internalSet(
|
internalSet(attributes, DB_STATEMENT, sanitizedStatement.getFullStatement());
|
||||||
attributes, DbIncubatingAttributes.DB_STATEMENT, sanitizedStatement.getFullStatement());
|
internalSet(attributes, DB_OPERATION, operation);
|
||||||
internalSet(attributes, DbIncubatingAttributes.DB_OPERATION, operation);
|
|
||||||
if (!SQL_CALL.equals(operation)) {
|
if (!SQL_CALL.equals(operation)) {
|
||||||
internalSet(attributes, dbTableAttribute, sanitizedStatement.getMainIdentifier());
|
internalSet(attributes, dbTableAttribute, sanitizedStatement.getMainIdentifier());
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,15 @@ import static java.util.Objects.requireNonNull;
|
||||||
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||||
import io.opentelemetry.api.common.AttributeKey;
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
|
|
||||||
|
|
||||||
/** A builder of {@link SqlClientAttributesExtractor}. */
|
/** A builder of {@link SqlClientAttributesExtractor}. */
|
||||||
public final class SqlClientAttributesExtractorBuilder<REQUEST, RESPONSE> {
|
public final class SqlClientAttributesExtractorBuilder<REQUEST, RESPONSE> {
|
||||||
|
|
||||||
|
// copied from DbIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> DB_SQL_TABLE = AttributeKey.stringKey("db.sql.table");
|
||||||
|
|
||||||
final SqlClientAttributesGetter<REQUEST> getter;
|
final SqlClientAttributesGetter<REQUEST> getter;
|
||||||
AttributeKey<String> dbTableAttribute = DbIncubatingAttributes.DB_SQL_TABLE;
|
AttributeKey<String> dbTableAttribute = DB_SQL_TABLE;
|
||||||
boolean statementSanitizationEnabled = true;
|
boolean statementSanitizationEnabled = true;
|
||||||
|
|
||||||
SqlClientAttributesExtractorBuilder(SqlClientAttributesGetter<REQUEST> getter) {
|
SqlClientAttributesExtractorBuilder(SqlClientAttributesGetter<REQUEST> getter) {
|
||||||
|
@ -26,7 +28,7 @@ public final class SqlClientAttributesExtractorBuilder<REQUEST, RESPONSE> {
|
||||||
/**
|
/**
|
||||||
* Configures the extractor to set the table value extracted by the {@link
|
* Configures the extractor to set the table value extracted by the {@link
|
||||||
* SqlClientAttributesExtractor} under the {@code dbTableAttribute} key. By default, the <code>
|
* SqlClientAttributesExtractor} under the {@code dbTableAttribute} key. By default, the <code>
|
||||||
* {@link DbIncubatingAttributes#DB_SQL_TABLE}</code> attribute is used.
|
* db.sql.table</code> attribute is used.
|
||||||
*
|
*
|
||||||
* @param dbTableAttribute The {@link AttributeKey} under which the table extracted by the {@link
|
* @param dbTableAttribute The {@link AttributeKey} under which the table extracted by the {@link
|
||||||
* SqlClientAttributesExtractor} will be stored.
|
* SqlClientAttributesExtractor} will be stored.
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
|
|
||||||
package io.opentelemetry.instrumentation.api.incubator.semconv.http;
|
package io.opentelemetry.instrumentation.api.incubator.semconv.http;
|
||||||
|
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.incubator.semconv.net.PeerServiceResolver;
|
import io.opentelemetry.instrumentation.api.incubator.semconv.net.PeerServiceResolver;
|
||||||
import io.opentelemetry.instrumentation.api.incubator.semconv.net.internal.UrlParser;
|
import io.opentelemetry.instrumentation.api.incubator.semconv.net.internal.UrlParser;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesGetter;
|
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesGetter;
|
||||||
import io.opentelemetry.semconv.incubating.PeerIncubatingAttributes;
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -23,6 +23,9 @@ import javax.annotation.Nullable;
|
||||||
public final class HttpClientPeerServiceAttributesExtractor<REQUEST, RESPONSE>
|
public final class HttpClientPeerServiceAttributesExtractor<REQUEST, RESPONSE>
|
||||||
implements AttributesExtractor<REQUEST, RESPONSE> {
|
implements AttributesExtractor<REQUEST, RESPONSE> {
|
||||||
|
|
||||||
|
// copied from PeerIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> PEER_SERVICE = AttributeKey.stringKey("peer.service");
|
||||||
|
|
||||||
private final HttpClientAttributesGetter<REQUEST, RESPONSE> attributesGetter;
|
private final HttpClientAttributesGetter<REQUEST, RESPONSE> attributesGetter;
|
||||||
private final PeerServiceResolver peerServiceResolver;
|
private final PeerServiceResolver peerServiceResolver;
|
||||||
|
|
||||||
|
@ -67,7 +70,7 @@ public final class HttpClientPeerServiceAttributesExtractor<REQUEST, RESPONSE>
|
||||||
Supplier<String> pathSupplier = () -> getUrlPath(attributesGetter, request);
|
Supplier<String> pathSupplier = () -> getUrlPath(attributesGetter, request);
|
||||||
String peerService = mapToPeerService(serverAddress, serverPort, pathSupplier);
|
String peerService = mapToPeerService(serverAddress, serverPort, pathSupplier);
|
||||||
if (peerService != null) {
|
if (peerService != null) {
|
||||||
attributes.put(PeerIncubatingAttributes.PEER_SERVICE, peerService);
|
attributes.put(PEER_SERVICE, peerService);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,19 +7,25 @@ package io.opentelemetry.instrumentation.api.incubator.semconv.http;
|
||||||
|
|
||||||
import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet;
|
import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet;
|
||||||
|
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesGetter;
|
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesGetter;
|
||||||
import io.opentelemetry.instrumentation.api.semconv.http.HttpCommonAttributesGetter;
|
import io.opentelemetry.instrumentation.api.semconv.http.HttpCommonAttributesGetter;
|
||||||
import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesGetter;
|
import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesGetter;
|
||||||
import io.opentelemetry.semconv.incubating.HttpIncubatingAttributes;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public final class HttpExperimentalAttributesExtractor<REQUEST, RESPONSE>
|
public final class HttpExperimentalAttributesExtractor<REQUEST, RESPONSE>
|
||||||
implements AttributesExtractor<REQUEST, RESPONSE> {
|
implements AttributesExtractor<REQUEST, RESPONSE> {
|
||||||
|
|
||||||
|
// copied from HttpIncubatingAttributes
|
||||||
|
static final AttributeKey<Long> HTTP_REQUEST_BODY_SIZE =
|
||||||
|
AttributeKey.longKey("http.request.body.size");
|
||||||
|
static final AttributeKey<Long> HTTP_RESPONSE_BODY_SIZE =
|
||||||
|
AttributeKey.longKey("http.response.body.size");
|
||||||
|
|
||||||
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
|
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
|
||||||
HttpClientAttributesGetter<REQUEST, RESPONSE> getter) {
|
HttpClientAttributesGetter<REQUEST, RESPONSE> getter) {
|
||||||
return new HttpExperimentalAttributesExtractor<>(getter);
|
return new HttpExperimentalAttributesExtractor<>(getter);
|
||||||
|
@ -49,11 +55,11 @@ public final class HttpExperimentalAttributesExtractor<REQUEST, RESPONSE>
|
||||||
@Nullable Throwable error) {
|
@Nullable Throwable error) {
|
||||||
|
|
||||||
Long requestBodySize = requestBodySize(request);
|
Long requestBodySize = requestBodySize(request);
|
||||||
internalSet(attributes, HttpIncubatingAttributes.HTTP_REQUEST_BODY_SIZE, requestBodySize);
|
internalSet(attributes, HTTP_REQUEST_BODY_SIZE, requestBodySize);
|
||||||
|
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
Long responseBodySize = responseBodySize(request, response);
|
Long responseBodySize = responseBodySize(request, response);
|
||||||
internalSet(attributes, HttpIncubatingAttributes.HTTP_RESPONSE_BODY_SIZE, responseBodySize);
|
internalSet(attributes, HTTP_RESPONSE_BODY_SIZE, responseBodySize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,19 +7,19 @@ package io.opentelemetry.instrumentation.api.incubator.semconv.http;
|
||||||
|
|
||||||
import io.opentelemetry.api.common.AttributeKey;
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.Attributes;
|
import io.opentelemetry.api.common.Attributes;
|
||||||
import io.opentelemetry.semconv.incubating.HttpIncubatingAttributes;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
final class HttpMessageBodySizeUtil {
|
final class HttpMessageBodySizeUtil {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
static Long getHttpRequestBodySize(Attributes... attributesList) {
|
static Long getHttpRequestBodySize(Attributes... attributesList) {
|
||||||
return getAttribute(HttpIncubatingAttributes.HTTP_REQUEST_BODY_SIZE, attributesList);
|
return getAttribute(HttpExperimentalAttributesExtractor.HTTP_REQUEST_BODY_SIZE, attributesList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
static Long getHttpResponseBodySize(Attributes... attributesList) {
|
static Long getHttpResponseBodySize(Attributes... attributesList) {
|
||||||
return getAttribute(HttpIncubatingAttributes.HTTP_RESPONSE_BODY_SIZE, attributesList);
|
return getAttribute(
|
||||||
|
HttpExperimentalAttributesExtractor.HTTP_RESPONSE_BODY_SIZE, attributesList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
|
@ -7,12 +7,12 @@ package io.opentelemetry.instrumentation.api.incubator.semconv.messaging;
|
||||||
|
|
||||||
import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet;
|
import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet;
|
||||||
|
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.internal.SpanKey;
|
import io.opentelemetry.instrumentation.api.internal.SpanKey;
|
||||||
import io.opentelemetry.instrumentation.api.internal.SpanKeyProvider;
|
import io.opentelemetry.instrumentation.api.internal.SpanKeyProvider;
|
||||||
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -27,6 +27,32 @@ import javax.annotation.Nullable;
|
||||||
public final class MessagingAttributesExtractor<REQUEST, RESPONSE>
|
public final class MessagingAttributesExtractor<REQUEST, RESPONSE>
|
||||||
implements AttributesExtractor<REQUEST, RESPONSE>, SpanKeyProvider {
|
implements AttributesExtractor<REQUEST, RESPONSE>, SpanKeyProvider {
|
||||||
|
|
||||||
|
// copied from MessagingIncubatingAttributes
|
||||||
|
private static final AttributeKey<Long> MESSAGING_BATCH_MESSAGE_COUNT =
|
||||||
|
AttributeKey.longKey("messaging.batch.message_count");
|
||||||
|
private static final AttributeKey<String> MESSAGING_CLIENT_ID =
|
||||||
|
AttributeKey.stringKey("messaging.client_id");
|
||||||
|
private static final AttributeKey<Boolean> MESSAGING_DESTINATION_ANONYMOUS =
|
||||||
|
AttributeKey.booleanKey("messaging.destination.anonymous");
|
||||||
|
private static final AttributeKey<String> MESSAGING_DESTINATION_NAME =
|
||||||
|
AttributeKey.stringKey("messaging.destination.name");
|
||||||
|
private static final AttributeKey<String> MESSAGING_DESTINATION_TEMPLATE =
|
||||||
|
AttributeKey.stringKey("messaging.destination.template");
|
||||||
|
private static final AttributeKey<Boolean> MESSAGING_DESTINATION_TEMPORARY =
|
||||||
|
AttributeKey.booleanKey("messaging.destination.temporary");
|
||||||
|
private static final AttributeKey<Long> MESSAGING_MESSAGE_BODY_SIZE =
|
||||||
|
AttributeKey.longKey("messaging.message.body.size");
|
||||||
|
private static final AttributeKey<String> MESSAGING_MESSAGE_CONVERSATION_ID =
|
||||||
|
AttributeKey.stringKey("messaging.message.conversation_id");
|
||||||
|
private static final AttributeKey<Long> MESSAGING_MESSAGE_ENVELOPE_SIZE =
|
||||||
|
AttributeKey.longKey("messaging.message.envelope.size");
|
||||||
|
private static final AttributeKey<String> MESSAGING_MESSAGE_ID =
|
||||||
|
AttributeKey.stringKey("messaging.message.id");
|
||||||
|
private static final AttributeKey<String> MESSAGING_OPERATION =
|
||||||
|
AttributeKey.stringKey("messaging.operation");
|
||||||
|
private static final AttributeKey<String> MESSAGING_SYSTEM =
|
||||||
|
AttributeKey.stringKey("messaging.system");
|
||||||
|
|
||||||
static final String TEMP_DESTINATION_NAME = "(temporary)";
|
static final String TEMP_DESTINATION_NAME = "(temporary)";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,46 +88,27 @@ public final class MessagingAttributesExtractor<REQUEST, RESPONSE>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {
|
public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {
|
||||||
internalSet(
|
internalSet(attributes, MESSAGING_SYSTEM, getter.getSystem(request));
|
||||||
attributes, MessagingIncubatingAttributes.MESSAGING_SYSTEM, getter.getSystem(request));
|
|
||||||
boolean isTemporaryDestination = getter.isTemporaryDestination(request);
|
boolean isTemporaryDestination = getter.isTemporaryDestination(request);
|
||||||
if (isTemporaryDestination) {
|
if (isTemporaryDestination) {
|
||||||
internalSet(attributes, MessagingIncubatingAttributes.MESSAGING_DESTINATION_TEMPORARY, true);
|
internalSet(attributes, MESSAGING_DESTINATION_TEMPORARY, true);
|
||||||
internalSet(
|
internalSet(attributes, MESSAGING_DESTINATION_NAME, TEMP_DESTINATION_NAME);
|
||||||
attributes,
|
|
||||||
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
|
||||||
TEMP_DESTINATION_NAME);
|
|
||||||
} else {
|
} else {
|
||||||
|
internalSet(attributes, MESSAGING_DESTINATION_NAME, getter.getDestination(request));
|
||||||
internalSet(
|
internalSet(
|
||||||
attributes,
|
attributes, MESSAGING_DESTINATION_TEMPLATE, getter.getDestinationTemplate(request));
|
||||||
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
|
||||||
getter.getDestination(request));
|
|
||||||
internalSet(
|
|
||||||
attributes,
|
|
||||||
MessagingIncubatingAttributes.MESSAGING_DESTINATION_TEMPLATE,
|
|
||||||
getter.getDestinationTemplate(request));
|
|
||||||
}
|
}
|
||||||
boolean isAnonymousDestination = getter.isAnonymousDestination(request);
|
boolean isAnonymousDestination = getter.isAnonymousDestination(request);
|
||||||
if (isAnonymousDestination) {
|
if (isAnonymousDestination) {
|
||||||
internalSet(attributes, MessagingIncubatingAttributes.MESSAGING_DESTINATION_ANONYMOUS, true);
|
internalSet(attributes, MESSAGING_DESTINATION_ANONYMOUS, true);
|
||||||
}
|
}
|
||||||
|
internalSet(attributes, MESSAGING_MESSAGE_CONVERSATION_ID, getter.getConversationId(request));
|
||||||
|
internalSet(attributes, MESSAGING_MESSAGE_BODY_SIZE, getter.getMessageBodySize(request));
|
||||||
internalSet(
|
internalSet(
|
||||||
attributes,
|
attributes, MESSAGING_MESSAGE_ENVELOPE_SIZE, getter.getMessageEnvelopeSize(request));
|
||||||
MessagingIncubatingAttributes.MESSAGING_MESSAGE_CONVERSATION_ID,
|
internalSet(attributes, MESSAGING_CLIENT_ID, getter.getClientId(request));
|
||||||
getter.getConversationId(request));
|
|
||||||
internalSet(
|
|
||||||
attributes,
|
|
||||||
MessagingIncubatingAttributes.MESSAGING_MESSAGE_BODY_SIZE,
|
|
||||||
getter.getMessageBodySize(request));
|
|
||||||
internalSet(
|
|
||||||
attributes,
|
|
||||||
MessagingIncubatingAttributes.MESSAGING_MESSAGE_ENVELOPE_SIZE,
|
|
||||||
getter.getMessageEnvelopeSize(request));
|
|
||||||
internalSet(
|
|
||||||
attributes, MessagingIncubatingAttributes.MESSAGING_CLIENT_ID, getter.getClientId(request));
|
|
||||||
if (operation != null) {
|
if (operation != null) {
|
||||||
internalSet(
|
internalSet(attributes, MESSAGING_OPERATION, operation.operationName());
|
||||||
attributes, MessagingIncubatingAttributes.MESSAGING_OPERATION, operation.operationName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,14 +119,9 @@ public final class MessagingAttributesExtractor<REQUEST, RESPONSE>
|
||||||
REQUEST request,
|
REQUEST request,
|
||||||
@Nullable RESPONSE response,
|
@Nullable RESPONSE response,
|
||||||
@Nullable Throwable error) {
|
@Nullable Throwable error) {
|
||||||
|
internalSet(attributes, MESSAGING_MESSAGE_ID, getter.getMessageId(request, response));
|
||||||
internalSet(
|
internalSet(
|
||||||
attributes,
|
attributes, MESSAGING_BATCH_MESSAGE_COUNT, getter.getBatchMessageCount(request, response));
|
||||||
MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID,
|
|
||||||
getter.getMessageId(request, response));
|
|
||||||
internalSet(
|
|
||||||
attributes,
|
|
||||||
MessagingIncubatingAttributes.MESSAGING_BATCH_MESSAGE_COUNT,
|
|
||||||
getter.getBatchMessageCount(request, response));
|
|
||||||
|
|
||||||
for (String name : capturedHeaders) {
|
for (String name : capturedHeaders) {
|
||||||
List<String> values = getter.getMessageHeader(request, name);
|
List<String> values = getter.getMessageHeader(request, name);
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
|
|
||||||
package io.opentelemetry.instrumentation.api.incubator.semconv.net;
|
package io.opentelemetry.instrumentation.api.incubator.semconv.net;
|
||||||
|
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.semconv.network.ServerAttributesGetter;
|
import io.opentelemetry.instrumentation.api.semconv.network.ServerAttributesGetter;
|
||||||
import io.opentelemetry.semconv.incubating.PeerIncubatingAttributes;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,6 +20,9 @@ import javax.annotation.Nullable;
|
||||||
public final class PeerServiceAttributesExtractor<REQUEST, RESPONSE>
|
public final class PeerServiceAttributesExtractor<REQUEST, RESPONSE>
|
||||||
implements AttributesExtractor<REQUEST, RESPONSE> {
|
implements AttributesExtractor<REQUEST, RESPONSE> {
|
||||||
|
|
||||||
|
// copied from PeerIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> PEER_SERVICE = AttributeKey.stringKey("peer.service");
|
||||||
|
|
||||||
private final ServerAttributesGetter<REQUEST> attributesGetter;
|
private final ServerAttributesGetter<REQUEST> attributesGetter;
|
||||||
private final PeerServiceResolver peerServiceResolver;
|
private final PeerServiceResolver peerServiceResolver;
|
||||||
|
|
||||||
|
@ -60,7 +63,7 @@ public final class PeerServiceAttributesExtractor<REQUEST, RESPONSE>
|
||||||
Integer serverPort = attributesGetter.getServerPort(request);
|
Integer serverPort = attributesGetter.getServerPort(request);
|
||||||
String peerService = mapToPeerService(serverAddress, serverPort);
|
String peerService = mapToPeerService(serverAddress, serverPort);
|
||||||
if (peerService != null) {
|
if (peerService != null) {
|
||||||
attributes.put(PeerIncubatingAttributes.PEER_SERVICE, peerService);
|
attributes.put(PEER_SERVICE, peerService);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,15 +7,20 @@ package io.opentelemetry.instrumentation.api.incubator.semconv.rpc;
|
||||||
|
|
||||||
import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet;
|
import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet;
|
||||||
|
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.incubating.RpcIncubatingAttributes;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
abstract class RpcCommonAttributesExtractor<REQUEST, RESPONSE>
|
abstract class RpcCommonAttributesExtractor<REQUEST, RESPONSE>
|
||||||
implements AttributesExtractor<REQUEST, RESPONSE> {
|
implements AttributesExtractor<REQUEST, RESPONSE> {
|
||||||
|
|
||||||
|
// copied from RpcIncubatingAttributes
|
||||||
|
static final AttributeKey<String> RPC_METHOD = AttributeKey.stringKey("rpc.method");
|
||||||
|
static final AttributeKey<String> RPC_SERVICE = AttributeKey.stringKey("rpc.service");
|
||||||
|
static final AttributeKey<String> RPC_SYSTEM = AttributeKey.stringKey("rpc.system");
|
||||||
|
|
||||||
private final RpcAttributesGetter<REQUEST> getter;
|
private final RpcAttributesGetter<REQUEST> getter;
|
||||||
|
|
||||||
RpcCommonAttributesExtractor(RpcAttributesGetter<REQUEST> getter) {
|
RpcCommonAttributesExtractor(RpcAttributesGetter<REQUEST> getter) {
|
||||||
|
@ -24,9 +29,9 @@ abstract class RpcCommonAttributesExtractor<REQUEST, RESPONSE>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {
|
public final void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {
|
||||||
internalSet(attributes, RpcIncubatingAttributes.RPC_SYSTEM, getter.getSystem(request));
|
internalSet(attributes, RPC_SYSTEM, getter.getSystem(request));
|
||||||
internalSet(attributes, RpcIncubatingAttributes.RPC_SERVICE, getter.getService(request));
|
internalSet(attributes, RPC_SERVICE, getter.getService(request));
|
||||||
internalSet(attributes, RpcIncubatingAttributes.RPC_METHOD, getter.getMethod(request));
|
internalSet(attributes, RPC_METHOD, getter.getMethod(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,15 +5,19 @@
|
||||||
|
|
||||||
package io.opentelemetry.instrumentation.api.incubator.semconv.rpc;
|
package io.opentelemetry.instrumentation.api.incubator.semconv.rpc;
|
||||||
|
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.incubator.metrics.ExtendedDoubleHistogramBuilder;
|
import io.opentelemetry.api.incubator.metrics.ExtendedDoubleHistogramBuilder;
|
||||||
import io.opentelemetry.api.metrics.DoubleHistogramBuilder;
|
import io.opentelemetry.api.metrics.DoubleHistogramBuilder;
|
||||||
import io.opentelemetry.semconv.NetworkAttributes;
|
import io.opentelemetry.semconv.NetworkAttributes;
|
||||||
import io.opentelemetry.semconv.ServerAttributes;
|
import io.opentelemetry.semconv.ServerAttributes;
|
||||||
import io.opentelemetry.semconv.incubating.RpcIncubatingAttributes;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
final class RpcMetricsAdvice {
|
final class RpcMetricsAdvice {
|
||||||
|
|
||||||
|
// copied from RpcIncubatingAttributes
|
||||||
|
private static final AttributeKey<Long> RPC_GRPC_STATUS_CODE =
|
||||||
|
AttributeKey.longKey("rpc.grpc.status_code");
|
||||||
|
|
||||||
static void applyClientDurationAdvice(DoubleHistogramBuilder builder) {
|
static void applyClientDurationAdvice(DoubleHistogramBuilder builder) {
|
||||||
if (!(builder instanceof ExtendedDoubleHistogramBuilder)) {
|
if (!(builder instanceof ExtendedDoubleHistogramBuilder)) {
|
||||||
return;
|
return;
|
||||||
|
@ -23,10 +27,10 @@ final class RpcMetricsAdvice {
|
||||||
((ExtendedDoubleHistogramBuilder) builder)
|
((ExtendedDoubleHistogramBuilder) builder)
|
||||||
.setAttributesAdvice(
|
.setAttributesAdvice(
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
RpcIncubatingAttributes.RPC_SYSTEM,
|
RpcCommonAttributesExtractor.RPC_SYSTEM,
|
||||||
RpcIncubatingAttributes.RPC_SERVICE,
|
RpcCommonAttributesExtractor.RPC_SERVICE,
|
||||||
RpcIncubatingAttributes.RPC_METHOD,
|
RpcCommonAttributesExtractor.RPC_METHOD,
|
||||||
RpcIncubatingAttributes.RPC_GRPC_STATUS_CODE,
|
RPC_GRPC_STATUS_CODE,
|
||||||
NetworkAttributes.NETWORK_TYPE,
|
NetworkAttributes.NETWORK_TYPE,
|
||||||
NetworkAttributes.NETWORK_TRANSPORT,
|
NetworkAttributes.NETWORK_TRANSPORT,
|
||||||
ServerAttributes.SERVER_ADDRESS,
|
ServerAttributes.SERVER_ADDRESS,
|
||||||
|
@ -42,10 +46,10 @@ final class RpcMetricsAdvice {
|
||||||
((ExtendedDoubleHistogramBuilder) builder)
|
((ExtendedDoubleHistogramBuilder) builder)
|
||||||
.setAttributesAdvice(
|
.setAttributesAdvice(
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
RpcIncubatingAttributes.RPC_SYSTEM,
|
RpcCommonAttributesExtractor.RPC_SYSTEM,
|
||||||
RpcIncubatingAttributes.RPC_SERVICE,
|
RpcCommonAttributesExtractor.RPC_SERVICE,
|
||||||
RpcIncubatingAttributes.RPC_METHOD,
|
RpcCommonAttributesExtractor.RPC_METHOD,
|
||||||
RpcIncubatingAttributes.RPC_GRPC_STATUS_CODE,
|
RPC_GRPC_STATUS_CODE,
|
||||||
NetworkAttributes.NETWORK_TYPE,
|
NetworkAttributes.NETWORK_TYPE,
|
||||||
NetworkAttributes.NETWORK_TRANSPORT,
|
NetworkAttributes.NETWORK_TRANSPORT,
|
||||||
ServerAttributes.SERVER_ADDRESS,
|
ServerAttributes.SERVER_ADDRESS,
|
||||||
|
|
|
@ -15,7 +15,6 @@ dependencies {
|
||||||
api("io.opentelemetry:opentelemetry-api")
|
api("io.opentelemetry:opentelemetry-api")
|
||||||
implementation("io.opentelemetry:opentelemetry-api-incubator")
|
implementation("io.opentelemetry:opentelemetry-api-incubator")
|
||||||
implementation("io.opentelemetry.semconv:opentelemetry-semconv")
|
implementation("io.opentelemetry.semconv:opentelemetry-semconv")
|
||||||
implementation("io.opentelemetry.semconv:opentelemetry-semconv-incubating")
|
|
||||||
|
|
||||||
compileOnly("com.google.auto.value:auto-value-annotations")
|
compileOnly("com.google.auto.value:auto-value-annotations")
|
||||||
annotationProcessor("com.google.auto.value:auto-value")
|
annotationProcessor("com.google.auto.value:auto-value")
|
||||||
|
|
|
@ -7,6 +7,7 @@ package io.opentelemetry.instrumentation.apachedubbo.v2_7;
|
||||||
|
|
||||||
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||||
import io.opentelemetry.api.OpenTelemetry;
|
import io.opentelemetry.api.OpenTelemetry;
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.instrumentation.apachedubbo.v2_7.internal.DubboClientNetworkAttributesGetter;
|
import io.opentelemetry.instrumentation.apachedubbo.v2_7.internal.DubboClientNetworkAttributesGetter;
|
||||||
import io.opentelemetry.instrumentation.api.incubator.semconv.rpc.RpcClientAttributesExtractor;
|
import io.opentelemetry.instrumentation.api.incubator.semconv.rpc.RpcClientAttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.incubator.semconv.rpc.RpcServerAttributesExtractor;
|
import io.opentelemetry.instrumentation.api.incubator.semconv.rpc.RpcServerAttributesExtractor;
|
||||||
|
@ -17,7 +18,6 @@ import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor;
|
import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.semconv.network.ServerAttributesExtractor;
|
import io.opentelemetry.instrumentation.api.semconv.network.ServerAttributesExtractor;
|
||||||
import io.opentelemetry.semconv.incubating.PeerIncubatingAttributes;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -28,6 +28,9 @@ public final class DubboTelemetryBuilder {
|
||||||
|
|
||||||
private static final String INSTRUMENTATION_NAME = "io.opentelemetry.apache-dubbo-2.7";
|
private static final String INSTRUMENTATION_NAME = "io.opentelemetry.apache-dubbo-2.7";
|
||||||
|
|
||||||
|
// copied from PeerIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> PEER_SERVICE = AttributeKey.stringKey("peer.service");
|
||||||
|
|
||||||
private final OpenTelemetry openTelemetry;
|
private final OpenTelemetry openTelemetry;
|
||||||
@Nullable private String peerService;
|
@Nullable private String peerService;
|
||||||
private final List<AttributesExtractor<DubboRequest, Result>> attributesExtractors =
|
private final List<AttributesExtractor<DubboRequest, Result>> attributesExtractors =
|
||||||
|
@ -82,7 +85,7 @@ public final class DubboTelemetryBuilder {
|
||||||
|
|
||||||
if (peerService != null) {
|
if (peerService != null) {
|
||||||
clientInstrumenterBuilder.addAttributesExtractor(
|
clientInstrumenterBuilder.addAttributesExtractor(
|
||||||
AttributesExtractor.constant(PeerIncubatingAttributes.PEER_SERVICE, peerService));
|
AttributesExtractor.constant(PEER_SERVICE, peerService));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new DubboTelemetry(
|
return new DubboTelemetry(
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.linecorp.armeria.common.RequestContext;
|
||||||
import com.linecorp.armeria.common.logging.RequestLog;
|
import com.linecorp.armeria.common.logging.RequestLog;
|
||||||
import com.linecorp.armeria.server.ServiceRequestContext;
|
import com.linecorp.armeria.server.ServiceRequestContext;
|
||||||
import io.opentelemetry.api.OpenTelemetry;
|
import io.opentelemetry.api.OpenTelemetry;
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.instrumentation.api.incubator.semconv.http.HttpClientExperimentalMetrics;
|
import io.opentelemetry.instrumentation.api.incubator.semconv.http.HttpClientExperimentalMetrics;
|
||||||
import io.opentelemetry.instrumentation.api.incubator.semconv.http.HttpExperimentalAttributesExtractor;
|
import io.opentelemetry.instrumentation.api.incubator.semconv.http.HttpExperimentalAttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.incubator.semconv.http.HttpServerExperimentalMetrics;
|
import io.opentelemetry.instrumentation.api.incubator.semconv.http.HttpServerExperimentalMetrics;
|
||||||
|
@ -30,7 +31,6 @@ import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractorBuilder;
|
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractorBuilder;
|
||||||
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanStatusExtractor;
|
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanStatusExtractor;
|
||||||
import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaHttpClientAttributesGetter;
|
import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaHttpClientAttributesGetter;
|
||||||
import io.opentelemetry.semconv.incubating.PeerIncubatingAttributes;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -41,6 +41,8 @@ import javax.annotation.Nullable;
|
||||||
public final class ArmeriaTelemetryBuilder {
|
public final class ArmeriaTelemetryBuilder {
|
||||||
|
|
||||||
private static final String INSTRUMENTATION_NAME = "io.opentelemetry.armeria-1.3";
|
private static final String INSTRUMENTATION_NAME = "io.opentelemetry.armeria-1.3";
|
||||||
|
// copied from PeerIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> PEER_SERVICE = AttributeKey.stringKey("peer.service");
|
||||||
|
|
||||||
private final OpenTelemetry openTelemetry;
|
private final OpenTelemetry openTelemetry;
|
||||||
@Nullable private String peerService;
|
@Nullable private String peerService;
|
||||||
|
@ -243,7 +245,7 @@ public final class ArmeriaTelemetryBuilder {
|
||||||
|
|
||||||
if (peerService != null) {
|
if (peerService != null) {
|
||||||
clientInstrumenterBuilder.addAttributesExtractor(
|
clientInstrumenterBuilder.addAttributesExtractor(
|
||||||
AttributesExtractor.constant(PeerIncubatingAttributes.PEER_SERVICE, peerService));
|
AttributesExtractor.constant(PEER_SERVICE, peerService));
|
||||||
}
|
}
|
||||||
if (emitExperimentalHttpClientMetrics) {
|
if (emitExperimentalHttpClientMetrics) {
|
||||||
clientInstrumenterBuilder
|
clientInstrumenterBuilder
|
||||||
|
|
|
@ -6,11 +6,10 @@
|
||||||
package io.opentelemetry.instrumentation.awslambdacore.v1_0.internal;
|
package io.opentelemetry.instrumentation.awslambdacore.v1_0.internal;
|
||||||
|
|
||||||
import com.amazonaws.services.lambda.runtime.Context;
|
import com.amazonaws.services.lambda.runtime.Context;
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.awslambdacore.v1_0.AwsLambdaRequest;
|
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.MethodHandle;
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.lang.invoke.MethodType;
|
import java.lang.invoke.MethodType;
|
||||||
|
@ -23,6 +22,15 @@ import javax.annotation.Nullable;
|
||||||
public final class AwsLambdaFunctionAttributesExtractor
|
public final class AwsLambdaFunctionAttributesExtractor
|
||||||
implements AttributesExtractor<AwsLambdaRequest, Object> {
|
implements AttributesExtractor<AwsLambdaRequest, Object> {
|
||||||
|
|
||||||
|
// copied from FaasIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> FAAS_INVOCATION_ID =
|
||||||
|
AttributeKey.stringKey("faas.invocation_id");
|
||||||
|
// copied from CloudIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> CLOUD_ACCOUNT_ID =
|
||||||
|
AttributeKey.stringKey("cloud.account.id");
|
||||||
|
private static final AttributeKey<String> CLOUD_RESOURCE_ID =
|
||||||
|
AttributeKey.stringKey("cloud.resource_id");
|
||||||
|
|
||||||
@Nullable private static final MethodHandle GET_FUNCTION_ARN;
|
@Nullable private static final MethodHandle GET_FUNCTION_ARN;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -47,11 +55,11 @@ public final class AwsLambdaFunctionAttributesExtractor
|
||||||
io.opentelemetry.context.Context parentContext,
|
io.opentelemetry.context.Context parentContext,
|
||||||
AwsLambdaRequest request) {
|
AwsLambdaRequest request) {
|
||||||
Context awsContext = request.getAwsContext();
|
Context awsContext = request.getAwsContext();
|
||||||
attributes.put(FaasIncubatingAttributes.FAAS_INVOCATION_ID, awsContext.getAwsRequestId());
|
attributes.put(FAAS_INVOCATION_ID, awsContext.getAwsRequestId());
|
||||||
String arn = getFunctionArn(awsContext);
|
String arn = getFunctionArn(awsContext);
|
||||||
if (arn != null) {
|
if (arn != null) {
|
||||||
attributes.put(CloudIncubatingAttributes.CLOUD_RESOURCE_ID, arn);
|
attributes.put(CLOUD_RESOURCE_ID, arn);
|
||||||
attributes.put(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID, getAccountId(arn));
|
attributes.put(CLOUD_ACCOUNT_ID, getAccountId(arn));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,13 @@ import static io.opentelemetry.semconv.UserAgentAttributes.USER_AGENT_ORIGINAL;
|
||||||
|
|
||||||
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
|
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
|
||||||
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
|
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.awslambdacore.v1_0.AwsLambdaRequest;
|
import io.opentelemetry.instrumentation.awslambdacore.v1_0.AwsLambdaRequest;
|
||||||
import io.opentelemetry.semconv.HttpAttributes;
|
import io.opentelemetry.semconv.HttpAttributes;
|
||||||
import io.opentelemetry.semconv.UrlAttributes;
|
import io.opentelemetry.semconv.UrlAttributes;
|
||||||
import io.opentelemetry.semconv.incubating.FaasIncubatingAttributes;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
@ -31,6 +31,11 @@ import javax.annotation.Nullable;
|
||||||
final class ApiGatewayProxyAttributesExtractor
|
final class ApiGatewayProxyAttributesExtractor
|
||||||
implements AttributesExtractor<AwsLambdaRequest, Object> {
|
implements AttributesExtractor<AwsLambdaRequest, Object> {
|
||||||
|
|
||||||
|
// copied from FaasIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> FAAS_TRIGGER = AttributeKey.stringKey("faas.trigger");
|
||||||
|
// copied from FaasIncubatingAttributes.FaasTriggerValues
|
||||||
|
private static final String HTTP = "http";
|
||||||
|
|
||||||
private final Set<String> knownMethods;
|
private final Set<String> knownMethods;
|
||||||
|
|
||||||
ApiGatewayProxyAttributesExtractor(Set<String> knownMethods) {
|
ApiGatewayProxyAttributesExtractor(Set<String> knownMethods) {
|
||||||
|
@ -41,8 +46,7 @@ final class ApiGatewayProxyAttributesExtractor
|
||||||
public void onStart(
|
public void onStart(
|
||||||
AttributesBuilder attributes, Context parentContext, AwsLambdaRequest request) {
|
AttributesBuilder attributes, Context parentContext, AwsLambdaRequest request) {
|
||||||
if (request.getInput() instanceof APIGatewayProxyRequestEvent) {
|
if (request.getInput() instanceof APIGatewayProxyRequestEvent) {
|
||||||
attributes.put(
|
attributes.put(FAAS_TRIGGER, HTTP);
|
||||||
FaasIncubatingAttributes.FAAS_TRIGGER, FaasIncubatingAttributes.FaasTriggerValues.HTTP);
|
|
||||||
onRequest(attributes, (APIGatewayProxyRequestEvent) request.getInput());
|
onRequest(attributes, (APIGatewayProxyRequestEvent) request.getInput());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,17 +6,26 @@
|
||||||
package io.opentelemetry.instrumentation.awslambdaevents.v2_2.internal;
|
package io.opentelemetry.instrumentation.awslambdaevents.v2_2.internal;
|
||||||
|
|
||||||
import com.amazonaws.services.lambda.runtime.events.SQSEvent;
|
import com.amazonaws.services.lambda.runtime.events.SQSEvent;
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
class SqsEventAttributesExtractor implements AttributesExtractor<SQSEvent, Void> {
|
class SqsEventAttributesExtractor implements AttributesExtractor<SQSEvent, Void> {
|
||||||
|
|
||||||
|
// copied from MessagingIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> MESSAGING_OPERATION =
|
||||||
|
AttributeKey.stringKey("messaging.operation");
|
||||||
|
private static final AttributeKey<String> MESSAGING_SYSTEM =
|
||||||
|
AttributeKey.stringKey("messaging.system");
|
||||||
|
// copied from MessagingIncubatingAttributes.MessagingSystemValues
|
||||||
|
private static final String AWS_SQS = "aws_sqs";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart(AttributesBuilder attributes, Context parentContext, SQSEvent event) {
|
public void onStart(AttributesBuilder attributes, Context parentContext, SQSEvent event) {
|
||||||
attributes.put(MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS");
|
attributes.put(MESSAGING_SYSTEM, AWS_SQS);
|
||||||
attributes.put(MessagingIncubatingAttributes.MESSAGING_OPERATION, "process");
|
attributes.put(MESSAGING_OPERATION, "process");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,20 +6,32 @@
|
||||||
package io.opentelemetry.instrumentation.awslambdaevents.v2_2.internal;
|
package io.opentelemetry.instrumentation.awslambdaevents.v2_2.internal;
|
||||||
|
|
||||||
import com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage;
|
import com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage;
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
class SqsMessageAttributesExtractor implements AttributesExtractor<SQSMessage, Void> {
|
class SqsMessageAttributesExtractor implements AttributesExtractor<SQSMessage, Void> {
|
||||||
|
|
||||||
|
// copied from MessagingIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> MESSAGING_DESTINATION_NAME =
|
||||||
|
AttributeKey.stringKey("messaging.destination.name");
|
||||||
|
private static final AttributeKey<String> MESSAGING_MESSAGE_ID =
|
||||||
|
AttributeKey.stringKey("messaging.message.id");
|
||||||
|
private static final AttributeKey<String> MESSAGING_OPERATION =
|
||||||
|
AttributeKey.stringKey("messaging.operation");
|
||||||
|
private static final AttributeKey<String> MESSAGING_SYSTEM =
|
||||||
|
AttributeKey.stringKey("messaging.system");
|
||||||
|
// copied from MessagingIncubatingAttributes.MessagingSystemValues
|
||||||
|
private static final String AWS_SQS = "aws_sqs";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart(AttributesBuilder attributes, Context parentContext, SQSMessage message) {
|
public void onStart(AttributesBuilder attributes, Context parentContext, SQSMessage message) {
|
||||||
attributes.put(MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS");
|
attributes.put(MESSAGING_SYSTEM, AWS_SQS);
|
||||||
attributes.put(MessagingIncubatingAttributes.MESSAGING_OPERATION, "process");
|
attributes.put(MESSAGING_OPERATION, "process");
|
||||||
attributes.put(MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID, message.getMessageId());
|
attributes.put(MESSAGING_MESSAGE_ID, message.getMessageId());
|
||||||
attributes.put(
|
attributes.put(MESSAGING_DESTINATION_NAME, message.getEventSource());
|
||||||
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME, message.getEventSource());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -84,7 +84,9 @@ public class AwsLambdaSqsEventWrapperTest {
|
||||||
span.hasName("otel process")
|
span.hasName("otel process")
|
||||||
.hasKind(SpanKind.CONSUMER)
|
.hasKind(SpanKind.CONSUMER)
|
||||||
.hasAttributesSatisfyingExactly(
|
.hasAttributesSatisfyingExactly(
|
||||||
equalTo(MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
|
equalTo(
|
||||||
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
|
MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"))));
|
MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"))));
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,9 @@ public class AwsLambdaSqsMessageHandlerTest {
|
||||||
.hasKind(SpanKind.CONSUMER)
|
.hasKind(SpanKind.CONSUMER)
|
||||||
.hasParentSpanId(trace.getSpan(0).getSpanId())
|
.hasParentSpanId(trace.getSpan(0).getSpanId())
|
||||||
.hasAttributesSatisfyingExactly(
|
.hasAttributesSatisfyingExactly(
|
||||||
equalTo(MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
|
equalTo(
|
||||||
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
|
MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS),
|
||||||
equalTo(MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"))
|
equalTo(MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"))
|
||||||
.hasLinks(
|
.hasLinks(
|
||||||
LinkData.create(
|
LinkData.create(
|
||||||
|
@ -106,7 +108,9 @@ public class AwsLambdaSqsMessageHandlerTest {
|
||||||
.hasKind(SpanKind.CONSUMER)
|
.hasKind(SpanKind.CONSUMER)
|
||||||
.hasParentSpanId(trace.getSpan(1).getSpanId())
|
.hasParentSpanId(trace.getSpan(1).getSpanId())
|
||||||
.hasAttributesSatisfyingExactly(
|
.hasAttributesSatisfyingExactly(
|
||||||
equalTo(MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
|
equalTo(
|
||||||
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
|
MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS),
|
||||||
equalTo(MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"),
|
equalTo(MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"),
|
||||||
equalTo(MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID, "message1"),
|
equalTo(MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID, "message1"),
|
||||||
equalTo(
|
equalTo(
|
||||||
|
@ -123,7 +127,9 @@ public class AwsLambdaSqsMessageHandlerTest {
|
||||||
.hasKind(SpanKind.CONSUMER)
|
.hasKind(SpanKind.CONSUMER)
|
||||||
.hasParentSpanId(trace.getSpan(1).getSpanId())
|
.hasParentSpanId(trace.getSpan(1).getSpanId())
|
||||||
.hasAttributesSatisfyingExactly(
|
.hasAttributesSatisfyingExactly(
|
||||||
equalTo(MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
|
equalTo(
|
||||||
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
|
MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS),
|
||||||
equalTo(MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"),
|
equalTo(MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"),
|
||||||
equalTo(MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID, "message2"),
|
equalTo(MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID, "message2"),
|
||||||
equalTo(
|
equalTo(
|
||||||
|
|
|
@ -81,7 +81,8 @@ public abstract class AbstractAwsLambdaSqsEventHandlerTest {
|
||||||
.hasParentSpanId(trace.getSpan(0).getSpanId())
|
.hasParentSpanId(trace.getSpan(0).getSpanId())
|
||||||
.hasAttributesSatisfyingExactly(
|
.hasAttributesSatisfyingExactly(
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
|
MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"))
|
MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"))
|
||||||
.hasLinksSatisfying(
|
.hasLinksSatisfying(
|
||||||
|
@ -129,7 +130,8 @@ public abstract class AbstractAwsLambdaSqsEventHandlerTest {
|
||||||
.hasParentSpanId(trace.getSpan(0).getSpanId())
|
.hasParentSpanId(trace.getSpan(0).getSpanId())
|
||||||
.hasAttributesSatisfyingExactly(
|
.hasAttributesSatisfyingExactly(
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
|
MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"))
|
MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"))
|
||||||
.hasLinksSatisfying(
|
.hasLinksSatisfying(
|
||||||
|
|
|
@ -197,7 +197,7 @@ class S3TracingTest extends AgentInstrumentationSpecification {
|
||||||
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
|
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
|
||||||
"$ServerAttributes.SERVER_ADDRESS" String
|
"$ServerAttributes.SERVER_ADDRESS" String
|
||||||
"$ServerAttributes.SERVER_PORT" { it == null || Number }
|
"$ServerAttributes.SERVER_PORT" { it == null || Number }
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
|
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "s3ToSqsTestQueue"
|
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "s3ToSqsTestQueue"
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "process"
|
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "process"
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
|
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
|
||||||
|
@ -533,7 +533,7 @@ class S3TracingTest extends AgentInstrumentationSpecification {
|
||||||
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
|
"$UrlAttributes.URL_FULL" { it.startsWith("http://") }
|
||||||
"$ServerAttributes.SERVER_ADDRESS" String
|
"$ServerAttributes.SERVER_ADDRESS" String
|
||||||
"$ServerAttributes.SERVER_PORT" { it == null || Number }
|
"$ServerAttributes.SERVER_PORT" { it == null || Number }
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
|
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "s3ToSnsToSqsTestQueue"
|
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "s3ToSnsToSqsTestQueue"
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "process"
|
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "process"
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
|
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
|
||||||
|
|
|
@ -188,7 +188,7 @@ class SnsTracingTest extends AgentInstrumentationSpecification {
|
||||||
"$UrlAttributes.URL_FULL" String
|
"$UrlAttributes.URL_FULL" String
|
||||||
"$ServerAttributes.SERVER_ADDRESS" String
|
"$ServerAttributes.SERVER_ADDRESS" String
|
||||||
"$ServerAttributes.SERVER_PORT" { it == null || Number }
|
"$ServerAttributes.SERVER_PORT" { it == null || Number }
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
|
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "snsToSqsTestQueue"
|
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "snsToSqsTestQueue"
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "process"
|
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "process"
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
|
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
|
||||||
|
|
|
@ -8,19 +8,23 @@ package io.opentelemetry.instrumentation.awssdk.v1_11;
|
||||||
import com.amazonaws.AmazonWebServiceRequest;
|
import com.amazonaws.AmazonWebServiceRequest;
|
||||||
import com.amazonaws.Request;
|
import com.amazonaws.Request;
|
||||||
import com.amazonaws.Response;
|
import com.amazonaws.Response;
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil;
|
import io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil;
|
||||||
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class SnsAttributesExtractor implements AttributesExtractor<Request<?>, Response<?>> {
|
public class SnsAttributesExtractor implements AttributesExtractor<Request<?>, Response<?>> {
|
||||||
|
|
||||||
|
// copied from MessagingIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> MESSAGING_DESTINATION_NAME =
|
||||||
|
AttributeKey.stringKey("messaging.destination.name");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart(AttributesBuilder attributes, Context parentContext, Request<?> request) {
|
public void onStart(AttributesBuilder attributes, Context parentContext, Request<?> request) {
|
||||||
String destination = findMessageDestination(request.getOriginalRequest());
|
String destination = findMessageDestination(request.getOriginalRequest());
|
||||||
AttributesExtractorUtil.internalSet(
|
AttributesExtractorUtil.internalSet(attributes, MESSAGING_DESTINATION_NAME, destination);
|
||||||
attributes, MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME, destination);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -15,9 +15,12 @@ import javax.annotation.Nullable;
|
||||||
enum SqsAttributesGetter implements MessagingAttributesGetter<Request<?>, Response<?>> {
|
enum SqsAttributesGetter implements MessagingAttributesGetter<Request<?>, Response<?>> {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
|
// copied from MessagingIncubatingAttributes.MessagingSystemValues
|
||||||
|
private static final String AWS_SQS = "aws_sqs";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSystem(Request<?> request) {
|
public String getSystem(Request<?> request) {
|
||||||
return "AmazonSQS";
|
return AWS_SQS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -15,9 +15,12 @@ enum SqsProcessRequestAttributesGetter
|
||||||
implements MessagingAttributesGetter<SqsProcessRequest, Response<?>> {
|
implements MessagingAttributesGetter<SqsProcessRequest, Response<?>> {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
|
// copied from MessagingIncubatingAttributes.MessagingSystemValues
|
||||||
|
private static final String AWS_SQS = "aws_sqs";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSystem(SqsProcessRequest request) {
|
public String getSystem(SqsProcessRequest request) {
|
||||||
return "AmazonSQS";
|
return AWS_SQS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,9 +16,12 @@ enum SqsReceiveRequestAttributesGetter
|
||||||
implements MessagingAttributesGetter<SqsReceiveRequest, Response<?>> {
|
implements MessagingAttributesGetter<SqsReceiveRequest, Response<?>> {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
|
// copied from MessagingIncubatingAttributes.MessagingSystemValues
|
||||||
|
private static final String AWS_SQS = "aws_sqs";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSystem(SqsReceiveRequest request) {
|
public String getSystem(SqsReceiveRequest request) {
|
||||||
return "AmazonSQS";
|
return AWS_SQS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -127,7 +127,8 @@ public abstract class AbstractSqsSuppressReceiveSpansTest {
|
||||||
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
|
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
|
||||||
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
|
MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
||||||
"testSdkSqs"),
|
"testSdkSqs"),
|
||||||
|
@ -156,7 +157,8 @@ public abstract class AbstractSqsSuppressReceiveSpansTest {
|
||||||
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
|
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
|
||||||
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
|
MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
||||||
"testSdkSqs"),
|
"testSdkSqs"),
|
||||||
|
@ -234,7 +236,8 @@ public abstract class AbstractSqsSuppressReceiveSpansTest {
|
||||||
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
|
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
|
||||||
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
|
MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
||||||
"testSdkSqs"),
|
"testSdkSqs"),
|
||||||
|
@ -263,7 +266,8 @@ public abstract class AbstractSqsSuppressReceiveSpansTest {
|
||||||
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
|
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
|
||||||
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
|
MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
||||||
"testSdkSqs"),
|
"testSdkSqs"),
|
||||||
|
|
|
@ -159,7 +159,8 @@ public abstract class AbstractSqsTracingTest {
|
||||||
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
|
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
|
||||||
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
|
MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
||||||
"testSdkSqs"),
|
"testSdkSqs"),
|
||||||
|
@ -202,7 +203,8 @@ public abstract class AbstractSqsTracingTest {
|
||||||
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
|
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
|
||||||
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
|
MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
||||||
"testSdkSqs"),
|
"testSdkSqs"),
|
||||||
|
@ -243,7 +245,8 @@ public abstract class AbstractSqsTracingTest {
|
||||||
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
|
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
|
||||||
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
|
MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
||||||
"testSdkSqs"),
|
"testSdkSqs"),
|
||||||
|
@ -333,7 +336,8 @@ public abstract class AbstractSqsTracingTest {
|
||||||
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
|
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
|
||||||
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
|
MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
||||||
"testSdkSqs"),
|
"testSdkSqs"),
|
||||||
|
@ -401,7 +405,8 @@ public abstract class AbstractSqsTracingTest {
|
||||||
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
"AmazonSQS"),
|
MessagingIncubatingAttributes.MessagingSystemValues
|
||||||
|
.AWS_SQS),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
||||||
"testSdkSqs"),
|
"testSdkSqs"),
|
||||||
|
@ -437,7 +442,8 @@ public abstract class AbstractSqsTracingTest {
|
||||||
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
"AmazonSQS"),
|
MessagingIncubatingAttributes.MessagingSystemValues
|
||||||
|
.AWS_SQS),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
||||||
"testSdkSqs"),
|
"testSdkSqs"),
|
||||||
|
|
|
@ -7,7 +7,7 @@ package io.opentelemetry.instrumentation.awssdk.v2_2;
|
||||||
|
|
||||||
import static io.opentelemetry.instrumentation.awssdk.v2_2.FieldMapping.request;
|
import static io.opentelemetry.instrumentation.awssdk.v2_2.FieldMapping.request;
|
||||||
|
|
||||||
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -21,8 +21,8 @@ enum AwsSdkRequestType {
|
||||||
/*
|
/*
|
||||||
* Only one of TopicArn and TargetArn are permitted on an SNS request.
|
* Only one of TopicArn and TargetArn are permitted on an SNS request.
|
||||||
*/
|
*/
|
||||||
request(MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME.getKey(), "TargetArn"),
|
request(AttributeKeys.MESSAGING_DESTINATION_NAME.getKey(), "TargetArn"),
|
||||||
request(MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME.getKey(), "TopicArn"));
|
request(AttributeKeys.MESSAGING_DESTINATION_NAME.getKey(), "TopicArn"));
|
||||||
|
|
||||||
// Wrapping in unmodifiableMap
|
// Wrapping in unmodifiableMap
|
||||||
@SuppressWarnings("ImmutableEnumChecker")
|
@SuppressWarnings("ImmutableEnumChecker")
|
||||||
|
@ -35,4 +35,10 @@ enum AwsSdkRequestType {
|
||||||
List<FieldMapping> fields(FieldMapping.Type type) {
|
List<FieldMapping> fields(FieldMapping.Type type) {
|
||||||
return fields.get(type);
|
return fields.get(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class AttributeKeys {
|
||||||
|
// copied from MessagingIncubatingAttributes
|
||||||
|
static final AttributeKey<String> MESSAGING_DESTINATION_NAME =
|
||||||
|
AttributeKey.stringKey("messaging.destination.name");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,12 @@ import software.amazon.awssdk.core.interceptor.ExecutionAttributes;
|
||||||
enum SqsAttributesGetter implements MessagingAttributesGetter<ExecutionAttributes, Response> {
|
enum SqsAttributesGetter implements MessagingAttributesGetter<ExecutionAttributes, Response> {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
|
// copied from MessagingIncubatingAttributes.MessagingSystemValues
|
||||||
|
private static final String AWS_SQS = "aws_sqs";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSystem(ExecutionAttributes request) {
|
public String getSystem(ExecutionAttributes request) {
|
||||||
return "AmazonSQS";
|
return AWS_SQS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -15,9 +15,12 @@ enum SqsProcessRequestAttributesGetter
|
||||||
implements MessagingAttributesGetter<SqsProcessRequest, Response> {
|
implements MessagingAttributesGetter<SqsProcessRequest, Response> {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
|
// copied from MessagingIncubatingAttributes.MessagingSystemValues
|
||||||
|
private static final String AWS_SQS = "aws_sqs";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSystem(SqsProcessRequest request) {
|
public String getSystem(SqsProcessRequest request) {
|
||||||
return "AmazonSQS";
|
return AWS_SQS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,9 +16,12 @@ enum SqsReceiveRequestAttributesGetter
|
||||||
implements MessagingAttributesGetter<SqsReceiveRequest, Response> {
|
implements MessagingAttributesGetter<SqsReceiveRequest, Response> {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
|
// copied from MessagingIncubatingAttributes.MessagingSystemValues
|
||||||
|
private static final String AWS_SQS = "aws_sqs";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSystem(SqsReceiveRequest request) {
|
public String getSystem(SqsReceiveRequest request) {
|
||||||
return "AmazonSQS";
|
return AWS_SQS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -18,7 +18,6 @@ import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
|
||||||
import io.opentelemetry.instrumentation.api.internal.InstrumenterUtil;
|
import io.opentelemetry.instrumentation.api.internal.InstrumenterUtil;
|
||||||
import io.opentelemetry.instrumentation.api.internal.Timer;
|
import io.opentelemetry.instrumentation.api.internal.Timer;
|
||||||
import io.opentelemetry.semconv.HttpAttributes;
|
import io.opentelemetry.semconv.HttpAttributes;
|
||||||
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -44,6 +43,12 @@ import software.amazon.awssdk.http.SdkHttpResponse;
|
||||||
/** AWS request execution interceptor. */
|
/** AWS request execution interceptor. */
|
||||||
final class TracingExecutionInterceptor implements ExecutionInterceptor {
|
final class TracingExecutionInterceptor implements ExecutionInterceptor {
|
||||||
|
|
||||||
|
// copied from DbIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> DB_OPERATION = AttributeKey.stringKey("db.operation");
|
||||||
|
private static final AttributeKey<String> DB_SYSTEM = AttributeKey.stringKey("db.system");
|
||||||
|
// copied from DbIncubatingAttributes.DbSystemValues
|
||||||
|
private static final String DB_SYSTEM_DYNAMODB = "dynamodb";
|
||||||
|
|
||||||
// the class name is part of the attribute name, so that it will be shaded when used in javaagent
|
// the class name is part of the attribute name, so that it will be shaded when used in javaagent
|
||||||
// instrumentation, and won't conflict with usage outside javaagent instrumentation
|
// instrumentation, and won't conflict with usage outside javaagent instrumentation
|
||||||
private static final ExecutionAttribute<io.opentelemetry.context.Context> CONTEXT_ATTRIBUTE =
|
private static final ExecutionAttribute<io.opentelemetry.context.Context> CONTEXT_ATTRIBUTE =
|
||||||
|
@ -311,10 +316,10 @@ final class TracingExecutionInterceptor implements ExecutionInterceptor {
|
||||||
fieldMapper.mapToAttributes(sdkRequest, awsSdkRequest, span);
|
fieldMapper.mapToAttributes(sdkRequest, awsSdkRequest, span);
|
||||||
|
|
||||||
if (awsSdkRequest.type() == DYNAMODB) {
|
if (awsSdkRequest.type() == DYNAMODB) {
|
||||||
span.setAttribute(DbIncubatingAttributes.DB_SYSTEM, "dynamodb");
|
span.setAttribute(DB_SYSTEM, DB_SYSTEM_DYNAMODB);
|
||||||
String operation = attributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME);
|
String operation = attributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME);
|
||||||
if (operation != null) {
|
if (operation != null) {
|
||||||
span.setAttribute(DbIncubatingAttributes.DB_OPERATION, operation);
|
span.setAttribute(DB_OPERATION, operation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,7 +145,7 @@ abstract class AbstractAws2ClientTest extends AbstractAws2ClientCoreTest {
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "somequeue"
|
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "somequeue"
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "publish"
|
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "publish"
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
|
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
|
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS
|
||||||
} else if (service == "Kinesis") {
|
} else if (service == "Kinesis") {
|
||||||
"aws.stream.name" "somestream"
|
"aws.stream.name" "somestream"
|
||||||
} else if (service == "Sns") {
|
} else if (service == "Sns") {
|
||||||
|
@ -305,7 +305,7 @@ abstract class AbstractAws2ClientTest extends AbstractAws2ClientCoreTest {
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "somequeue"
|
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "somequeue"
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "publish"
|
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "publish"
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
|
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
|
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS
|
||||||
} else if (service == "Kinesis") {
|
} else if (service == "Kinesis") {
|
||||||
"aws.stream.name" "somestream"
|
"aws.stream.name" "somestream"
|
||||||
} else if (service == "Sns") {
|
} else if (service == "Sns") {
|
||||||
|
|
|
@ -157,7 +157,7 @@ abstract class AbstractAws2SqsSuppressReceiveSpansTest extends InstrumentationSp
|
||||||
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
|
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
|
||||||
"$ServerAttributes.SERVER_ADDRESS" "localhost"
|
"$ServerAttributes.SERVER_ADDRESS" "localhost"
|
||||||
"$ServerAttributes.SERVER_PORT" sqsPort
|
"$ServerAttributes.SERVER_PORT" sqsPort
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
|
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
|
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "publish"
|
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "publish"
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
|
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
|
||||||
|
@ -178,7 +178,7 @@ abstract class AbstractAws2SqsSuppressReceiveSpansTest extends InstrumentationSp
|
||||||
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
|
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
|
||||||
"$ServerAttributes.SERVER_ADDRESS" "localhost"
|
"$ServerAttributes.SERVER_ADDRESS" "localhost"
|
||||||
"$ServerAttributes.SERVER_PORT" sqsPort
|
"$ServerAttributes.SERVER_PORT" sqsPort
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
|
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
|
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "process"
|
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "process"
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
|
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
|
||||||
|
@ -329,7 +329,7 @@ abstract class AbstractAws2SqsSuppressReceiveSpansTest extends InstrumentationSp
|
||||||
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
|
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
|
||||||
"$ServerAttributes.SERVER_ADDRESS" "localhost"
|
"$ServerAttributes.SERVER_ADDRESS" "localhost"
|
||||||
"$ServerAttributes.SERVER_PORT" sqsPort
|
"$ServerAttributes.SERVER_PORT" sqsPort
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
|
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
|
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "publish"
|
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "publish"
|
||||||
}
|
}
|
||||||
|
@ -351,7 +351,7 @@ abstract class AbstractAws2SqsSuppressReceiveSpansTest extends InstrumentationSp
|
||||||
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
|
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
|
||||||
"$ServerAttributes.SERVER_ADDRESS" "localhost"
|
"$ServerAttributes.SERVER_ADDRESS" "localhost"
|
||||||
"$ServerAttributes.SERVER_PORT" sqsPort
|
"$ServerAttributes.SERVER_PORT" sqsPort
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
|
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
|
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "process"
|
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "process"
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
|
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
|
||||||
|
@ -379,7 +379,7 @@ abstract class AbstractAws2SqsSuppressReceiveSpansTest extends InstrumentationSp
|
||||||
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
|
"$UrlAttributes.URL_FULL" { it.startsWith("http://localhost:$sqsPort") }
|
||||||
"$ServerAttributes.SERVER_ADDRESS" "localhost"
|
"$ServerAttributes.SERVER_ADDRESS" "localhost"
|
||||||
"$ServerAttributes.SERVER_PORT" sqsPort
|
"$ServerAttributes.SERVER_PORT" sqsPort
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" "AmazonSQS"
|
"$MessagingIncubatingAttributes.MESSAGING_SYSTEM" MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
|
"$MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME" "testSdkSqs"
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "process"
|
"$MessagingIncubatingAttributes.MESSAGING_OPERATION" "process"
|
||||||
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
|
"$MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID" String
|
||||||
|
|
|
@ -215,7 +215,8 @@ public abstract class AbstractAws2SqsTracingTest {
|
||||||
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
|
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
|
||||||
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
|
MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
||||||
"testSdkSqs"),
|
"testSdkSqs"),
|
||||||
|
@ -298,7 +299,8 @@ public abstract class AbstractAws2SqsTracingTest {
|
||||||
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
"AmazonSQS"),
|
MessagingIncubatingAttributes.MessagingSystemValues
|
||||||
|
.AWS_SQS),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
||||||
"testSdkSqs"),
|
"testSdkSqs"),
|
||||||
|
@ -344,7 +346,8 @@ public abstract class AbstractAws2SqsTracingTest {
|
||||||
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
"AmazonSQS"),
|
MessagingIncubatingAttributes.MessagingSystemValues
|
||||||
|
.AWS_SQS),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
||||||
"testSdkSqs"),
|
"testSdkSqs"),
|
||||||
|
@ -522,7 +525,9 @@ public abstract class AbstractAws2SqsTracingTest {
|
||||||
v -> v.startsWith("http://localhost:" + sqsPort)),
|
v -> v.startsWith("http://localhost:" + sqsPort)),
|
||||||
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
|
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
|
||||||
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
||||||
equalTo(MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
|
equalTo(
|
||||||
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
|
MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
||||||
"testSdkSqs"),
|
"testSdkSqs"),
|
||||||
|
@ -549,7 +554,9 @@ public abstract class AbstractAws2SqsTracingTest {
|
||||||
v -> v.startsWith("http://localhost:" + sqsPort)),
|
v -> v.startsWith("http://localhost:" + sqsPort)),
|
||||||
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
|
equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"),
|
||||||
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
||||||
equalTo(MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS"),
|
equalTo(
|
||||||
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
|
MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
||||||
"testSdkSqs"),
|
"testSdkSqs"),
|
||||||
|
@ -596,7 +603,8 @@ public abstract class AbstractAws2SqsTracingTest {
|
||||||
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
equalTo(ServerAttributes.SERVER_PORT, sqsPort),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
"AmazonSQS"),
|
MessagingIncubatingAttributes.MessagingSystemValues
|
||||||
|
.AWS_SQS),
|
||||||
equalTo(
|
equalTo(
|
||||||
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME,
|
||||||
"testSdkSqs"),
|
"testSdkSqs"),
|
||||||
|
|
|
@ -95,7 +95,9 @@ class AwsSpanAssertions {
|
||||||
attributeAssertions.addAll(
|
attributeAssertions.addAll(
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
equalTo(MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME, queueName),
|
equalTo(MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME, queueName),
|
||||||
equalTo(MessagingIncubatingAttributes.MESSAGING_SYSTEM, "AmazonSQS")));
|
equalTo(
|
||||||
|
MessagingIncubatingAttributes.MESSAGING_SYSTEM,
|
||||||
|
MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS)));
|
||||||
if (spanName.endsWith("receive")) {
|
if (spanName.endsWith("receive")) {
|
||||||
attributeAssertions.add(
|
attributeAssertions.add(
|
||||||
equalTo(MessagingIncubatingAttributes.MESSAGING_OPERATION, "receive"));
|
equalTo(MessagingIncubatingAttributes.MESSAGING_OPERATION, "receive"));
|
||||||
|
|
|
@ -13,11 +13,11 @@ import com.datastax.oss.driver.api.core.metadata.EndPoint;
|
||||||
import com.datastax.oss.driver.api.core.metadata.Node;
|
import com.datastax.oss.driver.api.core.metadata.Node;
|
||||||
import com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint;
|
import com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint;
|
||||||
import com.datastax.oss.driver.internal.core.metadata.SniEndPoint;
|
import com.datastax.oss.driver.internal.core.metadata.SniEndPoint;
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.ServerAttributes;
|
import io.opentelemetry.semconv.ServerAttributes;
|
||||||
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -30,6 +30,20 @@ final class CassandraAttributesExtractor
|
||||||
private static final Logger logger =
|
private static final Logger logger =
|
||||||
Logger.getLogger(CassandraAttributesExtractor.class.getName());
|
Logger.getLogger(CassandraAttributesExtractor.class.getName());
|
||||||
|
|
||||||
|
// copied from DbIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> DB_CASSANDRA_CONSISTENCY_LEVEL =
|
||||||
|
AttributeKey.stringKey("db.cassandra.consistency_level");
|
||||||
|
private static final AttributeKey<String> DB_CASSANDRA_COORDINATOR_DC =
|
||||||
|
AttributeKey.stringKey("db.cassandra.coordinator.dc");
|
||||||
|
private static final AttributeKey<String> DB_CASSANDRA_COORDINATOR_ID =
|
||||||
|
AttributeKey.stringKey("db.cassandra.coordinator.id");
|
||||||
|
private static final AttributeKey<Boolean> DB_CASSANDRA_IDEMPOTENCE =
|
||||||
|
AttributeKey.booleanKey("db.cassandra.idempotence");
|
||||||
|
private static final AttributeKey<Long> DB_CASSANDRA_PAGE_SIZE =
|
||||||
|
AttributeKey.longKey("db.cassandra.page_size");
|
||||||
|
private static final AttributeKey<Long> DB_CASSANDRA_SPECULATIVE_EXECUTION_COUNT =
|
||||||
|
AttributeKey.longKey("db.cassandra.speculative_execution_count");
|
||||||
|
|
||||||
private static final Field proxyAddressField = getProxyAddressField();
|
private static final Field proxyAddressField = getProxyAddressField();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -52,17 +66,14 @@ final class CassandraAttributesExtractor
|
||||||
updateServerAddressAndPort(attributes, coordinator);
|
updateServerAddressAndPort(attributes, coordinator);
|
||||||
|
|
||||||
if (coordinator.getDatacenter() != null) {
|
if (coordinator.getDatacenter() != null) {
|
||||||
attributes.put(
|
attributes.put(DB_CASSANDRA_COORDINATOR_DC, coordinator.getDatacenter());
|
||||||
DbIncubatingAttributes.DB_CASSANDRA_COORDINATOR_DC, coordinator.getDatacenter());
|
|
||||||
}
|
}
|
||||||
if (coordinator.getHostId() != null) {
|
if (coordinator.getHostId() != null) {
|
||||||
attributes.put(
|
attributes.put(DB_CASSANDRA_COORDINATOR_ID, coordinator.getHostId().toString());
|
||||||
DbIncubatingAttributes.DB_CASSANDRA_COORDINATOR_ID, coordinator.getHostId().toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
attributes.put(
|
attributes.put(
|
||||||
DbIncubatingAttributes.DB_CASSANDRA_SPECULATIVE_EXECUTION_COUNT,
|
DB_CASSANDRA_SPECULATIVE_EXECUTION_COUNT, executionInfo.getSpeculativeExecutionCount());
|
||||||
executionInfo.getSpeculativeExecutionCount());
|
|
||||||
|
|
||||||
Statement<?> statement = (Statement<?>) executionInfo.getRequest();
|
Statement<?> statement = (Statement<?>) executionInfo.getRequest();
|
||||||
String consistencyLevel;
|
String consistencyLevel;
|
||||||
|
@ -73,14 +84,14 @@ final class CassandraAttributesExtractor
|
||||||
} else {
|
} else {
|
||||||
consistencyLevel = config.getString(DefaultDriverOption.REQUEST_CONSISTENCY);
|
consistencyLevel = config.getString(DefaultDriverOption.REQUEST_CONSISTENCY);
|
||||||
}
|
}
|
||||||
attributes.put(DbIncubatingAttributes.DB_CASSANDRA_CONSISTENCY_LEVEL, consistencyLevel);
|
attributes.put(DB_CASSANDRA_CONSISTENCY_LEVEL, consistencyLevel);
|
||||||
|
|
||||||
if (statement.getPageSize() > 0) {
|
if (statement.getPageSize() > 0) {
|
||||||
attributes.put(DbIncubatingAttributes.DB_CASSANDRA_PAGE_SIZE, statement.getPageSize());
|
attributes.put(DB_CASSANDRA_PAGE_SIZE, statement.getPageSize());
|
||||||
} else {
|
} else {
|
||||||
int pageSize = config.getInt(DefaultDriverOption.REQUEST_PAGE_SIZE);
|
int pageSize = config.getInt(DefaultDriverOption.REQUEST_PAGE_SIZE);
|
||||||
if (pageSize > 0) {
|
if (pageSize > 0) {
|
||||||
attributes.put(DbIncubatingAttributes.DB_CASSANDRA_PAGE_SIZE, pageSize);
|
attributes.put(DB_CASSANDRA_PAGE_SIZE, pageSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +99,7 @@ final class CassandraAttributesExtractor
|
||||||
if (idempotent == null) {
|
if (idempotent == null) {
|
||||||
idempotent = config.getBoolean(DefaultDriverOption.REQUEST_DEFAULT_IDEMPOTENCE);
|
idempotent = config.getBoolean(DefaultDriverOption.REQUEST_DEFAULT_IDEMPOTENCE);
|
||||||
}
|
}
|
||||||
attributes.put(DbIncubatingAttributes.DB_CASSANDRA_IDEMPOTENCE, idempotent);
|
attributes.put(DB_CASSANDRA_IDEMPOTENCE, idempotent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updateServerAddressAndPort(AttributesBuilder attributes, Node coordinator) {
|
private static void updateServerAddressAndPort(AttributesBuilder attributes, Node coordinator) {
|
||||||
|
|
|
@ -7,14 +7,15 @@ package io.opentelemetry.instrumentation.cassandra.v4_4;
|
||||||
|
|
||||||
import com.datastax.oss.driver.api.core.CqlIdentifier;
|
import com.datastax.oss.driver.api.core.CqlIdentifier;
|
||||||
import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesGetter;
|
import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesGetter;
|
||||||
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
final class CassandraSqlAttributesGetter implements SqlClientAttributesGetter<CassandraRequest> {
|
final class CassandraSqlAttributesGetter implements SqlClientAttributesGetter<CassandraRequest> {
|
||||||
|
// copied from DbIncubatingAttributes.DbSystemValues
|
||||||
|
private static final String CASSANDRA = "cassandra";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSystem(CassandraRequest request) {
|
public String getSystem(CassandraRequest request) {
|
||||||
return DbIncubatingAttributes.DbSystemValues.CASSANDRA;
|
return CASSANDRA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -8,17 +8,20 @@ package io.opentelemetry.instrumentation.cassandra.v4_4;
|
||||||
import com.datastax.oss.driver.api.core.cql.ExecutionInfo;
|
import com.datastax.oss.driver.api.core.cql.ExecutionInfo;
|
||||||
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||||
import io.opentelemetry.api.OpenTelemetry;
|
import io.opentelemetry.api.OpenTelemetry;
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientSpanNameExtractor;
|
import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientSpanNameExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesExtractor;
|
import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
|
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor;
|
import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor;
|
||||||
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
|
|
||||||
|
|
||||||
/** A builder of {@link CassandraTelemetry}. */
|
/** A builder of {@link CassandraTelemetry}. */
|
||||||
public class CassandraTelemetryBuilder {
|
public class CassandraTelemetryBuilder {
|
||||||
|
|
||||||
private static final String INSTRUMENTATION_NAME = "io.opentelemetry.cassandra-4.4";
|
private static final String INSTRUMENTATION_NAME = "io.opentelemetry.cassandra-4.4";
|
||||||
|
// copied from DbIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> DB_CASSANDRA_TABLE =
|
||||||
|
AttributeKey.stringKey("db.cassandra.table");
|
||||||
|
|
||||||
private final OpenTelemetry openTelemetry;
|
private final OpenTelemetry openTelemetry;
|
||||||
|
|
||||||
|
@ -55,7 +58,7 @@ public class CassandraTelemetryBuilder {
|
||||||
openTelemetry, INSTRUMENTATION_NAME, DbClientSpanNameExtractor.create(attributesGetter))
|
openTelemetry, INSTRUMENTATION_NAME, DbClientSpanNameExtractor.create(attributesGetter))
|
||||||
.addAttributesExtractor(
|
.addAttributesExtractor(
|
||||||
SqlClientAttributesExtractor.builder(attributesGetter)
|
SqlClientAttributesExtractor.builder(attributesGetter)
|
||||||
.setTableAttribute(DbIncubatingAttributes.DB_CASSANDRA_TABLE)
|
.setTableAttribute(DB_CASSANDRA_TABLE)
|
||||||
.setStatementSanitizationEnabled(statementSanitizationEnabled)
|
.setStatementSanitizationEnabled(statementSanitizationEnabled)
|
||||||
.build())
|
.build())
|
||||||
.addAttributesExtractor(
|
.addAttributesExtractor(
|
||||||
|
|
|
@ -8,7 +8,6 @@ package io.opentelemetry.instrumentation.elasticsearch.rest.internal;
|
||||||
import static java.util.logging.Level.FINE;
|
import static java.util.logging.Level.FINE;
|
||||||
|
|
||||||
import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientAttributesGetter;
|
import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientAttributesGetter;
|
||||||
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
@ -28,6 +27,9 @@ final class ElasticsearchDbAttributesGetter
|
||||||
private static final Logger logger =
|
private static final Logger logger =
|
||||||
Logger.getLogger(ElasticsearchDbAttributesGetter.class.getName());
|
Logger.getLogger(ElasticsearchDbAttributesGetter.class.getName());
|
||||||
|
|
||||||
|
// copied from DbIncubatingAttributes.DbSystemValues
|
||||||
|
private static final String ELASTICSEARCH = "elasticsearch";
|
||||||
|
|
||||||
private final boolean captureSearchQuery;
|
private final boolean captureSearchQuery;
|
||||||
|
|
||||||
ElasticsearchDbAttributesGetter(boolean captureSearchQuery) {
|
ElasticsearchDbAttributesGetter(boolean captureSearchQuery) {
|
||||||
|
@ -36,7 +38,7 @@ final class ElasticsearchDbAttributesGetter
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSystem(ElasticsearchRestRequest request) {
|
public String getSystem(ElasticsearchRestRequest request) {
|
||||||
return DbIncubatingAttributes.DbSystemValues.ELASTICSEARCH;
|
return ELASTICSEARCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -9,14 +9,19 @@ import static io.opentelemetry.instrumentation.grpc.v1_6.CapturedGrpcMetadataUti
|
||||||
import static io.opentelemetry.instrumentation.grpc.v1_6.CapturedGrpcMetadataUtil.requestAttributeKey;
|
import static io.opentelemetry.instrumentation.grpc.v1_6.CapturedGrpcMetadataUtil.requestAttributeKey;
|
||||||
|
|
||||||
import io.grpc.Status;
|
import io.grpc.Status;
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.incubating.RpcIncubatingAttributes;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
final class GrpcAttributesExtractor implements AttributesExtractor<GrpcRequest, Status> {
|
final class GrpcAttributesExtractor implements AttributesExtractor<GrpcRequest, Status> {
|
||||||
|
|
||||||
|
// copied from RpcIncubatingAttributes
|
||||||
|
private static final AttributeKey<Long> RPC_GRPC_STATUS_CODE =
|
||||||
|
AttributeKey.longKey("rpc.grpc.status_code");
|
||||||
|
|
||||||
private final GrpcRpcAttributesGetter getter;
|
private final GrpcRpcAttributesGetter getter;
|
||||||
private final List<String> capturedRequestMetadata;
|
private final List<String> capturedRequestMetadata;
|
||||||
|
|
||||||
|
@ -39,7 +44,7 @@ final class GrpcAttributesExtractor implements AttributesExtractor<GrpcRequest,
|
||||||
@Nullable Status status,
|
@Nullable Status status,
|
||||||
@Nullable Throwable error) {
|
@Nullable Throwable error) {
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
attributes.put(RpcIncubatingAttributes.RPC_GRPC_STATUS_CODE, status.getCode().value());
|
attributes.put(RPC_GRPC_STATUS_CODE, status.getCode().value());
|
||||||
}
|
}
|
||||||
for (String key : capturedRequestMetadata) {
|
for (String key : capturedRequestMetadata) {
|
||||||
List<String> value = getter.metadataValue(request, key);
|
List<String> value = getter.metadataValue(request, key);
|
||||||
|
|
|
@ -8,6 +8,7 @@ package io.opentelemetry.instrumentation.grpc.v1_6;
|
||||||
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||||
import io.grpc.Status;
|
import io.grpc.Status;
|
||||||
import io.opentelemetry.api.OpenTelemetry;
|
import io.opentelemetry.api.OpenTelemetry;
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.instrumentation.api.incubator.semconv.rpc.RpcClientAttributesExtractor;
|
import io.opentelemetry.instrumentation.api.incubator.semconv.rpc.RpcClientAttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.incubator.semconv.rpc.RpcClientMetrics;
|
import io.opentelemetry.instrumentation.api.incubator.semconv.rpc.RpcClientMetrics;
|
||||||
import io.opentelemetry.instrumentation.api.incubator.semconv.rpc.RpcServerAttributesExtractor;
|
import io.opentelemetry.instrumentation.api.incubator.semconv.rpc.RpcServerAttributesExtractor;
|
||||||
|
@ -20,7 +21,6 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor;
|
import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.semconv.network.ServerAttributesExtractor;
|
import io.opentelemetry.instrumentation.api.semconv.network.ServerAttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.grpc.v1_6.internal.GrpcClientNetworkAttributesGetter;
|
import io.opentelemetry.instrumentation.grpc.v1_6.internal.GrpcClientNetworkAttributesGetter;
|
||||||
import io.opentelemetry.semconv.incubating.PeerIncubatingAttributes;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -31,6 +31,8 @@ import javax.annotation.Nullable;
|
||||||
public final class GrpcTelemetryBuilder {
|
public final class GrpcTelemetryBuilder {
|
||||||
|
|
||||||
private static final String INSTRUMENTATION_NAME = "io.opentelemetry.grpc-1.6";
|
private static final String INSTRUMENTATION_NAME = "io.opentelemetry.grpc-1.6";
|
||||||
|
// copied from PeerIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> PEER_SERVICE = AttributeKey.stringKey("peer.service");
|
||||||
|
|
||||||
private final OpenTelemetry openTelemetry;
|
private final OpenTelemetry openTelemetry;
|
||||||
@Nullable private String peerService;
|
@Nullable private String peerService;
|
||||||
|
@ -197,7 +199,7 @@ public final class GrpcTelemetryBuilder {
|
||||||
|
|
||||||
if (peerService != null) {
|
if (peerService != null) {
|
||||||
clientInstrumenterBuilder.addAttributesExtractor(
|
clientInstrumenterBuilder.addAttributesExtractor(
|
||||||
AttributesExtractor.constant(PeerIncubatingAttributes.PEER_SERVICE, peerService));
|
AttributesExtractor.constant(PEER_SERVICE, peerService));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new GrpcTelemetry(
|
return new GrpcTelemetry(
|
||||||
|
|
|
@ -15,17 +15,24 @@ import io.grpc.Grpc;
|
||||||
import io.grpc.Metadata;
|
import io.grpc.Metadata;
|
||||||
import io.grpc.MethodDescriptor;
|
import io.grpc.MethodDescriptor;
|
||||||
import io.grpc.Status;
|
import io.grpc.Status;
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.Attributes;
|
import io.opentelemetry.api.common.Attributes;
|
||||||
import io.opentelemetry.api.trace.Span;
|
import io.opentelemetry.api.trace.Span;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.context.Scope;
|
import io.opentelemetry.context.Scope;
|
||||||
import io.opentelemetry.context.propagation.ContextPropagators;
|
import io.opentelemetry.context.propagation.ContextPropagators;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
|
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
|
||||||
import io.opentelemetry.semconv.incubating.MessageIncubatingAttributes;
|
|
||||||
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
|
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
|
||||||
|
|
||||||
final class TracingClientInterceptor implements ClientInterceptor {
|
final class TracingClientInterceptor implements ClientInterceptor {
|
||||||
|
|
||||||
|
// copied from MessageIncubatingAttributes
|
||||||
|
private static final AttributeKey<Long> MESSAGE_ID = AttributeKey.longKey("message.id");
|
||||||
|
private static final AttributeKey<String> MESSAGE_TYPE = AttributeKey.stringKey("message.type");
|
||||||
|
// copied from MessageIncubatingAttributes.MessageTypeValues
|
||||||
|
private static final String SENT = "SENT";
|
||||||
|
private static final String RECEIVED = "RECEIVED";
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
private static final AtomicLongFieldUpdater<TracingClientCall> MESSAGE_ID_UPDATER =
|
private static final AtomicLongFieldUpdater<TracingClientCall> MESSAGE_ID_UPDATER =
|
||||||
AtomicLongFieldUpdater.newUpdater(TracingClientCall.class, "messageId");
|
AtomicLongFieldUpdater.newUpdater(TracingClientCall.class, "messageId");
|
||||||
|
@ -110,11 +117,7 @@ final class TracingClientInterceptor implements ClientInterceptor {
|
||||||
}
|
}
|
||||||
Span span = Span.fromContext(context);
|
Span span = Span.fromContext(context);
|
||||||
Attributes attributes =
|
Attributes attributes =
|
||||||
Attributes.of(
|
Attributes.of(MESSAGE_TYPE, SENT, MESSAGE_ID, MESSAGE_ID_UPDATER.incrementAndGet(this));
|
||||||
MessageIncubatingAttributes.MESSAGE_TYPE,
|
|
||||||
MessageIncubatingAttributes.MessageTypeValues.SENT,
|
|
||||||
MessageIncubatingAttributes.MESSAGE_ID,
|
|
||||||
MESSAGE_ID_UPDATER.incrementAndGet(this));
|
|
||||||
span.addEvent("message", attributes);
|
span.addEvent("message", attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,9 +144,9 @@ final class TracingClientInterceptor implements ClientInterceptor {
|
||||||
Span span = Span.fromContext(context);
|
Span span = Span.fromContext(context);
|
||||||
Attributes attributes =
|
Attributes attributes =
|
||||||
Attributes.of(
|
Attributes.of(
|
||||||
MessageIncubatingAttributes.MESSAGE_TYPE,
|
MESSAGE_TYPE,
|
||||||
MessageIncubatingAttributes.MessageTypeValues.RECEIVED,
|
RECEIVED,
|
||||||
MessageIncubatingAttributes.MESSAGE_ID,
|
MESSAGE_ID,
|
||||||
MESSAGE_ID_UPDATER.incrementAndGet(TracingClientCall.this));
|
MESSAGE_ID_UPDATER.incrementAndGet(TracingClientCall.this));
|
||||||
span.addEvent("message", attributes);
|
span.addEvent("message", attributes);
|
||||||
try (Scope ignored = context.makeCurrent()) {
|
try (Scope ignored = context.makeCurrent()) {
|
||||||
|
|
|
@ -14,16 +14,23 @@ import io.grpc.ServerCall;
|
||||||
import io.grpc.ServerCallHandler;
|
import io.grpc.ServerCallHandler;
|
||||||
import io.grpc.ServerInterceptor;
|
import io.grpc.ServerInterceptor;
|
||||||
import io.grpc.Status;
|
import io.grpc.Status;
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.Attributes;
|
import io.opentelemetry.api.common.Attributes;
|
||||||
import io.opentelemetry.api.trace.Span;
|
import io.opentelemetry.api.trace.Span;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.context.Scope;
|
import io.opentelemetry.context.Scope;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
|
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
|
||||||
import io.opentelemetry.semconv.incubating.MessageIncubatingAttributes;
|
|
||||||
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
|
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
|
||||||
|
|
||||||
final class TracingServerInterceptor implements ServerInterceptor {
|
final class TracingServerInterceptor implements ServerInterceptor {
|
||||||
|
|
||||||
|
// copied from MessageIncubatingAttributes
|
||||||
|
private static final AttributeKey<Long> MESSAGE_ID = AttributeKey.longKey("message.id");
|
||||||
|
private static final AttributeKey<String> MESSAGE_TYPE = AttributeKey.stringKey("message.type");
|
||||||
|
// copied from MessageIncubatingAttributes.MessageTypeValues
|
||||||
|
private static final String SENT = "SENT";
|
||||||
|
private static final String RECEIVED = "RECEIVED";
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
private static final AtomicLongFieldUpdater<TracingServerCall> MESSAGE_ID_UPDATER =
|
private static final AtomicLongFieldUpdater<TracingServerCall> MESSAGE_ID_UPDATER =
|
||||||
AtomicLongFieldUpdater.newUpdater(TracingServerCall.class, "messageId");
|
AtomicLongFieldUpdater.newUpdater(TracingServerCall.class, "messageId");
|
||||||
|
@ -92,11 +99,7 @@ final class TracingServerInterceptor implements ServerInterceptor {
|
||||||
}
|
}
|
||||||
Span span = Span.fromContext(context);
|
Span span = Span.fromContext(context);
|
||||||
Attributes attributes =
|
Attributes attributes =
|
||||||
Attributes.of(
|
Attributes.of(MESSAGE_TYPE, SENT, MESSAGE_ID, MESSAGE_ID_UPDATER.incrementAndGet(this));
|
||||||
MessageIncubatingAttributes.MESSAGE_TYPE,
|
|
||||||
MessageIncubatingAttributes.MessageTypeValues.SENT,
|
|
||||||
MessageIncubatingAttributes.MESSAGE_ID,
|
|
||||||
MESSAGE_ID_UPDATER.incrementAndGet(this));
|
|
||||||
span.addEvent("message", attributes);
|
span.addEvent("message", attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,9 +129,9 @@ final class TracingServerInterceptor implements ServerInterceptor {
|
||||||
public void onMessage(REQUEST message) {
|
public void onMessage(REQUEST message) {
|
||||||
Attributes attributes =
|
Attributes attributes =
|
||||||
Attributes.of(
|
Attributes.of(
|
||||||
MessageIncubatingAttributes.MESSAGE_TYPE,
|
MESSAGE_TYPE,
|
||||||
MessageIncubatingAttributes.MessageTypeValues.RECEIVED,
|
RECEIVED,
|
||||||
MessageIncubatingAttributes.MESSAGE_ID,
|
MESSAGE_ID,
|
||||||
MESSAGE_ID_UPDATER.incrementAndGet(TracingServerCall.this));
|
MESSAGE_ID_UPDATER.incrementAndGet(TracingServerCall.this));
|
||||||
Span.fromContext(context).addEvent("message", attributes);
|
Span.fromContext(context).addEvent("message", attributes);
|
||||||
delegate().onMessage(message);
|
delegate().onMessage(message);
|
||||||
|
|
|
@ -7,17 +7,22 @@ package io.opentelemetry.instrumentation.jdbc.internal;
|
||||||
|
|
||||||
import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet;
|
import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet;
|
||||||
|
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.jdbc.internal.dbinfo.DbInfo;
|
import io.opentelemetry.instrumentation.jdbc.internal.dbinfo.DbInfo;
|
||||||
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
enum DataSourceDbAttributesExtractor implements AttributesExtractor<DataSource, DbInfo> {
|
enum DataSourceDbAttributesExtractor implements AttributesExtractor<DataSource, DbInfo> {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
|
// copied from DbIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> DB_NAME = AttributeKey.stringKey("db.name");
|
||||||
|
private static final AttributeKey<String> DB_SYSTEM = AttributeKey.stringKey("db.system");
|
||||||
|
private static final AttributeKey<String> DB_USER = AttributeKey.stringKey("db.user");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart(AttributesBuilder attributes, Context parentContext, DataSource dataSource) {}
|
public void onStart(AttributesBuilder attributes, Context parentContext, DataSource dataSource) {}
|
||||||
|
|
||||||
|
@ -31,9 +36,9 @@ enum DataSourceDbAttributesExtractor implements AttributesExtractor<DataSource,
|
||||||
if (dbInfo == null) {
|
if (dbInfo == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
internalSet(attributes, DbIncubatingAttributes.DB_SYSTEM, dbInfo.getSystem());
|
internalSet(attributes, DB_SYSTEM, dbInfo.getSystem());
|
||||||
internalSet(attributes, DbIncubatingAttributes.DB_USER, dbInfo.getUser());
|
internalSet(attributes, DB_USER, dbInfo.getUser());
|
||||||
internalSet(attributes, DbIncubatingAttributes.DB_NAME, getName(dbInfo));
|
internalSet(attributes, DB_NAME, getName(dbInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getName(DbInfo dbInfo) {
|
private static String getName(DbInfo dbInfo) {
|
||||||
|
|
|
@ -11,7 +11,6 @@ import static java.util.regex.Pattern.CASE_INSENSITIVE;
|
||||||
|
|
||||||
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||||
import io.opentelemetry.instrumentation.jdbc.internal.dbinfo.DbInfo;
|
import io.opentelemetry.instrumentation.jdbc.internal.dbinfo.DbInfo;
|
||||||
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
|
@ -819,15 +818,15 @@ public enum JdbcConnectionUrlParser {
|
||||||
builder.subtype(subtype);
|
builder.subtype(subtype);
|
||||||
|
|
||||||
if (subtype.equals("sqlserver")) {
|
if (subtype.equals("sqlserver")) {
|
||||||
builder.system(DbIncubatingAttributes.DbSystemValues.MSSQL);
|
builder.system(DbSystemValues.MSSQL);
|
||||||
} else if (subtype.equals("oracle")) {
|
} else if (subtype.equals("oracle")) {
|
||||||
builder.system(DbIncubatingAttributes.DbSystemValues.ORACLE);
|
builder.system(DbSystemValues.ORACLE);
|
||||||
} else if (subtype.equals("mysql")) {
|
} else if (subtype.equals("mysql")) {
|
||||||
builder.system(DbIncubatingAttributes.DbSystemValues.MYSQL);
|
builder.system(DbSystemValues.MYSQL);
|
||||||
} else if (subtype.equals("postgresql")) {
|
} else if (subtype.equals("postgresql")) {
|
||||||
builder.system(DbIncubatingAttributes.DbSystemValues.POSTGRESQL);
|
builder.system(DbSystemValues.POSTGRESQL);
|
||||||
} else if (subtype.equals("db2")) {
|
} else if (subtype.equals("db2")) {
|
||||||
builder.system(DbIncubatingAttributes.DbSystemValues.DB2);
|
builder.system(DbSystemValues.DB2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return MODIFIED_URL_LIKE.doParse(jdbcUrl, builder);
|
return MODIFIED_URL_LIKE.doParse(jdbcUrl, builder);
|
||||||
|
@ -971,29 +970,45 @@ public enum JdbcConnectionUrlParser {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "as400": // IBM AS400 Database
|
case "as400": // IBM AS400 Database
|
||||||
case "db2": // IBM Db2
|
case "db2": // IBM Db2
|
||||||
return DbIncubatingAttributes.DbSystemValues.DB2;
|
return DbSystemValues.DB2;
|
||||||
case "derby": // Apache Derby
|
case "derby": // Apache Derby
|
||||||
return DbIncubatingAttributes.DbSystemValues.DERBY;
|
return DbSystemValues.DERBY;
|
||||||
case "h2": // H2 Database
|
case "h2": // H2 Database
|
||||||
return DbIncubatingAttributes.DbSystemValues.H2;
|
return DbSystemValues.H2;
|
||||||
case "hsqldb": // Hyper SQL Database
|
case "hsqldb": // Hyper SQL Database
|
||||||
return "hsqldb";
|
return "hsqldb";
|
||||||
case "mariadb": // MariaDB
|
case "mariadb": // MariaDB
|
||||||
return DbIncubatingAttributes.DbSystemValues.MARIADB;
|
return DbSystemValues.MARIADB;
|
||||||
case "mysql": // MySQL
|
case "mysql": // MySQL
|
||||||
return DbIncubatingAttributes.DbSystemValues.MYSQL;
|
return DbSystemValues.MYSQL;
|
||||||
case "oracle": // Oracle Database
|
case "oracle": // Oracle Database
|
||||||
return DbIncubatingAttributes.DbSystemValues.ORACLE;
|
return DbSystemValues.ORACLE;
|
||||||
case "postgresql": // PostgreSQL
|
case "postgresql": // PostgreSQL
|
||||||
return DbIncubatingAttributes.DbSystemValues.POSTGRESQL;
|
return DbSystemValues.POSTGRESQL;
|
||||||
case "jtds": // jTDS - the pure Java JDBC 3.0 driver for Microsoft SQL Server
|
case "jtds": // jTDS - the pure Java JDBC 3.0 driver for Microsoft SQL Server
|
||||||
case "microsoft":
|
case "microsoft":
|
||||||
case "sqlserver": // Microsoft SQL Server
|
case "sqlserver": // Microsoft SQL Server
|
||||||
return DbIncubatingAttributes.DbSystemValues.MSSQL;
|
return DbSystemValues.MSSQL;
|
||||||
case "sap": // SAP Hana
|
case "sap": // SAP Hana
|
||||||
return DbIncubatingAttributes.DbSystemValues.HANADB;
|
return DbSystemValues.HANADB;
|
||||||
default:
|
default:
|
||||||
return DbIncubatingAttributes.DbSystemValues.OTHER_SQL; // Unknown DBMS
|
return DbSystemValues.OTHER_SQL; // Unknown DBMS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// copied from DbIncubatingAttributes
|
||||||
|
private static final class DbSystemValues {
|
||||||
|
static final String OTHER_SQL = "other_sql";
|
||||||
|
static final String MSSQL = "mssql";
|
||||||
|
static final String MYSQL = "mysql";
|
||||||
|
static final String ORACLE = "oracle";
|
||||||
|
static final String DB2 = "db2";
|
||||||
|
static final String POSTGRESQL = "postgresql";
|
||||||
|
static final String HANADB = "hanadb";
|
||||||
|
static final String DERBY = "derby";
|
||||||
|
static final String MARIADB = "mariadb";
|
||||||
|
static final String H2 = "h2";
|
||||||
|
|
||||||
|
private DbSystemValues() {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
|
|
||||||
package io.opentelemetry.instrumentation.kafka.internal;
|
package io.opentelemetry.instrumentation.kafka.internal;
|
||||||
|
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import org.apache.kafka.clients.consumer.ConsumerRecord;
|
import org.apache.kafka.clients.consumer.ConsumerRecord;
|
||||||
|
@ -16,28 +16,38 @@ import org.apache.kafka.clients.consumer.ConsumerRecord;
|
||||||
final class KafkaConsumerAttributesExtractor
|
final class KafkaConsumerAttributesExtractor
|
||||||
implements AttributesExtractor<KafkaProcessRequest, Void> {
|
implements AttributesExtractor<KafkaProcessRequest, Void> {
|
||||||
|
|
||||||
|
// copied from MessagingIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> MESSAGING_DESTINATION_PARTITION_ID =
|
||||||
|
AttributeKey.stringKey("messaging.destination.partition.id");
|
||||||
|
private static final AttributeKey<String> MESSAGING_KAFKA_CONSUMER_GROUP =
|
||||||
|
AttributeKey.stringKey("messaging.kafka.consumer.group");
|
||||||
|
private static final AttributeKey<String> MESSAGING_KAFKA_MESSAGE_KEY =
|
||||||
|
AttributeKey.stringKey("messaging.kafka.message.key");
|
||||||
|
private static final AttributeKey<Long> MESSAGING_KAFKA_MESSAGE_OFFSET =
|
||||||
|
AttributeKey.longKey("messaging.kafka.message.offset");
|
||||||
|
private static final AttributeKey<Boolean> MESSAGING_KAFKA_MESSAGE_TOMBSTONE =
|
||||||
|
AttributeKey.booleanKey("messaging.kafka.message.tombstone");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart(
|
public void onStart(
|
||||||
AttributesBuilder attributes, Context parentContext, KafkaProcessRequest request) {
|
AttributesBuilder attributes, Context parentContext, KafkaProcessRequest request) {
|
||||||
|
|
||||||
ConsumerRecord<?, ?> record = request.getRecord();
|
ConsumerRecord<?, ?> record = request.getRecord();
|
||||||
|
|
||||||
attributes.put(
|
attributes.put(MESSAGING_DESTINATION_PARTITION_ID, String.valueOf(record.partition()));
|
||||||
MessagingIncubatingAttributes.MESSAGING_DESTINATION_PARTITION_ID,
|
attributes.put(MESSAGING_KAFKA_MESSAGE_OFFSET, record.offset());
|
||||||
String.valueOf(record.partition()));
|
|
||||||
attributes.put(MessagingIncubatingAttributes.MESSAGING_KAFKA_MESSAGE_OFFSET, record.offset());
|
|
||||||
|
|
||||||
Object key = record.key();
|
Object key = record.key();
|
||||||
if (key != null && canSerialize(key.getClass())) {
|
if (key != null && canSerialize(key.getClass())) {
|
||||||
attributes.put(MessagingIncubatingAttributes.MESSAGING_KAFKA_MESSAGE_KEY, key.toString());
|
attributes.put(MESSAGING_KAFKA_MESSAGE_KEY, key.toString());
|
||||||
}
|
}
|
||||||
if (record.value() == null) {
|
if (record.value() == null) {
|
||||||
attributes.put(MessagingIncubatingAttributes.MESSAGING_KAFKA_MESSAGE_TOMBSTONE, true);
|
attributes.put(MESSAGING_KAFKA_MESSAGE_TOMBSTONE, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
String consumerGroup = request.getConsumerGroup();
|
String consumerGroup = request.getConsumerGroup();
|
||||||
if (consumerGroup != null) {
|
if (consumerGroup != null) {
|
||||||
attributes.put(MessagingIncubatingAttributes.MESSAGING_KAFKA_CONSUMER_GROUP, consumerGroup);
|
attributes.put(MESSAGING_KAFKA_CONSUMER_GROUP, consumerGroup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,16 +5,25 @@
|
||||||
|
|
||||||
package io.opentelemetry.instrumentation.kafka.internal;
|
package io.opentelemetry.instrumentation.kafka.internal;
|
||||||
|
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import org.apache.kafka.clients.producer.RecordMetadata;
|
import org.apache.kafka.clients.producer.RecordMetadata;
|
||||||
|
|
||||||
final class KafkaProducerAttributesExtractor
|
final class KafkaProducerAttributesExtractor
|
||||||
implements AttributesExtractor<KafkaProducerRequest, RecordMetadata> {
|
implements AttributesExtractor<KafkaProducerRequest, RecordMetadata> {
|
||||||
|
// copied from MessagingIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> MESSAGING_DESTINATION_PARTITION_ID =
|
||||||
|
AttributeKey.stringKey("messaging.destination.partition.id");
|
||||||
|
private static final AttributeKey<String> MESSAGING_KAFKA_MESSAGE_KEY =
|
||||||
|
AttributeKey.stringKey("messaging.kafka.message.key");
|
||||||
|
private static final AttributeKey<Long> MESSAGING_KAFKA_MESSAGE_OFFSET =
|
||||||
|
AttributeKey.longKey("messaging.kafka.message.offset");
|
||||||
|
private static final AttributeKey<Boolean> MESSAGING_KAFKA_MESSAGE_TOMBSTONE =
|
||||||
|
AttributeKey.booleanKey("messaging.kafka.message.tombstone");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart(
|
public void onStart(
|
||||||
|
@ -22,10 +31,10 @@ final class KafkaProducerAttributesExtractor
|
||||||
|
|
||||||
Object key = request.getRecord().key();
|
Object key = request.getRecord().key();
|
||||||
if (key != null && canSerialize(key.getClass())) {
|
if (key != null && canSerialize(key.getClass())) {
|
||||||
attributes.put(MessagingIncubatingAttributes.MESSAGING_KAFKA_MESSAGE_KEY, key.toString());
|
attributes.put(MESSAGING_KAFKA_MESSAGE_KEY, key.toString());
|
||||||
}
|
}
|
||||||
if (request.getRecord().value() == null) {
|
if (request.getRecord().value() == null) {
|
||||||
attributes.put(MessagingIncubatingAttributes.MESSAGING_KAFKA_MESSAGE_TOMBSTONE, true);
|
attributes.put(MESSAGING_KAFKA_MESSAGE_TOMBSTONE, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,10 +54,8 @@ final class KafkaProducerAttributesExtractor
|
||||||
|
|
||||||
if (recordMetadata != null) {
|
if (recordMetadata != null) {
|
||||||
attributes.put(
|
attributes.put(
|
||||||
MessagingIncubatingAttributes.MESSAGING_DESTINATION_PARTITION_ID,
|
MESSAGING_DESTINATION_PARTITION_ID, String.valueOf(recordMetadata.partition()));
|
||||||
String.valueOf(recordMetadata.partition()));
|
attributes.put(MESSAGING_KAFKA_MESSAGE_OFFSET, recordMetadata.offset());
|
||||||
attributes.put(
|
|
||||||
MessagingIncubatingAttributes.MESSAGING_KAFKA_MESSAGE_OFFSET, recordMetadata.offset());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,22 +5,26 @@
|
||||||
|
|
||||||
package io.opentelemetry.instrumentation.kafka.internal;
|
package io.opentelemetry.instrumentation.kafka.internal;
|
||||||
|
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
enum KafkaReceiveAttributesExtractor implements AttributesExtractor<KafkaReceiveRequest, Void> {
|
enum KafkaReceiveAttributesExtractor implements AttributesExtractor<KafkaReceiveRequest, Void> {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
|
// copied from MessagingIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> MESSAGING_KAFKA_CONSUMER_GROUP =
|
||||||
|
AttributeKey.stringKey("messaging.kafka.consumer.group");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart(
|
public void onStart(
|
||||||
AttributesBuilder attributes, Context parentContext, KafkaReceiveRequest request) {
|
AttributesBuilder attributes, Context parentContext, KafkaReceiveRequest request) {
|
||||||
|
|
||||||
String consumerGroup = request.getConsumerGroup();
|
String consumerGroup = request.getConsumerGroup();
|
||||||
if (consumerGroup != null) {
|
if (consumerGroup != null) {
|
||||||
attributes.put(MessagingIncubatingAttributes.MESSAGING_KAFKA_CONSUMER_GROUP, consumerGroup);
|
attributes.put(MESSAGING_KAFKA_CONSUMER_GROUP, consumerGroup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import io.lettuce.core.tracing.TraceContextProvider;
|
||||||
import io.lettuce.core.tracing.Tracer;
|
import io.lettuce.core.tracing.Tracer;
|
||||||
import io.lettuce.core.tracing.TracerProvider;
|
import io.lettuce.core.tracing.TracerProvider;
|
||||||
import io.lettuce.core.tracing.Tracing;
|
import io.lettuce.core.tracing.Tracing;
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.Attributes;
|
import io.opentelemetry.api.common.Attributes;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.api.trace.Span;
|
import io.opentelemetry.api.trace.Span;
|
||||||
|
@ -28,7 +29,6 @@ import io.opentelemetry.instrumentation.api.incubator.semconv.db.RedisCommandSan
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor;
|
import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.semconv.network.ServerAttributesExtractor;
|
import io.opentelemetry.instrumentation.api.semconv.network.ServerAttributesExtractor;
|
||||||
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
@ -38,6 +38,12 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
final class OpenTelemetryTracing implements Tracing {
|
final class OpenTelemetryTracing implements Tracing {
|
||||||
|
|
||||||
|
// copied from DbIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> DB_SYSTEM = AttributeKey.stringKey("db.system");
|
||||||
|
private static final AttributeKey<String> DB_STATEMENT = AttributeKey.stringKey("db.statement");
|
||||||
|
// copied from DbIncubatingAttributes.DbSystemValues
|
||||||
|
private static final String REDIS = "redis";
|
||||||
|
|
||||||
private static final AttributesExtractor<OpenTelemetryEndpoint, Void> serverAttributesExtractor =
|
private static final AttributesExtractor<OpenTelemetryEndpoint, Void> serverAttributesExtractor =
|
||||||
ServerAttributesExtractor.create(new LettuceServerAttributesGetter());
|
ServerAttributesExtractor.create(new LettuceServerAttributesGetter());
|
||||||
private static final AttributesExtractor<OpenTelemetryEndpoint, Void> networkAttributesExtractor =
|
private static final AttributesExtractor<OpenTelemetryEndpoint, Void> networkAttributesExtractor =
|
||||||
|
@ -154,8 +160,7 @@ final class OpenTelemetryTracing implements Tracing {
|
||||||
.spanBuilder("redis")
|
.spanBuilder("redis")
|
||||||
.setSpanKind(SpanKind.CLIENT)
|
.setSpanKind(SpanKind.CLIENT)
|
||||||
.setParent(context)
|
.setParent(context)
|
||||||
.setAttribute(
|
.setAttribute(DB_SYSTEM, REDIS);
|
||||||
DbIncubatingAttributes.DB_SYSTEM, DbIncubatingAttributes.DbSystemValues.REDIS);
|
|
||||||
return new OpenTelemetrySpan(context, spanBuilder, sanitizer);
|
return new OpenTelemetrySpan(context, spanBuilder, sanitizer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -333,7 +338,7 @@ final class OpenTelemetryTracing implements Tracing {
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
String statement =
|
String statement =
|
||||||
sanitizer.sanitize(name, argsList != null ? argsList : splitArgs(argsString));
|
sanitizer.sanitize(name, argsList != null ? argsList : splitArgs(argsString));
|
||||||
span.setAttribute(DbIncubatingAttributes.DB_STATEMENT, statement);
|
span.setAttribute(DB_STATEMENT, statement);
|
||||||
}
|
}
|
||||||
span.end();
|
span.end();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ import io.opentelemetry.api.logs.Severity;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.internal.cache.Cache;
|
import io.opentelemetry.instrumentation.api.internal.cache.Cache;
|
||||||
import io.opentelemetry.semconv.ExceptionAttributes;
|
import io.opentelemetry.semconv.ExceptionAttributes;
|
||||||
import io.opentelemetry.semconv.incubating.ThreadIncubatingAttributes;
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -30,6 +29,10 @@ import org.apache.logging.log4j.message.Message;
|
||||||
*/
|
*/
|
||||||
public final class LogEventMapper<T> {
|
public final class LogEventMapper<T> {
|
||||||
|
|
||||||
|
// copied from ThreadIncubatingAttributes
|
||||||
|
private static final AttributeKey<Long> THREAD_ID = AttributeKey.longKey("thread.id");
|
||||||
|
private static final AttributeKey<String> THREAD_NAME = AttributeKey.stringKey("thread.name");
|
||||||
|
|
||||||
private static final String SPECIAL_MAP_MESSAGE_ATTRIBUTE = "message";
|
private static final String SPECIAL_MAP_MESSAGE_ATTRIBUTE = "message";
|
||||||
|
|
||||||
private static final Cache<String, AttributeKey<String>> contextDataAttributeKeyCache =
|
private static final Cache<String, AttributeKey<String>> contextDataAttributeKeyCache =
|
||||||
|
@ -108,8 +111,8 @@ public final class LogEventMapper<T> {
|
||||||
captureContextDataAttributes(attributes, contextData);
|
captureContextDataAttributes(attributes, contextData);
|
||||||
|
|
||||||
if (captureExperimentalAttributes) {
|
if (captureExperimentalAttributes) {
|
||||||
attributes.put(ThreadIncubatingAttributes.THREAD_NAME, threadName);
|
attributes.put(THREAD_NAME, threadName);
|
||||||
attributes.put(ThreadIncubatingAttributes.THREAD_ID, threadId);
|
attributes.put(THREAD_ID, threadId);
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.setAllAttributes(attributes.build());
|
builder.setAllAttributes(attributes.build());
|
||||||
|
|
|
@ -21,8 +21,6 @@ import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.internal.cache.Cache;
|
import io.opentelemetry.instrumentation.api.internal.cache.Cache;
|
||||||
import io.opentelemetry.javaagent.tooling.muzzle.NoMuzzle;
|
import io.opentelemetry.javaagent.tooling.muzzle.NoMuzzle;
|
||||||
import io.opentelemetry.semconv.ExceptionAttributes;
|
import io.opentelemetry.semconv.ExceptionAttributes;
|
||||||
import io.opentelemetry.semconv.incubating.CodeIncubatingAttributes;
|
|
||||||
import io.opentelemetry.semconv.incubating.ThreadIncubatingAttributes;
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -37,6 +35,15 @@ import org.slf4j.event.KeyValuePair;
|
||||||
* any time.
|
* any time.
|
||||||
*/
|
*/
|
||||||
public final class LoggingEventMapper {
|
public final class LoggingEventMapper {
|
||||||
|
// copied from CodeIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> CODE_FILEPATH = AttributeKey.stringKey("code.filepath");
|
||||||
|
private static final AttributeKey<String> CODE_FUNCTION = AttributeKey.stringKey("code.function");
|
||||||
|
private static final AttributeKey<Long> CODE_LINENO = AttributeKey.longKey("code.lineno");
|
||||||
|
private static final AttributeKey<String> CODE_NAMESPACE =
|
||||||
|
AttributeKey.stringKey("code.namespace");
|
||||||
|
// copied from
|
||||||
|
private static final AttributeKey<Long> THREAD_ID = AttributeKey.longKey("thread.id");
|
||||||
|
private static final AttributeKey<String> THREAD_NAME = AttributeKey.stringKey("thread.name");
|
||||||
|
|
||||||
private static final boolean supportsKeyValuePairs = supportsKeyValuePairs();
|
private static final boolean supportsKeyValuePairs = supportsKeyValuePairs();
|
||||||
private static final boolean supportsMultipleMarkers = supportsMultipleMarkers();
|
private static final boolean supportsMultipleMarkers = supportsMultipleMarkers();
|
||||||
|
@ -126,9 +133,9 @@ public final class LoggingEventMapper {
|
||||||
captureMdcAttributes(attributes, loggingEvent.getMDCPropertyMap());
|
captureMdcAttributes(attributes, loggingEvent.getMDCPropertyMap());
|
||||||
|
|
||||||
if (captureExperimentalAttributes) {
|
if (captureExperimentalAttributes) {
|
||||||
attributes.put(ThreadIncubatingAttributes.THREAD_NAME, loggingEvent.getThreadName());
|
attributes.put(THREAD_NAME, loggingEvent.getThreadName());
|
||||||
if (threadId != -1) {
|
if (threadId != -1) {
|
||||||
attributes.put(ThreadIncubatingAttributes.THREAD_ID, threadId);
|
attributes.put(THREAD_ID, threadId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,13 +145,13 @@ public final class LoggingEventMapper {
|
||||||
StackTraceElement firstStackElement = callerData[0];
|
StackTraceElement firstStackElement = callerData[0];
|
||||||
String fileName = firstStackElement.getFileName();
|
String fileName = firstStackElement.getFileName();
|
||||||
if (fileName != null) {
|
if (fileName != null) {
|
||||||
attributes.put(CodeIncubatingAttributes.CODE_FILEPATH, fileName);
|
attributes.put(CODE_FILEPATH, fileName);
|
||||||
}
|
}
|
||||||
attributes.put(CodeIncubatingAttributes.CODE_NAMESPACE, firstStackElement.getClassName());
|
attributes.put(CODE_NAMESPACE, firstStackElement.getClassName());
|
||||||
attributes.put(CodeIncubatingAttributes.CODE_FUNCTION, firstStackElement.getMethodName());
|
attributes.put(CODE_FUNCTION, firstStackElement.getMethodName());
|
||||||
int lineNumber = firstStackElement.getLineNumber();
|
int lineNumber = firstStackElement.getLineNumber();
|
||||||
if (lineNumber > 0) {
|
if (lineNumber > 0) {
|
||||||
attributes.put(CodeIncubatingAttributes.CODE_LINENO, lineNumber);
|
attributes.put(CODE_LINENO, lineNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
|
|
||||||
package io.opentelemetry.instrumentation.mongo.v3_1;
|
package io.opentelemetry.instrumentation.mongo.v3_1;
|
||||||
|
|
||||||
import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_MONGODB_COLLECTION;
|
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
|
|
||||||
import com.mongodb.event.CommandStartedEvent;
|
import com.mongodb.event.CommandStartedEvent;
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
|
@ -18,6 +18,10 @@ import javax.annotation.Nullable;
|
||||||
import org.bson.BsonValue;
|
import org.bson.BsonValue;
|
||||||
|
|
||||||
class MongoAttributesExtractor implements AttributesExtractor<CommandStartedEvent, Void> {
|
class MongoAttributesExtractor implements AttributesExtractor<CommandStartedEvent, Void> {
|
||||||
|
// copied from DbIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> DB_MONGODB_COLLECTION =
|
||||||
|
AttributeKey.stringKey("db.mongodb.collection");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart(
|
public void onStart(
|
||||||
AttributesBuilder attributes, Context parentContext, CommandStartedEvent event) {
|
AttributesBuilder attributes, Context parentContext, CommandStartedEvent event) {
|
||||||
|
|
|
@ -7,7 +7,6 @@ package io.opentelemetry.instrumentation.mongo.v3_1;
|
||||||
|
|
||||||
import com.mongodb.event.CommandStartedEvent;
|
import com.mongodb.event.CommandStartedEvent;
|
||||||
import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientAttributesGetter;
|
import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientAttributesGetter;
|
||||||
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -24,6 +23,9 @@ import org.bson.json.JsonWriterSettings;
|
||||||
|
|
||||||
class MongoDbAttributesGetter implements DbClientAttributesGetter<CommandStartedEvent> {
|
class MongoDbAttributesGetter implements DbClientAttributesGetter<CommandStartedEvent> {
|
||||||
|
|
||||||
|
// copied from DbIncubatingAttributes.DbSystemValues
|
||||||
|
private static final String MONGODB = "mongodb";
|
||||||
|
|
||||||
@Nullable private static final Method IS_TRUNCATED_METHOD;
|
@Nullable private static final Method IS_TRUNCATED_METHOD;
|
||||||
private static final String HIDDEN_CHAR = "?";
|
private static final String HIDDEN_CHAR = "?";
|
||||||
|
|
||||||
|
@ -47,7 +49,7 @@ class MongoDbAttributesGetter implements DbClientAttributesGetter<CommandStarted
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSystem(CommandStartedEvent event) {
|
public String getSystem(CommandStartedEvent event) {
|
||||||
return DbIncubatingAttributes.DbSystemValues.MONGODB;
|
return MONGODB;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -11,7 +11,6 @@ import static io.r2dbc.spi.ConnectionFactoryOptions.PORT;
|
||||||
import static io.r2dbc.spi.ConnectionFactoryOptions.USER;
|
import static io.r2dbc.spi.ConnectionFactoryOptions.USER;
|
||||||
|
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
|
|
||||||
import io.r2dbc.proxy.core.QueryExecutionInfo;
|
import io.r2dbc.proxy.core.QueryExecutionInfo;
|
||||||
import io.r2dbc.proxy.core.QueryInfo;
|
import io.r2dbc.proxy.core.QueryInfo;
|
||||||
import io.r2dbc.spi.Connection;
|
import io.r2dbc.spi.Connection;
|
||||||
|
@ -24,6 +23,9 @@ import java.util.stream.Collectors;
|
||||||
* any time.
|
* any time.
|
||||||
*/
|
*/
|
||||||
public final class DbExecution {
|
public final class DbExecution {
|
||||||
|
// copied from DbIncubatingAttributes.DbSystemValues
|
||||||
|
private static final String OTHER_SQL = "other_sql";
|
||||||
|
|
||||||
private final String system;
|
private final String system;
|
||||||
private final String user;
|
private final String user;
|
||||||
private final String name;
|
private final String name;
|
||||||
|
@ -42,7 +44,7 @@ public final class DbExecution {
|
||||||
.getDatabaseProductName()
|
.getDatabaseProductName()
|
||||||
.toLowerCase(Locale.ROOT)
|
.toLowerCase(Locale.ROOT)
|
||||||
.split(" ")[0]
|
.split(" ")[0]
|
||||||
: DbIncubatingAttributes.DbSystemValues.OTHER_SQL;
|
: OTHER_SQL;
|
||||||
this.user = factoryOptions.hasOption(USER) ? (String) factoryOptions.getValue(USER) : null;
|
this.user = factoryOptions.hasOption(USER) ? (String) factoryOptions.getValue(USER) : null;
|
||||||
this.name =
|
this.name =
|
||||||
factoryOptions.hasOption(DATABASE)
|
factoryOptions.hasOption(DATABASE)
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
package io.opentelemetry.instrumentation.resources;
|
package io.opentelemetry.instrumentation.resources;
|
||||||
|
|
||||||
import com.google.errorprone.annotations.MustBeClosed;
|
import com.google.errorprone.annotations.MustBeClosed;
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.Attributes;
|
import io.opentelemetry.api.common.Attributes;
|
||||||
import io.opentelemetry.sdk.resources.Resource;
|
import io.opentelemetry.sdk.resources.Resource;
|
||||||
import io.opentelemetry.semconv.incubating.ContainerIncubatingAttributes;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
@ -23,6 +23,9 @@ import java.util.stream.Stream;
|
||||||
*/
|
*/
|
||||||
public final class ContainerResource {
|
public final class ContainerResource {
|
||||||
|
|
||||||
|
// copied from ContainerIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> CONTAINER_ID = AttributeKey.stringKey("container.id");
|
||||||
|
|
||||||
static final Filesystem FILESYSTEM_INSTANCE = new Filesystem();
|
static final Filesystem FILESYSTEM_INSTANCE = new Filesystem();
|
||||||
private static final Resource INSTANCE = buildSingleton();
|
private static final Resource INSTANCE = buildSingleton();
|
||||||
|
|
||||||
|
@ -48,7 +51,7 @@ public final class ContainerResource {
|
||||||
// Visible for testing
|
// Visible for testing
|
||||||
Resource buildResource() {
|
Resource buildResource() {
|
||||||
return getContainerId()
|
return getContainerId()
|
||||||
.map(id -> Resource.create(Attributes.of(ContainerIncubatingAttributes.CONTAINER_ID, id)))
|
.map(id -> Resource.create(Attributes.of(CONTAINER_ID, id)))
|
||||||
.orElseGet(Resource::empty);
|
.orElseGet(Resource::empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@ package io.opentelemetry.instrumentation.resources;
|
||||||
|
|
||||||
import static java.util.logging.Level.FINE;
|
import static java.util.logging.Level.FINE;
|
||||||
|
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.Attributes;
|
import io.opentelemetry.api.common.Attributes;
|
||||||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
|
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
|
||||||
import io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider;
|
import io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider;
|
||||||
import io.opentelemetry.sdk.autoconfigure.spi.internal.ConditionalResourceProvider;
|
import io.opentelemetry.sdk.autoconfigure.spi.internal.ConditionalResourceProvider;
|
||||||
import io.opentelemetry.sdk.resources.Resource;
|
import io.opentelemetry.sdk.resources.Resource;
|
||||||
import io.opentelemetry.semconv.incubating.HostIncubatingAttributes;
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
@ -37,6 +37,9 @@ public final class HostIdResourceProvider implements ConditionalResourceProvider
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(HostIdResourceProvider.class.getName());
|
private static final Logger logger = Logger.getLogger(HostIdResourceProvider.class.getName());
|
||||||
|
|
||||||
|
// copied from HostIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> HOST_ID = AttributeKey.stringKey("host.id");
|
||||||
|
|
||||||
public static final String REGISTRY_QUERY =
|
public static final String REGISTRY_QUERY =
|
||||||
"reg query HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid";
|
"reg query HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid";
|
||||||
|
|
||||||
|
@ -97,7 +100,7 @@ public final class HostIdResourceProvider implements ConditionalResourceProvider
|
||||||
if (lines.isEmpty()) {
|
if (lines.isEmpty()) {
|
||||||
return Resource.empty();
|
return Resource.empty();
|
||||||
}
|
}
|
||||||
return Resource.create(Attributes.of(HostIncubatingAttributes.HOST_ID, lines.get(0)));
|
return Resource.create(Attributes.of(HOST_ID, lines.get(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<String> readMachineIdFile(Path path) {
|
private static List<String> readMachineIdFile(Path path) {
|
||||||
|
@ -120,7 +123,7 @@ public final class HostIdResourceProvider implements ConditionalResourceProvider
|
||||||
if (line.contains("MachineGuid")) {
|
if (line.contains("MachineGuid")) {
|
||||||
String[] parts = line.trim().split("\\s+");
|
String[] parts = line.trim().split("\\s+");
|
||||||
if (parts.length == 3) {
|
if (parts.length == 3) {
|
||||||
return Resource.create(Attributes.of(HostIncubatingAttributes.HOST_ID, parts[2]));
|
return Resource.create(Attributes.of(HOST_ID, parts[2]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,10 +173,8 @@ public final class HostIdResourceProvider implements ConditionalResourceProvider
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldApply(ConfigProperties config, Resource existing) {
|
public boolean shouldApply(ConfigProperties config, Resource existing) {
|
||||||
return !config
|
return !config.getMap("otel.resource.attributes").containsKey(HOST_ID.getKey())
|
||||||
.getMap("otel.resource.attributes")
|
&& existing.getAttribute(HOST_ID) == null;
|
||||||
.containsKey(HostIncubatingAttributes.HOST_ID.getKey())
|
|
||||||
&& existing.getAttribute(HostIncubatingAttributes.HOST_ID) == null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,17 +5,21 @@
|
||||||
|
|
||||||
package io.opentelemetry.instrumentation.resources;
|
package io.opentelemetry.instrumentation.resources;
|
||||||
|
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.Attributes;
|
import io.opentelemetry.api.common.Attributes;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.sdk.resources.Resource;
|
import io.opentelemetry.sdk.resources.Resource;
|
||||||
import io.opentelemetry.semconv.SchemaUrls;
|
import io.opentelemetry.semconv.SchemaUrls;
|
||||||
import io.opentelemetry.semconv.incubating.HostIncubatingAttributes;
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
/** Factory for a {@link Resource} which provides information about the host info. */
|
/** Factory for a {@link Resource} which provides information about the host info. */
|
||||||
public final class HostResource {
|
public final class HostResource {
|
||||||
|
|
||||||
|
// copied from HostIncubatingAttributes
|
||||||
|
public static final AttributeKey<String> HOST_ARCH = AttributeKey.stringKey("host.arch");
|
||||||
|
public static final AttributeKey<String> HOST_NAME = AttributeKey.stringKey("host.name");
|
||||||
|
|
||||||
private static final Resource INSTANCE = buildResource();
|
private static final Resource INSTANCE = buildResource();
|
||||||
|
|
||||||
/** Returns a {@link Resource} which provides information about host. */
|
/** Returns a {@link Resource} which provides information about host. */
|
||||||
|
@ -27,7 +31,7 @@ public final class HostResource {
|
||||||
static Resource buildResource() {
|
static Resource buildResource() {
|
||||||
AttributesBuilder attributes = Attributes.builder();
|
AttributesBuilder attributes = Attributes.builder();
|
||||||
try {
|
try {
|
||||||
attributes.put(HostIncubatingAttributes.HOST_NAME, InetAddress.getLocalHost().getHostName());
|
attributes.put(HOST_NAME, InetAddress.getLocalHost().getHostName());
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
|
@ -38,7 +42,7 @@ public final class HostResource {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
if (hostArch != null) {
|
if (hostArch != null) {
|
||||||
attributes.put(HostIncubatingAttributes.HOST_ARCH, hostArch);
|
attributes.put(HOST_ARCH, hostArch);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Resource.create(attributes.build(), SchemaUrls.V1_24_0);
|
return Resource.create(attributes.build(), SchemaUrls.V1_24_0);
|
||||||
|
|
|
@ -5,17 +5,22 @@
|
||||||
|
|
||||||
package io.opentelemetry.instrumentation.resources;
|
package io.opentelemetry.instrumentation.resources;
|
||||||
|
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.Attributes;
|
import io.opentelemetry.api.common.Attributes;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.sdk.resources.Resource;
|
import io.opentelemetry.sdk.resources.Resource;
|
||||||
import io.opentelemetry.semconv.SchemaUrls;
|
import io.opentelemetry.semconv.SchemaUrls;
|
||||||
import io.opentelemetry.semconv.incubating.OsIncubatingAttributes;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/** Factory of a {@link Resource} which provides information about the current operating system. */
|
/** Factory of a {@link Resource} which provides information about the current operating system. */
|
||||||
public final class OsResource {
|
public final class OsResource {
|
||||||
|
|
||||||
|
// copied from OsIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> OS_DESCRIPTION =
|
||||||
|
AttributeKey.stringKey("os.description");
|
||||||
|
private static final AttributeKey<String> OS_TYPE = AttributeKey.stringKey("os.type");
|
||||||
|
|
||||||
private static final Resource INSTANCE = buildResource();
|
private static final Resource INSTANCE = buildResource();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,7 +50,7 @@ public final class OsResource {
|
||||||
|
|
||||||
String osName = getOs(os);
|
String osName = getOs(os);
|
||||||
if (osName != null) {
|
if (osName != null) {
|
||||||
attributes.put(OsIncubatingAttributes.OS_TYPE, osName);
|
attributes.put(OS_TYPE, osName);
|
||||||
}
|
}
|
||||||
|
|
||||||
String version = null;
|
String version = null;
|
||||||
|
@ -55,7 +60,7 @@ public final class OsResource {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
String osDescription = version != null ? os + ' ' + version : os;
|
String osDescription = version != null ? os + ' ' + version : os;
|
||||||
attributes.put(OsIncubatingAttributes.OS_DESCRIPTION, osDescription);
|
attributes.put(OS_DESCRIPTION, osDescription);
|
||||||
|
|
||||||
return Resource.create(attributes.build(), SchemaUrls.V1_24_0);
|
return Resource.create(attributes.build(), SchemaUrls.V1_24_0);
|
||||||
}
|
}
|
||||||
|
@ -64,30 +69,47 @@ public final class OsResource {
|
||||||
private static String getOs(String os) {
|
private static String getOs(String os) {
|
||||||
os = os.toLowerCase(Locale.ROOT);
|
os = os.toLowerCase(Locale.ROOT);
|
||||||
if (os.startsWith("windows")) {
|
if (os.startsWith("windows")) {
|
||||||
return OsIncubatingAttributes.OsTypeValues.WINDOWS;
|
return OsTypeValues.WINDOWS;
|
||||||
} else if (os.startsWith("linux")) {
|
} else if (os.startsWith("linux")) {
|
||||||
return OsIncubatingAttributes.OsTypeValues.LINUX;
|
return OsTypeValues.LINUX;
|
||||||
} else if (os.startsWith("mac")) {
|
} else if (os.startsWith("mac")) {
|
||||||
return OsIncubatingAttributes.OsTypeValues.DARWIN;
|
return OsTypeValues.DARWIN;
|
||||||
} else if (os.startsWith("freebsd")) {
|
} else if (os.startsWith("freebsd")) {
|
||||||
return OsIncubatingAttributes.OsTypeValues.FREEBSD;
|
return OsTypeValues.FREEBSD;
|
||||||
} else if (os.startsWith("netbsd")) {
|
} else if (os.startsWith("netbsd")) {
|
||||||
return OsIncubatingAttributes.OsTypeValues.NETBSD;
|
return OsTypeValues.NETBSD;
|
||||||
} else if (os.startsWith("openbsd")) {
|
} else if (os.startsWith("openbsd")) {
|
||||||
return OsIncubatingAttributes.OsTypeValues.OPENBSD;
|
return OsTypeValues.OPENBSD;
|
||||||
} else if (os.startsWith("dragonflybsd")) {
|
} else if (os.startsWith("dragonflybsd")) {
|
||||||
return OsIncubatingAttributes.OsTypeValues.DRAGONFLYBSD;
|
return OsTypeValues.DRAGONFLYBSD;
|
||||||
} else if (os.startsWith("hp-ux")) {
|
} else if (os.startsWith("hp-ux")) {
|
||||||
return OsIncubatingAttributes.OsTypeValues.HPUX;
|
return OsTypeValues.HPUX;
|
||||||
} else if (os.startsWith("aix")) {
|
} else if (os.startsWith("aix")) {
|
||||||
return OsIncubatingAttributes.OsTypeValues.AIX;
|
return OsTypeValues.AIX;
|
||||||
} else if (os.startsWith("solaris")) {
|
} else if (os.startsWith("solaris")) {
|
||||||
return OsIncubatingAttributes.OsTypeValues.SOLARIS;
|
return OsTypeValues.SOLARIS;
|
||||||
} else if (os.startsWith("z/os")) {
|
} else if (os.startsWith("z/os")) {
|
||||||
return OsIncubatingAttributes.OsTypeValues.Z_OS;
|
return OsTypeValues.Z_OS;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private OsResource() {}
|
private OsResource() {}
|
||||||
|
|
||||||
|
// copied from OsIncubatingAttributes
|
||||||
|
private static final class OsTypeValues {
|
||||||
|
static final String WINDOWS = "windows";
|
||||||
|
static final String LINUX = "linux";
|
||||||
|
static final String DARWIN = "darwin";
|
||||||
|
static final String FREEBSD = "freebsd";
|
||||||
|
static final String NETBSD = "netbsd";
|
||||||
|
static final String OPENBSD = "openbsd";
|
||||||
|
static final String DRAGONFLYBSD = "dragonflybsd";
|
||||||
|
static final String HPUX = "hpux";
|
||||||
|
static final String AIX = "aix";
|
||||||
|
static final String SOLARIS = "solaris";
|
||||||
|
static final String Z_OS = "z_os";
|
||||||
|
|
||||||
|
private OsTypeValues() {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
|
|
||||||
package io.opentelemetry.instrumentation.resources;
|
package io.opentelemetry.instrumentation.resources;
|
||||||
|
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.Attributes;
|
import io.opentelemetry.api.common.Attributes;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.sdk.resources.Resource;
|
import io.opentelemetry.sdk.resources.Resource;
|
||||||
import io.opentelemetry.semconv.SchemaUrls;
|
import io.opentelemetry.semconv.SchemaUrls;
|
||||||
import io.opentelemetry.semconv.incubating.ProcessIncubatingAttributes;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.lang.management.RuntimeMXBean;
|
import java.lang.management.RuntimeMXBean;
|
||||||
|
@ -22,6 +22,15 @@ import java.util.regex.Pattern;
|
||||||
/** Factory of a {@link Resource} which provides information about the current running process. */
|
/** Factory of a {@link Resource} which provides information about the current running process. */
|
||||||
public final class ProcessResource {
|
public final class ProcessResource {
|
||||||
|
|
||||||
|
// copied from ProcessIncubatingAttributes
|
||||||
|
private static final AttributeKey<List<String>> PROCESS_COMMAND_ARGS =
|
||||||
|
AttributeKey.stringArrayKey("process.command_args");
|
||||||
|
private static final AttributeKey<String> PROCESS_COMMAND_LINE =
|
||||||
|
AttributeKey.stringKey("process.command_line");
|
||||||
|
private static final AttributeKey<String> PROCESS_EXECUTABLE_PATH =
|
||||||
|
AttributeKey.stringKey("process.executable.path");
|
||||||
|
private static final AttributeKey<Long> PROCESS_PID = AttributeKey.longKey("process.pid");
|
||||||
|
|
||||||
// Note: This pattern doesn't support file paths with spaces in them.
|
// Note: This pattern doesn't support file paths with spaces in them.
|
||||||
// Important: This is statically used in buildResource, so must be declared/initialized first.
|
// Important: This is statically used in buildResource, so must be declared/initialized first.
|
||||||
private static final Pattern JAR_FILE_PATTERN =
|
private static final Pattern JAR_FILE_PATTERN =
|
||||||
|
@ -56,7 +65,7 @@ public final class ProcessResource {
|
||||||
long pid = ProcessPid.getPid();
|
long pid = ProcessPid.getPid();
|
||||||
|
|
||||||
if (pid >= 0) {
|
if (pid >= 0) {
|
||||||
attributes.put(ProcessIncubatingAttributes.PROCESS_PID, pid);
|
attributes.put(PROCESS_PID, pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
String javaHome = null;
|
String javaHome = null;
|
||||||
|
@ -78,8 +87,7 @@ public final class ProcessResource {
|
||||||
executablePath.append(".exe");
|
executablePath.append(".exe");
|
||||||
}
|
}
|
||||||
|
|
||||||
attributes.put(
|
attributes.put(PROCESS_EXECUTABLE_PATH, executablePath.toString());
|
||||||
ProcessIncubatingAttributes.PROCESS_EXECUTABLE_PATH, executablePath.toString());
|
|
||||||
|
|
||||||
String[] args = ProcessArguments.getProcessArguments();
|
String[] args = ProcessArguments.getProcessArguments();
|
||||||
// This will only work with Java 9+ but provides everything except the executablePath.
|
// This will only work with Java 9+ but provides everything except the executablePath.
|
||||||
|
@ -87,7 +95,7 @@ public final class ProcessResource {
|
||||||
List<String> commandArgs = new ArrayList<>(args.length + 1);
|
List<String> commandArgs = new ArrayList<>(args.length + 1);
|
||||||
commandArgs.add(executablePath.toString());
|
commandArgs.add(executablePath.toString());
|
||||||
commandArgs.addAll(Arrays.asList(args));
|
commandArgs.addAll(Arrays.asList(args));
|
||||||
attributes.put(ProcessIncubatingAttributes.PROCESS_COMMAND_ARGS, commandArgs);
|
attributes.put(PROCESS_COMMAND_ARGS, commandArgs);
|
||||||
} else { // Java 8
|
} else { // Java 8
|
||||||
StringBuilder commandLine = new StringBuilder(executablePath);
|
StringBuilder commandLine = new StringBuilder(executablePath);
|
||||||
for (String arg : runtime.getInputArguments()) {
|
for (String arg : runtime.getInputArguments()) {
|
||||||
|
@ -103,7 +111,7 @@ public final class ProcessResource {
|
||||||
}
|
}
|
||||||
commandLine.append(' ').append(javaCommand);
|
commandLine.append(' ').append(javaCommand);
|
||||||
}
|
}
|
||||||
attributes.put(ProcessIncubatingAttributes.PROCESS_COMMAND_LINE, commandLine.toString());
|
attributes.put(PROCESS_COMMAND_LINE, commandLine.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,14 +5,22 @@
|
||||||
|
|
||||||
package io.opentelemetry.instrumentation.resources;
|
package io.opentelemetry.instrumentation.resources;
|
||||||
|
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.Attributes;
|
import io.opentelemetry.api.common.Attributes;
|
||||||
import io.opentelemetry.sdk.resources.Resource;
|
import io.opentelemetry.sdk.resources.Resource;
|
||||||
import io.opentelemetry.semconv.SchemaUrls;
|
import io.opentelemetry.semconv.SchemaUrls;
|
||||||
import io.opentelemetry.semconv.incubating.ProcessIncubatingAttributes;
|
|
||||||
|
|
||||||
/** Factory of a {@link Resource} which provides information about the Java runtime. */
|
/** Factory of a {@link Resource} which provides information about the Java runtime. */
|
||||||
public final class ProcessRuntimeResource {
|
public final class ProcessRuntimeResource {
|
||||||
|
|
||||||
|
// copied from ProcessIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> PROCESS_RUNTIME_DESCRIPTION =
|
||||||
|
AttributeKey.stringKey("process.runtime.description");
|
||||||
|
private static final AttributeKey<String> PROCESS_RUNTIME_NAME =
|
||||||
|
AttributeKey.stringKey("process.runtime.name");
|
||||||
|
private static final AttributeKey<String> PROCESS_RUNTIME_VERSION =
|
||||||
|
AttributeKey.stringKey("process.runtime.version");
|
||||||
|
|
||||||
private static final Resource INSTANCE = buildResource();
|
private static final Resource INSTANCE = buildResource();
|
||||||
|
|
||||||
/** Returns a factory for a {@link Resource} which provides information about the Java runtime. */
|
/** Returns a factory for a {@link Resource} which provides information about the Java runtime. */
|
||||||
|
@ -34,11 +42,11 @@ public final class ProcessRuntimeResource {
|
||||||
|
|
||||||
return Resource.create(
|
return Resource.create(
|
||||||
Attributes.of(
|
Attributes.of(
|
||||||
ProcessIncubatingAttributes.PROCESS_RUNTIME_NAME,
|
PROCESS_RUNTIME_NAME,
|
||||||
name,
|
name,
|
||||||
ProcessIncubatingAttributes.PROCESS_RUNTIME_VERSION,
|
PROCESS_RUNTIME_VERSION,
|
||||||
version,
|
version,
|
||||||
ProcessIncubatingAttributes.PROCESS_RUNTIME_DESCRIPTION,
|
PROCESS_RUNTIME_DESCRIPTION,
|
||||||
description),
|
description),
|
||||||
SchemaUrls.V1_24_0);
|
SchemaUrls.V1_24_0);
|
||||||
} catch (SecurityException ignored) {
|
} catch (SecurityException ignored) {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
|
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import org.apache.rocketmq.common.message.MessageExt;
|
import org.apache.rocketmq.common.message.MessageExt;
|
||||||
|
@ -18,6 +17,10 @@ enum RocketMqConsumerExperimentalAttributeExtractor
|
||||||
implements AttributesExtractor<MessageExt, Void> {
|
implements AttributesExtractor<MessageExt, Void> {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
|
// copied from MessagingIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> MESSAGING_ROCKETMQ_MESSAGE_TAG =
|
||||||
|
AttributeKey.stringKey("messaging.rocketmq.message.tag");
|
||||||
|
|
||||||
private static final AttributeKey<Long> MESSAGING_ROCKETMQ_QUEUE_ID =
|
private static final AttributeKey<Long> MESSAGING_ROCKETMQ_QUEUE_ID =
|
||||||
AttributeKey.longKey("messaging.rocketmq.queue_id");
|
AttributeKey.longKey("messaging.rocketmq.queue_id");
|
||||||
private static final AttributeKey<Long> MESSAGING_ROCKETMQ_QUEUE_OFFSET =
|
private static final AttributeKey<Long> MESSAGING_ROCKETMQ_QUEUE_OFFSET =
|
||||||
|
@ -29,7 +32,7 @@ enum RocketMqConsumerExperimentalAttributeExtractor
|
||||||
public void onStart(AttributesBuilder attributes, Context parentContext, MessageExt msg) {
|
public void onStart(AttributesBuilder attributes, Context parentContext, MessageExt msg) {
|
||||||
String tags = msg.getTags();
|
String tags = msg.getTags();
|
||||||
if (tags != null) {
|
if (tags != null) {
|
||||||
attributes.put(MessagingIncubatingAttributes.MESSAGING_ROCKETMQ_MESSAGE_TAG, tags);
|
attributes.put(MESSAGING_ROCKETMQ_MESSAGE_TAG, tags);
|
||||||
}
|
}
|
||||||
attributes.put(MESSAGING_ROCKETMQ_QUEUE_ID, msg.getQueueId());
|
attributes.put(MESSAGING_ROCKETMQ_QUEUE_ID, msg.getQueueId());
|
||||||
attributes.put(MESSAGING_ROCKETMQ_QUEUE_OFFSET, msg.getQueueOffset());
|
attributes.put(MESSAGING_ROCKETMQ_QUEUE_OFFSET, msg.getQueueOffset());
|
||||||
|
|
|
@ -6,10 +6,9 @@
|
||||||
package io.opentelemetry.instrumentation.rocketmqclient.v4_8;
|
package io.opentelemetry.instrumentation.rocketmqclient.v4_8;
|
||||||
|
|
||||||
import static io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor.constant;
|
import static io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor.constant;
|
||||||
import static io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes.MESSAGING_OPERATION;
|
|
||||||
import static io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes.MESSAGING_SYSTEM;
|
|
||||||
|
|
||||||
import io.opentelemetry.api.OpenTelemetry;
|
import io.opentelemetry.api.OpenTelemetry;
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessageOperation;
|
import io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessageOperation;
|
||||||
import io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessagingAttributesExtractor;
|
import io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessagingAttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessagingAttributesGetter;
|
import io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessagingAttributesGetter;
|
||||||
|
@ -28,6 +27,12 @@ class RocketMqInstrumenterFactory {
|
||||||
|
|
||||||
private static final String INSTRUMENTATION_NAME = "io.opentelemetry.rocketmq-client-4.8";
|
private static final String INSTRUMENTATION_NAME = "io.opentelemetry.rocketmq-client-4.8";
|
||||||
|
|
||||||
|
// copied from MessagingIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> MESSAGING_OPERATION =
|
||||||
|
AttributeKey.stringKey("messaging.operation");
|
||||||
|
private static final AttributeKey<String> MESSAGING_SYSTEM =
|
||||||
|
AttributeKey.stringKey("messaging.system");
|
||||||
|
|
||||||
static Instrumenter<SendMessageContext, Void> createProducerInstrumenter(
|
static Instrumenter<SendMessageContext, Void> createProducerInstrumenter(
|
||||||
OpenTelemetry openTelemetry,
|
OpenTelemetry openTelemetry,
|
||||||
List<String> capturedHeaders,
|
List<String> capturedHeaders,
|
||||||
|
|
|
@ -9,7 +9,6 @@ import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.common.AttributesBuilder;
|
import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import org.apache.rocketmq.client.hook.SendMessageContext;
|
import org.apache.rocketmq.client.hook.SendMessageContext;
|
||||||
|
|
||||||
|
@ -17,6 +16,10 @@ enum RocketMqProducerExperimentalAttributeExtractor
|
||||||
implements AttributesExtractor<SendMessageContext, Void> {
|
implements AttributesExtractor<SendMessageContext, Void> {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
|
// copied from MessagingIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> MESSAGING_ROCKETMQ_MESSAGE_TAG =
|
||||||
|
AttributeKey.stringKey("messaging.rocketmq.message.tag");
|
||||||
|
|
||||||
private static final AttributeKey<String> MESSAGING_ROCKETMQ_BROKER_ADDRESS =
|
private static final AttributeKey<String> MESSAGING_ROCKETMQ_BROKER_ADDRESS =
|
||||||
AttributeKey.stringKey("messaging.rocketmq.broker_address");
|
AttributeKey.stringKey("messaging.rocketmq.broker_address");
|
||||||
private static final AttributeKey<String> MESSAGING_ROCKETMQ_SEND_RESULT =
|
private static final AttributeKey<String> MESSAGING_ROCKETMQ_SEND_RESULT =
|
||||||
|
@ -28,7 +31,7 @@ enum RocketMqProducerExperimentalAttributeExtractor
|
||||||
if (request.getMessage() != null) {
|
if (request.getMessage() != null) {
|
||||||
String tags = request.getMessage().getTags();
|
String tags = request.getMessage().getTags();
|
||||||
if (tags != null) {
|
if (tags != null) {
|
||||||
attributes.put(MessagingIncubatingAttributes.MESSAGING_ROCKETMQ_MESSAGE_TAG, tags);
|
attributes.put(MESSAGING_ROCKETMQ_MESSAGE_TAG, tags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String brokerAddr = request.getBrokerAddr();
|
String brokerAddr = request.getBrokerAddr();
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
|
|
||||||
package io.opentelemetry.instrumentation.spring.security.config.v6_0;
|
package io.opentelemetry.instrumentation.spring.security.config.v6_0;
|
||||||
|
|
||||||
|
import io.opentelemetry.api.common.AttributeKey;
|
||||||
import io.opentelemetry.api.trace.Span;
|
import io.opentelemetry.api.trace.Span;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.LocalRootSpan;
|
import io.opentelemetry.instrumentation.api.instrumenter.LocalRootSpan;
|
||||||
import io.opentelemetry.semconv.incubating.EnduserIncubatingAttributes;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
|
@ -21,6 +21,11 @@ import org.springframework.security.core.GrantedAuthority;
|
||||||
*/
|
*/
|
||||||
public final class EnduserAttributesCapturer {
|
public final class EnduserAttributesCapturer {
|
||||||
|
|
||||||
|
// copied from EnduserIncubatingAttributes
|
||||||
|
private static final AttributeKey<String> ENDUSER_ID = AttributeKey.stringKey("enduser.id");
|
||||||
|
private static final AttributeKey<String> ENDUSER_ROLE = AttributeKey.stringKey("enduser.role");
|
||||||
|
private static final AttributeKey<String> ENDUSER_SCOPE = AttributeKey.stringKey("enduser.scope");
|
||||||
|
|
||||||
private static final String DEFAULT_ROLE_PREFIX = "ROLE_";
|
private static final String DEFAULT_ROLE_PREFIX = "ROLE_";
|
||||||
private static final String DEFAULT_SCOPE_PREFIX = "SCOPE_";
|
private static final String DEFAULT_SCOPE_PREFIX = "SCOPE_";
|
||||||
|
|
||||||
|
@ -67,8 +72,7 @@ public final class EnduserAttributesCapturer {
|
||||||
Span localRootSpan = LocalRootSpan.fromContext(otelContext);
|
Span localRootSpan = LocalRootSpan.fromContext(otelContext);
|
||||||
|
|
||||||
if (enduserIdEnabled && authentication.getName() != null) {
|
if (enduserIdEnabled && authentication.getName() != null) {
|
||||||
localRootSpan.setAttribute(
|
localRootSpan.setAttribute(ENDUSER_ID, authentication.getName());
|
||||||
EnduserIncubatingAttributes.ENDUSER_ID, authentication.getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder roleBuilder = null;
|
StringBuilder roleBuilder = null;
|
||||||
|
@ -85,12 +89,10 @@ public final class EnduserAttributesCapturer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (roleBuilder != null) {
|
if (roleBuilder != null) {
|
||||||
localRootSpan.setAttribute(
|
localRootSpan.setAttribute(ENDUSER_ROLE, roleBuilder.toString());
|
||||||
EnduserIncubatingAttributes.ENDUSER_ROLE, roleBuilder.toString());
|
|
||||||
}
|
}
|
||||||
if (scopeBuilder != null) {
|
if (scopeBuilder != null) {
|
||||||
localRootSpan.setAttribute(
|
localRootSpan.setAttribute(ENDUSER_SCOPE, scopeBuilder.toString());
|
||||||
EnduserIncubatingAttributes.ENDUSER_SCOPE, scopeBuilder.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ dependencies {
|
||||||
api("io.opentelemetry:opentelemetry-api")
|
api("io.opentelemetry:opentelemetry-api")
|
||||||
api("io.opentelemetry:opentelemetry-sdk")
|
api("io.opentelemetry:opentelemetry-sdk")
|
||||||
api("io.opentelemetry:opentelemetry-sdk-testing")
|
api("io.opentelemetry:opentelemetry-sdk-testing")
|
||||||
|
api("io.opentelemetry.semconv:opentelemetry-semconv-incubating")
|
||||||
api(project(":instrumentation-api"))
|
api(project(":instrumentation-api"))
|
||||||
|
|
||||||
api("org.assertj:assertj-core")
|
api("org.assertj:assertj-core")
|
||||||
|
|
Loading…
Reference in New Issue