Skip to content

Commit 0078079

Browse files
msonnbclaude
andcommitted
feat(google-cloud-serverless)!: Use grpc span op for GCP gRPC calls
The service suffix fragmented grouping and was unbounded for non- `googleapis.com` service paths. Service identity moves to `rpc.service`, with `rpc.system.name` and `rpc.method` added alongside. Ref: JS-3105 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent c6e3775 commit 0078079

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

packages/google-cloud-serverless/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"access": "public"
4242
},
4343
"dependencies": {
44+
"@sentry/conventions": "^0.16.0",
4445
"@sentry/core": "10.67.0",
4546
"@sentry/node": "10.67.0"
4647
},

packages/google-cloud-serverless/src/integrations/google-cloud-grpc.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { RPC_METHOD, RPC_SERVICE, RPC_SYSTEM_NAME } from '@sentry/conventions/attributes';
2+
import { FAAS_GRPC_SPAN_OP } from '@sentry/conventions/op';
13
import type { Client, IntegrationFn } from '@sentry/core';
24
import { defineIntegration, fill, getClient, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
35
import { startInactiveSpan } from '@sentry/node';
@@ -106,9 +108,12 @@ export function fillGrpcFunction(stub: Stub, serviceIdentifier: string, methodNa
106108
const span = startInactiveSpan({
107109
name: `${callType} ${methodName}`,
108110
onlyIfParent: true,
109-
op: `grpc.${serviceIdentifier}`,
111+
op: FAAS_GRPC_SPAN_OP,
110112
attributes: {
111113
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.grpc.serverless',
114+
[RPC_SYSTEM_NAME]: 'grpc',
115+
[RPC_SERVICE]: serviceIdentifier,
116+
[RPC_METHOD]: methodName,
112117
},
113118
});
114119
ret.on('status', () => {

packages/google-cloud-serverless/test/integrations/google-cloud-grpc.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,12 @@ describe('GoogleCloudGrpc tracing', () => {
142142
expect(mockStartInactiveSpan).toHaveBeenCalledWith({
143143
name: 'unary call unaryMethod',
144144
onlyIfParent: true,
145-
op: 'grpc.test-service',
145+
op: 'grpc',
146146
attributes: {
147147
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.grpc.serverless',
148+
'rpc.system.name': 'grpc',
149+
'rpc.service': 'test-service',
150+
'rpc.method': 'unaryMethod',
148151
},
149152
});
150153
});

0 commit comments

Comments
 (0)