-
Notifications
You must be signed in to change notification settings - Fork 339
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: add pre and post receive message callbacks #426
Conversation
CLA Assistant Lite bot CLA CHECK All Contributors have signed the CLA |
Code Climate has analyzed commit 95c12dc and detected 1 issue on this pull request. Here's the issue category breakdown:
The test coverage on the diff in this pull request is 100.0% (80% is the threshold). This pull request will bring the total coverage in the repository to 97.0% (0.0% change). View more on Code Climate. |
Hey, thanks for the PR! If you could just follow the instructions here first that'd be great: #426 (comment) After that, you just need to run the command to format your code (that's why the tests are currently erroring). There is a complexity issue from CodeClimate but we can pick this up as later clean up, I don't think it's entirely too bad. Aside from that, do you have an example of where you're using OpenTelemetry with SQS Consumer? I'd be interested in how this is being used, not had someone mention that they're using it before. |
I have read the CLA Document and I hereby sign the CLA |
recheck |
Sure :) So here's where I have the Consumer wrapped: https://github.com/standardnotes/server/blob/1632c83217d0f466e8686e13829fd1ce1881a252/packages/domain-events-infra/src/Infra/SQS/SQSDomainEventSubscriberFactory.ts Here is where I have the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it does the job to me, thanks!
Thanks, that's super helpful for us to understand use cases. |
@nicholasgriffintn any chances for a merge :) ? |
Hey, yeah it'll be merged just before we're ready to create a release, which will be Monday if I don't get to it any time sooner, leaving it un merged so we don't forget to release it. |
Released as v7.4.0-canary.0, we'll be testing that version and then release it as 7.4.0 once we're happy with the changes. |
Resolves #17
Description:
This adds an option to hook your code just before and right after the SQS Client sends the
ReceiveMessageCommand
.Type of change:
Why is this change required?:
This is a change that is required if you'd like to use OpenTelemetry in an organised way with their official js instrumentation for AWS SDK.
The way open telemetry works is that it creates
Traces
for what's going on in a distributed system. Think of them as a request or single SQS message processing. Those traces are then broken down intoSpans
later on for things like db communication, http request etc. Usually the top level span you'd want to create in a trace is one that is representing the consumer service. And that is where the problem kicks in. The way that OpenTelemetry AWS SDK Instrumentation works is that it patches the module exports of the SQS ClientBy doing so it is able to wrap the SQS communication of
ReceiveMessageCommand
into aSegment
of its own. So this way when you visualise your telemetry you are stuck with having the SQS queue as a service instead of the actual consumer of the SQS queue. Hooking up on thehandleMessage
function in order to wrap the top level segment is a bit too late since theReceiveMessageCommand
has been already executed at this point.Code changes:
ConsumerOptions
Checklist: