Hide non-specd attributes for aws-sdk-2.2
MODIFY
instrumentation/aws-sdk/aws-sdk-2.2/javaagent/aws-sdk-2.2-javaagent.gradle
instrumentation/aws-sdk/aws-sdk-2.2/javaagent/aws-sdk-2.2-javaagent.gradle
@@ -18,3 +18,8 @@ dependencies {
testImplementation project(':instrumentation:apache-httpclient:apache-httpclient-4.0:javaagent')
testImplementation project(':instrumentation:netty:netty-4.1:javaagent')
}
+
+tasks.withType(Test) {
+ // TODO run tests both with and without experimental span attributes
+ jvmArgs "-Dotel.instrumentation.aws-sdk.experimental-span-attributes=true"
+}

MODIFY
instrumentation/aws-sdk/aws-sdk-2.2/library/aws-sdk-2.2-library.gradle
instrumentation/aws-sdk/aws-sdk-2.2/library/aws-sdk-2.2-library.gradle
@@ -11,3 +11,7 @@ dependencies {
testImplementation deps.assertj
testImplementation group: 'org.mockito', name: 'mockito-core', version: '3.6.0'
}
+
+test {
+ systemProperty "otel.instrumentation.aws-sdk.experimental-span-attributes", true
+}

MODIFY
instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingExecutionInterceptor.java
instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingExecutionInterceptor.java
@@ -11,6 +11,7 @@ import static io.opentelemetry.instrumentation.awssdk.v2_2.AwsSdkRequestType.Dyn
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.context.Scope;
+import io.opentelemetry.instrumentation.api.config.Config;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import software.amazon.awssdk.awscore.AwsResponse;
import software.amazon.awssdk.core.ClientType;
@@ -26,6 +27,10 @@ import software.amazon.awssdk.http.SdkHttpRequest;
/** AWS request execution interceptor. */
final class TracingExecutionInterceptor implements ExecutionInterceptor {
+ private static final boolean CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES =
+ Config.get()
+ .getBooleanProperty("otel.instrumentation.aws-sdk.experimental-span-attributes", false);
+
// the class name is part of the attribute name, so that it will be shaded when used in javaagent
// instrumentation, and won't conflict with usage outside javaagent instrumentation
static final ExecutionAttribute<io.opentelemetry.context.Context> CONTEXT_ATTRIBUTE =
@@ -108,7 +113,7 @@ final class TracingExecutionInterceptor implements ExecutionInterceptor {
}
private void populateGenericAttributes(Span span, ExecutionAttributes attributes) {
-
+ if (CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES) {
String awsServiceName = attributes.getAttribute(SdkExecutionAttribute.SERVICE_NAME);
String awsOperation = attributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME);
@@ -116,6 +121,7 @@ final class TracingExecutionInterceptor implements ExecutionInterceptor {
span.setAttribute("aws.service", awsServiceName);
span.setAttribute("aws.operation", awsOperation);
}
+ }
@Override
public void afterExecution(
@@ -140,6 +146,7 @@ final class TracingExecutionInterceptor implements ExecutionInterceptor {
private void onSdkResponse(
Span span, SdkResponse response, ExecutionAttributes executionAttributes) {
+ if (CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES) {
if (response instanceof AwsResponse) {
span.setAttribute("aws.requestId", ((AwsResponse) response).responseMetadata().requestId());
}
@@ -148,6 +155,7 @@ final class TracingExecutionInterceptor implements ExecutionInterceptor {
fieldMapper.mapToAttributes(response, sdkRequest, span);
}
}
+ }
@Override
public void onExecutionFailure(

Hide non-specd attributes for aws-sdk-2.2 (#2434)