Skip to content

Commit

Permalink
fix(aws-sdk): reintroduce which were changed
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Nov 26, 2024
1 parent 3626c52 commit ad845bd
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/
import { Span, SpanKind, Tracer, diag, Attributes } from '@opentelemetry/api';
import { SEMATTRS_FAAS_EXECUTION } from '@opentelemetry/semantic-conventions';
import {
ATTR_FAAS_INVOCATION_ID,
ATTR_FAAS_INVOKED_NAME,
Expand Down Expand Up @@ -85,6 +86,7 @@ export class LambdaServiceExtension implements ServiceExtension {
switch (response.request.commandName) {
case LambdaCommands.Invoke:
{
span.setAttribute(SEMATTRS_FAAS_EXECUTION, response.requestId);
span.setAttribute(ATTR_FAAS_INVOCATION_ID, response.requestId);
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import { Span, Tracer, SpanKind, Attributes } from '@opentelemetry/api';
import {
MESSAGINGDESTINATIONKINDVALUES_TOPIC,
SEMATTRS_MESSAGING_DESTINATION,
SEMATTRS_MESSAGING_DESTINATION_KIND,
} from '@opentelemetry/semantic-conventions';
import {
Expand Down Expand Up @@ -47,13 +48,15 @@ export class SnsServiceExtension implements ServiceExtension {
spanAttributes[SEMATTRS_MESSAGING_DESTINATION_KIND] =
MESSAGINGDESTINATIONKINDVALUES_TOPIC;
const { TopicArn, TargetArn, PhoneNumber } = request.commandInput;
spanAttributes[ATTR_MESSAGING_DESTINATION_NAME] =
spanAttributes[SEMATTRS_MESSAGING_DESTINATION] =
this.extractDestinationName(TopicArn, TargetArn, PhoneNumber);
spanAttributes[ATTR_MESSAGING_DESTINATION_NAME] =
TopicArn || TargetArn || PhoneNumber || 'unknown';

spanName = `${
PhoneNumber
? 'phone_number'
: spanAttributes[ATTR_MESSAGING_DESTINATION_NAME]
: spanAttributes[SEMATTRS_MESSAGING_DESTINATION]
} send`;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
MESSAGINGDESTINATIONKINDVALUES_QUEUE,
MESSAGINGOPERATIONVALUES_PROCESS,
MESSAGINGOPERATIONVALUES_RECEIVE,
SEMATTRS_MESSAGING_DESTINATION,
SEMATTRS_MESSAGING_DESTINATION_KIND,
SEMATTRS_MESSAGING_URL,
} from '@opentelemetry/semantic-conventions';
Expand Down Expand Up @@ -65,6 +66,7 @@ export class SqsServiceExtension implements ServiceExtension {
[ATTR_MESSAGING_SYSTEM]: 'aws.sqs',
[SEMATTRS_MESSAGING_DESTINATION_KIND]:
MESSAGINGDESTINATIONKINDVALUES_QUEUE,
[SEMATTRS_MESSAGING_DESTINATION]: queueName,
[ATTR_MESSAGING_DESTINATION_NAME]: queueName,
[SEMATTRS_MESSAGING_URL]: queueUrl,
};
Expand Down Expand Up @@ -170,6 +172,7 @@ export class SqsServiceExtension implements ServiceExtension {
),
attributes: {
[ATTR_MESSAGING_SYSTEM]: 'aws.sqs',
[SEMATTRS_MESSAGING_DESTINATION]: queueName,
[ATTR_MESSAGING_DESTINATION_NAME]: queueName,
[SEMATTRS_MESSAGING_DESTINATION_KIND]:
MESSAGINGDESTINATIONKINDVALUES_QUEUE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from '@opentelemetry/contrib-test-utils';
registerInstrumentationTesting(new AwsInstrumentation());

import { SEMATTRS_FAAS_EXECUTION } from '@opentelemetry/semantic-conventions';
import {
ATTR_FAAS_INVOCATION_ID,
ATTR_FAAS_INVOKED_NAME,
Expand Down Expand Up @@ -385,6 +386,9 @@ describe('Lambda', () => {
expect(getTestSpans().length).toBe(1);
const [span] = getTestSpans();

expect(span.attributes[SEMATTRS_FAAS_EXECUTION]).toEqual(
'95882c2b-3fd2-485d-ada3-9fcb1ca65459'
);
expect(span.attributes[ATTR_FAAS_INVOCATION_ID]).toEqual(
'95882c2b-3fd2-485d-ada3-9fcb1ca65459'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
import * as sinon from 'sinon';
import {
MESSAGINGDESTINATIONKINDVALUES_TOPIC,
SEMATTRS_MESSAGING_DESTINATION,
SEMATTRS_MESSAGING_DESTINATION_KIND,
} from '@opentelemetry/semantic-conventions';
import {
Expand Down Expand Up @@ -86,9 +87,12 @@ describe('SNS - v2', () => {
expect(publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND]).toBe(
MESSAGINGDESTINATIONKINDVALUES_TOPIC
);
expect(publishSpan.attributes[ATTR_MESSAGING_DESTINATION_NAME]).toBe(
expect(publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]).toBe(
topicName
);
expect(publishSpan.attributes[ATTR_MESSAGING_DESTINATION_NAME]).toBe(
fakeARN
);
expect(publishSpan.attributes[ATTR_RPC_METHOD]).toBe('Publish');
expect(publishSpan.attributes[ATTR_MESSAGING_SYSTEM]).toBe('aws.sns');
expect(publishSpan.kind).toBe(SpanKind.PRODUCER);
Expand All @@ -109,6 +113,9 @@ describe('SNS - v2', () => {
);
expect(publishSpans.length).toBe(1);
const publishSpan = publishSpans[0];
expect(publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]).toBe(
PhoneNumber
);
expect(publishSpan.attributes[ATTR_MESSAGING_DESTINATION_NAME]).toBe(
PhoneNumber
);
Expand Down Expand Up @@ -155,6 +162,9 @@ describe('SNS - v2', () => {
expect(
createTopicSpan.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND]
).toBeUndefined();
expect(
createTopicSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]
).toBeUndefined();
expect(
createTopicSpan.attributes[ATTR_MESSAGING_DESTINATION_NAME]
).toBeUndefined();
Expand Down Expand Up @@ -201,9 +211,12 @@ describe('SNS - v3', () => {
expect(publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND]).toBe(
MESSAGINGDESTINATIONKINDVALUES_TOPIC
);
expect(publishSpan.attributes[ATTR_MESSAGING_DESTINATION_NAME]).toBe(
expect(publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]).toBe(
topicV3Name
);
expect(publishSpan.attributes[ATTR_MESSAGING_DESTINATION_NAME]).toBe(
topicV3ARN
);
expect(publishSpan.attributes[ATTR_RPC_METHOD]).toBe('Publish');
expect(publishSpan.attributes[ATTR_MESSAGING_SYSTEM]).toBe('aws.sns');
expect(publishSpan.kind).toBe(SpanKind.PRODUCER);
Expand All @@ -221,7 +234,7 @@ describe('SNS - v3', () => {
);
expect(publishSpans.length).toBe(1);
const publishSpan = publishSpans[0];
expect(publishSpan.attributes[ATTR_MESSAGING_DESTINATION_NAME]).toBe(
expect(publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]).toBe(
PhoneNumber
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
MESSAGINGDESTINATIONKINDVALUES_QUEUE,
MESSAGINGOPERATIONVALUES_PROCESS,
MESSAGINGOPERATIONVALUES_RECEIVE,
SEMATTRS_MESSAGING_DESTINATION,
SEMATTRS_MESSAGING_DESTINATION_KIND,
SEMATTRS_MESSAGING_URL,
} from '@opentelemetry/semantic-conventions';
Expand Down Expand Up @@ -404,6 +405,9 @@ describe('SQS', () => {
expect(span.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND]).toEqual(
MESSAGINGDESTINATIONKINDVALUES_QUEUE
);
expect(span.attributes[SEMATTRS_MESSAGING_DESTINATION]).toEqual(
QueueName
);
expect(span.attributes[ATTR_MESSAGING_DESTINATION_NAME]).toEqual(
QueueName
);
Expand Down

0 comments on commit ad845bd

Please sign in to comment.