Stop sending params with AWS traces
can potentially contain sensitive data.
(See
MODIFY
dd-java-agent/instrumentation/aws-java-sdk-1.11.0/src/main/java/datadog/trace/instrumentation/aws/v0/SpanDecorator.java
dd-java-agent/instrumentation/aws-java-sdk-1.11.0/src/main/java/datadog/trace/instrumentation/aws/v0/SpanDecorator.java
@@ -28,9 +28,7 @@ import io.opentracing.tag.Tags;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
class SpanDecorator {
@@ -55,35 +53,6 @@ class SpanDecorator {
span.setTag(
DDTags.RESOURCE_NAME,
remapServiceName(awsServiceName) + "." + remapOperationName(awsOperation));
-
- try {
- final StringBuilder params = new StringBuilder("{");
- final Map<String, List<String>> requestParams = request.getParameters();
- boolean firstKey = true;
- for (final Entry<String, List<String>> entry : requestParams.entrySet()) {
- if (!firstKey) {
- params.append(",");
- }
- params.append(entry.getKey()).append("=[");
- for (int i = 0; i < entry.getValue().size(); ++i) {
- if (i > 0) {
- params.append(",");
- }
- params.append(entry.getValue().get(i));
- }
- params.append("]");
- firstKey = false;
- }
- params.append("}");
- span.setTag("params", params.toString());
- } catch (final Exception e) {
- try {
- org.slf4j.LoggerFactory.getLogger(SpanDecorator.class)
- .debug("Failed to decorate aws span", e);
- } catch (final Exception e2) {
- // can't reach logger. Silently eat excetpion.
- }
- }
}
static void onResponse(final Response response, final Span span) {

MODIFY
dd-java-agent/instrumentation/aws-java-sdk-1.11.0/src/test/groovy/AWSClientTest.groovy
dd-java-agent/instrumentation/aws-java-sdk-1.11.0/src/test/groovy/AWSClientTest.groovy
@@ -140,32 +140,31 @@ class AWSClientTest extends AgentTestRunner {
tags["aws.endpoint"] == "http://localhost:$server.address.port"
tags["aws.operation"] == "${operation}Request"
tags["aws.agent"] == "java-aws-sdk"
- tags["params"] == params
tags["span.type"] == "web"
tags["thread.name"] != null
tags["thread.id"] != null
- tags.size() == 13
+ tags.size() == 12
server.lastRequest.headers.get("x-datadog-trace-id") == "$span.traceId"
server.lastRequest.headers.get("x-datadog-parent-id") == "$span.spanId"
where:
- service | operation | method | url | handlerCount | call | body | params | client
- "S3" | "CreateBucket" | "PUT" | "testbucket/" | 1 | { client -> client.setS3ClientOptions(S3ClientOptions.builder().setPathStyleAccess(true).build()); client.createBucket("testbucket") } | "" | "{}" | new AmazonS3Client().withEndpoint("http://localhost:$server.address.port")
- "S3" | "GetObject" | "GET" | "someBucket/someKey" | 1 | { client -> client.getObject("someBucket", "someKey") } | "" | "{}" | new AmazonS3Client().withEndpoint("http://localhost:$server.address.port")
+ service | operation | method | url | handlerCount | call | body | client
+ "S3" | "CreateBucket" | "PUT" | "testbucket/" | 1 | { client -> client.setS3ClientOptions(S3ClientOptions.builder().setPathStyleAccess(true).build()); client.createBucket("testbucket") } | "" | new AmazonS3Client().withEndpoint("http://localhost:$server.address.port")
+ "S3" | "GetObject" | "GET" | "someBucket/someKey" | 1 | { client -> client.getObject("someBucket", "someKey") } | "" | new AmazonS3Client().withEndpoint("http://localhost:$server.address.port")
"EC2" | "AllocateAddress" | "POST" | "" | 4 | { client -> client.allocateAddress() } | """
<AllocateAddressResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
<publicIp>192.0.2.1</publicIp>
<domain>standard</domain>
</AllocateAddressResponse>
- """ | "{Action=[AllocateAddress],Version=[2015-10-01]}" | new AmazonEC2Client().withEndpoint("http://localhost:$server.address.port")
+ """ | new AmazonEC2Client().withEndpoint("http://localhost:$server.address.port")
"RDS" | "DeleteOptionGroup" | "POST" | "" | 1 | { client -> client.deleteOptionGroup(new DeleteOptionGroupRequest()) } | """
<DeleteOptionGroupResponse xmlns="http://rds.amazonaws.com/doc/2014-09-01/">
<ResponseMetadata>
<RequestId>0ac9cda2-bbf4-11d3-f92b-31fa5e8dbc99</RequestId>
</ResponseMetadata>
</DeleteOptionGroupResponse>
- """ | "{Action=[DeleteOptionGroup],Version=[2014-10-31]}" | new AmazonRDSClient().withEndpoint("http://localhost:$server.address.port")
+ """ | new AmazonRDSClient().withEndpoint("http://localhost:$server.address.port")
}
}

MODIFY
dd-java-agent/instrumentation/aws-java-sdk-1.11.106/src/main/java/datadog/trace/instrumentation/aws/v106/SpanDecorator.java
dd-java-agent/instrumentation/aws-java-sdk-1.11.106/src/main/java/datadog/trace/instrumentation/aws/v106/SpanDecorator.java
@@ -28,9 +28,7 @@ import io.opentracing.tag.Tags;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
class SpanDecorator {
@@ -55,35 +53,6 @@ class SpanDecorator {
span.setTag(
DDTags.RESOURCE_NAME,
remapServiceName(awsServiceName) + "." + remapOperationName(awsOperation));
-
- try {
- final StringBuilder params = new StringBuilder("{");
- final Map<String, List<String>> requestParams = request.getParameters();
- boolean firstKey = true;
- for (final Entry<String, List<String>> entry : requestParams.entrySet()) {
- if (!firstKey) {
- params.append(",");
- }
- params.append(entry.getKey()).append("=[");
- for (int i = 0; i < entry.getValue().size(); ++i) {
- if (i > 0) {
- params.append(",");
- }
- params.append(entry.getValue().get(i));
- }
- params.append("]");
- firstKey = false;
- }
- params.append("}");
- span.setTag("params", params.toString());
- } catch (final Exception e) {
- try {
- org.slf4j.LoggerFactory.getLogger(SpanDecorator.class)
- .debug("Failed to decorate aws span", e);
- } catch (final Exception e2) {
- // can't reach logger. Silently eat excetpion.
- }
- }
}
static void onResponse(final Response response, final Span span) {

MODIFY
dd-java-agent/instrumentation/aws-java-sdk-1.11.106/src/test/groovy/AWSClientTest.groovy
dd-java-agent/instrumentation/aws-java-sdk-1.11.106/src/test/groovy/AWSClientTest.groovy
@@ -169,32 +169,31 @@ class AWSClientTest extends AgentTestRunner {
tags["aws.endpoint"] == "http://localhost:$server.address.port"
tags["aws.operation"] == "${operation}Request"
tags["aws.agent"] == "java-aws-sdk"
- tags["params"] == params
tags["span.type"] == "web"
tags["thread.name"] != null
tags["thread.id"] != null
- tags.size() == 13
+ tags.size() == 12
server.lastRequest.headers.get("x-datadog-trace-id") == "$span.traceId"
server.lastRequest.headers.get("x-datadog-parent-id") == "$span.spanId"
where:
- service | operation | method | url | handlerCount | call | body | params | client
- "S3" | "CreateBucket" | "PUT" | "testbucket/" | 1 | { client -> client.createBucket("testbucket") } | "" | "{}" | AmazonS3ClientBuilder.standard().withPathStyleAccessEnabled(true).withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build()
- "S3" | "GetObject" | "GET" | "someBucket/someKey" | 1 | { client -> client.getObject("someBucket", "someKey") } | "" | "{}" | AmazonS3ClientBuilder.standard().withPathStyleAccessEnabled(true).withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build()
+ service | operation | method | url | handlerCount | call | body | client
+ "S3" | "CreateBucket" | "PUT" | "testbucket/" | 1 | { client -> client.createBucket("testbucket") } | "" | AmazonS3ClientBuilder.standard().withPathStyleAccessEnabled(true).withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build()
+ "S3" | "GetObject" | "GET" | "someBucket/someKey" | 1 | { client -> client.getObject("someBucket", "someKey") } | "" | AmazonS3ClientBuilder.standard().withPathStyleAccessEnabled(true).withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build()
"EC2" | "AllocateAddress" | "POST" | "" | 4 | { client -> client.allocateAddress() } | """
<AllocateAddressResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
<publicIp>192.0.2.1</publicIp>
<domain>standard</domain>
</AllocateAddressResponse>
- """ | "{Action=[AllocateAddress],Version=[2016-11-15]}" | AmazonEC2ClientBuilder.standard().withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build()
+ """ | AmazonEC2ClientBuilder.standard().withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build()
"RDS" | "DeleteOptionGroup" | "POST" | "" | 5 | { client -> client.deleteOptionGroup(new DeleteOptionGroupRequest()) } | """
<DeleteOptionGroupResponse xmlns="http://rds.amazonaws.com/doc/2014-09-01/">
<ResponseMetadata>
<RequestId>0ac9cda2-bbf4-11d3-f92b-31fa5e8dbc99</RequestId>
</ResponseMetadata>
</DeleteOptionGroupResponse>
- """ | "{Action=[DeleteOptionGroup],Version=[2014-10-31]}" | AmazonRDSClientBuilder.standard().withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build()
+ """ | AmazonRDSClientBuilder.standard().withEndpointConfiguration(endpoint).withCredentials(credentialsProvider).build()
}
}

MODIFY
dd-java-agent/instrumentation/jdbc/src/test/groovy/JDBCInstrumentationTest.groovy
dd-java-agent/instrumentation/jdbc/src/test/groovy/JDBCInstrumentationTest.groovy
@@ -16,6 +16,7 @@ import java.sql.PreparedStatement
import java.sql.ResultSet
import java.sql.Statement
+import static datadog.trace.agent.test.TestUtils.runUnderTrace
import static datadog.trace.agent.test.asserts.ListWriterAssert.assertTraces
class JDBCInstrumentationTest extends AgentTestRunner {
@@ -142,18 +143,25 @@ class JDBCInstrumentationTest extends AgentTestRunner {
def "basic statement with #connection.getClass().getCanonicalName() on #driver generates spans"() {
setup:
Statement statement = connection.createStatement()
- ResultSet resultSet = statement.executeQuery(query)
+ ResultSet resultSet = runUnderTrace("parent") {
+ return statement.executeQuery(query)
+ }
expect:
resultSet.next()
resultSet.getInt(1) == 3
assertTraces(TEST_WRITER, 1) {
- trace(0, 1) {
+ trace(0, 2) {
span(0) {
+ operationName "parent"
+ parent()
+ }
+ span(1) {
operationName "${driver}.query"
serviceName driver
resourceName query
spanType DDSpanTypes.SQL
+ childOf span(0)
errored false
tags {
"db.type" driver
@@ -195,19 +203,26 @@ class JDBCInstrumentationTest extends AgentTestRunner {
def "prepared statement execute on #driver with #connection.getClass().getCanonicalName() generates a span"() {
setup:
PreparedStatement statement = connection.prepareStatement(query)
+ ResultSet resultSet = runUnderTrace("parent") {
assert statement.execute()
- ResultSet resultSet = statement.resultSet
+ return statement.resultSet
+ }
expect:
resultSet.next()
resultSet.getInt(1) == 3
assertTraces(TEST_WRITER, 1) {
- trace(0, 1) {
+ trace(0, 2) {
span(0) {
+ operationName "parent"
+ parent()
+ }
+ span(1) {
operationName "${driver}.query"
serviceName driver
resourceName query
spanType DDSpanTypes.SQL
+ childOf span(0)
errored false
tags {
"db.type" driver
@@ -245,18 +260,25 @@ class JDBCInstrumentationTest extends AgentTestRunner {
def "prepared statement query on #driver with #connection.getClass().getCanonicalName() generates a span"() {
setup:
PreparedStatement statement = connection.prepareStatement(query)
- ResultSet resultSet = statement.executeQuery()
+ ResultSet resultSet = runUnderTrace("parent") {
+ return statement.executeQuery()
+ }
expect:
resultSet.next()
resultSet.getInt(1) == 3
assertTraces(TEST_WRITER, 1) {
- trace(0, 1) {
+ trace(0, 2) {
span(0) {
+ operationName "parent"
+ parent()
+ }
+ span(1) {
operationName "${driver}.query"
serviceName driver
resourceName query
spanType DDSpanTypes.SQL
+ childOf span(0)
errored false
tags {
"db.type" driver
@@ -297,15 +319,22 @@ class JDBCInstrumentationTest extends AgentTestRunner {
def sql = connection.nativeSQL(query)
expect:
- !statement.execute(sql)
+ runUnderTrace("parent") {
+ return !statement.execute(sql)
+ }
statement.updateCount == 0
assertTraces(TEST_WRITER, 1) {
- trace(0, 1) {
+ trace(0, 2) {
span(0) {
+ operationName "parent"
+ parent()
+ }
+ span(1) {
operationName "${driver}.query"
serviceName driver
resourceName query
spanType DDSpanTypes.SQL
+ childOf span(0)
errored false
tags {
"db.type" driver
@@ -350,14 +379,21 @@ class JDBCInstrumentationTest extends AgentTestRunner {
PreparedStatement statement = connection.prepareStatement(sql)
expect:
- statement.executeUpdate() == 0
+ runUnderTrace("parent") {
+ return statement.executeUpdate() == 0
+ }
assertTraces(TEST_WRITER, 1) {
- trace(0, 1) {
+ trace(0, 2) {
span(0) {
+ operationName "parent"
+ parent()
+ }
+ span(1) {
operationName "${driver}.query"
serviceName driver
resourceName query
spanType DDSpanTypes.SQL
+ childOf span(0)
errored false
tags {
"db.type" driver
@@ -405,25 +441,31 @@ class JDBCInstrumentationTest extends AgentTestRunner {
}
Statement statement = null
- ResultSet rs = null
+ ResultSet rs = runUnderTrace("parent") {
if (prepareStatement) {
statement = connection.prepareStatement(query)
- rs = statement.executeQuery()
- } else {
+ return statement.executeQuery()
+ }
+
statement = connection.createStatement()
- rs = statement.executeQuery(query)
+ return statement.executeQuery(query)
}
then:
rs.next()
rs.getInt(1) == 3
assertTraces(TEST_WRITER, 1) {
- trace(0, 1) {
+ trace(0, 2) {
span(0) {
+ operationName "parent"
+ parent()
+ }
+ span(1) {
operationName "${driver}.query"
serviceName driver
resourceName query
spanType DDSpanTypes.SQL
+ childOf span(0)
errored false
tags {
"db.type" driver

Stop sending params with AWS traces

can potentially contain sensitive data.

(See #461)