Skip to content

[dotnet] Implement .NET system test for SNS#4897

Merged
robcarlan-datadog merged 11 commits intomainfrom
rob.carlan/dsm-sns-dotnet-test
Jul 11, 2025
Merged

[dotnet] Implement .NET system test for SNS#4897
robcarlan-datadog merged 11 commits intomainfrom
rob.carlan/dsm-sns-dotnet-test

Conversation

@robcarlan-datadog
Copy link
Copy Markdown
Contributor

@robcarlan-datadog robcarlan-datadog commented Jul 3, 2025

Motivation

SNS implementation was broken in .NET, and is fixed by
DataDog/dd-trace-dotnet#7205

Before this fix (hence the tests fail before the PR merges). we failed to extract parent context, and so the checkpoint on the consume side doesn't have a parent. This explains why we never saw a link between the services in the DSM map.

Failing test output, before:

20:36:29.455 INFO     Look for 4521388511681537097, 0, ('direction:out', 'topic:dsm-system-tests-topic_dotnet_poc_04011a51EBD716eF_raw', 'type:sns')
20:36:29.455 INFO     Observed checkpoint: 18266884589021324247, 0, ('direction:out', 'topic:dsm-system-tests-queue_dotnet_poc_04011a51EBD716eF', 'type:sqs')
20:36:29.455 INFO     Observed checkpoint: 7629229515586254500, 18266884589021324247, ('direction:in', 'topic:dsm-system-tests-queue_dotnet_poc_04011a51EBD716eF', 'type:sqs')
20:36:29.455 INFO     Observed checkpoint: 18266884589021324247, 0, ('direction:out', 'topic:dsm-system-tests-queue_dotnet_poc_04011a51EBD716eF', 'type:sqs')
20:36:29.455 INFO     Observed checkpoint: 7629229515586254500, 18266884589021324247, ('direction:in', 'topic:dsm-system-tests-queue_dotnet_poc_04011a51EBD716eF', 'type:sqs')
20:36:29.455 INFO     Observed checkpoint: 4521388511681537097, 0, ('direction:out', 'topic:dsm-system-tests-topic_dotnet_poc_04011a51EBD716eF_raw', 'type:sns')
20:36:29.455 INFO     checkpoint found ✅
20:36:29.455 INFO     Look for 13165901053110699513, 4521388511681537097, ('direction:in', 'topic:dsm-system-tests-sns-queue_dotnet_poc_04011a51EBD716eF_raw', 'type:sqs')
20:36:29.455 INFO     Observed checkpoint: 18266884589021324247, 0, ('direction:out', 'topic:dsm-system-tests-queue_dotnet_poc_04011a51EBD716eF', 'type:sqs')
20:36:29.456 INFO     Observed checkpoint: 7629229515586254500, 18266884589021324247, ('direction:in', 'topic:dsm-system-tests-queue_dotnet_poc_04011a51EBD716eF', 'type:sqs')
20:36:29.456 INFO     Observed checkpoint: 18266884589021324247, 0, ('direction:out', 'topic:dsm-system-tests-queue_dotnet_poc_04011a51EBD716eF', 'type:sqs')
20:36:29.456 INFO     Observed checkpoint: 7629229515586254500, 18266884589021324247, ('direction:in', 'topic:dsm-system-tests-queue_dotnet_poc_04011a51EBD716eF', 'type:sqs')
20:36:29.456 INFO     Observed checkpoint: 4521388511681537097, 0, ('direction:out', 'topic:dsm-system-tests-topic_dotnet_poc_04011a51EBD716eF_raw', 'type:sns')
20:36:29.456 INFO     Observed checkpoint: 5934457306594508011, 0, ('direction:in', 'topic:dsm-system-tests-sns-queue_dotnet_poc_04011a51EBD716eF_raw', 'type:sqs')
20:36:29.456 INFO     Observed checkpoint: 4521388511681537097, 0, ('direction:out', 'topic:dsm-system-tests-topic_dotnet_poc_04011a51EBD716eF_raw', 'type:sns')
20:36:29.456 INFO     Observed checkpoint: 5934457306594508011, 0, ('direction:in', 'topic:dsm-system-tests-sns-queue_dotnet_poc_04011a51EBD716eF_raw', 'type:sqs')
20:36:29.456 ERROR    Checkpoint not found 🚨

