Return interface instead of concrete implementation in instrumentatio… (#7658)
…n-api-semconv We're already doing that for `SpanNameExtractor`, `OperationMetrics`, `ContextCustomizer`, etc., so I figured we should do the same for `AttributesExtractor` implementation. Also, none of the implementations have any additional public surface - aside from the builder/factory method users can just simply use the interface everywhere.
This commit is contained in:
parent
d8f7604e8d
commit
a9c065930d
|
@ -22,7 +22,7 @@ public final class CodeAttributesExtractor<REQUEST, RESPONSE>
|
||||||
implements AttributesExtractor<REQUEST, RESPONSE> {
|
implements AttributesExtractor<REQUEST, RESPONSE> {
|
||||||
|
|
||||||
/** Creates the code attributes extractor. */
|
/** Creates the code attributes extractor. */
|
||||||
public static <REQUEST, RESPONSE> CodeAttributesExtractor<REQUEST, RESPONSE> create(
|
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
|
||||||
CodeAttributesGetter<REQUEST> getter) {
|
CodeAttributesGetter<REQUEST> getter) {
|
||||||
return new CodeAttributesExtractor<>(getter);
|
return new CodeAttributesExtractor<>(getter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorU
|
||||||
|
|
||||||
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.semconv.trace.attributes.SemanticAttributes;
|
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,7 +25,7 @@ public final class DbClientAttributesExtractor<REQUEST, RESPONSE>
|
||||||
REQUEST, RESPONSE, DbClientAttributesGetter<REQUEST>> {
|
REQUEST, RESPONSE, DbClientAttributesGetter<REQUEST>> {
|
||||||
|
|
||||||
/** Creates the database client attributes extractor with default configuration. */
|
/** Creates the database client attributes extractor with default configuration. */
|
||||||
public static <REQUEST, RESPONSE> DbClientAttributesExtractor<REQUEST, RESPONSE> create(
|
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
|
||||||
DbClientAttributesGetter<REQUEST> getter) {
|
DbClientAttributesGetter<REQUEST> getter) {
|
||||||
return new DbClientAttributesExtractor<>(getter);
|
return new DbClientAttributesExtractor<>(getter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import io.opentelemetry.api.common.AttributesBuilder;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.db.SqlStatementInfo;
|
import io.opentelemetry.instrumentation.api.db.SqlStatementInfo;
|
||||||
import io.opentelemetry.instrumentation.api.db.SqlStatementSanitizer;
|
import io.opentelemetry.instrumentation.api.db.SqlStatementSanitizer;
|
||||||
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,7 +30,7 @@ public final class SqlClientAttributesExtractor<REQUEST, RESPONSE>
|
||||||
REQUEST, RESPONSE, SqlClientAttributesGetter<REQUEST>> {
|
REQUEST, RESPONSE, SqlClientAttributesGetter<REQUEST>> {
|
||||||
|
|
||||||
/** Creates the SQL client attributes extractor with default configuration. */
|
/** Creates the SQL client attributes extractor with default configuration. */
|
||||||
public static <REQUEST, RESPONSE> SqlClientAttributesExtractor<REQUEST, RESPONSE> create(
|
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
|
||||||
SqlClientAttributesGetter<REQUEST> getter) {
|
SqlClientAttributesGetter<REQUEST> getter) {
|
||||||
return SqlClientAttributesExtractor.<REQUEST, RESPONSE>builder(getter).build();
|
return SqlClientAttributesExtractor.<REQUEST, RESPONSE>builder(getter).build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ 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.db.SqlStatementSanitizer;
|
import io.opentelemetry.instrumentation.api.db.SqlStatementSanitizer;
|
||||||
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||||
|
|
||||||
/** A builder of {@link SqlClientAttributesExtractor}. */
|
/** A builder of {@link SqlClientAttributesExtractor}. */
|
||||||
|
@ -54,7 +55,7 @@ public final class SqlClientAttributesExtractorBuilder<REQUEST, RESPONSE> {
|
||||||
* Returns a new {@link SqlClientAttributesExtractor} with the settings of this {@link
|
* Returns a new {@link SqlClientAttributesExtractor} with the settings of this {@link
|
||||||
* SqlClientAttributesExtractorBuilder}.
|
* SqlClientAttributesExtractorBuilder}.
|
||||||
*/
|
*/
|
||||||
public SqlClientAttributesExtractor<REQUEST, RESPONSE> build() {
|
public AttributesExtractor<REQUEST, RESPONSE> build() {
|
||||||
return new SqlClientAttributesExtractor<>(
|
return new SqlClientAttributesExtractor<>(
|
||||||
getter, dbTableAttribute, SqlStatementSanitizer.create(statementSanitizationEnabled));
|
getter, dbTableAttribute, SqlStatementSanitizer.create(statementSanitizationEnabled));
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorU
|
||||||
|
|
||||||
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.net.NetClientAttributesGetter;
|
import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.net.internal.InternalNetClientAttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.net.internal.InternalNetClientAttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.internal.SpanKey;
|
import io.opentelemetry.instrumentation.api.internal.SpanKey;
|
||||||
|
@ -37,13 +38,13 @@ public final class HttpClientAttributesExtractor<REQUEST, RESPONSE>
|
||||||
* @deprecated Use {@link #create(HttpClientAttributesGetter, NetClientAttributesGetter)} instead.
|
* @deprecated Use {@link #create(HttpClientAttributesGetter, NetClientAttributesGetter)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static <REQUEST, RESPONSE> HttpClientAttributesExtractor<REQUEST, RESPONSE> create(
|
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
|
||||||
HttpClientAttributesGetter<REQUEST, RESPONSE> getter) {
|
HttpClientAttributesGetter<REQUEST, RESPONSE> getter) {
|
||||||
return builder(getter).build();
|
return builder(getter).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Creates the HTTP client attributes extractor with default configuration. */
|
/** Creates the HTTP client attributes extractor with default configuration. */
|
||||||
public static <REQUEST, RESPONSE> HttpClientAttributesExtractor<REQUEST, RESPONSE> create(
|
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
|
||||||
HttpClientAttributesGetter<REQUEST, RESPONSE> httpAttributesGetter,
|
HttpClientAttributesGetter<REQUEST, RESPONSE> httpAttributesGetter,
|
||||||
NetClientAttributesGetter<REQUEST, RESPONSE> netAttributesGetter) {
|
NetClientAttributesGetter<REQUEST, RESPONSE> netAttributesGetter) {
|
||||||
return builder(httpAttributesGetter, netAttributesGetter).build();
|
return builder(httpAttributesGetter, netAttributesGetter).build();
|
||||||
|
|
|
@ -8,6 +8,7 @@ package io.opentelemetry.instrumentation.api.instrumenter.http;
|
||||||
import static java.util.Collections.emptyList;
|
import static java.util.Collections.emptyList;
|
||||||
|
|
||||||
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||||
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter;
|
import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ public final class HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE> {
|
||||||
* Returns a new {@link HttpClientAttributesExtractor} with the settings of this {@link
|
* Returns a new {@link HttpClientAttributesExtractor} with the settings of this {@link
|
||||||
* HttpClientAttributesExtractorBuilder}.
|
* HttpClientAttributesExtractorBuilder}.
|
||||||
*/
|
*/
|
||||||
public HttpClientAttributesExtractor<REQUEST, RESPONSE> build() {
|
public AttributesExtractor<REQUEST, RESPONSE> build() {
|
||||||
return new HttpClientAttributesExtractor<>(
|
return new HttpClientAttributesExtractor<>(
|
||||||
httpAttributesGetter, netAttributesGetter, capturedRequestHeaders, capturedResponseHeaders);
|
httpAttributesGetter, netAttributesGetter, capturedRequestHeaders, capturedResponseHeaders);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorU
|
||||||
|
|
||||||
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.net.NetServerAttributesGetter;
|
import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesGetter;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.net.internal.InternalNetServerAttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.net.internal.InternalNetServerAttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.internal.SpanKey;
|
import io.opentelemetry.instrumentation.api.internal.SpanKey;
|
||||||
|
@ -37,7 +38,7 @@ public final class HttpServerAttributesExtractor<REQUEST, RESPONSE>
|
||||||
implements SpanKeyProvider {
|
implements SpanKeyProvider {
|
||||||
|
|
||||||
/** Creates the HTTP server attributes extractor with default configuration. */
|
/** Creates the HTTP server attributes extractor with default configuration. */
|
||||||
public static <REQUEST, RESPONSE> HttpServerAttributesExtractor<REQUEST, RESPONSE> create(
|
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
|
||||||
HttpServerAttributesGetter<REQUEST, RESPONSE> httpAttributesGetter,
|
HttpServerAttributesGetter<REQUEST, RESPONSE> httpAttributesGetter,
|
||||||
NetServerAttributesGetter<REQUEST> netAttributesGetter) {
|
NetServerAttributesGetter<REQUEST> netAttributesGetter) {
|
||||||
return builder(httpAttributesGetter, netAttributesGetter).build();
|
return builder(httpAttributesGetter, netAttributesGetter).build();
|
||||||
|
|
|
@ -8,6 +8,7 @@ package io.opentelemetry.instrumentation.api.instrumenter.http;
|
||||||
import static java.util.Collections.emptyList;
|
import static java.util.Collections.emptyList;
|
||||||
|
|
||||||
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||||
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesGetter;
|
import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesGetter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ public final class HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE> {
|
||||||
* Returns a new {@link HttpServerAttributesExtractor} with the settings of this {@link
|
* Returns a new {@link HttpServerAttributesExtractor} with the settings of this {@link
|
||||||
* HttpServerAttributesExtractorBuilder}.
|
* HttpServerAttributesExtractorBuilder}.
|
||||||
*/
|
*/
|
||||||
public HttpServerAttributesExtractor<REQUEST, RESPONSE> build() {
|
public AttributesExtractor<REQUEST, RESPONSE> build() {
|
||||||
return new HttpServerAttributesExtractor<>(
|
return new HttpServerAttributesExtractor<>(
|
||||||
httpAttributesGetter, netAttributesGetter, capturedRequestHeaders, capturedResponseHeaders);
|
httpAttributesGetter, netAttributesGetter, capturedRequestHeaders, capturedResponseHeaders);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ public final class MessagingAttributesExtractor<REQUEST, RESPONSE>
|
||||||
* Creates the messaging attributes extractor for the given {@link MessageOperation operation}
|
* Creates the messaging attributes extractor for the given {@link MessageOperation operation}
|
||||||
* with default configuration.
|
* with default configuration.
|
||||||
*/
|
*/
|
||||||
public static <REQUEST, RESPONSE> MessagingAttributesExtractor<REQUEST, RESPONSE> create(
|
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
|
||||||
MessagingAttributesGetter<REQUEST, RESPONSE> getter, MessageOperation operation) {
|
MessagingAttributesGetter<REQUEST, RESPONSE> getter, MessageOperation operation) {
|
||||||
return builder(getter, operation).build();
|
return builder(getter, operation).build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ package io.opentelemetry.instrumentation.api.instrumenter.messaging;
|
||||||
import static java.util.Collections.emptyList;
|
import static java.util.Collections.emptyList;
|
||||||
|
|
||||||
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||||
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/** A builder of {@link MessagingAttributesExtractor}. */
|
/** A builder of {@link MessagingAttributesExtractor}. */
|
||||||
|
@ -43,7 +44,7 @@ public final class MessagingAttributesExtractorBuilder<REQUEST, RESPONSE> {
|
||||||
* Returns a new {@link MessagingAttributesExtractor} with the settings of this {@link
|
* Returns a new {@link MessagingAttributesExtractor} with the settings of this {@link
|
||||||
* MessagingAttributesExtractorBuilder}.
|
* MessagingAttributesExtractorBuilder}.
|
||||||
*/
|
*/
|
||||||
public MessagingAttributesExtractor<REQUEST, RESPONSE> build() {
|
public AttributesExtractor<REQUEST, RESPONSE> build() {
|
||||||
return new MessagingAttributesExtractor<>(getter, operation, capturedHeaders);
|
return new MessagingAttributesExtractor<>(getter, operation, capturedHeaders);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ public final class MessagingSpanNameExtractor<REQUEST> implements SpanNameExtrac
|
||||||
this.operation = operation;
|
this.operation = operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation") // operationName
|
|
||||||
@Override
|
@Override
|
||||||
public String extract(REQUEST request) {
|
public String extract(REQUEST request) {
|
||||||
String destinationName =
|
String destinationName =
|
||||||
|
|
|
@ -26,7 +26,7 @@ public final class NetClientAttributesExtractor<REQUEST, RESPONSE>
|
||||||
|
|
||||||
private final InternalNetClientAttributesExtractor<REQUEST, RESPONSE> internalExtractor;
|
private final InternalNetClientAttributesExtractor<REQUEST, RESPONSE> internalExtractor;
|
||||||
|
|
||||||
public static <REQUEST, RESPONSE> NetClientAttributesExtractor<REQUEST, RESPONSE> create(
|
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
|
||||||
NetClientAttributesGetter<REQUEST, RESPONSE> getter) {
|
NetClientAttributesGetter<REQUEST, RESPONSE> getter) {
|
||||||
return new NetClientAttributesExtractor<>(getter);
|
return new NetClientAttributesExtractor<>(getter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ public final class NetServerAttributesExtractor<REQUEST, RESPONSE>
|
||||||
|
|
||||||
private final InternalNetServerAttributesExtractor<REQUEST> internalExtractor;
|
private final InternalNetServerAttributesExtractor<REQUEST> internalExtractor;
|
||||||
|
|
||||||
public static <REQUEST, RESPONSE> NetServerAttributesExtractor<REQUEST, RESPONSE> create(
|
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
|
||||||
NetServerAttributesGetter<REQUEST> getter) {
|
NetServerAttributesGetter<REQUEST> getter) {
|
||||||
return new NetServerAttributesExtractor<>(getter);
|
return new NetServerAttributesExtractor<>(getter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public final class PeerServiceAttributesExtractor<REQUEST, RESPONSE>
|
||||||
* Returns a new {@link PeerServiceAttributesExtractor} that will use the passed {@code
|
* Returns a new {@link PeerServiceAttributesExtractor} that will use the passed {@code
|
||||||
* netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute.
|
* netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute.
|
||||||
*/
|
*/
|
||||||
public static <REQUEST, RESPONSE> PeerServiceAttributesExtractor<REQUEST, RESPONSE> create(
|
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
|
||||||
NetClientAttributesGetter<REQUEST, RESPONSE> attributesGetter,
|
NetClientAttributesGetter<REQUEST, RESPONSE> attributesGetter,
|
||||||
Map<String, String> peerServiceMapping) {
|
Map<String, String> peerServiceMapping) {
|
||||||
return new PeerServiceAttributesExtractor<>(attributesGetter, peerServiceMapping);
|
return new PeerServiceAttributesExtractor<>(attributesGetter, peerServiceMapping);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
package io.opentelemetry.instrumentation.api.instrumenter.rpc;
|
package io.opentelemetry.instrumentation.api.instrumenter.rpc;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@ public final class RpcClientAttributesExtractor<REQUEST, RESPONSE>
|
||||||
extends RpcCommonAttributesExtractor<REQUEST, RESPONSE> implements SpanKeyProvider {
|
extends RpcCommonAttributesExtractor<REQUEST, RESPONSE> implements SpanKeyProvider {
|
||||||
|
|
||||||
/** Creates the RPC client attributes extractor. */
|
/** Creates the RPC client attributes extractor. */
|
||||||
public static <REQUEST, RESPONSE> RpcClientAttributesExtractor<REQUEST, RESPONSE> create(
|
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
|
||||||
RpcAttributesGetter<REQUEST> getter) {
|
RpcAttributesGetter<REQUEST> getter) {
|
||||||
return new RpcClientAttributesExtractor<>(getter);
|
return new RpcClientAttributesExtractor<>(getter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
package io.opentelemetry.instrumentation.api.instrumenter.rpc;
|
package io.opentelemetry.instrumentation.api.instrumenter.rpc;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@ public final class RpcServerAttributesExtractor<REQUEST, RESPONSE>
|
||||||
extends RpcCommonAttributesExtractor<REQUEST, RESPONSE> implements SpanKeyProvider {
|
extends RpcCommonAttributesExtractor<REQUEST, RESPONSE> implements SpanKeyProvider {
|
||||||
|
|
||||||
/** Creates the RPC server attributes extractor. */
|
/** Creates the RPC server attributes extractor. */
|
||||||
public static <REQUEST, RESPONSE> RpcServerAttributesExtractor<REQUEST, RESPONSE> create(
|
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
|
||||||
RpcAttributesGetter<REQUEST> getter) {
|
RpcAttributesGetter<REQUEST> getter) {
|
||||||
return new RpcServerAttributesExtractor<>(getter);
|
return new RpcServerAttributesExtractor<>(getter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import static org.assertj.core.api.Assertions.entry;
|
||||||
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.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -45,7 +46,7 @@ class CodeAttributesExtractorTest {
|
||||||
|
|
||||||
Context context = Context.root();
|
Context context = Context.root();
|
||||||
|
|
||||||
CodeAttributesExtractor<Map<String, String>, Void> underTest =
|
AttributesExtractor<Map<String, String>, Void> underTest =
|
||||||
CodeAttributesExtractor.create(new TestAttributesGetter());
|
CodeAttributesExtractor.create(new TestAttributesGetter());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
|
@ -67,7 +68,7 @@ class CodeAttributesExtractorTest {
|
||||||
@Test
|
@Test
|
||||||
void shouldExtractNoAttributesIfNoneAreAvailable() {
|
void shouldExtractNoAttributesIfNoneAreAvailable() {
|
||||||
// given
|
// given
|
||||||
CodeAttributesExtractor<Map<String, String>, Void> underTest =
|
AttributesExtractor<Map<String, String>, Void> underTest =
|
||||||
CodeAttributesExtractor.create(new TestAttributesGetter());
|
CodeAttributesExtractor.create(new TestAttributesGetter());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
|
|
|
@ -11,6 +11,7 @@ import static org.assertj.core.api.Assertions.entry;
|
||||||
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.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -64,7 +65,7 @@ class DbClientAttributesExtractorTest {
|
||||||
|
|
||||||
Context context = Context.root();
|
Context context = Context.root();
|
||||||
|
|
||||||
DbClientAttributesExtractor<Map<String, String>, Void> underTest =
|
AttributesExtractor<Map<String, String>, Void> underTest =
|
||||||
DbClientAttributesExtractor.create(new TestAttributesGetter());
|
DbClientAttributesExtractor.create(new TestAttributesGetter());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
|
@ -90,7 +91,7 @@ class DbClientAttributesExtractorTest {
|
||||||
@Test
|
@Test
|
||||||
void shouldExtractNoAttributesIfNoneAreAvailable() {
|
void shouldExtractNoAttributesIfNoneAreAvailable() {
|
||||||
// given
|
// given
|
||||||
DbClientAttributesExtractor<Map<String, String>, Void> underTest =
|
AttributesExtractor<Map<String, String>, Void> underTest =
|
||||||
DbClientAttributesExtractor.create(new TestAttributesGetter());
|
DbClientAttributesExtractor.create(new TestAttributesGetter());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
|
|
|
@ -11,6 +11,7 @@ import static org.assertj.core.api.Assertions.entry;
|
||||||
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.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -60,7 +61,7 @@ class SqlClientAttributesExtractorTest {
|
||||||
|
|
||||||
Context context = Context.root();
|
Context context = Context.root();
|
||||||
|
|
||||||
SqlClientAttributesExtractor<Map<String, String>, Void> underTest =
|
AttributesExtractor<Map<String, String>, Void> underTest =
|
||||||
SqlClientAttributesExtractor.create(new TestAttributesGetter());
|
SqlClientAttributesExtractor.create(new TestAttributesGetter());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
|
@ -92,7 +93,7 @@ class SqlClientAttributesExtractorTest {
|
||||||
|
|
||||||
Context context = Context.root();
|
Context context = Context.root();
|
||||||
|
|
||||||
SqlClientAttributesExtractor<Map<String, String>, Void> underTest =
|
AttributesExtractor<Map<String, String>, Void> underTest =
|
||||||
SqlClientAttributesExtractor.create(new TestAttributesGetter());
|
SqlClientAttributesExtractor.create(new TestAttributesGetter());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
|
@ -114,7 +115,7 @@ class SqlClientAttributesExtractorTest {
|
||||||
|
|
||||||
Context context = Context.root();
|
Context context = Context.root();
|
||||||
|
|
||||||
SqlClientAttributesExtractor<Map<String, String>, Void> underTest =
|
AttributesExtractor<Map<String, String>, Void> underTest =
|
||||||
SqlClientAttributesExtractor.<Map<String, String>, Void>builder(new TestAttributesGetter())
|
SqlClientAttributesExtractor.<Map<String, String>, Void>builder(new TestAttributesGetter())
|
||||||
.setTableAttribute(SemanticAttributes.DB_CASSANDRA_TABLE)
|
.setTableAttribute(SemanticAttributes.DB_CASSANDRA_TABLE)
|
||||||
.build();
|
.build();
|
||||||
|
@ -134,7 +135,7 @@ class SqlClientAttributesExtractorTest {
|
||||||
@Test
|
@Test
|
||||||
void shouldExtractNoAttributesIfNoneAreAvailable() {
|
void shouldExtractNoAttributesIfNoneAreAvailable() {
|
||||||
// when
|
// when
|
||||||
SqlClientAttributesExtractor<Map<String, String>, Void> underTest =
|
AttributesExtractor<Map<String, String>, Void> underTest =
|
||||||
SqlClientAttributesExtractor.create(new TestAttributesGetter());
|
SqlClientAttributesExtractor.create(new TestAttributesGetter());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
|
|
|
@ -17,6 +17,7 @@ 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.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter;
|
import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter;
|
||||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -113,7 +114,7 @@ class HttpClientAttributesExtractorTest {
|
||||||
response.put("header.custom-response-header", "654,321");
|
response.put("header.custom-response-header", "654,321");
|
||||||
response.put("transport", IP_TCP);
|
response.put("transport", IP_TCP);
|
||||||
|
|
||||||
HttpClientAttributesExtractor<Map<String, String>, Map<String, String>> extractor =
|
AttributesExtractor<Map<String, String>, Map<String, String>> extractor =
|
||||||
HttpClientAttributesExtractor.builder(
|
HttpClientAttributesExtractor.builder(
|
||||||
new TestHttpClientAttributesGetter(), new TestNetClientAttributesGetter())
|
new TestHttpClientAttributesGetter(), new TestNetClientAttributesGetter())
|
||||||
.setCapturedRequestHeaders(singletonList("Custom-Request-Header"))
|
.setCapturedRequestHeaders(singletonList("Custom-Request-Header"))
|
||||||
|
@ -153,7 +154,7 @@ class HttpClientAttributesExtractorTest {
|
||||||
Map<String, String> request = new HashMap<>();
|
Map<String, String> request = new HashMap<>();
|
||||||
request.put("url", url);
|
request.put("url", url);
|
||||||
|
|
||||||
HttpClientAttributesExtractor<Map<String, String>, Map<String, String>> extractor =
|
AttributesExtractor<Map<String, String>, Map<String, String>> extractor =
|
||||||
HttpClientAttributesExtractor.builder(
|
HttpClientAttributesExtractor.builder(
|
||||||
new TestHttpClientAttributesGetter(), new TestNetClientAttributesGetter())
|
new TestHttpClientAttributesGetter(), new TestNetClientAttributesGetter())
|
||||||
.build();
|
.build();
|
||||||
|
@ -189,7 +190,7 @@ class HttpClientAttributesExtractorTest {
|
||||||
Map<String, String> response = new HashMap<>();
|
Map<String, String> response = new HashMap<>();
|
||||||
response.put("statusCode", "0");
|
response.put("statusCode", "0");
|
||||||
|
|
||||||
HttpClientAttributesExtractor<Map<String, String>, Map<String, String>> extractor =
|
AttributesExtractor<Map<String, String>, Map<String, String>> extractor =
|
||||||
HttpClientAttributesExtractor.builder(
|
HttpClientAttributesExtractor.builder(
|
||||||
new TestHttpClientAttributesGetter(), new TestNetClientAttributesGetter())
|
new TestHttpClientAttributesGetter(), new TestNetClientAttributesGetter())
|
||||||
.setCapturedRequestHeaders(emptyList())
|
.setCapturedRequestHeaders(emptyList())
|
||||||
|
@ -209,7 +210,7 @@ class HttpClientAttributesExtractorTest {
|
||||||
Map<String, String> request = new HashMap<>();
|
Map<String, String> request = new HashMap<>();
|
||||||
request.put("header.host", "thehost:777");
|
request.put("header.host", "thehost:777");
|
||||||
|
|
||||||
HttpClientAttributesExtractor<Map<String, String>, Map<String, String>> extractor =
|
AttributesExtractor<Map<String, String>, Map<String, String>> extractor =
|
||||||
HttpClientAttributesExtractor.create(
|
HttpClientAttributesExtractor.create(
|
||||||
new TestHttpClientAttributesGetter(), new TestNetClientAttributesGetter());
|
new TestHttpClientAttributesGetter(), new TestNetClientAttributesGetter());
|
||||||
|
|
||||||
|
@ -229,7 +230,7 @@ class HttpClientAttributesExtractorTest {
|
||||||
request.put("peerName", "thehost");
|
request.put("peerName", "thehost");
|
||||||
request.put("peerPort", "777");
|
request.put("peerPort", "777");
|
||||||
|
|
||||||
HttpClientAttributesExtractor<Map<String, String>, Map<String, String>> extractor =
|
AttributesExtractor<Map<String, String>, Map<String, String>> extractor =
|
||||||
HttpClientAttributesExtractor.create(
|
HttpClientAttributesExtractor.create(
|
||||||
new TestHttpClientAttributesGetter(), new TestNetClientAttributesGetter());
|
new TestHttpClientAttributesGetter(), new TestNetClientAttributesGetter());
|
||||||
|
|
||||||
|
@ -249,7 +250,7 @@ class HttpClientAttributesExtractorTest {
|
||||||
request.put("url", url);
|
request.put("url", url);
|
||||||
request.put("peerPort", String.valueOf(peerPort));
|
request.put("peerPort", String.valueOf(peerPort));
|
||||||
|
|
||||||
HttpClientAttributesExtractor<Map<String, String>, Map<String, String>> extractor =
|
AttributesExtractor<Map<String, String>, Map<String, String>> extractor =
|
||||||
HttpClientAttributesExtractor.builder(
|
HttpClientAttributesExtractor.builder(
|
||||||
new TestHttpClientAttributesGetter(), new TestNetClientAttributesGetter())
|
new TestHttpClientAttributesGetter(), new TestNetClientAttributesGetter())
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -16,6 +16,7 @@ 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.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesGetter;
|
import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesGetter;
|
||||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -176,7 +177,7 @@ class HttpServerAttributesExtractorTest {
|
||||||
Map<String, Object> request = new HashMap<>();
|
Map<String, Object> request = new HashMap<>();
|
||||||
request.put("header.x-forwarded-for", "1.1.1.1");
|
request.put("header.x-forwarded-for", "1.1.1.1");
|
||||||
|
|
||||||
HttpServerAttributesExtractor<Map<String, Object>, Map<String, Object>> extractor =
|
AttributesExtractor<Map<String, Object>, Map<String, Object>> extractor =
|
||||||
HttpServerAttributesExtractor.builder(
|
HttpServerAttributesExtractor.builder(
|
||||||
new TestHttpServerAttributesGetter(), new TestNetServerAttributesGetter())
|
new TestHttpServerAttributesGetter(), new TestNetServerAttributesGetter())
|
||||||
.setCapturedRequestHeaders(emptyList())
|
.setCapturedRequestHeaders(emptyList())
|
||||||
|
@ -198,7 +199,7 @@ class HttpServerAttributesExtractorTest {
|
||||||
Map<String, Object> request = new HashMap<>();
|
Map<String, Object> request = new HashMap<>();
|
||||||
request.put("header.x-forwarded-proto", "https");
|
request.put("header.x-forwarded-proto", "https");
|
||||||
|
|
||||||
HttpServerAttributesExtractor<Map<String, Object>, Map<String, Object>> extractor =
|
AttributesExtractor<Map<String, Object>, Map<String, Object>> extractor =
|
||||||
HttpServerAttributesExtractor.builder(
|
HttpServerAttributesExtractor.builder(
|
||||||
new TestHttpServerAttributesGetter(), new TestNetServerAttributesGetter())
|
new TestHttpServerAttributesGetter(), new TestNetServerAttributesGetter())
|
||||||
.setCapturedRequestHeaders(emptyList())
|
.setCapturedRequestHeaders(emptyList())
|
||||||
|
@ -218,7 +219,7 @@ class HttpServerAttributesExtractorTest {
|
||||||
Map<String, Object> request = new HashMap<>();
|
Map<String, Object> request = new HashMap<>();
|
||||||
request.put("header.host", "thehost:777");
|
request.put("header.host", "thehost:777");
|
||||||
|
|
||||||
HttpServerAttributesExtractor<Map<String, Object>, Map<String, Object>> extractor =
|
AttributesExtractor<Map<String, Object>, Map<String, Object>> extractor =
|
||||||
HttpServerAttributesExtractor.builder(
|
HttpServerAttributesExtractor.builder(
|
||||||
new TestHttpServerAttributesGetter(), new TestNetServerAttributesGetter())
|
new TestHttpServerAttributesGetter(), new TestNetServerAttributesGetter())
|
||||||
.setCapturedRequestHeaders(emptyList())
|
.setCapturedRequestHeaders(emptyList())
|
||||||
|
@ -240,7 +241,7 @@ class HttpServerAttributesExtractorTest {
|
||||||
request.put("hostName", "thehost");
|
request.put("hostName", "thehost");
|
||||||
request.put("hostPort", 777);
|
request.put("hostPort", 777);
|
||||||
|
|
||||||
HttpServerAttributesExtractor<Map<String, Object>, Map<String, Object>> extractor =
|
AttributesExtractor<Map<String, Object>, Map<String, Object>> extractor =
|
||||||
HttpServerAttributesExtractor.builder(
|
HttpServerAttributesExtractor.builder(
|
||||||
new TestHttpServerAttributesGetter(), new TestNetServerAttributesGetter())
|
new TestHttpServerAttributesGetter(), new TestNetServerAttributesGetter())
|
||||||
.setCapturedRequestHeaders(emptyList())
|
.setCapturedRequestHeaders(emptyList())
|
||||||
|
@ -262,7 +263,7 @@ class HttpServerAttributesExtractorTest {
|
||||||
request.put("scheme", scheme);
|
request.put("scheme", scheme);
|
||||||
request.put("hostPort", hostPort);
|
request.put("hostPort", hostPort);
|
||||||
|
|
||||||
HttpServerAttributesExtractor<Map<String, Object>, Map<String, Object>> extractor =
|
AttributesExtractor<Map<String, Object>, Map<String, Object>> extractor =
|
||||||
HttpServerAttributesExtractor.builder(
|
HttpServerAttributesExtractor.builder(
|
||||||
new TestHttpServerAttributesGetter(), new TestNetServerAttributesGetter())
|
new TestHttpServerAttributesGetter(), new TestNetServerAttributesGetter())
|
||||||
.setCapturedRequestHeaders(emptyList())
|
.setCapturedRequestHeaders(emptyList())
|
||||||
|
|
|
@ -12,6 +12,7 @@ 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.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -50,7 +51,7 @@ class MessagingAttributesExtractorTest {
|
||||||
request.put("payloadSize", "100");
|
request.put("payloadSize", "100");
|
||||||
request.put("payloadCompressedSize", "10");
|
request.put("payloadCompressedSize", "10");
|
||||||
|
|
||||||
MessagingAttributesExtractor<Map<String, String>, String> underTest =
|
AttributesExtractor<Map<String, String>, String> underTest =
|
||||||
MessagingAttributesExtractor.create(TestGetter.INSTANCE, operation);
|
MessagingAttributesExtractor.create(TestGetter.INSTANCE, operation);
|
||||||
|
|
||||||
Context context = Context.root();
|
Context context = Context.root();
|
||||||
|
@ -97,7 +98,7 @@ class MessagingAttributesExtractorTest {
|
||||||
@Test
|
@Test
|
||||||
void shouldExtractNoAttributesIfNoneAreAvailable() {
|
void shouldExtractNoAttributesIfNoneAreAvailable() {
|
||||||
// given
|
// given
|
||||||
MessagingAttributesExtractor<Map<String, String>, String> underTest =
|
AttributesExtractor<Map<String, String>, String> underTest =
|
||||||
MessagingAttributesExtractor.create(TestGetter.INSTANCE, MessageOperation.SEND);
|
MessagingAttributesExtractor.create(TestGetter.INSTANCE, MessageOperation.SEND);
|
||||||
|
|
||||||
Context context = Context.root();
|
Context context = Context.root();
|
||||||
|
|
|
@ -11,6 +11,7 @@ import static org.assertj.core.api.Assertions.entry;
|
||||||
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.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||||
import java.net.Inet4Address;
|
import java.net.Inet4Address;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
|
@ -47,7 +48,7 @@ class InetSocketAddressNetClientAttributesGetterTest {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private final NetClientAttributesExtractor<InetSocketAddress, InetSocketAddress> extractor =
|
private final AttributesExtractor<InetSocketAddress, InetSocketAddress> extractor =
|
||||||
NetClientAttributesExtractor.create(getter);
|
NetClientAttributesExtractor.create(getter);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -11,6 +11,7 @@ import static org.assertj.core.api.Assertions.entry;
|
||||||
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.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||||
import java.net.Inet4Address;
|
import java.net.Inet4Address;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
|
@ -51,7 +52,7 @@ class InetSocketAddressNetServerAttributesGetterTest {
|
||||||
return request.host;
|
return request.host;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private final NetServerAttributesExtractor<Addresses, Addresses> extractor =
|
private final AttributesExtractor<Addresses, Addresses> extractor =
|
||||||
NetServerAttributesExtractor.create(getter);
|
NetServerAttributesExtractor.create(getter);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -13,6 +13,7 @@ import static org.assertj.core.api.Assertions.entry;
|
||||||
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.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -74,7 +75,7 @@ class NetServerAttributesExtractorTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NetServerAttributesExtractor<Map<String, String>, Map<String, String>> extractor =
|
AttributesExtractor<Map<String, String>, Map<String, String>> extractor =
|
||||||
NetServerAttributesExtractor.create(new TestNetServerAttributesGetter());
|
NetServerAttributesExtractor.create(new TestNetServerAttributesGetter());
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -9,6 +9,7 @@ import static java.util.Collections.emptyList;
|
||||||
|
|
||||||
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.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
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.instrumenter.messaging.MessageOperation;
|
import io.opentelemetry.instrumentation.api.instrumenter.messaging.MessageOperation;
|
||||||
|
@ -84,8 +85,8 @@ public final class JmsInstrumenterFactory {
|
||||||
.buildConsumerInstrumenter(MessagePropertyGetter.INSTANCE);
|
.buildConsumerInstrumenter(MessagePropertyGetter.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private MessagingAttributesExtractor<MessageWithDestination, Void>
|
private AttributesExtractor<MessageWithDestination, Void> createMessagingAttributesExtractor(
|
||||||
createMessagingAttributesExtractor(MessageOperation operation) {
|
MessageOperation operation) {
|
||||||
return MessagingAttributesExtractor.builder(JmsMessageAttributesGetter.INSTANCE, operation)
|
return MessagingAttributesExtractor.builder(JmsMessageAttributesGetter.INSTANCE, operation)
|
||||||
.setCapturedHeaders(capturedHeaders)
|
.setCapturedHeaders(capturedHeaders)
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -171,7 +171,7 @@ public final class KafkaInstrumenterFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <REQUEST, RESPONSE>
|
private static <REQUEST, RESPONSE>
|
||||||
MessagingAttributesExtractor<REQUEST, RESPONSE> buildMessagingAttributesExtractor(
|
AttributesExtractor<REQUEST, RESPONSE> buildMessagingAttributesExtractor(
|
||||||
MessagingAttributesGetter<REQUEST, RESPONSE> getter,
|
MessagingAttributesGetter<REQUEST, RESPONSE> getter,
|
||||||
MessageOperation operation,
|
MessageOperation operation,
|
||||||
List<String> capturedHeaders) {
|
List<String> capturedHeaders) {
|
||||||
|
|
|
@ -24,6 +24,7 @@ import io.opentelemetry.api.trace.SpanKind;
|
||||||
import io.opentelemetry.api.trace.StatusCode;
|
import io.opentelemetry.api.trace.StatusCode;
|
||||||
import io.opentelemetry.context.Context;
|
import io.opentelemetry.context.Context;
|
||||||
import io.opentelemetry.instrumentation.api.db.RedisCommandSanitizer;
|
import io.opentelemetry.instrumentation.api.db.RedisCommandSanitizer;
|
||||||
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor;
|
||||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
|
||||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes.DbSystemValues;
|
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes.DbSystemValues;
|
||||||
|
@ -36,9 +37,8 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
final class OpenTelemetryTracing implements Tracing {
|
final class OpenTelemetryTracing implements Tracing {
|
||||||
|
|
||||||
private static final NetClientAttributesExtractor<OpenTelemetryEndpoint, Void>
|
private static final AttributesExtractor<OpenTelemetryEndpoint, Void> netAttributesExtractor =
|
||||||
netAttributesExtractor =
|
NetClientAttributesExtractor.create(new LettuceNetAttributesGetter());
|
||||||
NetClientAttributesExtractor.create(new LettuceNetAttributesGetter());
|
|
||||||
private final TracerProvider tracerProvider;
|
private final TracerProvider tracerProvider;
|
||||||
|
|
||||||
OpenTelemetryTracing(io.opentelemetry.api.trace.Tracer tracer, RedisCommandSanitizer sanitizer) {
|
OpenTelemetryTracing(io.opentelemetry.api.trace.Tracer tracer, RedisCommandSanitizer sanitizer) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ package io.opentelemetry.instrumentation.mongo.v3_1;
|
||||||
|
|
||||||
import com.mongodb.event.CommandStartedEvent;
|
import com.mongodb.event.CommandStartedEvent;
|
||||||
import io.opentelemetry.api.OpenTelemetry;
|
import io.opentelemetry.api.OpenTelemetry;
|
||||||
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
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.instrumenter.SpanNameExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
|
||||||
|
@ -17,8 +18,8 @@ class MongoInstrumenterFactory {
|
||||||
|
|
||||||
private static final MongoAttributesExtractor attributesExtractor =
|
private static final MongoAttributesExtractor attributesExtractor =
|
||||||
new MongoAttributesExtractor();
|
new MongoAttributesExtractor();
|
||||||
private static final NetClientAttributesExtractor<CommandStartedEvent, Void>
|
private static final AttributesExtractor<CommandStartedEvent, Void> netAttributesExtractor =
|
||||||
netAttributesExtractor = NetClientAttributesExtractor.create(new MongoNetAttributesGetter());
|
NetClientAttributesExtractor.create(new MongoNetAttributesGetter());
|
||||||
|
|
||||||
static Instrumenter<CommandStartedEvent, Void> createInstrumenter(
|
static Instrumenter<CommandStartedEvent, Void> createInstrumenter(
|
||||||
OpenTelemetry openTelemetry,
|
OpenTelemetry openTelemetry,
|
||||||
|
|
|
@ -104,7 +104,7 @@ public final class RabbitSingletons {
|
||||||
.buildConsumerInstrumenter(DeliveryRequestGetter.INSTANCE);
|
.buildConsumerInstrumenter(DeliveryRequestGetter.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T, V> MessagingAttributesExtractor<T, V> buildMessagingAttributesExtractor(
|
private static <T, V> AttributesExtractor<T, V> buildMessagingAttributesExtractor(
|
||||||
MessagingAttributesGetter<T, V> getter, MessageOperation operation) {
|
MessagingAttributesGetter<T, V> getter, MessageOperation operation) {
|
||||||
return MessagingAttributesExtractor.builder(getter, operation)
|
return MessagingAttributesExtractor.builder(getter, operation)
|
||||||
.setCapturedHeaders(ExperimentalConfig.get().getMessagingHeaders())
|
.setCapturedHeaders(ExperimentalConfig.get().getMessagingHeaders())
|
||||||
|
|
|
@ -8,7 +8,6 @@ package io.opentelemetry.instrumentation.restlet.v2_0.internal;
|
||||||
import io.opentelemetry.api.OpenTelemetry;
|
import io.opentelemetry.api.OpenTelemetry;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
|
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesExtractor;
|
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerMetrics;
|
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerMetrics;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
|
||||||
|
@ -26,7 +25,7 @@ public final class RestletInstrumenterFactory {
|
||||||
|
|
||||||
public static Instrumenter<Request, Response> newServerInstrumenter(
|
public static Instrumenter<Request, Response> newServerInstrumenter(
|
||||||
OpenTelemetry openTelemetry,
|
OpenTelemetry openTelemetry,
|
||||||
HttpServerAttributesExtractor<Request, Response> httpServerAttributesExtractor,
|
AttributesExtractor<Request, Response> httpServerAttributesExtractor,
|
||||||
List<AttributesExtractor<Request, Response>> additionalExtractors) {
|
List<AttributesExtractor<Request, Response>> additionalExtractors) {
|
||||||
|
|
||||||
RestletHttpAttributesGetter httpAttributesGetter = RestletHttpAttributesGetter.INSTANCE;
|
RestletHttpAttributesGetter httpAttributesGetter = RestletHttpAttributesGetter.INSTANCE;
|
||||||
|
|
|
@ -10,6 +10,7 @@ import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.MESSA
|
||||||
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.MESSAGING_SYSTEM;
|
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.MESSAGING_SYSTEM;
|
||||||
|
|
||||||
import io.opentelemetry.api.OpenTelemetry;
|
import io.opentelemetry.api.OpenTelemetry;
|
||||||
|
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
|
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
|
import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
|
||||||
import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor;
|
import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor;
|
||||||
|
@ -123,7 +124,7 @@ class RocketMqInstrumenterFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> MessagingAttributesExtractor<T, Void> buildMessagingAttributesExtractor(
|
private static <T> AttributesExtractor<T, Void> buildMessagingAttributesExtractor(
|
||||||
MessagingAttributesGetter<T, Void> getter,
|
MessagingAttributesGetter<T, Void> getter,
|
||||||
MessageOperation operation,
|
MessageOperation operation,
|
||||||
List<String> capturedHeaders) {
|
List<String> capturedHeaders) {
|
||||||
|
|
|
@ -53,7 +53,7 @@ final class RocketMqInstrumenterFactory {
|
||||||
RocketMqConsumerReceiveAttributeGetter getter = RocketMqConsumerReceiveAttributeGetter.INSTANCE;
|
RocketMqConsumerReceiveAttributeGetter getter = RocketMqConsumerReceiveAttributeGetter.INSTANCE;
|
||||||
MessageOperation operation = MessageOperation.RECEIVE;
|
MessageOperation operation = MessageOperation.RECEIVE;
|
||||||
|
|
||||||
MessagingAttributesExtractor<ReceiveMessageRequest, List<MessageView>> attributesExtractor =
|
AttributesExtractor<ReceiveMessageRequest, List<MessageView>> attributesExtractor =
|
||||||
buildMessagingAttributesExtractor(getter, operation, capturedHeaders);
|
buildMessagingAttributesExtractor(getter, operation, capturedHeaders);
|
||||||
|
|
||||||
InstrumenterBuilder<ReceiveMessageRequest, List<MessageView>> instrumenterBuilder =
|
InstrumenterBuilder<ReceiveMessageRequest, List<MessageView>> instrumenterBuilder =
|
||||||
|
@ -74,7 +74,7 @@ final class RocketMqInstrumenterFactory {
|
||||||
RocketMqConsumerProcessAttributeGetter getter = RocketMqConsumerProcessAttributeGetter.INSTANCE;
|
RocketMqConsumerProcessAttributeGetter getter = RocketMqConsumerProcessAttributeGetter.INSTANCE;
|
||||||
MessageOperation operation = MessageOperation.PROCESS;
|
MessageOperation operation = MessageOperation.PROCESS;
|
||||||
|
|
||||||
MessagingAttributesExtractor<MessageView, ConsumeResult> attributesExtractor =
|
AttributesExtractor<MessageView, ConsumeResult> attributesExtractor =
|
||||||
buildMessagingAttributesExtractor(getter, operation, capturedHeaders);
|
buildMessagingAttributesExtractor(getter, operation, capturedHeaders);
|
||||||
|
|
||||||
InstrumenterBuilder<MessageView, ConsumeResult> instrumenterBuilder =
|
InstrumenterBuilder<MessageView, ConsumeResult> instrumenterBuilder =
|
||||||
|
@ -101,7 +101,7 @@ final class RocketMqInstrumenterFactory {
|
||||||
return instrumenterBuilder.buildConsumerInstrumenter(MessageMapGetter.INSTANCE);
|
return instrumenterBuilder.buildConsumerInstrumenter(MessageMapGetter.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T, R> MessagingAttributesExtractor<T, R> buildMessagingAttributesExtractor(
|
private static <T, R> AttributesExtractor<T, R> buildMessagingAttributesExtractor(
|
||||||
MessagingAttributesGetter<T, R> getter,
|
MessagingAttributesGetter<T, R> getter,
|
||||||
MessageOperation operation,
|
MessageOperation operation,
|
||||||
List<String> capturedHeaders) {
|
List<String> capturedHeaders) {
|
||||||
|
|
|
@ -111,11 +111,10 @@ public final class SpringIntegrationTelemetryBuilder {
|
||||||
producerSpanEnabled);
|
producerSpanEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MessagingAttributesExtractor<MessageWithChannel, Void>
|
private static AttributesExtractor<MessageWithChannel, Void> buildMessagingAttributesExtractor(
|
||||||
buildMessagingAttributesExtractor(
|
MessagingAttributesGetter<MessageWithChannel, Void> getter,
|
||||||
MessagingAttributesGetter<MessageWithChannel, Void> getter,
|
MessageOperation operation,
|
||||||
MessageOperation operation,
|
List<String> capturedHeaders) {
|
||||||
List<String> capturedHeaders) {
|
|
||||||
return MessagingAttributesExtractor.builder(getter, operation)
|
return MessagingAttributesExtractor.builder(getter, operation)
|
||||||
.setCapturedHeaders(capturedHeaders)
|
.setCapturedHeaders(capturedHeaders)
|
||||||
.build();
|
.build();
|
||||||
|
|
Loading…
Reference in New Issue