ref: Export SPAN_KIND from core and drop OTel SpanKind imports#21668
Draft
logaretm wants to merge 4 commits into
Draft
ref: Export SPAN_KIND from core and drop OTel SpanKind imports#21668logaretm wants to merge 4 commits into
logaretm wants to merge 4 commits into
Conversation
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.
Contributor
size-limit report 📦
|
182ad1a to
113e778
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While streamlining a few instrumentations I noticed sometimes we import from
@opentelemetry/apiin some instrumentations purely for the SPAN_KIND enum, so might as well just vendor it to make it easier.So this exports a
SPAN_KINDconstant from@sentry/coreso vendored instrumentations (and core itself) can set a span's kind without importing@opentelemetry/apisolely for theSpanKindenum.