Skip to content

Commit 0cbdf67

Browse files
authored
feat(core): Deprecate arguments for startSpan() (#10101)
In v8, there will be a reduced API surface.
1 parent b0496ea commit 0cbdf67

File tree

2 files changed

+116
-2
lines changed

2 files changed

+116
-2
lines changed

MIGRATION.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ npx @sentry/migr8@latest
88

99
This will let you select which updates to run, and automatically update your code. Make sure to still review all code changes!
1010

11+
## Deprecate arguments for `startSpan()` APIs
12+
13+
In v8, the API to start a new span will be reduced from the currently available options.
14+
Going forward, only these argument will be passable to `startSpan()`, `startSpanManual()` and `startInactiveSpan()`:
15+
16+
* `name`
17+
* `attributes`
18+
* `origin`
19+
* `op`
20+
* `startTime`
21+
* `scope`
22+
1123
## Deprecate `startTransaction()` & `span.startChild()`
1224

1325
In v8, the old performance API `startTransaction()` (and `hub.startTransaction()`), as well as `span.startChild()`, will be removed.

packages/core/src/tracing/trace.ts

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
import type { Scope, Span, SpanTimeInput, TransactionContext } from '@sentry/types';
1+
import type {
2+
Instrumenter,
3+
Primitive,
4+
Scope,
5+
Span,
6+
SpanTimeInput,
7+
TransactionContext,
8+
TransactionMetadata,
9+
} from '@sentry/types';
10+
import type { SpanAttributes } from '@sentry/types';
11+
import type { SpanOrigin } from '@sentry/types';
12+
import type { TransactionSource } from '@sentry/types';
213
import { dropUndefinedKeys, logger, tracingContextFromHeaders } from '@sentry/utils';
314

415
import { DEBUG_BUILD } from '../debug-build';
@@ -15,6 +26,97 @@ interface StartSpanOptions extends TransactionContext {
1526

1627
/** If defined, start this span off this scope instead off the current scope. */
1728
scope?: Scope;
29+
30+
/** The name of the span. */
31+
name: string;
32+
33+
/** An op for the span. This is a categorization for spans. */
34+
op?: string;
35+
36+
/** The origin of the span - if it comes from auto instrumenation or manual instrumentation. */
37+
origin?: SpanOrigin;
38+
39+
/** Attributes for the span. */
40+
attributes?: SpanAttributes;
41+
42+
// All remaining fields are deprecated
43+
44+
/**
45+
* @deprecated Manually set the end timestamp instead.
46+
*/
47+
trimEnd?: boolean;
48+
49+
/**
50+
* @deprecated This cannot be set manually anymore.
51+
*/
52+
parentSampled?: boolean;
53+
54+
/**
55+
* @deprecated Use attributes or set data on scopes instead.
56+
*/
57+
metadata?: Partial<TransactionMetadata>;
58+
59+
/**
60+
* The name thingy.
61+
* @deprecated Use `name` instead.
62+
*/
63+
description?: string;
64+
65+
/**
66+
* @deprecated Use `span.setStatus()` instead.
67+
*/
68+
status?: string;
69+
70+
/**
71+
* @deprecated Use `scope` instead.
72+
*/
73+
parentSpanId?: string;
74+
75+
/**
76+
* @deprecated You cannot manually set the span to sampled anymore.
77+
*/
78+
sampled?: boolean;
79+
80+
/**
81+
* @deprecated You cannot manually set the spanId anymore.
82+
*/
83+
spanId?: string;
84+
85+
/**
86+
* @deprecated You cannot manually set the traceId anymore.
87+
*/
88+
traceId?: string;
89+
90+
/**
91+
* @deprecated Use an attribute instead.
92+
*/
93+
source?: TransactionSource;
94+
95+
/**
96+
* @deprecated Use attributes or set tags on the scope instead.
97+
*/
98+
tags?: { [key: string]: Primitive };
99+
100+
/**
101+
* @deprecated Use attributes instead.
102+
*/
103+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
104+
data?: { [key: string]: any };
105+
106+
/**
107+
* @deprecated Use `startTime` instead.
108+
*/
109+
startTimestamp?: number;
110+
111+
/**
112+
* @deprecated Use `span.end()` instead.
113+
*/
114+
endTimestamp?: number;
115+
116+
/**
117+
* @deprecated You cannot set the instrumenter manually anymore.
118+
*/
119+
instrumenter?: Instrumenter;
18120
}
19121

20122
/**
@@ -259,7 +361,7 @@ function createChildSpanOrTransaction(
259361
*/
260362
function normalizeContext(context: StartSpanOptions): TransactionContext {
261363
if (context.startTime) {
262-
const ctx = { ...context };
364+
const ctx: TransactionContext & { startTime?: SpanTimeInput } = { ...context };
263365
ctx.startTimestamp = spanTimeInputToSeconds(context.startTime);
264366
delete ctx.startTime;
265367
return ctx;

0 commit comments

Comments
 (0)