@@ -5,22 +5,39 @@ import type { Options } from '../types-hoist';
5
5
declare const __SENTRY_TRACING__ : boolean | undefined ;
6
6
7
7
/**
8
- * Determines if tracing is currently enabled.
8
+ * Determines if span recording is currently enabled.
9
9
*
10
- * Tracing is enabled when at least one of `tracesSampleRate` and `tracesSampler` is defined in the SDK config.
10
+ * Spans are recorded when at least one of `tracesSampleRate` and `tracesSampler`
11
+ * is defined in the SDK config. This function does not make any assumption about
12
+ * sampling decisions, it only checks if the SDK is configured to record spans.
13
+ *
14
+ * Important: This function only determines if span recording is enabled. Trace
15
+ * continuation and propagation is separately controlled and not covered by this function.
16
+ * If this function returns `false`, traces can still be propagated (which is what
17
+ * we refer to by "Tracing without Performance")
18
+ * @see https://develop.sentry.dev/sdk/telemetry/traces/tracing-without-performance/
19
+ *
20
+ * @param maybeOptions An SDK options object to be passed to this function.
21
+ * If this option is not provided, the function will use the current client's options.
11
22
*/
12
- export function hasTracingEnabled (
23
+ export function hasSpansEnabled (
13
24
maybeOptions ?: Pick < Options , 'tracesSampleRate' | 'tracesSampler' > | undefined ,
14
25
) : boolean {
15
26
if ( typeof __SENTRY_TRACING__ === 'boolean' && ! __SENTRY_TRACING__ ) {
16
27
return false ;
17
28
}
18
29
19
- const client = getClient ( ) ;
20
- const options = maybeOptions || client ?. getOptions ( ) ;
30
+ const options = maybeOptions || getClient ( ) ?. getOptions ( ) ;
21
31
return (
22
32
! ! options &&
23
33
// Note: This check is `!= null`, meaning "nullish". `0` is not "nullish", `undefined` and `null` are. (This comment was brought to you by 15 minutes of questioning life)
24
34
( options . tracesSampleRate != null || ! ! options . tracesSampler )
25
35
) ;
26
36
}
37
+
38
+ /**
39
+ * @see JSDoc of hasSpansEnabled()
40
+ * @deprecated Use `hasSpansEnabled` instead, which is a more accurately named version of this function
41
+ */
42
+ // TODO(v10): Remove this export
43
+ export const hasTracingEnabled = hasSpansEnabled ;
0 commit comments