From 99608c45eaaeb20030b5dc5aea81c69107197439 Mon Sep 17 00:00:00 2001 From: Yury Gribkov Date: Tue, 5 Nov 2024 00:36:44 -0800 Subject: [PATCH] Do not collect null values from AWS SdkPojos --- .../aws/v2/AwsSdkClientDecorator.java | 2 +- .../groovy/PayloadTaggingTest.groovy | 39 ++++++++----------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/dd-java-agent/instrumentation/aws-java-sdk-2.2/src/main/java/datadog/trace/instrumentation/aws/v2/AwsSdkClientDecorator.java b/dd-java-agent/instrumentation/aws-java-sdk-2.2/src/main/java/datadog/trace/instrumentation/aws/v2/AwsSdkClientDecorator.java index 6d81cc083ab..94227b68124 100644 --- a/dd-java-agent/instrumentation/aws-java-sdk-2.2/src/main/java/datadog/trace/instrumentation/aws/v2/AwsSdkClientDecorator.java +++ b/dd-java-agent/instrumentation/aws-java-sdk-2.2/src/main/java/datadog/trace/instrumentation/aws/v2/AwsSdkClientDecorator.java @@ -495,7 +495,7 @@ private void collectPayloadTagsData( } else if (object instanceof SdkBytes) { SdkBytes bytes = (SdkBytes) object; payloadTagsData.add(new PayloadTagsData.PathAndValue(path.toArray(), bytes.asInputStream())); - } else { + } else if (object != null) { payloadTagsData.add(new PayloadTagsData.PathAndValue(path.toArray(), object)); } } diff --git a/dd-java-agent/instrumentation/aws-java-sdk-2.2/src/payloadTaggingTest/groovy/PayloadTaggingTest.groovy b/dd-java-agent/instrumentation/aws-java-sdk-2.2/src/payloadTaggingTest/groovy/PayloadTaggingTest.groovy index 81508ced1d5..e8b810239ba 100644 --- a/dd-java-agent/instrumentation/aws-java-sdk-2.2/src/payloadTaggingTest/groovy/PayloadTaggingTest.groovy +++ b/dd-java-agent/instrumentation/aws-java-sdk-2.2/src/payloadTaggingTest/groovy/PayloadTaggingTest.groovy @@ -114,9 +114,8 @@ class PayloadTaggingRedactionForkedTest extends AbstractPayloadTaggingTest { @Override protected void configurePreAgent() { super.configurePreAgent() - def redactTopLevelTags = "\$.*,\$.Owner.DisplayName" - injectSysConfig(TracerConfig.TRACE_CLOUD_REQUEST_PAYLOAD_TAGGING, redactTopLevelTags) - injectSysConfig(TracerConfig.TRACE_CLOUD_RESPONSE_PAYLOAD_TAGGING, redactTopLevelTags) + injectSysConfig(TracerConfig.TRACE_CLOUD_REQUEST_PAYLOAD_TAGGING, "all") + injectSysConfig(TracerConfig.TRACE_CLOUD_RESPONSE_PAYLOAD_TAGGING, "\$.*,\$.Owner.DisplayName") } def "test payload tag observability support for #service"() { @@ -133,45 +132,46 @@ class PayloadTaggingRedactionForkedTest extends AbstractPayloadTaggingTest { span { spanType DDSpanTypes.HTTP_CLIENT childOf(span(0)) - assert expectedReqTag == NA || span.tags.get("aws.request.body." + expectedReqTag) == "redacted" + assert expectedReqTag == NA || span.tags.get("aws.request.body." + expectedReqTag) == "tagvalue" assert expectedRespTag == NA || span.tags.get("aws.response.body." + expectedRespTag) == "redacted" assert !span.tags.containsKey("_dd.payload_tags_incomplete") assert !span.tags.containsKey("aws.request.body") assert !span.tags.containsKey("aws.response.body") + assert !span.tags.containsValue(null) } } } where: - service | expectedReqTag | expectedRespTag | apiCall - "ApiGateway" | "name" | "value" | { + service | expectedReqTag | expectedRespTag | apiCall + "ApiGateway" | "name" | "value" | { apiGatewayClient.createApiKey { - it.name("testapi") + it.name("tagvalue") } } - "EventBridge" | "Name" | "EventBusArn" | { + "EventBridge" | "Name" | "EventBusArn" | { eventBridgeClient.createEventBus { - it.name("testbus") + it.name("tagvalue") } } - "Sns" | "Name" | "TopicArn" | { + "Sns" | "Name" | "TopicArn" | { snsClient.createTopic { - it.name("testtopic") + it.name("tagvalue") } } - "Sqs" | "QueueName" | "QueueUrl" | { + "Sqs" | "QueueName" | "QueueUrl" | { sqsClient.createQueue { - it.queueName("testqueue") + it.queueName("tagvalue") } } - "Kinesis" | "StreamModeDetails" | NA | { + "Kinesis" | "StreamName" | NA | { kinesisClient.createStream { - it.streamName("teststream") + it.streamName("tagvalue") } } - "Kinesis" | NA | "ShardLimit" | { kinesisClient.describeLimits() } - "S3" | NA | "Owner.DisplayName" | { s3Client.listBuckets() } + "Kinesis" | NA | "ShardLimit" | { kinesisClient.describeLimits() } + "S3" | NA | "Owner.DisplayName" | { s3Client.listBuckets() } } } @@ -346,11 +346,6 @@ class PayloadTaggingMaxTagsForkedTest extends AbstractPayloadTaggingTest { where: apiCall << [ - { - snsClient.publish { - it.phoneNumber("+15555555555").message('message') - } - }, { snsClient.createTopic { it.name("testtopic")