Skip to content

feat: Add AWS_SNS_TOPIC_ARN semantic convention support for AWS SNS SDK #14035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

lukeina2z
Copy link
Contributor

This PR adds the AWS_SNS_TOPIC_ARN semantic convention attribute for the following AWS resources:

AWS SNS SDK v1
AWS SNS SDK v2

The topic ARN is extracted from both request and response objects, and this behavior is covered by unit tests.

Tests Run:
./gradlew spotlessCheck
./gradlew instrumentation:check
./gradlew :smoke-tests:test

All newly added tests pass, and no regressions were found.

Backward Compatibility:
This change is fully backward compatible. It introduces instrumentation for an additional AWS resource without modifying existing behavior in the auto-instrumentation library.

@lukeina2z lukeina2z requested a review from a team as a code owner June 13, 2025 21:41
Copy link
Contributor

@laurit laurit left a comment

Choose a reason for hiding this comment

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

Do I understand correctly that usually aws.sns.topic.arn contains the same value as messaging.destination.name? @trask is there any guidance on having multiple attributes with the same value?

@lukeina2z
Copy link
Contributor Author

Do I understand correctly that usually aws.sns.topic.arn contains the same value as messaging.destination.name? @trask is there any guidance on having multiple attributes with the same value?

MESSAGING_DESTINATION_NAME does not cover APIs like 'CreateTopic' which sets TopicArn on Response instead of Request. AWS_SNS_TOPIC_ARN is the generic semconv attribute for SNS Apis.

@lukeina2z lukeina2z force-pushed the xy-foo-3-sns branch 2 times, most recently from 282e855 to 39fee7a Compare June 24, 2025 05:46
@lukeina2z
Copy link
Contributor Author

@trask Would you please take a look at this PR? @laurit is requesting feedback from your side.

@trask
Copy link
Member

trask commented Jun 25, 2025

MESSAGING_DESTINATION_NAME does not cover APIs like 'CreateTopic' which sets TopicArn on Response instead of Request. AWS_SNS_TOPIC_ARN is the generic semconv attribute for SNS Apis.

it seems ok based on this

semconv tends to avoid conditionally setting the second one only when it's different

c.publish(
new PublishRequest().withMessage("somemessage").withTargetArn("somearn"))));
@Test
public void testCreateTopicRequestWithMockedResponse() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

usually we add tests as package private methods

Copy link
Contributor Author

Choose a reason for hiding this comment

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

access modifier removed. I think the default is package-private.

@@ -32,47 +50,66 @@ protected boolean hasRequestId() {
return true;
}

@ParameterizedTest
@MethodSource("provideArguments")
public void testSendRequestWithMockedResponse(Function<AmazonSNS, Object> call) throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

as far as I can tell you could have kept the original parameterized tests and just added the additionalAttributes as another parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good feedback. Thank you @laurit.

This PR adds the AWS_SNS_TOPIC_ARN semantic convention attribute for the following AWS resources:
AWS SNS SDK v1
AWS SNS SDK v2

The topic ARN is extracted from both request and response objects, and this behavior is covered by unit tests.

Tests Run:
./gradlew spotlessCheck
./gradlew instrumentation:check
./gradlew :smoke-tests:test

All newly added tests pass, and no regressions were found.

Backward Compatibility:
This change is fully backward compatible. It introduces instrumentation for an additional AWS resource without modifying existing behavior in the auto-instrumentation library.
@lukeina2z
Copy link
Contributor Author

@trask and @laurit, all feedback have been addressed. Would you please approve this PR?

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.

3 participants