Skip to content

Commit 608b31d

Browse files
committed
Add missing telemetry for empty Supabase queue consumer responses
1 parent 8298d8d commit 608b31d

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

packages/core/src/integrations/supabase.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,16 @@ const _instrumentRpcConsumer = (target: unknown, thisArg: unknown, argumentsList
843843
DEBUG_BUILD && debug.log('Consumer received empty response', { queueName });
844844
span.setStatus({ code: SPAN_STATUS_OK });
845845
span.setAttribute('messaging.batch.message_count', 0);
846+
// Set retry count to 0 for empty responses (no messages to retry)
847+
span.setAttribute('messaging.message.retry.count', 0);
848+
// Create breadcrumb for empty queue polling (consistent with non-empty responses)
849+
const breadcrumbData: Record<string, unknown> = {
850+
'messaging.batch.message_count': 0,
851+
};
852+
if (queueName) {
853+
breadcrumbData['messaging.destination.name'] = queueName;
854+
}
855+
_createQueueBreadcrumb('queue.process', queueName, breadcrumbData);
846856
return res;
847857
}
848858

packages/core/test/lib/integrations/supabase-queues.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,32 @@ describe('Supabase Queue Instrumentation', () => {
942942
}),
943943
);
944944
});
945+
946+
it('should create breadcrumb for empty consumer response', async () => {
947+
const mockResponse: SupabaseResponse = {
948+
data: [],
949+
status: 200,
950+
};
951+
952+
mockRpcFunction.mockResolvedValue(mockResponse);
953+
instrumentSupabaseClient(mockSupabaseClient);
954+
955+
await mockSupabaseClient.rpc('pop', {
956+
queue_name: 'empty-queue',
957+
});
958+
959+
expect(addBreadcrumbSpy).toHaveBeenCalledWith(
960+
expect.objectContaining({
961+
type: 'supabase',
962+
category: 'queue.process',
963+
message: 'queue.process(empty-queue)',
964+
data: expect.objectContaining({
965+
'messaging.destination.name': 'empty-queue',
966+
'messaging.batch.message_count': 0,
967+
}),
968+
}),
969+
);
970+
});
945971
});
946972

947973
describe('Span Attributes', () => {

0 commit comments

Comments
 (0)