Skip to content

Commit 21c7767

Browse files
committed
Add test case when there are no message attributes
1 parent 6f658fe commit 21c7767

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

dd-java-agent/instrumentation/aws-java-sqs-1.0/src/test/groovy/SqsClientTest.groovy

+30-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ abstract class SqsClientTest extends VersionedNamingTestBase {
4444
// Set a service name that gets sorted early with SORT_BY_NAMES
4545
injectSysConfig(GeneralConfig.SERVICE_NAME, "A-service")
4646
injectSysConfig(GeneralConfig.DATA_STREAMS_ENABLED, isDataStreamsEnabled().toString())
47-
injectSysConfig("sqs.body.propagation.enabled", "true")
47+
injectSysConfig("trace.sqs.body.propagation.enabled", "true")
4848
}
4949

5050
@Shared
@@ -585,6 +585,35 @@ class SqsClientV1DataStreamsForkedTest extends SqsClientTest {
585585
client.shutdown()
586586
}
587587

588+
def "Data streams context not extracted from message body when message attributes are not present"() {
589+
setup:
590+
def client = AmazonSQSClientBuilder.standard()
591+
.withEndpointConfiguration(endpoint)
592+
.withCredentials(credentialsProvider)
593+
.build()
594+
def queueUrl = client.createQueue('somequeue').queueUrl
595+
TEST_WRITER.clear()
596+
597+
when:
598+
injectSysConfig(GeneralConfig.DATA_STREAMS_ENABLED, "false")
599+
client.sendMessage(queueUrl, '{"Message": "sometext"}')
600+
injectSysConfig(GeneralConfig.DATA_STREAMS_ENABLED, "true")
601+
def messages = client.receiveMessage(queueUrl).messages
602+
messages.forEach {}
603+
604+
TEST_DATA_STREAMS_WRITER.waitForGroups(1)
605+
606+
then:
607+
StatsGroup first = TEST_DATA_STREAMS_WRITER.groups.find { it.parentHash == 0 }
608+
609+
verifyAll(first) {
610+
edgeTags == ["direction:in", "topic:somequeue", "type:sqs"]
611+
edgeTags.size() == 3
612+
}
613+
614+
cleanup:
615+
client.shutdown()
616+
}
588617
}
589618

590619

dd-trace-api/src/main/java/datadog/trace/api/config/TraceInstrumentationConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public final class TraceInstrumentationConfig {
159159
/** If set, the instrumentation will set its resource name on the local root too. */
160160
public static final String AXIS_PROMOTE_RESOURCE_NAME = "trace.axis.promote.resource-name";
161161

162-
public static final String SQS_BODY_PROPAGATION_ENABLED = "sqs.body.propagation.enabled";
162+
public static final String SQS_BODY_PROPAGATION_ENABLED = "trace.sqs.body.propagation.enabled";
163163

164164
private TraceInstrumentationConfig() {}
165165
}

0 commit comments

Comments
 (0)