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:
Mateusz Rzeszutek 2023-01-31 13:21:28 +01:00 committed by GitHub
parent d8f7604e8d
commit a9c065930d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 80 additions and 61 deletions

View File

@ -22,7 +22,7 @@ public final class CodeAttributesExtractor<REQUEST, RESPONSE>
implements AttributesExtractor<REQUEST, RESPONSE> {
/** Creates the code attributes extractor. */
public static <REQUEST, RESPONSE> CodeAttributesExtractor<REQUEST, RESPONSE> create(
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
CodeAttributesGetter<REQUEST> getter) {
return new CodeAttributesExtractor<>(getter);
}

View File

@ -9,6 +9,7 @@ import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorU
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
/**
@ -24,7 +25,7 @@ public final class DbClientAttributesExtractor<REQUEST, RESPONSE>
REQUEST, RESPONSE, DbClientAttributesGetter<REQUEST>> {
/** 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) {
return new DbClientAttributesExtractor<>(getter);
}

View File

@ -12,6 +12,7 @@ import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.db.SqlStatementInfo;
import io.opentelemetry.instrumentation.api.db.SqlStatementSanitizer;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
/**
@ -29,7 +30,7 @@ public final class SqlClientAttributesExtractor<REQUEST, RESPONSE>
REQUEST, RESPONSE, SqlClientAttributesGetter<REQUEST>> {
/** 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) {
return SqlClientAttributesExtractor.<REQUEST, RESPONSE>builder(getter).build();
}

View File

@ -10,6 +10,7 @@ import static java.util.Objects.requireNonNull;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.instrumentation.api.db.SqlStatementSanitizer;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
/** 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
* SqlClientAttributesExtractorBuilder}.
*/
public SqlClientAttributesExtractor<REQUEST, RESPONSE> build() {
public AttributesExtractor<REQUEST, RESPONSE> build() {
return new SqlClientAttributesExtractor<>(
getter, dbTableAttribute, SqlStatementSanitizer.create(statementSanitizationEnabled));
}

View File

@ -9,6 +9,7 @@ import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorU
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter;
import io.opentelemetry.instrumentation.api.instrumenter.net.internal.InternalNetClientAttributesExtractor;
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
public static <REQUEST, RESPONSE> HttpClientAttributesExtractor<REQUEST, RESPONSE> create(
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
HttpClientAttributesGetter<REQUEST, RESPONSE> getter) {
return builder(getter).build();
}
/** 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,
NetClientAttributesGetter<REQUEST, RESPONSE> netAttributesGetter) {
return builder(httpAttributesGetter, netAttributesGetter).build();

View File

@ -8,6 +8,7 @@ package io.opentelemetry.instrumentation.api.instrumenter.http;
import static java.util.Collections.emptyList;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter;
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
* HttpClientAttributesExtractorBuilder}.
*/
public HttpClientAttributesExtractor<REQUEST, RESPONSE> build() {
public AttributesExtractor<REQUEST, RESPONSE> build() {
return new HttpClientAttributesExtractor<>(
httpAttributesGetter, netAttributesGetter, capturedRequestHeaders, capturedResponseHeaders);
}

View File

@ -13,6 +13,7 @@ import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorU
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesGetter;
import io.opentelemetry.instrumentation.api.instrumenter.net.internal.InternalNetServerAttributesExtractor;
import io.opentelemetry.instrumentation.api.internal.SpanKey;
@ -37,7 +38,7 @@ public final class HttpServerAttributesExtractor<REQUEST, RESPONSE>
implements SpanKeyProvider {
/** 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,
NetServerAttributesGetter<REQUEST> netAttributesGetter) {
return builder(httpAttributesGetter, netAttributesGetter).build();

View File

@ -8,6 +8,7 @@ package io.opentelemetry.instrumentation.api.instrumenter.http;
import static java.util.Collections.emptyList;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesGetter;
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
* HttpServerAttributesExtractorBuilder}.
*/
public HttpServerAttributesExtractor<REQUEST, RESPONSE> build() {
public AttributesExtractor<REQUEST, RESPONSE> build() {
return new HttpServerAttributesExtractor<>(
httpAttributesGetter, netAttributesGetter, capturedRequestHeaders, capturedResponseHeaders);
}

View File

@ -37,7 +37,7 @@ public final class MessagingAttributesExtractor<REQUEST, RESPONSE>
* Creates the messaging attributes extractor for the given {@link MessageOperation operation}
* 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) {
return builder(getter, operation).build();
}

View File

@ -8,6 +8,7 @@ package io.opentelemetry.instrumentation.api.instrumenter.messaging;
import static java.util.Collections.emptyList;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import java.util.List;
/** 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
* MessagingAttributesExtractorBuilder}.
*/
public MessagingAttributesExtractor<REQUEST, RESPONSE> build() {
public AttributesExtractor<REQUEST, RESPONSE> build() {
return new MessagingAttributesExtractor<>(getter, operation, capturedHeaders);
}
}

View File

@ -32,7 +32,6 @@ public final class MessagingSpanNameExtractor<REQUEST> implements SpanNameExtrac
this.operation = operation;
}
@SuppressWarnings("deprecation") // operationName
@Override
public String extract(REQUEST request) {
String destinationName =

View File

@ -26,7 +26,7 @@ public final class NetClientAttributesExtractor<REQUEST, RESPONSE>
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) {
return new NetClientAttributesExtractor<>(getter);
}

View File

@ -23,7 +23,7 @@ public final class NetServerAttributesExtractor<REQUEST, RESPONSE>
private final InternalNetServerAttributesExtractor<REQUEST> internalExtractor;
public static <REQUEST, RESPONSE> NetServerAttributesExtractor<REQUEST, RESPONSE> create(
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
NetServerAttributesGetter<REQUEST> getter) {
return new NetServerAttributesExtractor<>(getter);
}

View File

@ -35,7 +35,7 @@ public final class PeerServiceAttributesExtractor<REQUEST, RESPONSE>
* Returns a new {@link PeerServiceAttributesExtractor} that will use the passed {@code
* 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,
Map<String, String> peerServiceMapping) {
return new PeerServiceAttributesExtractor<>(attributesGetter, peerServiceMapping);

View File

@ -5,6 +5,7 @@
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.SpanKeyProvider;
@ -20,7 +21,7 @@ public final class RpcClientAttributesExtractor<REQUEST, RESPONSE>
extends RpcCommonAttributesExtractor<REQUEST, RESPONSE> implements SpanKeyProvider {
/** 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) {
return new RpcClientAttributesExtractor<>(getter);
}

View File

@ -5,6 +5,7 @@
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.SpanKeyProvider;
@ -20,7 +21,7 @@ public final class RpcServerAttributesExtractor<REQUEST, RESPONSE>
extends RpcCommonAttributesExtractor<REQUEST, RESPONSE> implements SpanKeyProvider {
/** 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) {
return new RpcServerAttributesExtractor<>(getter);
}

View File

@ -11,6 +11,7 @@ import static org.assertj.core.api.Assertions.entry;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.util.Collections;
import java.util.HashMap;
@ -45,7 +46,7 @@ class CodeAttributesExtractorTest {
Context context = Context.root();
CodeAttributesExtractor<Map<String, String>, Void> underTest =
AttributesExtractor<Map<String, String>, Void> underTest =
CodeAttributesExtractor.create(new TestAttributesGetter());
// when
@ -67,7 +68,7 @@ class CodeAttributesExtractorTest {
@Test
void shouldExtractNoAttributesIfNoneAreAvailable() {
// given
CodeAttributesExtractor<Map<String, String>, Void> underTest =
AttributesExtractor<Map<String, String>, Void> underTest =
CodeAttributesExtractor.create(new TestAttributesGetter());
// when

View File

@ -11,6 +11,7 @@ import static org.assertj.core.api.Assertions.entry;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.util.Collections;
import java.util.HashMap;
@ -64,7 +65,7 @@ class DbClientAttributesExtractorTest {
Context context = Context.root();
DbClientAttributesExtractor<Map<String, String>, Void> underTest =
AttributesExtractor<Map<String, String>, Void> underTest =
DbClientAttributesExtractor.create(new TestAttributesGetter());
// when
@ -90,7 +91,7 @@ class DbClientAttributesExtractorTest {
@Test
void shouldExtractNoAttributesIfNoneAreAvailable() {
// given
DbClientAttributesExtractor<Map<String, String>, Void> underTest =
AttributesExtractor<Map<String, String>, Void> underTest =
DbClientAttributesExtractor.create(new TestAttributesGetter());
// when

View File

@ -11,6 +11,7 @@ import static org.assertj.core.api.Assertions.entry;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.util.Collections;
import java.util.HashMap;
@ -60,7 +61,7 @@ class SqlClientAttributesExtractorTest {
Context context = Context.root();
SqlClientAttributesExtractor<Map<String, String>, Void> underTest =
AttributesExtractor<Map<String, String>, Void> underTest =
SqlClientAttributesExtractor.create(new TestAttributesGetter());
// when
@ -92,7 +93,7 @@ class SqlClientAttributesExtractorTest {
Context context = Context.root();
SqlClientAttributesExtractor<Map<String, String>, Void> underTest =
AttributesExtractor<Map<String, String>, Void> underTest =
SqlClientAttributesExtractor.create(new TestAttributesGetter());
// when
@ -114,7 +115,7 @@ class SqlClientAttributesExtractorTest {
Context context = Context.root();
SqlClientAttributesExtractor<Map<String, String>, Void> underTest =
AttributesExtractor<Map<String, String>, Void> underTest =
SqlClientAttributesExtractor.<Map<String, String>, Void>builder(new TestAttributesGetter())
.setTableAttribute(SemanticAttributes.DB_CASSANDRA_TABLE)
.build();
@ -134,7 +135,7 @@ class SqlClientAttributesExtractorTest {
@Test
void shouldExtractNoAttributesIfNoneAreAvailable() {
// when
SqlClientAttributesExtractor<Map<String, String>, Void> underTest =
AttributesExtractor<Map<String, String>, Void> underTest =
SqlClientAttributesExtractor.create(new TestAttributesGetter());
// when

View File

@ -17,6 +17,7 @@ import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.util.HashMap;
@ -113,7 +114,7 @@ class HttpClientAttributesExtractorTest {
response.put("header.custom-response-header", "654,321");
response.put("transport", IP_TCP);
HttpClientAttributesExtractor<Map<String, String>, Map<String, String>> extractor =
AttributesExtractor<Map<String, String>, Map<String, String>> extractor =
HttpClientAttributesExtractor.builder(
new TestHttpClientAttributesGetter(), new TestNetClientAttributesGetter())
.setCapturedRequestHeaders(singletonList("Custom-Request-Header"))
@ -153,7 +154,7 @@ class HttpClientAttributesExtractorTest {
Map<String, String> request = new HashMap<>();
request.put("url", url);
HttpClientAttributesExtractor<Map<String, String>, Map<String, String>> extractor =
AttributesExtractor<Map<String, String>, Map<String, String>> extractor =
HttpClientAttributesExtractor.builder(
new TestHttpClientAttributesGetter(), new TestNetClientAttributesGetter())
.build();
@ -189,7 +190,7 @@ class HttpClientAttributesExtractorTest {
Map<String, String> response = new HashMap<>();
response.put("statusCode", "0");
HttpClientAttributesExtractor<Map<String, String>, Map<String, String>> extractor =
AttributesExtractor<Map<String, String>, Map<String, String>> extractor =
HttpClientAttributesExtractor.builder(
new TestHttpClientAttributesGetter(), new TestNetClientAttributesGetter())
.setCapturedRequestHeaders(emptyList())
@ -209,7 +210,7 @@ class HttpClientAttributesExtractorTest {
Map<String, String> request = new HashMap<>();
request.put("header.host", "thehost:777");
HttpClientAttributesExtractor<Map<String, String>, Map<String, String>> extractor =
AttributesExtractor<Map<String, String>, Map<String, String>> extractor =
HttpClientAttributesExtractor.create(
new TestHttpClientAttributesGetter(), new TestNetClientAttributesGetter());
@ -229,7 +230,7 @@ class HttpClientAttributesExtractorTest {
request.put("peerName", "thehost");
request.put("peerPort", "777");
HttpClientAttributesExtractor<Map<String, String>, Map<String, String>> extractor =
AttributesExtractor<Map<String, String>, Map<String, String>> extractor =
HttpClientAttributesExtractor.create(
new TestHttpClientAttributesGetter(), new TestNetClientAttributesGetter());
@ -249,7 +250,7 @@ class HttpClientAttributesExtractorTest {
request.put("url", url);
request.put("peerPort", String.valueOf(peerPort));
HttpClientAttributesExtractor<Map<String, String>, Map<String, String>> extractor =
AttributesExtractor<Map<String, String>, Map<String, String>> extractor =
HttpClientAttributesExtractor.builder(
new TestHttpClientAttributesGetter(), new TestNetClientAttributesGetter())
.build();

View File

@ -16,6 +16,7 @@ import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesGetter;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.util.HashMap;
@ -176,7 +177,7 @@ class HttpServerAttributesExtractorTest {
Map<String, Object> request = new HashMap<>();
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(
new TestHttpServerAttributesGetter(), new TestNetServerAttributesGetter())
.setCapturedRequestHeaders(emptyList())
@ -198,7 +199,7 @@ class HttpServerAttributesExtractorTest {
Map<String, Object> request = new HashMap<>();
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(
new TestHttpServerAttributesGetter(), new TestNetServerAttributesGetter())
.setCapturedRequestHeaders(emptyList())
@ -218,7 +219,7 @@ class HttpServerAttributesExtractorTest {
Map<String, Object> request = new HashMap<>();
request.put("header.host", "thehost:777");
HttpServerAttributesExtractor<Map<String, Object>, Map<String, Object>> extractor =
AttributesExtractor<Map<String, Object>, Map<String, Object>> extractor =
HttpServerAttributesExtractor.builder(
new TestHttpServerAttributesGetter(), new TestNetServerAttributesGetter())
.setCapturedRequestHeaders(emptyList())
@ -240,7 +241,7 @@ class HttpServerAttributesExtractorTest {
request.put("hostName", "thehost");
request.put("hostPort", 777);
HttpServerAttributesExtractor<Map<String, Object>, Map<String, Object>> extractor =
AttributesExtractor<Map<String, Object>, Map<String, Object>> extractor =
HttpServerAttributesExtractor.builder(
new TestHttpServerAttributesGetter(), new TestNetServerAttributesGetter())
.setCapturedRequestHeaders(emptyList())
@ -262,7 +263,7 @@ class HttpServerAttributesExtractorTest {
request.put("scheme", scheme);
request.put("hostPort", hostPort);
HttpServerAttributesExtractor<Map<String, Object>, Map<String, Object>> extractor =
AttributesExtractor<Map<String, Object>, Map<String, Object>> extractor =
HttpServerAttributesExtractor.builder(
new TestHttpServerAttributesGetter(), new TestNetServerAttributesGetter())
.setCapturedRequestHeaders(emptyList())

View File

@ -12,6 +12,7 @@ import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.util.ArrayList;
import java.util.Collections;
@ -50,7 +51,7 @@ class MessagingAttributesExtractorTest {
request.put("payloadSize", "100");
request.put("payloadCompressedSize", "10");
MessagingAttributesExtractor<Map<String, String>, String> underTest =
AttributesExtractor<Map<String, String>, String> underTest =
MessagingAttributesExtractor.create(TestGetter.INSTANCE, operation);
Context context = Context.root();
@ -97,7 +98,7 @@ class MessagingAttributesExtractorTest {
@Test
void shouldExtractNoAttributesIfNoneAreAvailable() {
// given
MessagingAttributesExtractor<Map<String, String>, String> underTest =
AttributesExtractor<Map<String, String>, String> underTest =
MessagingAttributesExtractor.create(TestGetter.INSTANCE, MessageOperation.SEND);
Context context = Context.root();

View File

@ -11,6 +11,7 @@ import static org.assertj.core.api.Assertions.entry;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.net.Inet4Address;
import java.net.InetSocketAddress;
@ -47,7 +48,7 @@ class InetSocketAddressNetClientAttributesGetterTest {
return response;
}
};
private final NetClientAttributesExtractor<InetSocketAddress, InetSocketAddress> extractor =
private final AttributesExtractor<InetSocketAddress, InetSocketAddress> extractor =
NetClientAttributesExtractor.create(getter);
@Test

View File

@ -11,6 +11,7 @@ import static org.assertj.core.api.Assertions.entry;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.net.Inet4Address;
import java.net.InetSocketAddress;
@ -51,7 +52,7 @@ class InetSocketAddressNetServerAttributesGetterTest {
return request.host;
}
};
private final NetServerAttributesExtractor<Addresses, Addresses> extractor =
private final AttributesExtractor<Addresses, Addresses> extractor =
NetServerAttributesExtractor.create(getter);
@Test

View File

@ -13,6 +13,7 @@ import static org.assertj.core.api.Assertions.entry;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.util.HashMap;
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());
@Test

View File

@ -9,6 +9,7 @@ import static java.util.Collections.emptyList;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
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.SpanKindExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.messaging.MessageOperation;
@ -84,8 +85,8 @@ public final class JmsInstrumenterFactory {
.buildConsumerInstrumenter(MessagePropertyGetter.INSTANCE);
}
private MessagingAttributesExtractor<MessageWithDestination, Void>
createMessagingAttributesExtractor(MessageOperation operation) {
private AttributesExtractor<MessageWithDestination, Void> createMessagingAttributesExtractor(
MessageOperation operation) {
return MessagingAttributesExtractor.builder(JmsMessageAttributesGetter.INSTANCE, operation)
.setCapturedHeaders(capturedHeaders)
.build();

View File

@ -171,7 +171,7 @@ public final class KafkaInstrumenterFactory {
}
private static <REQUEST, RESPONSE>
MessagingAttributesExtractor<REQUEST, RESPONSE> buildMessagingAttributesExtractor(
AttributesExtractor<REQUEST, RESPONSE> buildMessagingAttributesExtractor(
MessagingAttributesGetter<REQUEST, RESPONSE> getter,
MessageOperation operation,
List<String> capturedHeaders) {

View File

@ -24,6 +24,7 @@ import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.api.trace.StatusCode;
import io.opentelemetry.context.Context;
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.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes.DbSystemValues;
@ -36,8 +37,7 @@ import javax.annotation.Nullable;
final class OpenTelemetryTracing implements Tracing {
private static final NetClientAttributesExtractor<OpenTelemetryEndpoint, Void>
netAttributesExtractor =
private static final AttributesExtractor<OpenTelemetryEndpoint, Void> netAttributesExtractor =
NetClientAttributesExtractor.create(new LettuceNetAttributesGetter());
private final TracerProvider tracerProvider;

View File

@ -7,6 +7,7 @@ package io.opentelemetry.instrumentation.mongo.v3_1;
import com.mongodb.event.CommandStartedEvent;
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.SpanKindExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
@ -17,8 +18,8 @@ class MongoInstrumenterFactory {
private static final MongoAttributesExtractor attributesExtractor =
new MongoAttributesExtractor();
private static final NetClientAttributesExtractor<CommandStartedEvent, Void>
netAttributesExtractor = NetClientAttributesExtractor.create(new MongoNetAttributesGetter());
private static final AttributesExtractor<CommandStartedEvent, Void> netAttributesExtractor =
NetClientAttributesExtractor.create(new MongoNetAttributesGetter());
static Instrumenter<CommandStartedEvent, Void> createInstrumenter(
OpenTelemetry openTelemetry,

View File

@ -104,7 +104,7 @@ public final class RabbitSingletons {
.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) {
return MessagingAttributesExtractor.builder(getter, operation)
.setCapturedHeaders(ExperimentalConfig.get().getMessagingHeaders())

View File

@ -8,7 +8,6 @@ package io.opentelemetry.instrumentation.restlet.v2_0.internal;
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.http.HttpServerAttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerMetrics;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
@ -26,7 +25,7 @@ public final class RestletInstrumenterFactory {
public static Instrumenter<Request, Response> newServerInstrumenter(
OpenTelemetry openTelemetry,
HttpServerAttributesExtractor<Request, Response> httpServerAttributesExtractor,
AttributesExtractor<Request, Response> httpServerAttributesExtractor,
List<AttributesExtractor<Request, Response>> additionalExtractors) {
RestletHttpAttributesGetter httpAttributesGetter = RestletHttpAttributesGetter.INSTANCE;

View File

@ -10,6 +10,7 @@ import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.MESSA
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.MESSAGING_SYSTEM;
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.InstrumenterBuilder;
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,
MessageOperation operation,
List<String> capturedHeaders) {

View File

@ -53,7 +53,7 @@ final class RocketMqInstrumenterFactory {
RocketMqConsumerReceiveAttributeGetter getter = RocketMqConsumerReceiveAttributeGetter.INSTANCE;
MessageOperation operation = MessageOperation.RECEIVE;
MessagingAttributesExtractor<ReceiveMessageRequest, List<MessageView>> attributesExtractor =
AttributesExtractor<ReceiveMessageRequest, List<MessageView>> attributesExtractor =
buildMessagingAttributesExtractor(getter, operation, capturedHeaders);
InstrumenterBuilder<ReceiveMessageRequest, List<MessageView>> instrumenterBuilder =
@ -74,7 +74,7 @@ final class RocketMqInstrumenterFactory {
RocketMqConsumerProcessAttributeGetter getter = RocketMqConsumerProcessAttributeGetter.INSTANCE;
MessageOperation operation = MessageOperation.PROCESS;
MessagingAttributesExtractor<MessageView, ConsumeResult> attributesExtractor =
AttributesExtractor<MessageView, ConsumeResult> attributesExtractor =
buildMessagingAttributesExtractor(getter, operation, capturedHeaders);
InstrumenterBuilder<MessageView, ConsumeResult> instrumenterBuilder =
@ -101,7 +101,7 @@ final class RocketMqInstrumenterFactory {
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,
MessageOperation operation,
List<String> capturedHeaders) {

View File

@ -111,8 +111,7 @@ public final class SpringIntegrationTelemetryBuilder {
producerSpanEnabled);
}
private static MessagingAttributesExtractor<MessageWithChannel, Void>
buildMessagingAttributesExtractor(
private static AttributesExtractor<MessageWithChannel, Void> buildMessagingAttributesExtractor(
MessagingAttributesGetter<MessageWithChannel, Void> getter,
MessageOperation operation,
List<String> capturedHeaders) {