Skip to content

feat(server-utils): Emit low cardinality graphql span names - #23542

Open
andreiborza wants to merge 7 commits into
developfrom
ab/graphql-low-cardinality-span-names
Open

feat(server-utils): Emit low cardinality graphql span names#23542
andreiborza wants to merge 7 commits into
developfrom
ab/graphql-low-cardinality-span-names

Conversation

@andreiborza

@andreiborza andreiborza commented Aug 24, 2026

Copy link
Copy Markdown
Member

What

With span streaming enabled, graphql spans are now named after the operation type (GraphQL query), or GraphQL Operation where the SDK has no operation type, instead of after the client-supplied operation name or resolver field path. useOperationNameForRootSpan also no longer renames the enclosing root span. Every graphql span now carries graphql.processing.type, which says whether it is a parse, validate, execute or resolve span.

Why

Span names must be low cardinality when span streaming is enabled, and the operation name and field path both come from the client. A low-cardinality name cannot also say which part of request processing a span covers, so graphql.processing.type carries that instead, following the GraphQL OpenTelemetry Working Group proposal in open-telemetry/semantic-conventions#3515. Blocked on getsentry/sentry-conventions#572, which defines the attribute; the key is inlined until that ships.

Closes: #23526

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.57 kB - -
@sentry/browser - with treeshaking flags 26.92 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.82 kB - -
@sentry/browser (incl. Tracing) 48.37 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.39 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.27 kB - -
@sentry/browser (incl. Tracing, Replay) 87.77 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.23 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.47 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.14 kB - -
@sentry/browser (incl. Feedback) 45.81 kB - -
@sentry/browser (incl. sendFeedback) 33.36 kB - -
@sentry/browser (incl. FeedbackAsync) 38.47 kB - -
@sentry/browser (incl. Metrics) 29.52 kB - -
@sentry/browser (incl. Logs) 29.8 kB - -
@sentry/browser (incl. Metrics & Logs) 30.45 kB - -
@sentry/react 30.33 kB - -
@sentry/react (incl. Tracing) 50.56 kB - -
@sentry/vue 35.41 kB - -
@sentry/vue (incl. Tracing) 50.37 kB - -
@sentry/svelte 28.6 kB - -
CDN Bundle 30.32 kB - -
CDN Bundle (incl. Tracing) 48.9 kB - -
CDN Bundle (incl. Logs, Metrics) 32.54 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 50.78 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 72.91 kB - -
CDN Bundle (incl. Tracing, Replay) 86.35 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.19 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.09 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.04 kB - -
CDN Bundle - uncompressed 89.94 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.25 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.23 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 151.94 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.18 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 265.52 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.2 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.22 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 284.89 kB - -
@sentry/nextjs (client) 53.12 kB - -
@sentry/sveltekit (client) 48.8 kB - -
@sentry/core/server 64.95 kB - -
@sentry/core/browser 52.11 kB - -
@sentry/node 117.67 kB +0.13% +149 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.18 kB - -
@sentry/node - without tracing 82.08 kB +0.03% +24 B 🔺
@sentry/aws-serverless 91.51 kB +0.03% +22 B 🔺
@sentry/cloudflare (withSentry) - minified 196.3 kB - -
@sentry/cloudflare (withSentry) 485.93 kB - -

View base workflow run

andreiborza and others added 2 commits August 24, 2026 21:13
With span streaming enabled, name graphql spans after the operation type
or the graphql phase, and stop renaming the enclosing root span with the
operation. Names are unchanged in static mode.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013bjBXkGkJo8eL8hkz48byi
….processing.type

Follows the GraphQL OpenTelemetry Working Group, which added a dedicated
attribute for the processing type rather than widening
graphql.operation.type. Parse, validate and resolve spans take the static
fallback name and carry the phase as an attribute instead.

Claude-Session: https://claude.ai/code/session_013bjBXkGkJo8eL8hkz48byi
@andreiborza
andreiborza force-pushed the ab/graphql-low-cardinality-span-names branch from f11596c to ca3bd08 Compare August 24, 2026 19:15

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ca3bd08. Configure here.

@andreiborza
andreiborza marked this pull request as ready for review August 25, 2026 09:41
@andreiborza
andreiborza requested review from a team as code owners August 25, 2026 09:41
@andreiborza
andreiborza requested review from JPeer264, Lms24, isaacs and msonnb and removed request for a team and isaacs August 25, 2026 09:41
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: GRAPHQL,
[GRAPHQL_PROCESSING_TYPE]: PROCESSING_TYPE_EXECUTE,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The setupOperationChannel function hardcodes the graphql.processing.type attribute to 'execute', causing GraphQL subscription operations to be incorrectly tagged.
Severity: LOW

Suggested Fix

Modify setupOperationChannel to accept a processingType parameter. Pass 'execute' for execute channels and a new 'subscribe' value for subscribe channels. This will ensure subscription spans are correctly tagged with graphql.processing.type = 'subscribe'.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/server-utils/src/integrations/graphql/graphql-dc-subscriber.ts#L217

Potential issue: The `setupOperationChannel` function is used for both GraphQL `execute`
and `subscribe` operations. However, it hardcodes the `GRAPHQL_PROCESSING_TYPE`
attribute to `PROCESSING_TYPE_EXECUTE` ('execute') for all operations it handles. As a
result, spans for GraphQL subscription operations are incorrectly tagged with
`graphql.processing.type = 'execute'`. This is a semantic error, as subscriptions are a
distinct operation type in GraphQL. This will mislead users who are filtering or
analyzing telemetry data, as they won't be able to distinguish subscription operations
from execute operations based on this attribute.

Did we get this right? 👍 / 👎 to inform future reviews.

import { loggingTransport } from '@sentry-internal/node-integration-tests';

Sentry.init({
traceLifecycle: 'stream',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

superduper-l: Theoretically we don't need to add this line as it is on by default


return startInactiveSpan({
name:
client && hasSpanStreamingEnabled(client) ? GRAPHQL_SPAN_NAME_FALLBACK : `${SPAN_NAME_RESOLVE} ${path.join('.')}`,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suuuper-l: You think this could be a helper function? Something like getSpanName(`${SPAN_NAME_RESOLVE} ${path.join('.')}`) could maybe safe some bytes as it is used 9 times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Emit low cardinality graphql span names

2 participants