Skip to content

ref: Export SPAN_KIND from core and drop OTel SpanKind imports - #21668

Merged
logaretm merged 4 commits into
developfrom
awad/deotlify-span-kind
Jun 24, 2026
Merged

ref: Export SPAN_KIND from core and drop OTel SpanKind imports#21668
logaretm merged 4 commits into
developfrom
awad/deotlify-span-kind

Conversation

@logaretm

@logaretmlogaretm commented Jun 19, 2026

Copy link
Copy Markdown
Member

While streamlining a few instrumentations I noticed sometimes we import from @opentelemetry/api in some instrumentations purely for the SPAN_KIND enum, so might as well just vendor it to make it easier.

So this exports a SPAN_KIND constant from @sentry/core so vendored instrumentations (and core itself) can set a span's kind without importing @opentelemetry/api solely for the SpanKind enum.

Add a `SPAN_KIND` const object (and derived `SpanKindValue` type) mirroring
OpenTelemetry's `SpanKind` enum values, so SDK code can set a span's kind
without importing `@opentelemetry/api` solely for the enum. `StartSpanOptions.kind`
now derives its type from `SPAN_KIND` to keep values and type in sync.
…entations
Replace `SpanKind` from `@opentelemetry/api` with the `SPAN_KIND` const from
`@sentry/core` in vendored instrumentations whose `kind` flows into Sentry's
`startSpan`/`startInactiveSpan`. Drops the `@opentelemetry/api` import entirely
from dataloader, mysql2, ioredis, mongoose, mongo, postgres, knex, and tedious;
trims it to a type-only/partial import for redis and kafka.
Instrumentations that pass `kind` into a real OTel `tracer.startSpan` are left
untouched, since the OTel API expects the `SpanKind` enum type.
…ription
Replace the bare `kind: 1` (with explanatory `// SpanKind.SERVER = 1` comment)
with the now-exported `SPAN_KIND.SERVER`, dropping the magic number.
Replace the locally-inlined `SPAN_KIND_CLIENT = 2` constant with `SPAN_KIND.CLIENT`
from `@sentry/core`, now that the shared constant exists.
@github-actions

github-actionsBot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize% ChangeChange
@sentry/browser27.45 kB--
@sentry/browser - with treeshaking flags25.88 kB--
@sentry/browser (incl. Tracing)45.94 kB--
@sentry/browser (incl. Tracing + Span Streaming)47.7 kB--
@sentry/browser (incl. Tracing, Profiling)50.73 kB--
@sentry/browser (incl. Tracing, Replay)85.14 kB--
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags74.73 kB--
@sentry/browser (incl. Tracing, Replay with Canvas)89.83 kB--
@sentry/browser (incl. Tracing, Replay, Feedback)102.49 kB--
@sentry/browser (incl. Feedback)44.62 kB--
@sentry/browser (incl. sendFeedback)32.24 kB--
@sentry/browser (incl. FeedbackAsync)37.38 kB--
@sentry/browser (incl. Metrics)28.52 kB--
@sentry/browser (incl. Logs)28.76 kB--
@sentry/browser (incl. Metrics & Logs)29.45 kB--
@sentry/react29.25 kB--
@sentry/react (incl. Tracing)48.24 kB--
@sentry/vue32.61 kB--
@sentry/vue (incl. Tracing)47.8 kB--
@sentry/svelte27.48 kB--
CDN Bundle29.84 kB--
CDN Bundle (incl. Tracing)47.85 kB--
CDN Bundle (incl. Logs, Metrics)31.39 kB--
CDN Bundle (incl. Tracing, Logs, Metrics)49.19 kB--
CDN Bundle (incl. Replay, Logs, Metrics)70.7 kB--
CDN Bundle (incl. Tracing, Replay)85.21 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics)86.48 kB--
CDN Bundle (incl. Tracing, Replay, Feedback)91.05 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics)92.31 kB--
CDN Bundle - uncompressed88.8 kB--
CDN Bundle (incl. Tracing) - uncompressed144.84 kB--
CDN Bundle (incl. Logs, Metrics) - uncompressed93.5 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed148.81 kB--
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed218.33 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed263.7 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed267.66 kB--
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed277.4 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed281.35 kB--
@sentry/nextjs (client)50.63 kB--
@sentry/sveltekit (client)46.33 kB--
@sentry/core/server75.95 kB+0.13%+96 B 🔺
@sentry/core/browser63.08 kB+0.11%+64 B 🔺
@sentry/node-core61.63 kB+0.01%+2 B 🔺
@sentry/node123.59 kB-0.02%-19 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection)69.95 kB--
@sentry/node/light50.55 kB-0.01%-1 B 🔽
@sentry/node - without tracing73.69 kB--
@sentry/aws-serverless84.89 kB-0.01%-1 B 🔽
@sentry/cloudflare (withSentry) - minified172.9 kB--
@sentry/cloudflare (withSentry)432.48 kB--

View base workflow run

@logaretm
logaretmforce-pushed the awad/deotlify-span-kind branch from 182ad1a to 113e778CompareJune 19, 2026 20:23
@logaretm
logaretm marked this pull request as ready for review June 22, 2026 13:49
@logaretm
logaretm requested a review from a team as a code ownerJune 22, 2026 13:49
@logaretm
logaretm requested review from JPeer264, andreiborza, mydea and nicohrubec and removed request for a teamJune 22, 2026 13:49
@logaretm
logaretm merged commit 291c1e3 into developJun 24, 2026
553 of 554 checks passed
@logaretm
logaretm deleted the awad/deotlify-span-kind branch June 24, 2026 12:58
andreiborza added a commit that referenced this pull request Jun 25, 2026
…21780)
Building up on #21668
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for freeto 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

@logaretm@mydea@nicohrubec