Skip to content

Commit d5565e9

Browse files
committed
fix(opentelemetry): re-drop unnecessary tracer casts after develop rebase
The develop rebase reintroduced the OTel span casts (its span-kind refactor touched this file); tsgolint flags them as unnecessary again, so drop them while keeping develop's `attributes ... || {}` change.
1 parent a93da9b commit d5565e9

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

packages/opentelemetry/src/tracer.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
startNewTrace,
2121
withScope,
2222
} from '@sentry/core';
23-
import type { Span, SpanAttributes, SpanLink } from '@sentry/core';
23+
import type { Span, SpanAttributes } from '@sentry/core';
2424
import { applyOtelSpanData } from './applyOtelSpanData';
2525
import { SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY, SENTRY_TRACE_STATE_DSC } from './constants';
2626
import { getSamplingDecision } from './utils/getSamplingDecision';
@@ -47,7 +47,7 @@ export class SentryTracer implements Tracer {
4747
markSpanForOtelSourceInference(span);
4848
}
4949
applyOtelSpanData(span);
50-
return span as OpenTelemetrySpan;
50+
return span;
5151
}
5252

5353
/** @inheritdoc */
@@ -81,7 +81,7 @@ export class SentryTracer implements Tracer {
8181
// used or set during the span (tags, breadcrumbs, captured errors) belongs to that span and stays
8282
// isolated from other concurrent work. Without this it can land on a different isolation scope. This
8383
// holds for ignored spans too, which run the callback without ever becoming the active span.
84-
const capturedIsolationScope = getCapturedScopesOnSpan(span as unknown as Span).isolationScope;
84+
const capturedIsolationScope = getCapturedScopesOnSpan(span).isolationScope;
8585
const withCapturedIsolationScope = (contextToFork: Context): Context =>
8686
capturedIsolationScope
8787
? contextToFork.setValue(SENTRY_FORK_SET_ISOLATION_SCOPE_CONTEXT_KEY, capturedIsolationScope)
@@ -92,12 +92,12 @@ export class SentryTracer implements Tracer {
9292
// along with it (cascading the drop down the whole subtree). Leaving the parent active lets the
9393
// children attach to it and get re-parented instead. An ignored root span has no parent and still
9494
// becomes active, so its subtree is dropped as intended.
95-
if (spanIsIgnored(span as unknown as Span) && trace.getSpan(ctx)) {
95+
if (spanIsIgnored(span) && trace.getSpan(ctx)) {
9696
return context.with(withCapturedIsolationScope(ctx), () => callback(span)) as ReturnType<F>;
9797
}
9898

9999
return context.with(withCapturedIsolationScope(trace.setSpan(ctx, span)), () => {
100-
_INTERNAL_setSpanForScope(getCurrentScope(), span as unknown as Span);
100+
_INTERNAL_setSpanForScope(getCurrentScope(), span);
101101
return callback(span) as ReturnType<F>;
102102
});
103103
}
@@ -111,7 +111,7 @@ export class SentryTracer implements Tracer {
111111
const sentryOptions = {
112112
name,
113113
attributes: (options.attributes as SpanAttributes) || {},
114-
links: options.links as SpanLink[] | undefined,
114+
links: options.links,
115115
startTime: options.startTime,
116116
};
117117

@@ -129,7 +129,7 @@ export class SentryTracer implements Tracer {
129129
}
130130

131131
if (parentSpan) {
132-
return _INTERNAL_startInactiveSpan({ ...sentryOptions, parentSpan: parentSpan as unknown as Span });
132+
return _INTERNAL_startInactiveSpan({ ...sentryOptions, parentSpan: parentSpan });
133133
}
134134

135135
// No parent span and no remote parent: this is a fresh root span. Start a new trace instead of
@@ -148,7 +148,7 @@ export class SentryTracer implements Tracer {
148148
parentSpan: OpenTelemetrySpan,
149149
): Span {
150150
const { spanId, traceId, traceState } = parentSpan.spanContext();
151-
const dsc = getDynamicSamplingContextFromSpan(parentSpan as unknown as Span);
151+
const dsc = getDynamicSamplingContextFromSpan(parentSpan);
152152
const sampleRand = typeof dsc.sample_rand === 'string' ? Number(dsc.sample_rand) : undefined;
153153

154154
// Only freeze the DSC when the remote parent actually carried one (i.e. there was incoming
@@ -176,11 +176,11 @@ export class SentryTracer implements Tracer {
176176
// Link to the parent (like core's `createChildOrRootSpan`) so `getRootSpan` and DSC
177177
// resolution reach the parent. Non-recording spans no longer carry a `parentSpanId`.
178178
if (parentSpan) {
179-
addChildSpanToSpan(parentSpan as unknown as Span, span);
179+
addChildSpanToSpan(parentSpan, span);
180180
}
181181
// Capture the scopes (mirroring `createChildOrRootSpan`) so `startActiveSpan` can
182182
// fork the isolation scope onto the OTel context for work inside a suppressed span.
183183
setCapturedScopesOnSpan(span, getCurrentScope(), getIsolationScope());
184-
return span as OpenTelemetrySpan;
184+
return span;
185185
}
186186
}

0 commit comments

Comments
 (0)