I ran system-tests locally with a tracer from the above PR, and saw that the checkpoints are now connected:

20:48:25.566 INFO     Look for 14863322665041935644, 0, ('direction:out', 'topic:dsm-system-tests-topic_dotnet_poc_a351B9ADc2eCC1E9_raw', 'type:sns')
20:48:25.567 INFO     Observed checkpoint: 14863322665041935644, 0, ('direction:out', 'topic:dsm-system-tests-topic_dotnet_poc_a351B9ADc2eCC1E9_raw', 'type:sns')
20:48:25.567 INFO     checkpoint found ✅
20:48:25.567 INFO     Look for 15057313816480470290, 14863322665041935644, ('direction:in', 'topic:dsm-system-tests-sns-queue_dotnet_poc_a351B9ADc2eCC1E9_raw', 'type:sqs')
20:48:25.567 INFO     Observed checkpoint: 14863322665041935644, 0, ('direction:out', 'topic:dsm-system-tests-topic_dotnet_poc_a351B9ADc2eCC1E9_raw', 'type:sns')
20:48:25.567 INFO     Observed checkpoint: 15057313816480470290, 14863322665041935644, ('direction:in', 'topic:dsm-system-tests-sns-queue_dotnet_poc_a351B9ADc2eCC1E9_raw', 'type:sqs')
20:48:25.567 INFO     checkpoint found ✅

Latest CI check on the .NET Dev INTEGRATIONS_AWS scenario:

   weblog GET http://localhost:7777/dsm?integration=sns&timeout=60&queue=dsm-system-tests-sns-queue_dotnet_poc_5ec768A2a245D7B8_raw&topic=dsm-system-tests-topic_dotnet_poc_5ec768A2a245D7B8_raw&message=[test_dsm.py::Test_DsmSNS] [SNS] Hello from dotnet DSM test: 5ec768A2a245D7B8 -> 200
16:59:40.231 INFO     Look for 17562147650134908894, 0, ('direction:out', 'topic:dsm-system-tests-topic_dotnet_poc_5ec768A2a245D7B8_raw', 'type:sns')
16:59:40.231 INFO     Observed checkpoint: 3872871481328257660, 0, ('direction:out', 'topic:dsm-system-tests-queue_dotnet_poc_5ec768A2a245D7B8', 'type:sqs')
16:59:40.231 INFO     Observed checkpoint: 18233515535318049456, 3872871481328257660, ('direction:in', 'topic:dsm-system-tests-queue_dotnet_poc_5ec768A2a245D7B8', 'type:sqs')
16:59:40.231 INFO     Observed checkpoint: 17562147650134908894, 0, ('direction:out', 'topic:dsm-system-tests-topic_dotnet_poc_5ec768A2a245D7B8_raw', 'type:sns')
16:59:40.232 INFO     checkpoint found ✅
16:59:40.232 INFO     Look for 7243140481743836900, 17562147650134908894, ('direction:in', 'topic:dsm-system-tests-sns-queue_dotnet_poc_5ec768A2a245D7B8_raw', 'type:sqs')
16:59:40.232 INFO     Observed checkpoint: 3872871481328257660, 0, ('direction:out', 'topic:dsm-system-tests-queue_dotnet_poc_5ec768A2a245D7B8', 'type:sqs')
16:59:40.232 INFO     Observed checkpoint: 18233515535318049456, 3872871481328257660, ('direction:in', 'topic:dsm-system-tests-queue_dotnet_poc_5ec768A2a245D7B8', 'type:sqs')
16:59:40.232 INFO     Observed checkpoint: 17562147650134908894, 0, ('direction:out', 'topic:dsm-system-tests-topic_dotnet_poc_5ec768A2a245D7B8_raw', 'type:sns')
16:59:40.232 INFO     Observed checkpoint: 7243140481743836900, 17562147650134908894, ('direction:in', 'topic:dsm-system-tests-sns-queue_dotnet_poc_5ec768A2a245D7B8_raw', 'type:sqs')
16:59:40.232 INFO     checkpoint found ✅

