Skip to content

Commit a54be32

Browse files
committed
Remove receive alias and fix generic RPC span attributes
1 parent 4f6b955 commit a54be32

File tree

6 files changed

+21
-49
lines changed

6 files changed

+21
-49
lines changed

dev-packages/browser-integration-tests/suites/integrations/supabase/generic-rpc/test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ sentryTest(
5050
'sentry.op': 'db',
5151
'sentry.origin': 'auto.db.supabase',
5252
'db.system': 'postgresql',
53-
'db.operation': 'insert',
54-
'db.table': 'my_custom_function',
53+
'db.operation': 'rpc',
5554
'db.params': { param1: 'value1' },
5655
}),
5756
});

dev-packages/e2e-tests/test-applications/supabase-nextjs/pages/api/queue/batch-flow.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
2929
return res.status(500).json({ error: `Send batch failed: ${sendError.message}` });
3030
}
3131

32-
const { data: receiveData, error: receiveError } = await supabaseClient.rpc('receive', {
32+
const { data: readData, error: readError } = await supabaseClient.rpc('read', {
3333
queue_name: 'batch-flow-queue',
34-
vt: 30,
35-
qty: 3,
34+
sleep_seconds: 30,
35+
n: 3,
3636
});
3737

38-
if (receiveError) {
39-
return res.status(500).json({ error: `Receive failed: ${receiveError.message}` });
38+
if (readError) {
39+
return res.status(500).json({ error: `Read failed: ${readError.message}` });
4040
}
4141

42-
const processedMessages = receiveData?.map((msg: Record<string, unknown>) => ({
42+
const processedMessages = readData?.map((msg: Record<string, unknown>) => ({
4343
messageId: msg.msg_id,
4444
message: msg.message,
4545
}));
4646

47-
const messageIds = receiveData?.map((msg: Record<string, unknown>) => msg.msg_id).filter(Boolean);
47+
const messageIds = readData?.map((msg: Record<string, unknown>) => msg.msg_id).filter(Boolean);
4848
if (messageIds && messageIds.length > 0) {
4949
const { error: archiveError } = await supabaseClient.rpc('archive', {
5050
queue_name: 'batch-flow-queue',
@@ -61,7 +61,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
6161
batchSize: 3,
6262
produced: { messageIds: sendData },
6363
consumed: {
64-
count: receiveData?.length || 0,
64+
count: readData?.length || 0,
6565
messages: processedMessages,
6666
},
6767
});

dev-packages/e2e-tests/test-applications/supabase-nextjs/pages/api/queue/producer-consumer-flow.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
1717
return res.status(500).json({ error: `Send failed: ${sendError.message}` });
1818
}
1919

20-
const { data: receiveData, error: receiveError } = await supabaseClient.rpc('receive', {
20+
const { data: readData, error: readError } = await supabaseClient.rpc('read', {
2121
queue_name: 'e2e-flow-queue',
22-
vt: 30,
23-
qty: 1,
22+
sleep_seconds: 30,
23+
n: 1,
2424
});
2525

26-
if (receiveError) {
27-
return res.status(500).json({ error: `Receive failed: ${receiveError.message}` });
26+
if (readError) {
27+
return res.status(500).json({ error: `Read failed: ${readError.message}` });
2828
}
2929

30-
const processedMessage = receiveData?.[0];
30+
const processedMessage = readData?.[0];
3131

3232
if (processedMessage?.msg_id) {
3333
const { error: archiveError } = await supabaseClient.rpc('archive', {

dev-packages/e2e-tests/test-applications/supabase-nextjs/supabase/migrations/20250515080602_enable-queues.sql

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -141,29 +141,6 @@ $$;
141141

142142
comment on function pgmq_public.read(queue_name text, sleep_seconds integer, n integer) is 'Reads up to "n" messages from the specified queue with an optional "sleep_seconds" (visibility timeout).';
143143

144-
-- Create receive function (alias for read with different parameter names for E2E test compatibility)
145-
create or replace function pgmq_public.receive(
146-
queue_name text,
147-
vt integer,
148-
qty integer
149-
)
150-
returns setof pgmq.message_record
151-
language plpgsql
152-
set search_path = ''
153-
as $$
154-
begin
155-
return query
156-
select *
157-
from pgmq.read(
158-
queue_name := queue_name,
159-
vt := vt,
160-
qty := qty
161-
);
162-
end;
163-
$$;
164-
165-
comment on function pgmq_public.receive(queue_name text, vt integer, qty integer) is 'Alias for read() - reads messages from the specified queue with visibility timeout.';
166-
167144
-- Grant execute permissions on wrapper functions to roles
168145
grant execute on function pgmq_public.pop(text) to postgres, service_role, anon, authenticated;
169146
grant execute on function pgmq.pop(text) to postgres, service_role, anon, authenticated;
@@ -174,8 +151,6 @@ grant execute on function pgmq.send(text, jsonb, integer) to postgres, service_r
174151
grant execute on function pgmq_public.send_batch(text, jsonb[], integer) to postgres, service_role, anon, authenticated;
175152
grant execute on function pgmq.send_batch(text, jsonb[], integer) to postgres, service_role, anon, authenticated;
176153

177-
grant execute on function pgmq_public.receive(text, integer, integer) to postgres, service_role, anon, authenticated;
178-
179154
grant execute on function pgmq_public.archive(text, bigint[]) to postgres, service_role, anon, authenticated;
180155

181156
grant execute on function pgmq_public.delete(text, bigint) to postgres, service_role, anon, authenticated;

dev-packages/e2e-tests/test-applications/supabase-nextjs/tests/performance.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ test('Sends server-side Supabase RPC spans and breadcrumbs', async ({ page, base
6262
expect(rpcSpan).toBeDefined();
6363
expect(rpcSpan?.data).toEqual(
6464
expect.objectContaining({
65-
'db.operation': 'insert',
66-
'db.table': 'get_supabase_status',
65+
'db.operation': 'rpc',
6766
'db.system': 'postgresql',
6867
'sentry.op': 'db',
6968
'sentry.origin': 'auto.db.supabase',
@@ -76,7 +75,7 @@ test('Sends server-side Supabase RPC spans and breadcrumbs', async ({ page, base
7675
transactionEvent.breadcrumbs?.some(
7776
breadcrumb =>
7877
breadcrumb?.type === 'supabase' &&
79-
breadcrumb?.category === 'db.insert' &&
78+
breadcrumb?.category === 'db.rpc' &&
8079
typeof breadcrumb?.message === 'string' &&
8180
breadcrumb.message.includes('get_supabase_status'),
8281
),

packages/core/src/integrations/supabase.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ function instrumentRpcConsumer(
901901
return instrumentGenericRpc(target, thisArg, argumentsList);
902902
}
903903

904-
const typedParams = queueParams as { queue_name?: string; vt?: number; qty?: number };
904+
const typedParams = queueParams as { queue_name?: string; sleep_seconds?: number; n?: number };
905905
const queueName = typedParams.queue_name;
906906

907907
if (!queueName) {
@@ -1019,7 +1019,7 @@ function createRpcProxyHandler(): ProxyHandler<(...args: unknown[]) => unknown>
10191019
try {
10201020
const normalizedName = normalizeRpcFunctionName(argumentsList[0]);
10211021
const isProducerSpan = normalizedName === 'send' || normalizedName === 'send_batch';
1022-
const isConsumerSpan = normalizedName === 'pop' || normalizedName === 'receive' || normalizedName === 'read';
1022+
const isConsumerSpan = normalizedName === 'pop' || normalizedName === 'read';
10231023

10241024
if (isProducerSpan) {
10251025
return instrumentRpcProducer(target, thisArg, argumentsList);
@@ -1058,8 +1058,7 @@ function instrumentGenericRpc(
10581058
builder.then = function (onfulfilled?: (value: unknown) => unknown, onrejected?: (reason: unknown) => unknown) {
10591059
const attributes: Record<string, unknown> = {
10601060
'db.system': 'postgresql',
1061-
'db.operation': 'insert', // RPC calls use POST which maps to 'insert'
1062-
'db.table': functionName,
1061+
'db.operation': 'rpc',
10631062
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.supabase',
10641063
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'db',
10651064
};
@@ -1091,7 +1090,7 @@ function instrumentGenericRpc(
10911090

10921091
const breadcrumb: SupabaseBreadcrumb = {
10931092
type: 'supabase',
1094-
category: 'db.insert',
1093+
category: 'db.rpc',
10951094
message: `rpc(${functionName})`,
10961095
};
10971096

0 commit comments

Comments
 (0)