MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / setup

Function setup

packages/core/src/integrations/spanStreaming.ts:15–42  ·  view source on GitHub ↗
(client)

Source from the content-addressed store, hash-verified

13 name: 'SpanStreaming' as const,
14
15 setup(client) {
16 const initialMessage = 'SpanStreaming integration requires';
17 const fallbackMsg = 'Falling back to static trace lifecycle.';
18 const clientOptions = client.getOptions();
19
20 if (!hasSpanStreamingEnabled(client)) {
21 clientOptions.traceLifecycle = 'static';
22 DEBUG_BUILD && debug.warn(`${initialMessage} \`traceLifecycle\` to be set to "stream"! ${fallbackMsg}`);
23 return;
24 }
25
26 const beforeSendSpan = clientOptions.beforeSendSpan;
27 if (beforeSendSpan && !isStreamedBeforeSendSpanCallback(beforeSendSpan)) {
28 clientOptions.traceLifecycle = 'static';
29 DEBUG_BUILD &&
30 debug.warn(`${initialMessage} a beforeSendSpan callback using \`withStreamedSpan\`! ${fallbackMsg}`);
31 return;
32 }
33
34 const buffer = new SpanBuffer(client);
35
36 client.on('afterSpanEnd', span => {
37 if (!spanIsSampled(span)) {
38 return;
39 }
40 buffer.add(captureSpan(span, client));
41 });
42 },
43 };
44}) satisfies IntegrationFn;

Callers

nothing calls this directly

Calls 8

addMethod · 0.95
hasSpanStreamingEnabledFunction · 0.90
spanIsSampledFunction · 0.90
captureSpanFunction · 0.90
getOptionsMethod · 0.65
warnMethod · 0.65
onMethod · 0.65

Tested by

no test coverage detected