Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import io.opentelemetry.instrumentation.api.internal.SpanKey;
import io.opentelemetry.instrumentation.api.internal.SpanKeyProvider;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -120,14 +119,6 @@ public InstrumenterBuilder<REQUEST, RESPONSE> addAttributesExtractors(
return this;
}

/** Adds {@link AttributesExtractor}s that will extract attributes from requests and responses. */
@SafeVarargs
@SuppressWarnings("varargs")
public final InstrumenterBuilder<REQUEST, RESPONSE> addAttributesExtractors(
AttributesExtractor<? super REQUEST, ? super RESPONSE>... attributesExtractors) {
return addAttributesExtractors(Arrays.asList(attributesExtractors));
}

/** Adds a {@link SpanLinksExtractor} that will extract span links from requests. */
public InstrumenterBuilder<REQUEST, RESPONSE> addSpanLinksExtractor(
SpanLinksExtractor<REQUEST> spanLinksExtractor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ void server() {
Instrumenter<Map<String, String>, Map<String, String>> instrumenter =
Instrumenter.<Map<String, String>, Map<String, String>>builder(
otelTesting.getOpenTelemetry(), "test", unused -> "span")
.addAttributesExtractors(new AttributesExtractor1(), new AttributesExtractor2())
.addAttributesExtractor(new AttributesExtractor1())
.addAttributesExtractor(new AttributesExtractor2())
.addSpanLinksExtractor(new LinksExtractor())
.buildServerInstrumenter(new MapGetter());

Expand Down Expand Up @@ -195,7 +196,8 @@ void server_error() {
Instrumenter<Map<String, String>, Map<String, String>> instrumenter =
Instrumenter.<Map<String, String>, Map<String, String>>builder(
otelTesting.getOpenTelemetry(), "test", unused -> "span")
.addAttributesExtractors(new AttributesExtractor1(), new AttributesExtractor2())
.addAttributesExtractor(new AttributesExtractor1())
.addAttributesExtractor(new AttributesExtractor2())
.buildServerInstrumenter(new MapGetter());

Context context = instrumenter.start(Context.root(), REQUEST);
Expand All @@ -216,7 +218,8 @@ void server_parent() {
Instrumenter<Map<String, String>, Map<String, String>> instrumenter =
Instrumenter.<Map<String, String>, Map<String, String>>builder(
otelTesting.getOpenTelemetry(), "test", unused -> "span")
.addAttributesExtractors(new AttributesExtractor1(), new AttributesExtractor2())
.addAttributesExtractor(new AttributesExtractor1())
.addAttributesExtractor(new AttributesExtractor2())
.buildServerInstrumenter(new MapGetter());

Map<String, String> request = new HashMap<>(REQUEST);
Expand Down Expand Up @@ -256,7 +259,8 @@ void client() {
Instrumenter<Map<String, String>, Map<String, String>> instrumenter =
Instrumenter.<Map<String, String>, Map<String, String>>builder(
otelTesting.getOpenTelemetry(), "test", unused -> "span")
.addAttributesExtractors(new AttributesExtractor1(), new AttributesExtractor2())
.addAttributesExtractor(new AttributesExtractor1())
.addAttributesExtractor(new AttributesExtractor2())
.addSpanLinksExtractor(new LinksExtractor())
.buildClientInstrumenter(Map::put);

Expand Down Expand Up @@ -300,7 +304,8 @@ void client_error() {
Instrumenter<Map<String, String>, Map<String, String>> instrumenter =
Instrumenter.<Map<String, String>, Map<String, String>>builder(
otelTesting.getOpenTelemetry(), "test", unused -> "span")
.addAttributesExtractors(new AttributesExtractor1(), new AttributesExtractor2())
.addAttributesExtractor(new AttributesExtractor1())
.addAttributesExtractor(new AttributesExtractor2())
.buildClientInstrumenter(Map::put);

Map<String, String> request = new HashMap<>(REQUEST);
Expand All @@ -325,7 +330,8 @@ void client_parent() {
Instrumenter<Map<String, String>, Map<String, String>> instrumenter =
Instrumenter.<Map<String, String>, Map<String, String>>builder(
otelTesting.getOpenTelemetry(), "test", unused -> "span")
.addAttributesExtractors(new AttributesExtractor1(), new AttributesExtractor2())
.addAttributesExtractor(new AttributesExtractor1())
.addAttributesExtractor(new AttributesExtractor2())
.buildClientInstrumenter(Map::put);

Context parent =
Expand Down Expand Up @@ -560,11 +566,10 @@ void shouldRetrieveSpanKeysFromAttributesExtractors() {
Instrumenter<Map<String, String>, Map<String, String>> instrumenter =
Instrumenter.<Map<String, String>, Map<String, String>>builder(
otelTesting.getOpenTelemetry(), "test", unused -> "span")
.addAttributesExtractors(
new AttributesExtractor2(),
mockHttpClientAttributes,
mockNetClientAttributes,
mockDbClientAttributes)
.addAttributesExtractor(new AttributesExtractor2())
.addAttributesExtractor(mockHttpClientAttributes)
.addAttributesExtractor(mockNetClientAttributes)
.addAttributesExtractor(mockDbClientAttributes)
.buildInstrumenter();

Context context = instrumenter.start(Context.root(), REQUEST);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public DubboTelemetry build() {
InstrumenterBuilder<DubboRequest, Result> serverInstrumenterBuilder =
Instrumenter.<DubboRequest, Result>builder(
openTelemetry, INSTRUMENTATION_NAME, spanNameExtractor)
.addAttributesExtractors(RpcServerAttributesExtractor.create(rpcAttributesGetter))
.addAttributesExtractor(RpcServerAttributesExtractor.create(rpcAttributesGetter))
.addAttributesExtractor(
NetServerAttributesExtractor.create(new DubboNetServerAttributesGetter()))
.addAttributesExtractors(attributesExtractors);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static AwsLambdaFunctionInstrumenter createInstrumenter(OpenTelemetry ope
openTelemetry,
"io.opentelemetry.aws-lambda-core-1.0",
AwsLambdaFunctionInstrumenterFactory::spanName)
.addAttributesExtractors(new AwsLambdaFunctionAttributesExtractor())
.addAttributesExtractor(new AwsLambdaFunctionAttributesExtractor())
.buildInstrumenter(SpanKindExtractor.alwaysServer()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ public static AwsLambdaFunctionInstrumenter createInstrumenter(OpenTelemetry ope
openTelemetry,
"io.opentelemetry.aws-lambda-events-2.2",
AwsLambdaEventsInstrumenterFactory::spanName)
.addAttributesExtractors(
new AwsLambdaFunctionAttributesExtractor(),
new ApiGatewayProxyAttributesExtractor())
.addAttributesExtractor(new AwsLambdaFunctionAttributesExtractor())
.addAttributesExtractor(new ApiGatewayProxyAttributesExtractor())
.buildInstrumenter(SpanKindExtractor.alwaysServer()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static Instrumenter<SQSEvent, Void> forEvent(OpenTelemetry openTelemetry)
openTelemetry,
"io.opentelemetry.aws-lambda-events-2.2",
AwsLambdaSqsInstrumenterFactory::spanName)
.addAttributesExtractors(new SqsEventAttributesExtractor())
.addAttributesExtractor(new SqsEventAttributesExtractor())
.addSpanLinksExtractor(new SqsEventSpanLinksExtractor())
.buildInstrumenter(SpanKindExtractor.alwaysConsumer());
}
Expand All @@ -32,7 +32,7 @@ public static Instrumenter<SQSMessage, Void> forMessage(OpenTelemetry openTeleme
openTelemetry,
"io.opentelemetry.aws-lambda-events-2.2",
message -> message.getEventSource() + " process")
.addAttributesExtractors(new SqsMessageAttributesExtractor())
.addAttributesExtractor(new SqsMessageAttributesExtractor())
.addSpanLinksExtractor(new SqsMessageSpanLinksExtractor())
.buildInstrumenter(SpanKindExtractor.alwaysConsumer());
}
Expand Down