Changes

Workflow

  1. ⚠️ Create your PR as draft ⚠️
  2. Work on you PR until the CI passes
  3. Mark it as ready for review
    • Test logic is modified? -> Get a review from RFC owner.
    • Framework is modified, or non obvious usage of it -> get a review from R&P team

🚀 Once your PR is reviewed and the CI green, you can merge it!

🛟 #apm-shared-testing 🛟

Reviewer checklist

  • If PR title starts with [<language>], double-check that only <language> is impacted by the change
  • No system-tests internal is modified. Otherwise, I have the approval from R&P team
  • A docker base image is modified?
    • the relevant build-XXX-image label is present
  • A scenario is added (or removed)?

robcarlan-datadog added a commit to DataDog/dd-trace-dotnet that referenced this pull request Jul 11, 2025
…ction (#7205)

## Summary of changes
SNS -> SQS context propagation was broken, as we encode the value of the
`_datadog` header into base64. On the consume side, we assume it is
written as a string, which is only true if we send a message directly
through SQS.

The fix is to decode the `_datadog` value based on the type, just as in
[this](DataDog/datadog-lambda-js#269) PR.

This soles issues where the DSM map doesn't show links between SNS and
SQS, as the checkpoint is still created on the consumer, just without a
link to the parent.

## Reason for change

## Implementation details

## Test coverage
I tested this via system-tests, with a description of my test
methodology in [this
PR](DataDog/system-tests#4897).
The SNS system test above pass when I ran locally with this tracer
build.

## Other details
<!-- Fixes #{issue} -->

<!-- ⚠️ Note: where possible, please obtain 2 approvals prior to
merging. Unless CODEOWNERS specifies otherwise, for external teams it is
typically best to have one review from a team member, and one review
from apm-dotnet. Trivial changes do not require 2 reviews. -->
@robcarlan-datadog
Copy link
Copy Markdown
Contributor Author

Failing tests are for other languages


topic = self.topic if context.library == "java" else f"arn:aws:sns:us-east-1:{AWS_ACCT}:{self.topic}"
arn = f"arn:aws:sns:us-east-1:{AWS_ACCT}:{self.topic}"
topic = self.topic if context.library in ["java", "dotnet"] else arn
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SNS api for .NET & Java allow sending messages just by topic name, can't deduce full ARN for these tracers

@robcarlan-datadog robcarlan-datadog marked this pull request as ready for review July 11, 2025 19:17
@robcarlan-datadog robcarlan-datadog requested review from a team as code owners July 11, 2025 19:17
}
}

class SnsProducer
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This practically follows the Java implementation as close as possible

@robcarlan-datadog robcarlan-datadog changed the title Implement .NET system test for SNS [dotnet] Implement .NET system test for SNS Jul 11, 2025
@robcarlan-datadog robcarlan-datadog merged commit ceced0c into main Jul 11, 2025
108 checks passed
@robcarlan-datadog robcarlan-datadog deleted the rob.carlan/dsm-sns-dotnet-test branch July 11, 2025 20:08
chojomok pushed a commit to DataDog/dd-trace-dotnet that referenced this pull request Jul 15, 2025
…ction (#7205)

## Summary of changes
SNS -> SQS context propagation was broken, as we encode the value of the
`_datadog` header into base64. On the consume side, we assume it is
written as a string, which is only true if we send a message directly
through SQS.

The fix is to decode the `_datadog` value based on the type, just as in
[this](DataDog/datadog-lambda-js#269) PR.

This soles issues where the DSM map doesn't show links between SNS and
SQS, as the checkpoint is still created on the consumer, just without a
link to the parent.

## Reason for change

## Implementation details

## Test coverage
I tested this via system-tests, with a description of my test
methodology in [this
PR](DataDog/system-tests#4897).
The SNS system test above pass when I ran locally with this tracer
build.

## Other details
<!-- Fixes #{issue} -->

<!-- ⚠️ Note: where possible, please obtain 2 approvals prior to
merging. Unless CODEOWNERS specifies otherwise, for external teams it is
typically best to have one review from a team member, and one review
from apm-dotnet. Trivial changes do not require 2 reviews. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants