Skip to content

Commit 1d58df1

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 4b43c39 commit 1d58df1

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

MIGRATION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ Span operations (`sentry.op`) were aligned with the values defined in `@sentry/c
263263
- `@sentry/node`: Firebase Functions spans now use `function.gcp` instead of `http.request`. The wrapper instruments all function trigger types (HTTP, Firestore, scheduler, storage), so a fixed HTTP op was wrong. The trigger type remains available on the `faas.trigger` attribute.
264264
- `@sentry/google-cloud-serverless`: `googleCloudHttpIntegration` spans now use `http.client` instead of `http.client.<service>`. The service is now identified by the new `server.address` attribute.
265265
- `@sentry/opentelemetry`: HTTP spans inferred from OpenTelemetry attributes no longer get a `.prefetch` suffix, so prefetch requests use `http.client`/`http.server` like any other request. Prefetch requests remain identifiable via the `sentry.http.prefetch` attribute.
266+
- `@sentry/google-cloud-serverless`: `googleCloudGrpcIntegration` spans now use `grpc` instead of `grpc.<service>`. The service is now identified by the new `rpc.service` attribute, alongside `rpc.system.name` and `rpc.method`.
266267

267268
If you reference these operations in dashboards, alerts, or `beforeSendSpan`, update them to the new values.
268269

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import { RPC_METHOD, RPC_SERVICE, RPC_SYSTEM_NAME, SENTRY_ORIGIN } from '@sentry/conventions/attributes';
2+
import { FAAS_GRPC_SPAN_OP } from '@sentry/conventions/op';
13
import type { Client, IntegrationFn } from '@sentry/core';
2-
import { defineIntegration, fill, getClient, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
4+
import { defineIntegration, fill, getClient } from '@sentry/core';
35
import { startInactiveSpan } from '@sentry/node';
46
import type { EventEmitter } from 'events';
57

@@ -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: {
111-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.grpc.serverless',
113+
[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)