Skip to content

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

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 2 commits into
base: main
Choose a base branch
from

Conversation

lukeina2z
Copy link

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

AWS SNS SDK

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

Tests Run:
npm run compile
npm run lint
npm run 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.

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

AWS SNS SDK

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

Tests Run:
npm run compile
npm run lint
npm run 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.
);
});

it('topic arn', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
it('topic arn', async () => {
it('should create topic ARN and capture expected trace attributes', async () => {

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for the feedback. Would you please approve the second iteration? @JacksonWeber

Copy link
Contributor

@JacksonWeber JacksonWeber left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

codecov bot commented Jun 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.78%. Comparing base (5861dfa) to head (f7ba763).
Report is 34 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2885      +/-   ##
==========================================
+ Coverage   89.69%   89.78%   +0.09%     
==========================================
  Files         186      187       +1     
  Lines        9041     9155     +114     
  Branches     1855     1886      +31     
==========================================
+ Hits         8109     8220     +111     
- Misses        932      935       +3     
Files with missing lines Coverage Δ
...entelemetry-instrumentation-aws-sdk/src/semconv.ts 100.00% <100.00%> (ø)
...emetry-instrumentation-aws-sdk/src/services/sns.ts 92.85% <100.00%> (+1.42%) ⬆️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@david-luna david-luna left a comment

Choose a reason for hiding this comment

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

LGTM. Just a small nit :)

@@ -158,3 +158,6 @@ export const GEN_AI_TOKEN_TYPE_VALUE_INPUT = 'input' as const;
* Enum value "output" for attribute {@link ATTR_GEN_AI_TOKEN_TYPE}.
*/
export const GEN_AI_TOKEN_TYPE_VALUE_OUTPUT = 'output' as const;

// Copied ATTR_AWS_SNS_TOPIC_ARN from '@opentelemetry/semantic-conventions/incubating'
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: copying also the docs would give more info to other contributors if they happen to work with this instrumentation. It also will reflect the experiemental status of the attribute in the IDE

Suggested change
// Copied ATTR_AWS_SNS_TOPIC_ARN from '@opentelemetry/semantic-conventions/incubating'
/**
* Originally from '@opentelemetry/semantic-conventions/incubating'
* The ARN of the AWS SNS Topic. An Amazon SNS [topic](https://docs.aws.amazon.com/sns/latest/dg/sns-create-topic.html) is a logical access point that acts as a communication channel.
*
* @example arn:aws:sns:us-east-1:123456789012:mystack-mytopic-NZJ5JSMVGFIE
*
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
*/

Copy link
Contributor

Choose a reason for hiding this comment

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

+1, copying the docs is usually preferred.

Copy link
Contributor

@JacksonWeber JacksonWeber left a comment

Choose a reason for hiding this comment

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

LGTM

@lukeina2z
Copy link
Author

Thank you for approving this PR @JacksonWeber and @david-luna. May I know why it is not merged into main branch?

@david-luna
Copy link
Contributor

Comment on lines +127 to +129
const publishSpans = getTestSpans().filter(
(s: ReadableSpan) => s.name === 'SNS CreateTopic'
);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit - update name to createTopicSpans

@@ -158,3 +158,6 @@ export const GEN_AI_TOKEN_TYPE_VALUE_INPUT = 'input' as const;
* Enum value "output" for attribute {@link ATTR_GEN_AI_TOKEN_TYPE}.
*/
export const GEN_AI_TOKEN_TYPE_VALUE_OUTPUT = 'output' as const;

// Copied ATTR_AWS_SNS_TOPIC_ARN from '@opentelemetry/semantic-conventions/incubating'
Copy link
Contributor

Choose a reason for hiding this comment

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

+1, copying the docs is usually preferred.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants