Skip to content

Commit ad845bd

Browse files
committed
fix(aws-sdk): reintroduce which were changed
1 parent 3626c52 commit ad845bd

File tree

6 files changed

+34
-5
lines changed

6 files changed

+34
-5
lines changed

plugins/node/opentelemetry-instrumentation-aws-sdk/src/services/lambda.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616
import { Span, SpanKind, Tracer, diag, Attributes } from '@opentelemetry/api';
17+
import { SEMATTRS_FAAS_EXECUTION } from '@opentelemetry/semantic-conventions';
1718
import {
1819
ATTR_FAAS_INVOCATION_ID,
1920
ATTR_FAAS_INVOKED_NAME,
@@ -85,6 +86,7 @@ export class LambdaServiceExtension implements ServiceExtension {
8586
switch (response.request.commandName) {
8687
case LambdaCommands.Invoke:
8788
{
89+
span.setAttribute(SEMATTRS_FAAS_EXECUTION, response.requestId);
8890
span.setAttribute(ATTR_FAAS_INVOCATION_ID, response.requestId);
8991
}
9092
break;

plugins/node/opentelemetry-instrumentation-aws-sdk/src/services/sns.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import { Span, Tracer, SpanKind, Attributes } from '@opentelemetry/api';
1717
import {
1818
MESSAGINGDESTINATIONKINDVALUES_TOPIC,
19+
SEMATTRS_MESSAGING_DESTINATION,
1920
SEMATTRS_MESSAGING_DESTINATION_KIND,
2021
} from '@opentelemetry/semantic-conventions';
2122
import {
@@ -47,13 +48,15 @@ export class SnsServiceExtension implements ServiceExtension {
4748
spanAttributes[SEMATTRS_MESSAGING_DESTINATION_KIND] =
4849
MESSAGINGDESTINATIONKINDVALUES_TOPIC;
4950
const { TopicArn, TargetArn, PhoneNumber } = request.commandInput;
50-
spanAttributes[ATTR_MESSAGING_DESTINATION_NAME] =
51+
spanAttributes[SEMATTRS_MESSAGING_DESTINATION] =
5152
this.extractDestinationName(TopicArn, TargetArn, PhoneNumber);
53+
spanAttributes[ATTR_MESSAGING_DESTINATION_NAME] =
54+
TopicArn || TargetArn || PhoneNumber || 'unknown';
5255

5356
spanName = `${
5457
PhoneNumber
5558
? 'phone_number'
56-
: spanAttributes[ATTR_MESSAGING_DESTINATION_NAME]
59+
: spanAttributes[SEMATTRS_MESSAGING_DESTINATION]
5760
} send`;
5861
}
5962

plugins/node/opentelemetry-instrumentation-aws-sdk/src/services/sqs.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
MESSAGINGDESTINATIONKINDVALUES_QUEUE,
3636
MESSAGINGOPERATIONVALUES_PROCESS,
3737
MESSAGINGOPERATIONVALUES_RECEIVE,
38+
SEMATTRS_MESSAGING_DESTINATION,
3839
SEMATTRS_MESSAGING_DESTINATION_KIND,
3940
SEMATTRS_MESSAGING_URL,
4041
} from '@opentelemetry/semantic-conventions';
@@ -65,6 +66,7 @@ export class SqsServiceExtension implements ServiceExtension {
6566
[ATTR_MESSAGING_SYSTEM]: 'aws.sqs',
6667
[SEMATTRS_MESSAGING_DESTINATION_KIND]:
6768
MESSAGINGDESTINATIONKINDVALUES_QUEUE,
69+
[SEMATTRS_MESSAGING_DESTINATION]: queueName,
6870
[ATTR_MESSAGING_DESTINATION_NAME]: queueName,
6971
[SEMATTRS_MESSAGING_URL]: queueUrl,
7072
};
@@ -170,6 +172,7 @@ export class SqsServiceExtension implements ServiceExtension {
170172
),
171173
attributes: {
172174
[ATTR_MESSAGING_SYSTEM]: 'aws.sqs',
175+
[SEMATTRS_MESSAGING_DESTINATION]: queueName,
173176
[ATTR_MESSAGING_DESTINATION_NAME]: queueName,
174177
[SEMATTRS_MESSAGING_DESTINATION_KIND]:
175178
MESSAGINGDESTINATIONKINDVALUES_QUEUE,

plugins/node/opentelemetry-instrumentation-aws-sdk/test/lambda.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
} from '@opentelemetry/contrib-test-utils';
2222
registerInstrumentationTesting(new AwsInstrumentation());
2323

24+
import { SEMATTRS_FAAS_EXECUTION } from '@opentelemetry/semantic-conventions';
2425
import {
2526
ATTR_FAAS_INVOCATION_ID,
2627
ATTR_FAAS_INVOKED_NAME,
@@ -385,6 +386,9 @@ describe('Lambda', () => {
385386
expect(getTestSpans().length).toBe(1);
386387
const [span] = getTestSpans();
387388

389+
expect(span.attributes[SEMATTRS_FAAS_EXECUTION]).toEqual(
390+
'95882c2b-3fd2-485d-ada3-9fcb1ca65459'
391+
);
388392
expect(span.attributes[ATTR_FAAS_INVOCATION_ID]).toEqual(
389393
'95882c2b-3fd2-485d-ada3-9fcb1ca65459'
390394
);

plugins/node/opentelemetry-instrumentation-aws-sdk/test/sns.test.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
3232
import * as sinon from 'sinon';
3333
import {
3434
MESSAGINGDESTINATIONKINDVALUES_TOPIC,
35+
SEMATTRS_MESSAGING_DESTINATION,
3536
SEMATTRS_MESSAGING_DESTINATION_KIND,
3637
} from '@opentelemetry/semantic-conventions';
3738
import {
@@ -86,9 +87,12 @@ describe('SNS - v2', () => {
8687
expect(publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND]).toBe(
8788
MESSAGINGDESTINATIONKINDVALUES_TOPIC
8889
);
89-
expect(publishSpan.attributes[ATTR_MESSAGING_DESTINATION_NAME]).toBe(
90+
expect(publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]).toBe(
9091
topicName
9192
);
93+
expect(publishSpan.attributes[ATTR_MESSAGING_DESTINATION_NAME]).toBe(
94+
fakeARN
95+
);
9296
expect(publishSpan.attributes[ATTR_RPC_METHOD]).toBe('Publish');
9397
expect(publishSpan.attributes[ATTR_MESSAGING_SYSTEM]).toBe('aws.sns');
9498
expect(publishSpan.kind).toBe(SpanKind.PRODUCER);
@@ -109,6 +113,9 @@ describe('SNS - v2', () => {
109113
);
110114
expect(publishSpans.length).toBe(1);
111115
const publishSpan = publishSpans[0];
116+
expect(publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]).toBe(
117+
PhoneNumber
118+
);
112119
expect(publishSpan.attributes[ATTR_MESSAGING_DESTINATION_NAME]).toBe(
113120
PhoneNumber
114121
);
@@ -155,6 +162,9 @@ describe('SNS - v2', () => {
155162
expect(
156163
createTopicSpan.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND]
157164
).toBeUndefined();
165+
expect(
166+
createTopicSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]
167+
).toBeUndefined();
158168
expect(
159169
createTopicSpan.attributes[ATTR_MESSAGING_DESTINATION_NAME]
160170
).toBeUndefined();
@@ -201,9 +211,12 @@ describe('SNS - v3', () => {
201211
expect(publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND]).toBe(
202212
MESSAGINGDESTINATIONKINDVALUES_TOPIC
203213
);
204-
expect(publishSpan.attributes[ATTR_MESSAGING_DESTINATION_NAME]).toBe(
214+
expect(publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]).toBe(
205215
topicV3Name
206216
);
217+
expect(publishSpan.attributes[ATTR_MESSAGING_DESTINATION_NAME]).toBe(
218+
topicV3ARN
219+
);
207220
expect(publishSpan.attributes[ATTR_RPC_METHOD]).toBe('Publish');
208221
expect(publishSpan.attributes[ATTR_MESSAGING_SYSTEM]).toBe('aws.sns');
209222
expect(publishSpan.kind).toBe(SpanKind.PRODUCER);
@@ -221,7 +234,7 @@ describe('SNS - v3', () => {
221234
);
222235
expect(publishSpans.length).toBe(1);
223236
const publishSpan = publishSpans[0];
224-
expect(publishSpan.attributes[ATTR_MESSAGING_DESTINATION_NAME]).toBe(
237+
expect(publishSpan.attributes[SEMATTRS_MESSAGING_DESTINATION]).toBe(
225238
PhoneNumber
226239
);
227240
});

plugins/node/opentelemetry-instrumentation-aws-sdk/test/sqs.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
MESSAGINGDESTINATIONKINDVALUES_QUEUE,
3030
MESSAGINGOPERATIONVALUES_PROCESS,
3131
MESSAGINGOPERATIONVALUES_RECEIVE,
32+
SEMATTRS_MESSAGING_DESTINATION,
3233
SEMATTRS_MESSAGING_DESTINATION_KIND,
3334
SEMATTRS_MESSAGING_URL,
3435
} from '@opentelemetry/semantic-conventions';
@@ -404,6 +405,9 @@ describe('SQS', () => {
404405
expect(span.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND]).toEqual(
405406
MESSAGINGDESTINATIONKINDVALUES_QUEUE
406407
);
408+
expect(span.attributes[SEMATTRS_MESSAGING_DESTINATION]).toEqual(
409+
QueueName
410+
);
407411
expect(span.attributes[ATTR_MESSAGING_DESTINATION_NAME]).toEqual(
408412
QueueName
409413
);

0 commit comments

Comments
 (0)