Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit d276dd7

Browse files
author
Amir Blum
committed
fix: dont add sqs MessageAttribute if we are over the limit
1 parent b235f20 commit d276dd7

File tree

1 file changed

+10
-2
lines changed
  • packages/plugin-aws-sdk/src/services

1 file changed

+10
-2
lines changed

packages/plugin-aws-sdk/src/services/sqs.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ export const END_SPAN_FUNCTION = Symbol(
3131
"opentelemetry.plugin.aws-sdk.sqs.end_span"
3232
);
3333

34+
// https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-quotas.html
35+
const SQS_MAX_MESSAGE_ATTRIBUTES = 10;
36+
3437
const contextSetterFunc = (
3538
messageAttributes: AWS.SQS.MessageBodyAttributeMap,
3639
key: string,
@@ -95,8 +98,13 @@ export class SqsServiceExtension implements ServiceExtension {
9598

9699
const params: Record<string, any> = (request as any).params;
97100
const attributes = params.MessageAttributes || {};
98-
propagation.inject(attributes, contextSetterFunc);
99-
params.MessageAttributes = attributes;
101+
if (attributes.length < SQS_MAX_MESSAGE_ATTRIBUTES) {
102+
propagation.inject(attributes, contextSetterFunc);
103+
params.MessageAttributes = attributes;
104+
} else {
105+
// TODO: in this case we are not setting the context propagtion for consumers
106+
// how to log the issue?
107+
}
100108
}
101109
break;
102110
}

0 commit comments

Comments
 (0)