Skip to content

Commit

Permalink
Do not collect null values from AWS SdkPojos
Browse files Browse the repository at this point in the history
  • Loading branch information
ygree committed Nov 6, 2024
1 parent 2b4a735 commit 99608c4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"() {
Expand All @@ -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() }
}
}

Expand Down Expand Up @@ -346,11 +346,6 @@ class PayloadTaggingMaxTagsForkedTest extends AbstractPayloadTaggingTest {

where:
apiCall << [
{
snsClient.publish {
it.phoneNumber("+15555555555").message('message')
}
},
{
snsClient.createTopic {
it.name("testtopic")
Expand Down

0 comments on commit 99608c4

Please sign in to comment.