feat(cloudflare): Support tracing for queue producer#20529
feat(cloudflare): Support tracing for queue producer#20529
Conversation
ef6442b to
b9b0533
Compare
size-limit report 📦
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b9b0533. Configure here.
| const totalBodySize = messageArray.reduce<number>((acc, m) => { | ||
| const size = getBodySize(m.body); | ||
| return size === undefined ? acc : acc + size; | ||
| }, 0); |
There was a problem hiding this comment.
sendBatch reports body size 0 instead of undefined
Low Severity
The sendBatch body size calculation uses reduce with an initial value of 0, so totalBodySize is always a number (minimum 0). When all messages have unsizable bodies (e.g., null or circular references), totalBodySize will be 0 and messaging.message.body.size gets set to 0. This is inconsistent with send, which correctly passes undefined from getBodySize when the body can't be sized, causing the attribute to be omitted. The sendBatch path emits a misleading 0 instead.
Reviewed by Cursor Bugbot for commit b9b0533. Configure here.
|
👋 @mydea, @logaretm, @andreiborza — Please review this PR when you get a chance! |


closes #14387
closes JS-1813
We already had support for the consumer, but the producer was never instrumented. Which means we only knew when a queue was consumed, but never when it was produced.
Example trace (producer new): https://sentry-sdks.sentry.io/explore/traces/trace/7ee71fd6dc8b4ce1a22b1bb9f9610b26/
Example trace (consumer): https://sentry-sdks.sentry.io/explore/traces/trace/486eb86cd02146279c4d547efb4cabab/
In
wrangler.jsonca producer needs to be configured viaqueues.producers:{ "queues": { "producers": [ { "queue": "test-queue", "binding": "MY_QUEUE", }, ], }, }Once this happens the
MY_QUEUEis available in theenvvariable, which we already instrument. With that we only addisQueueinsideinstrumentEnv.tsand get instrument the producer:Additional info
We are using
messaging.batch.message_count, which is not yet in our semantic conventions: https://getsentry.github.io/sentry-conventions/attributes/messaging/But it was already used before in our queue consumer logic. So the only thing is that it needs to be added first: getsentry/sentry-conventions#338 to make it official