Skip to content

Commit

Permalink
fix message id assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
jaydeluca committed Dec 15, 2024
1 parent 01f1721 commit 13ff8a0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ static SpanDataAssert processSpan(SpanDataAssert span, SpanData parent) {
}

@SuppressWarnings("deprecation") // using deprecated semconv
static SpanDataAssert publishSpan(SpanDataAssert span, String queueUrl) {
static SpanDataAssert publishSpan(SpanDataAssert span, String queueUrl, String rcpMethod) {
return span.hasName("testSdkSqs publish")
.hasKind(SpanKind.PRODUCER)
.hasNoParent()
Expand All @@ -259,14 +259,20 @@ static SpanDataAssert publishSpan(SpanDataAssert span, String queueUrl) {
val -> val.matches("\\s*00000000-0000-0000-0000-000000000000\\s*|UNKNOWN")),
equalTo(RPC_SYSTEM, "aws-api"),
equalTo(RPC_SERVICE, "Sqs"),
equalTo(RPC_METHOD, "SendMessageBatch"),
equalTo(RPC_METHOD, rcpMethod),
equalTo(HTTP_REQUEST_METHOD, "POST"),
equalTo(HTTP_RESPONSE_STATUS_CODE, 200),
satisfies(URL_FULL, v -> v.startsWith("http://localhost:" + sqsPort)),
equalTo(SERVER_ADDRESS, "localhost"),
equalTo(SERVER_PORT, sqsPort),
equalTo(MESSAGING_SYSTEM, AWS_SQS),
equalTo(MESSAGING_DESTINATION_NAME, "testSdkSqs"),
equalTo(MESSAGING_OPERATION, "publish"));
equalTo(MESSAGING_OPERATION, "publish"),
satisfies(
MESSAGING_MESSAGE_ID,
val ->
val.satisfiesAnyOf(
v -> assertThat(v).isInstanceOf(String.class),
v -> assertThat(v).isNull())));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected void assertSqsTraces(Boolean withParent, Boolean captureHeaders) {
trace -> trace.hasSpansSatisfyingExactly(span -> createQueueSpan(span)),
trace ->
trace.hasSpansSatisfyingExactly(
span -> publishSpan(span, queueUrl),
span -> publishSpan(span, queueUrl, "SendMessage"),
span -> processSpan(span, trace.getSpan(0)),
span ->
span.hasName("process child")
Expand Down Expand Up @@ -121,7 +121,8 @@ void testBatchSqsProducerConsumerServicesSync() throws URISyntaxException {
trace -> trace.hasSpansSatisfyingExactly(span -> createQueueSpan(span)),
trace -> {
List<Consumer<SpanDataAssert>> spanAsserts =
new ArrayList<>(singletonList(span -> publishSpan(span, queueUrl)));
new ArrayList<>(
singletonList(span -> publishSpan(span, queueUrl, "SendMessageBatch")));

for (int i = 0; i <= (isXrayInjectionEnabled() ? 2 : 1); i++) {
spanAsserts.add(span -> processSpan(span, trace.getSpan(0)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ void testBatchSqsProducerConsumerServicesSync() throws URISyntaxException {
span -> span.hasName("Sqs.CreateQueue").hasKind(SpanKind.CLIENT)),
trace -> {
publishSpan.set(trace.getSpan(0));
trace.hasSpansSatisfyingExactly(span -> publishSpan(span, queueUrl));
trace.hasSpansSatisfyingExactly(
span -> publishSpan(span, queueUrl, "SendMessageBatch"));
},
trace -> {
List<Consumer<SpanDataAssert>> spanAsserts = new ArrayList<>();
Expand Down

0 comments on commit 13ff8a0

Please sign in to comment.