Skip to content

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

Draft
logaretm wants to merge 4 commits into
developfrom
awad/deotlify-span-kind
Draft

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

Conversation

@logaretm

@logaretm logaretm 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.

logaretm added 4 commits June 19, 2026 15:55
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-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.45 kB - -
@sentry/browser - with treeshaking flags 25.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 flags 74.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/react 29.25 kB - -
@sentry/react (incl. Tracing) 48.24 kB - -
@sentry/vue 32.61 kB - -
@sentry/vue (incl. Tracing) 47.8 kB - -
@sentry/svelte 27.48 kB - -
CDN Bundle 29.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 - uncompressed 88.8 kB - -
CDN Bundle (incl. Tracing) - uncompressed 144.84 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 93.5 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 148.81 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 218.33 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 263.7 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 267.66 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 277.4 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 281.35 kB - -
@sentry/nextjs (client) 50.63 kB - -
@sentry/sveltekit (client) 46.33 kB - -
@sentry/core/server 75.95 kB +0.13% +96 B 🔺
@sentry/core/browser 63.08 kB +0.11% +64 B 🔺
@sentry/node-core 61.63 kB +0.01% +2 B 🔺
@sentry/node 123.59 kB -0.02% -19 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 69.95 kB - -
@sentry/node/light 50.55 kB -0.01% -1 B 🔽
@sentry/node - without tracing 73.69 kB - -
@sentry/aws-serverless 84.89 kB -0.01% -1 B 🔽
@sentry/cloudflare (withSentry) - minified 172.9 kB - -
@sentry/cloudflare (withSentry) 432.48 kB - -

View base workflow run

@logaretm logaretm force-pushed the awad/deotlify-span-kind branch from 182ad1a to 113e778 Compare June 19, 2026 20:23
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.

1 participant