Skip to content

feat(core)!: Remove kind for spans, move to sentry.kind attribute#22528

Merged
mydea merged 7 commits into
developfrom
fn/span-kind
Jul 23, 2026
Merged

feat(core)!: Remove kind for spans, move to sentry.kind attribute#22528
mydea merged 7 commits into
developfrom
fn/span-kind

Conversation

@mydea

@mydea mydea commented Jul 23, 2026

Copy link
Copy Markdown
Member

This removes kind from start span options, and refactors all our usage to instead set the sentry.kind attribute directly.
This is one of the things we rely on for span description inferral, so removing this takes us a step closer to this.

While at it, this also aligns the values to actually be lowercase as specced.

@mydea mydea self-assigned this Jul 23, 2026
Comment thread packages/aws-serverless/src/integration/aws/vendored/aws-sdk.ts
/** An op for the span. This is a categorization for spans. */
op?: string;

/**

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Public API broken without deprecation

High Severity

This removes public surface without a deprecation path in a v10 minor: the kind option on StartSpanOptions, the SPAN_KIND / SpanKindValue exports from @sentry/core, and getSpanKind from @sentry/opentelemetry. The review rules require deprecation notices for public API removals and signature changes. Flagged because it was mentioned in this rules file.

Additional Locations (2)
Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 973aafc. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

need to add deprecation in follow up

Comment thread packages/deno/src/opentelemetry/tracer.ts
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.79 kB - -
@sentry/browser - with treeshaking flags 26.23 kB - -
@sentry/browser (incl. Tracing) 46.31 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.06 kB -0.04% -19 B 🔽
@sentry/browser (incl. Tracing, Profiling) 51.12 kB - -
@sentry/browser (incl. Tracing, Replay) 85.59 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.23 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 90.29 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 102.97 kB - -
@sentry/browser (incl. Feedback) 44.96 kB - -
@sentry/browser (incl. sendFeedback) 32.59 kB - -
@sentry/browser (incl. FeedbackAsync) 37.64 kB - -
@sentry/browser (incl. Metrics) 28.88 kB - -
@sentry/browser (incl. Logs) 29.11 kB - -
@sentry/browser (incl. Metrics & Logs) 29.8 kB - -
@sentry/react 29.59 kB - -
@sentry/react (incl. Tracing) 48.6 kB - -
@sentry/vue 33.22 kB - -
@sentry/vue (incl. Tracing) 48.28 kB - -
@sentry/svelte 27.81 kB - -
CDN Bundle 30.11 kB - -
CDN Bundle (incl. Tracing) 48.14 kB -0.04% -15 B 🔽
CDN Bundle (incl. Logs, Metrics) 31.69 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.47 kB -0.04% -16 B 🔽
CDN Bundle (incl. Replay, Logs, Metrics) 70.95 kB - -
CDN Bundle (incl. Tracing, Replay) 85.72 kB -0.02% -14 B 🔽
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.01 kB -0.02% -13 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) 91.49 kB -0.02% -14 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.78 kB -0.02% -10 B 🔽
CDN Bundle - uncompressed 89.77 kB - -
CDN Bundle (incl. Tracing) - uncompressed 144.84 kB -0.02% -28 B 🔽
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.48 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 148.82 kB -0.02% -28 B 🔽
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 219.24 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 264.08 kB -0.02% -28 B 🔽
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 268.04 kB -0.02% -28 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 277.78 kB -0.02% -28 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 281.74 kB -0.01% -28 B 🔽
@sentry/nextjs (client) 51.13 kB - -
@sentry/sveltekit (client) 46.75 kB - -
@sentry/core/server 80.07 kB -0.15% -113 B 🔽
@sentry/core/browser 51.9 kB -0.18% -91 B 🔽
@sentry/node 124.57 kB -0.06% -69 B 🔽
@sentry/node (incl. diagnostics channel injection) 149.97 kB -0.06% -86 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 70.03 kB - -
@sentry/node - without tracing 74.66 kB -0.15% -110 B 🔽
@sentry/aws-serverless 84.13 kB -0.16% -131 B 🔽
@sentry/cloudflare (withSentry) - minified 196.61 kB -0.02% -26 B 🔽
@sentry/cloudflare (withSentry) 483.83 kB -0.01% -44 B 🔽

View base workflow run

@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 3 potential issues.

There are 5 total unresolved issues (including 2 from previous reviews).

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 0863e20. Configure here.

Comment thread packages/opentelemetry/src/utils/parseSpanDescription.ts
Comment thread packages/opentelemetry/src/tracer.ts
hook: 'preprocessSpan',
callback: (streamedSpanJSON: StreamedSpanJSON, hint?: { spanKind?: number }) => void,
): () => void;
public on(hook: 'preprocessSpan', callback: (streamedSpanJSON: StreamedSpanJSON) => void): () => void;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

preprocessSpan hint removed undeprecated

Medium Severity

The public preprocessSpan hook no longer accepts the { spanKind } hint argument. External subscribers typing or depending on that second parameter break without a deprecation path. Flagged because it was mentioned in the PR review rules file.

Additional Locations (1)
Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 0863e20. Configure here.

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.

that's fine IMHO, since nothing else is in the hint

@mydea
mydea marked this pull request as ready for review July 23, 2026 12:30
@mydea
mydea requested review from a team as code owners July 23, 2026 12:30
@mydea
mydea requested review from andreiborza, chargome, isaacs and nicohrubec and removed request for a team July 23, 2026 12:30
Comment on lines 155 to 165
const opParts = ['http'];
const kind = attributes[SENTRY_KIND];

switch (kind) {
case SpanKind.CLIENT:
case 'client':
opParts.push('client');
break;
case SpanKind.SERVER:
case 'server':
opParts.push('server');
break;
}

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 code incorrectly reads the span kind from attributes[SENTRY_KIND], which is not available for standard OTel spans, leading to incorrect op and transaction names.
Severity: HIGH

Suggested Fix

Modify parseSpanDescription to get the span kind from the ReadableSpan.kind property directly, rather than relying on the SENTRY_KIND attribute which is populated later. This ensures the correct kind is used for determining the op and inferring the description.

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/opentelemetry/src/utils/parseSpanDescription.ts#L149-L165

Potential issue: The function `descriptionForHttpMethod` now reads the span kind from
`attributes[SENTRY_KIND]`. However, for spans from standard OpenTelemetry
instrumentations like `@opentelemetry/instrumentation-http`, this attribute is not yet
set when `parseSpanDescription` is called. The `sentry.kind` is derived from
`ReadableSpan.kind` later in the processing pipeline. This timing issue causes the span
`kind` to be `undefined` during description parsing, resulting in an incorrect `op`
(e.g., `'http'` instead of `'http.server'`) and preventing the correct inference of
transaction names from URL patterns.

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

@Lms24 Lms24 Jul 23, 2026

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.

Probably irrelevant for us, given otel spans go through our tracer and we set the attribute there 🤔

@andreiborza andreiborza left a comment

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.

LGTM, but could we wait with these kind of refactors until after the otel vendored instrumentations are removed from develop please? It's cumbersome to review otherwise.

@Lms24 Lms24 left a comment

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.

nit: can/should we add a feat(core)!: to the PR/commit? It's behaviour breaking. Not sure how we handled non-API-breaking but still behaviour-breaking changes so far this.

hook: 'preprocessSpan',
callback: (streamedSpanJSON: StreamedSpanJSON, hint?: { spanKind?: number }) => void,
): () => void;
public on(hook: 'preprocessSpan', callback: (streamedSpanJSON: StreamedSpanJSON) => void): () => void;

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.

that's fine IMHO, since nothing else is in the hint

Comment on lines 155 to 165
const opParts = ['http'];
const kind = attributes[SENTRY_KIND];

switch (kind) {
case SpanKind.CLIENT:
case 'client':
opParts.push('client');
break;
case SpanKind.SERVER:
case 'server':
opParts.push('server');
break;
}

@Lms24 Lms24 Jul 23, 2026

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.

Probably irrelevant for us, given otel spans go through our tracer and we set the attribute there 🤔

@mydea mydea changed the title feat(core): Remove kind for spans, move to sentry.kind attribute feat(core)!: Remove kind for spans, move to sentry.kind attribute Jul 23, 2026
@mydea
mydea merged commit 3a01e08 into develop Jul 23, 2026
550 of 552 checks passed
@mydea
mydea deleted the fn/span-kind branch July 23, 2026 13:40
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.

3 participants