From 1c089b00110176d247d77bc9e8858c5e8ebf1a9f Mon Sep 17 00:00:00 2001 From: Alex Bouma Date: Mon, 7 Jul 2025 23:38:25 +0200 Subject: [PATCH 1/2] Calculate retries not attempts The `message.attempts` property starts at 1 so we were calculating the number of attempts not the number of retries. Since attempt 2 is the first retry. --- packages/cloudflare/src/handler.ts | 2 +- packages/cloudflare/test/handler.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cloudflare/src/handler.ts b/packages/cloudflare/src/handler.ts index 3640d3cf7229..c4b36206c957 100644 --- a/packages/cloudflare/src/handler.ts +++ b/packages/cloudflare/src/handler.ts @@ -175,7 +175,7 @@ export function withSentry acc + message.attempts, 0), + 'messaging.message.retry.count': batch.messages.reduce((acc, message) => acc + message.attempts - 1, 0), [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'queue.process', [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.queue', [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task', diff --git a/packages/cloudflare/test/handler.test.ts b/packages/cloudflare/test/handler.test.ts index 2e5c0f836e89..ddd4b0010ec0 100644 --- a/packages/cloudflare/test/handler.test.ts +++ b/packages/cloudflare/test/handler.test.ts @@ -843,7 +843,7 @@ describe('withSentry', () => { 'messaging.destination.name': batch.queue, 'messaging.system': 'cloudflare', 'messaging.batch.message_count': batch.messages.length, - 'messaging.message.retry.count': batch.messages.reduce((acc, message) => acc + message.attempts, 0), + 'messaging.message.retry.count': batch.messages.reduce((acc, message) => acc + message.attempts - 1, 0), 'sentry.sample_rate': 1, 'sentry.source': 'task', }, From 62790885b37317d47753764ca706b2247c9061f7 Mon Sep 17 00:00:00 2001 From: Alex Bouma Date: Tue, 8 Jul 2025 10:40:09 +0200 Subject: [PATCH 2/2] CS --- packages/cloudflare/src/handler.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/cloudflare/src/handler.ts b/packages/cloudflare/src/handler.ts index c4b36206c957..001ab55049ab 100644 --- a/packages/cloudflare/src/handler.ts +++ b/packages/cloudflare/src/handler.ts @@ -175,7 +175,10 @@ export function withSentry acc + message.attempts - 1, 0), + 'messaging.message.retry.count': batch.messages.reduce( + (acc, message) => acc + message.attempts - 1, + 0, + ), [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'queue.process', [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.queue', [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',