Skip to content

Conversation

@lukeina2z
Copy link
Contributor

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
Contributor 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

@codecov
Copy link

codecov bot commented Jun 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.00%. Comparing base (5988c79) to head (3665bc9).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2885   +/-   ##
=======================================
  Coverage   88.99%   89.00%           
=======================================
  Files         188      188           
  Lines        9181     9189    +8     
  Branches     1889     1891    +2     
=======================================
+ Hits         8171     8179    +8     
  Misses       1010     1010           
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%) ⬆️
🚀 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 :)

*/
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
Contributor 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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That will fail the UT. I believe the span name comes from the auto-instrumentation library. The predicate only reads it, not set it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I meant the variable name publishSpans -> createTopicSpans, I assume the original variable name was from the other test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it.

*/
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.

lukeina2z added 2 commits July 3, 2025 13:01
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.
@jj22ee jj22ee added the has:owner-approval Approved by Component Owner label Jul 3, 2025
@david-luna david-luna merged commit cb900ea into open-telemetry:main Jul 4, 2025
28 checks passed
@dyladan dyladan mentioned this pull request Jul 2, 2025
@lukeina2z lukeina2z deleted the foo-1-sns branch July 11, 2025 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants