Skip to content
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

feat: config option to extract sqs context from message payload #737

Merged
merged 18 commits into from
Nov 17, 2021

Conversation

habmic
Copy link
Contributor

@habmic habmic commented Nov 14, 2021

Which problem is this PR solving?

  • Context propagation between SNS to SQS didn't work without enabling AWS raw message delivery feature
  • By default SNS message attributes are embedded within the payload when set to SQS

Short description of the changes

  • Added a configuration (sqsExtractContextPropagationFromPayload ) that parse and extract the context propagation headers from the SQS payload ( off be default )

Copy link
Member

@blumamir blumamir 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 Nov 15, 2021

Codecov Report

Merging #737 (2bc3b2d) into main (82ebc49) will decrease coverage by 0.49%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #737      +/-   ##
==========================================
- Coverage   96.87%   96.37%   -0.50%     
==========================================
  Files          11       26      +15     
  Lines         640     1767    +1127     
  Branches      126      231     +105     
==========================================
+ Hits          620     1703    +1083     
- Misses         20       64      +44     
Impacted Files Coverage Δ
...y-instrumentation-aws-sdk/src/services/dynamodb.ts 100.00% <0.00%> (ø)
...etry-instrumentation-aws-sdk/test/dynamodb.test.ts 100.00% <0.00%> (ø)
...ry-instrumentation-aws-sdk/test/aws-sdk-v3.test.ts 100.00% <0.00%> (ø)
...emetry-instrumentation-aws-sdk/src/services/sns.ts 93.33% <0.00%> (ø)
...opentelemetry-instrumentation-aws-sdk/src/utils.ts 97.29% <0.00%> (ø)
...etry-instrumentation-aws-sdk/test/testing-utils.ts 100.00% <0.00%> (ø)
...opentelemetry-instrumentation-aws-sdk/src/enums.ts 100.00% <0.00%> (ø)
...ry-instrumentation-aws-sdk/test/aws-sdk-v2.test.ts 100.00% <0.00%> (ø)
...ntation-aws-sdk/src/services/ServicesExtensions.ts 100.00% <0.00%> (ø)
...telemetry-instrumentation-aws-sdk/test/sns.test.ts 100.00% <0.00%> (ø)
... and 5 more

@blumamir
Copy link
Member

Is anyone else planning to review this? if not I'll merge today

@blumamir blumamir changed the title feat: sqs payload context feat: config option to extract sqs context from message payload Nov 17, 2021
@blumamir blumamir merged commit 28e2113 into open-telemetry:main Nov 17, 2021

const responseMockSuccess = {
requestId: '0000000000000',
error: null,
};

const extractContextSpy = sinon.spy(
Copy link
Member

Choose a reason for hiding this comment

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

Creating a spy on this scope effects all tests. You could move it into the relevant test/testsuite and instead of calling resetHistory() you could create a new spy for each test and use sinon.restore() after each test.


it('should extract from payload', async () => {
const traceparent = {
traceparent: {
Copy link
Member

@Flarna Flarna Nov 17, 2021

Choose a reason for hiding this comment

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

Is this object structure documented somewhere? How should it look like for other propagators like e.g. Baggage or B3?

@Flarna
Copy link
Member

Flarna commented Nov 17, 2021

Seems my review was too late :o) but there are anyway no blockers.

But I wonder that support for extract is added but not for inject.

@blumamir
Copy link
Member

blumamir commented Nov 18, 2021

@Flarna Thanks for adding a review :)
@habmic - interested in implementing the above sinon refactor in a new PR?

@blumamir
Copy link
Member

But I wonder that support for extract is added but not for inject.

Inject is always injecting the propagation headers into the message attributes at time of "Publish" \ "SendMessage"
When SNS forwards the message to SQS, it can place these headers as message metadata, or embed them into the payload. This is a configuration option for the SNS-SQS subscription.

This PR is about support for extracting the context for the second option - taking them from message payload, which is why only extract is relevant

@dyladan dyladan mentioned this pull request Feb 28, 2022
@dyladan dyladan mentioned this pull request Jan 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants