Skip to content

Commit ae2f79f

Browse files
mydeaJPeer264
authored andcommitted
ref(opentelemetry): Remove OpenTelemetrySpanContext (#23285)
The type is no longer needed, we handle the kind separately already in the tracer.
1 parent 4f14d1b commit ae2f79f

2 files changed

Lines changed: 8 additions & 19 deletions

File tree

packages/opentelemetry/src/trace.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Context, Span, SpanContext, SpanOptions, TimeInput, Tracer } from '@opentelemetry/api';
22
import { context, SpanStatusCode, trace, TraceFlags } from '@opentelemetry/api';
33
import { isTracingSuppressed, suppressTracing } from './utils/suppressTracing';
4-
import type { Client, Scope, Span as SentrySpan } from '@sentry/core';
4+
import type { Client, Scope, Span as SentrySpan, StartSpanOptions } from '@sentry/core';
55
import {
66
getClient,
77
getCurrentScope,
@@ -13,7 +13,6 @@ import {
1313
SEMANTIC_ATTRIBUTE_SENTRY_OP,
1414
spanToStaticSpanJSON,
1515
} from '@sentry/core';
16-
import type { OpenTelemetrySpanContext } from './types';
1716
import { getContextFromScope } from './utils/contextData';
1817
import { getSamplingDecision } from './utils/getSamplingDecision';
1918
import { makeTraceState } from './utils/makeTraceState';
@@ -26,7 +25,7 @@ import { SENTRY_TRACE_STATE_DSC } from './constants';
2625
* @param callback - The callback to execute with the span
2726
* @param autoEnd - Whether to automatically end the span after the callback completes
2827
*/
29-
function _startSpan<T>(options: OpenTelemetrySpanContext, callback: (span: Span) => T, autoEnd: boolean): T {
28+
function _startSpan<T>(options: StartSpanOptions, callback: (span: Span) => T, autoEnd: boolean): T {
3029
const tracer = getTracer();
3130

3231
const { name, parentSpan: customParentSpan } = options;
@@ -106,7 +105,7 @@ function _startSpan<T>(options: OpenTelemetrySpanContext, callback: (span: Span)
106105
* You'll always get a span passed to the callback,
107106
* it may just be a non-recording span if the span is not sampled or if tracing is disabled.
108107
*/
109-
export function startSpan<T>(options: OpenTelemetrySpanContext, callback: (span: Span) => T): T {
108+
export function startSpan<T>(options: StartSpanOptions, callback: (span: Span) => T): T {
110109
return _startSpan(options, callback, true);
111110
}
112111

@@ -120,10 +119,7 @@ export function startSpan<T>(options: OpenTelemetrySpanContext, callback: (span:
120119
* You'll always get a span passed to the callback,
121120
* it may just be a non-recording span if the span is not sampled or if tracing is disabled.
122121
*/
123-
export function startSpanManual<T>(
124-
options: OpenTelemetrySpanContext,
125-
callback: (span: Span, finish: () => void) => T,
126-
): T {
122+
export function startSpanManual<T>(options: StartSpanOptions, callback: (span: Span, finish: () => void) => T): T {
127123
return _startSpan(options, span => callback(span, () => span.end()), false);
128124
}
129125

@@ -136,7 +132,7 @@ export function startSpanManual<T>(
136132
* This function will always return a span,
137133
* it may just be a non-recording span if the span is not sampled or if tracing is disabled.
138134
*/
139-
export function startInactiveSpan(options: OpenTelemetrySpanContext): Span {
135+
export function startInactiveSpan(options: StartSpanOptions): Span {
140136
const tracer = getTracer();
141137

142138
const { name, parentSpan: customParentSpan } = options;
@@ -185,8 +181,8 @@ function getTracer(): Tracer {
185181
return client?.tracer || trace.getTracer('@sentry/opentelemetry', SDK_VERSION);
186182
}
187183

188-
function getSpanOptions(options: OpenTelemetrySpanContext): SpanOptions {
189-
const { startTime, attributes, kind, op, links } = options;
184+
function getSpanOptions(options: StartSpanOptions): SpanOptions {
185+
const { startTime, attributes, op, links } = options;
190186

191187
// OTEL expects timestamps in ms, not seconds
192188
const fixedStartTime = typeof startTime === 'number' ? ensureTimestampInMilliseconds(startTime) : startTime;
@@ -198,7 +194,6 @@ function getSpanOptions(options: OpenTelemetrySpanContext): SpanOptions {
198194
...attributes,
199195
}
200196
: attributes,
201-
kind,
202197
links,
203198
startTime: fixedStartTime,
204199
};

packages/opentelemetry/src/types.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import type { SpanKind } from '@opentelemetry/api';
2-
import type { Scope, StartSpanOptions } from '@sentry/core';
3-
4-
export interface OpenTelemetrySpanContext extends StartSpanOptions {
5-
// Additional otel-only option, for now...?
6-
kind?: SpanKind;
7-
}
1+
import type { Scope } from '@sentry/core';
82

93
export interface CurrentScopes {
104
scope: Scope;

0 commit comments

Comments
 (0)