Move rest of non-specd attributes to experimental
MODIFY
instrumentation/apache-camel-2.20/javaagent/apache-camel-2.20-javaagent.gradle
instrumentation/apache-camel-2.20/javaagent/apache-camel-2.20-javaagent.gradle
@@ -52,3 +52,9 @@ dependencies {
latestDepTestLibrary group: 'org.apache.camel', name: 'camel-undertow', version: '2.+'
latestDepTestLibrary group: 'org.apache.camel', name: 'camel-aws', version: '2.+'
}
+
+tasks.withType(Test) {
+ // TODO run tests both with and without experimental span attributes
+ jvmArgs "-Dotel.instrumentation.apache-camel.experimental-span-attributes=true"
+ jvmArgs "-Dotel.instrumentation.aws-sdk.experimental-span-attributes=true"
+}

MODIFY
instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/BaseSpanDecorator.java
instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/BaseSpanDecorator.java
@@ -26,6 +26,7 @@ package io.opentelemetry.javaagent.instrumentation.apachecamel.decorators;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.api.trace.StatusCode;
+import io.opentelemetry.instrumentation.api.config.Config;
import io.opentelemetry.javaagent.instrumentation.apachecamel.CamelDirection;
import io.opentelemetry.javaagent.instrumentation.apachecamel.SpanDecorator;
import java.util.Collections;
@@ -39,6 +40,11 @@ import org.apache.camel.util.URISupport;
/** An abstract base implementation of the {@link SpanDecorator} interface. */
class BaseSpanDecorator implements SpanDecorator {
+ static final boolean CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES =
+ Config.get()
+ .getBooleanProperty(
+ "otel.instrumentation.apache-camel.experimental-span-attributes", false);
+
static final String DEFAULT_OPERATION_NAME = "CamelOperation";
/**
@@ -92,8 +98,10 @@ class BaseSpanDecorator implements SpanDecorator {
@Override
public void pre(Span span, Exchange exchange, Endpoint endpoint, CamelDirection camelDirection) {
+ if (CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES) {
span.setAttribute("apache-camel.uri", URISupport.sanitizeUri(endpoint.getEndpointUri()));
}
+ }
@Override
public void post(Span span, Exchange exchange, Endpoint endpoint) {

MODIFY
instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/KafkaSpanDecorator.java
instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/KafkaSpanDecorator.java
@@ -64,6 +64,7 @@ class KafkaSpanDecorator extends MessagingSpanDecorator {
span.setAttribute(SemanticAttributes.MESSAGING_KAFKA_PARTITION, partition);
}
+ if (CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES) {
String partitionKey = (String) exchange.getIn().getHeader(PARTITION_KEY);
if (partitionKey != null) {
span.setAttribute("apache-camel.kafka.partitionKey", partitionKey);
@@ -79,6 +80,7 @@ class KafkaSpanDecorator extends MessagingSpanDecorator {
span.setAttribute("apache-camel.kafka.offset", offset);
}
}
+ }
/**
* Extracts header value from the exchange for given header.

MODIFY
instrumentation/aws-sdk/aws-sdk-1.11/javaagent/aws-sdk-1.11-javaagent.gradle
instrumentation/aws-sdk/aws-sdk-1.11/javaagent/aws-sdk-1.11-javaagent.gradle
@@ -84,3 +84,8 @@ test {
if (!testLatestDeps) {
test.dependsOn test_before_1_11_106
}
+
+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-1.11/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/awssdk/v1_11/AwsSdkClientTracer.java
instrumentation/aws-sdk/aws-sdk-1.11/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/awssdk/v1_11/AwsSdkClientTracer.java
@@ -14,12 +14,17 @@ import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.propagation.TextMapSetter;
import io.opentelemetry.extension.aws.AwsXrayPropagator;
+import io.opentelemetry.instrumentation.api.config.Config;
import io.opentelemetry.instrumentation.api.tracer.HttpClientTracer;
import java.net.URI;
import java.util.concurrent.ConcurrentHashMap;
public class AwsSdkClientTracer extends HttpClientTracer<Request<?>, Request<?>, Response<?>> {
+ private static final boolean CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES =
+ Config.get()
+ .getBooleanProperty("otel.instrumentation.aws-sdk.experimental-span-attributes", false);
+
static final String COMPONENT_NAME = "java-aws-sdk";
private static final AwsSdkClientTracer TRACER = new AwsSdkClientTracer();
@@ -56,6 +61,7 @@ public class AwsSdkClientTracer extends HttpClientTracer<Request<?>, Request<?>,
AmazonWebServiceRequest originalRequest = request.getOriginalRequest();
Class<?> awsOperation = originalRequest.getClass();
+ if (CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES) {
span.setAttribute("aws.agent", COMPONENT_NAME);
span.setAttribute("aws.service", awsServiceName);
span.setAttribute("aws.operation", awsOperation.getSimpleName());
@@ -68,13 +74,16 @@ public class AwsSdkClientTracer extends HttpClientTracer<Request<?>, Request<?>,
span.setAttribute("aws.stream.name", requestMeta.getStreamName());
span.setAttribute("aws.table.name", requestMeta.getTableName());
}
+ }
return context;
}
@Override
public void onResponse(Span span, Response<?> response) {
- if (response != null && response.getAwsResponse() instanceof AmazonWebServiceResponse) {
- AmazonWebServiceResponse awsResp = (AmazonWebServiceResponse) response.getAwsResponse();
+ if (CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES
+ && response != null
+ && response.getAwsResponse() instanceof AmazonWebServiceResponse) {
+ AmazonWebServiceResponse<?> awsResp = (AmazonWebServiceResponse<?>) response.getAwsResponse();
span.setAttribute("aws.requestId", awsResp.getRequestId());
}
super.onResponse(span, response);

MODIFY
instrumentation/elasticsearch/elasticsearch-transport-5.0/javaagent/elasticsearch-transport-5.0-javaagent.gradle
instrumentation/elasticsearch/elasticsearch-transport-5.0/javaagent/elasticsearch-transport-5.0-javaagent.gradle
@@ -39,3 +39,8 @@ dependencies {
testImplementation group: 'org.elasticsearch.plugin', name: 'transport-netty3-client', version: '5.0.0'
testImplementation group: 'org.elasticsearch.client', name: 'transport', version: '5.0.0'
}
+
+tasks.withType(Test) {
+ // TODO run tests both with and without experimental span attributes
+ jvmArgs "-Dotel.instrumentation.elasticsearch.experimental-span-attributes=true"
+}

MODIFY
instrumentation/elasticsearch/elasticsearch-transport-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_0/TransportActionListener.java
instrumentation/elasticsearch/elasticsearch-transport-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_0/TransportActionListener.java
@@ -9,6 +9,7 @@ import static io.opentelemetry.javaagent.instrumentation.elasticsearch.transport
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.context.Context;
+import io.opentelemetry.instrumentation.api.config.Config;
import io.opentelemetry.instrumentation.api.tracer.utils.NetPeerUtils;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import org.elasticsearch.action.ActionListener;
@@ -26,6 +27,11 @@ import org.elasticsearch.action.support.replication.ReplicationResponse;
public class TransportActionListener<T extends ActionResponse> implements ActionListener<T> {
+ private static final boolean CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES =
+ Config.get()
+ .getBooleanProperty(
+ "otel.instrumentation.elasticsearch.experimental-span-attributes", false);
+
private final ActionListener<T> listener;
private final Context context;
@@ -36,7 +42,8 @@ public class TransportActionListener<T extends ActionResponse> implements Action
onRequest(actionRequest);
}
- private void onRequest(ActionRequest request) {
+ private void onRequest(ActionRequest<?> request) {
+ if (CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES) {
Span span = Span.fromContext(context);
if (request instanceof IndicesRequest) {
@@ -54,11 +61,12 @@ public class TransportActionListener<T extends ActionResponse> implements Action
}
}
if (request instanceof DocumentRequest) {
- DocumentRequest req = (DocumentRequest) request;
+ DocumentRequest<?> req = (DocumentRequest<?>) request;
span.setAttribute("elasticsearch.request.write.type", req.type());
span.setAttribute("elasticsearch.request.write.routing", req.routing());
}
}
+ }
@Override
public void onResponse(T response) {
@@ -71,6 +79,7 @@ public class TransportActionListener<T extends ActionResponse> implements Action
SemanticAttributes.NET_PEER_PORT, (long) response.remoteAddress().getPort());
}
+ if (CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES) {
if (response instanceof GetResponse) {
GetResponse resp = (GetResponse) response;
span.setAttribute("elasticsearch.type", resp.getType());
@@ -90,7 +99,8 @@ public class TransportActionListener<T extends ActionResponse> implements Action
span.setAttribute("elasticsearch.shard.replication.total", resp.getShardInfo().getTotal());
span.setAttribute(
"elasticsearch.shard.replication.successful", resp.getShardInfo().getSuccessful());
- span.setAttribute("elasticsearch.shard.replication.failed", resp.getShardInfo().getFailed());
+ span.setAttribute(
+ "elasticsearch.shard.replication.failed", resp.getShardInfo().getFailed());
}
if (response instanceof IndexResponse) {
@@ -105,12 +115,13 @@ public class TransportActionListener<T extends ActionResponse> implements Action
}
if (response instanceof BaseNodesResponse) {
- BaseNodesResponse resp = (BaseNodesResponse) response;
+ BaseNodesResponse<?> resp = (BaseNodesResponse<?>) response;
if (resp.hasFailures()) {
span.setAttribute("elasticsearch.node.failures", resp.failures().size());
}
span.setAttribute("elasticsearch.node.cluster.name", resp.getClusterName().value());
}
+ }
tracer().end(span);
listener.onResponse(response);

MODIFY
instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/elasticsearch-transport-5.3-javaagent.gradle
instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/elasticsearch-transport-5.3-javaagent.gradle
@@ -44,3 +44,8 @@ dependencies {
latestDepTestLibrary group: 'org.elasticsearch.client', name: 'transport', version: '5.+'
latestDepTestLibrary group: 'org.springframework.data', name: 'spring-data-elasticsearch', version: '3.0.+'
}
+
+tasks.withType(Test) {
+ // TODO run tests both with and without experimental span attributes
+ jvmArgs "-Dotel.instrumentation.elasticsearch.experimental-span-attributes=true"
+}

MODIFY
instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_3/TransportActionListener.java
instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_3/TransportActionListener.java
@@ -9,6 +9,7 @@ import static io.opentelemetry.javaagent.instrumentation.elasticsearch.transport
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.context.Context;
+import io.opentelemetry.instrumentation.api.config.Config;
import io.opentelemetry.instrumentation.api.tracer.utils.NetPeerUtils;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import org.elasticsearch.action.ActionListener;
@@ -26,6 +27,11 @@ import org.elasticsearch.action.support.replication.ReplicationResponse;
public class TransportActionListener<T extends ActionResponse> implements ActionListener<T> {
+ private static final boolean CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES =
+ Config.get()
+ .getBooleanProperty(
+ "otel.instrumentation.elasticsearch.experimental-span-attributes", false);
+
private final ActionListener<T> listener;
private final Context context;
@@ -37,6 +43,7 @@ public class TransportActionListener<T extends ActionResponse> implements Action
}
private void onRequest(ActionRequest request) {
+ if (CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES) {
Span span = Span.fromContext(context);
if (request instanceof IndicesRequest) {
@@ -54,12 +61,13 @@ public class TransportActionListener<T extends ActionResponse> implements Action
}
}
if (request instanceof DocWriteRequest) {
- DocWriteRequest req = (DocWriteRequest) request;
+ DocWriteRequest<?> req = (DocWriteRequest<?>) request;
span.setAttribute("elasticsearch.request.write.type", req.type());
span.setAttribute("elasticsearch.request.write.routing", req.routing());
span.setAttribute("elasticsearch.request.write.version", req.version());
}
}
+ }
@Override
public void onResponse(T response) {
@@ -72,6 +80,7 @@ public class TransportActionListener<T extends ActionResponse> implements Action
SemanticAttributes.NET_PEER_PORT, (long) response.remoteAddress().getPort());
}
+ if (CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES) {
if (response instanceof GetResponse) {
GetResponse resp = (GetResponse) response;
span.setAttribute("elasticsearch.type", resp.getType());
@@ -91,7 +100,8 @@ public class TransportActionListener<T extends ActionResponse> implements Action
span.setAttribute("elasticsearch.shard.replication.total", resp.getShardInfo().getTotal());
span.setAttribute(
"elasticsearch.shard.replication.successful", resp.getShardInfo().getSuccessful());
- span.setAttribute("elasticsearch.shard.replication.failed", resp.getShardInfo().getFailed());
+ span.setAttribute(
+ "elasticsearch.shard.replication.failed", resp.getShardInfo().getFailed());
}
if (response instanceof IndexResponse) {
@@ -106,12 +116,13 @@ public class TransportActionListener<T extends ActionResponse> implements Action
}
if (response instanceof BaseNodesResponse) {
- BaseNodesResponse resp = (BaseNodesResponse) response;
+ BaseNodesResponse<?> resp = (BaseNodesResponse<?>) response;
if (resp.hasFailures()) {
span.setAttribute("elasticsearch.node.failures", resp.failures().size());
}
span.setAttribute("elasticsearch.node.cluster.name", resp.getClusterName().value());
}
+ }
tracer().end(span);
listener.onResponse(response);

MODIFY
instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/elasticsearch-transport-6.0-javaagent.gradle
instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/elasticsearch-transport-6.0-javaagent.gradle
@@ -42,3 +42,8 @@ dependencies {
latestDepTestLibrary group: 'org.elasticsearch.plugin', name: 'transport-netty4-client', version: '(6.1,6.5)'
latestDepTestLibrary group: 'org.elasticsearch.client', name: 'transport', version: '(6.1,6.5)'
}
+
+tasks.withType(Test) {
+ // TODO run tests both with and without experimental span attributes
+ jvmArgs "-Dotel.instrumentation.elasticsearch.experimental-span-attributes=true"
+}

MODIFY
instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v6_0/TransportActionListener.java
instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v6_0/TransportActionListener.java
@@ -9,6 +9,7 @@ import static io.opentelemetry.javaagent.instrumentation.elasticsearch.transport
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.context.Context;
+import io.opentelemetry.instrumentation.api.config.Config;
import io.opentelemetry.instrumentation.api.tracer.utils.NetPeerUtils;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import org.elasticsearch.action.ActionListener;
@@ -30,6 +31,11 @@ import org.elasticsearch.action.support.replication.ReplicationResponse;
*/
public class TransportActionListener<T extends ActionResponse> implements ActionListener<T> {
+ private static final boolean CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES =
+ Config.get()
+ .getBooleanProperty(
+ "otel.instrumentation.elasticsearch.experimental-span-attributes", false);
+
private final ActionListener<T> listener;
private final Context context;
@@ -41,6 +47,7 @@ public class TransportActionListener<T extends ActionResponse> implements Action
}
private void onRequest(ActionRequest request) {
+ if (CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES) {
Span span = Span.fromContext(context);
if (request instanceof IndicesRequest) {
IndicesRequest req = (IndicesRequest) request;
@@ -57,12 +64,13 @@ public class TransportActionListener<T extends ActionResponse> implements Action
}
}
if (request instanceof DocWriteRequest) {
- DocWriteRequest req = (DocWriteRequest) request;
+ DocWriteRequest<?> req = (DocWriteRequest<?>) request;
span.setAttribute("elasticsearch.request.write.type", req.type());
span.setAttribute("elasticsearch.request.write.routing", req.routing());
span.setAttribute("elasticsearch.request.write.version", req.version());
}
}
+ }
@Override
public void onResponse(T response) {
@@ -77,6 +85,7 @@ public class TransportActionListener<T extends ActionResponse> implements Action
SemanticAttributes.NET_PEER_PORT, (long) response.remoteAddress().getPort());
}
+ if (CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES) {
if (response instanceof GetResponse) {
GetResponse resp = (GetResponse) response;
span.setAttribute("elasticsearch.type", resp.getType());
@@ -96,7 +105,8 @@ public class TransportActionListener<T extends ActionResponse> implements Action
span.setAttribute("elasticsearch.shard.replication.total", resp.getShardInfo().getTotal());
span.setAttribute(
"elasticsearch.shard.replication.successful", resp.getShardInfo().getSuccessful());
- span.setAttribute("elasticsearch.shard.replication.failed", resp.getShardInfo().getFailed());
+ span.setAttribute(
+ "elasticsearch.shard.replication.failed", resp.getShardInfo().getFailed());
}
if (response instanceof IndexResponse) {
@@ -111,12 +121,13 @@ public class TransportActionListener<T extends ActionResponse> implements Action
}
if (response instanceof BaseNodesResponse) {
- BaseNodesResponse resp = (BaseNodesResponse) response;
+ BaseNodesResponse<?> resp = (BaseNodesResponse<?>) response;
if (resp.hasFailures()) {
span.setAttribute("elasticsearch.node.failures", resp.failures().size());
}
span.setAttribute("elasticsearch.node.cluster.name", resp.getClusterName().value());
}
+ }
tracer().end(context);
listener.onResponse(response);

MODIFY
instrumentation/elasticsearch/elasticsearch-transport-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticsearchTransportClientTracer.java
instrumentation/elasticsearch/elasticsearch-transport-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticsearchTransportClientTracer.java
@@ -7,12 +7,19 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.context.Context;
+import io.opentelemetry.instrumentation.api.config.Config;
import io.opentelemetry.instrumentation.api.tracer.DatabaseClientTracer;
import java.net.InetSocketAddress;
import org.elasticsearch.action.Action;
public class ElasticsearchTransportClientTracer
extends DatabaseClientTracer<Void, Action<?, ?, ?>, String> {
+
+ private static final boolean CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES =
+ Config.get()
+ .getBooleanProperty(
+ "otel.instrumentation.elasticsearch.experimental-span-attributes", false);
+
private static final ElasticsearchTransportClientTracer TRACER =
new ElasticsearchTransportClientTracer();
@@ -21,10 +28,12 @@ public class ElasticsearchTransportClientTracer
}
public void onRequest(Context context, Class<?> action, Class<?> request) {
+ if (CAPTURE_EXPERIMENTAL_SPAN_ATTRIBUTES) {
Span span = Span.fromContext(context);
span.setAttribute("elasticsearch.action", action.getSimpleName());
span.setAttribute("elasticsearch.request", request.getSimpleName());
}
+ }
@Override
protected String sanitizeStatement(Action<?, ?, ?> action) {

Move rest of non-specd attributes to experimental (#2402)