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

Function executeSpan

packages/cloudflare/src/wrapMethodWithSentry.ts:187–218  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

185 : {};
186
187 const executeSpan = (): unknown => {
188 return startSpan({ name: methodName, attributes }, span => {
189 if (startNewTrace && storage) {
190 const storedContext = getStoredSpanContext(storage, methodName);
191
192 if (storedContext) {
193 span.addLinks(buildSpanLinks(storedContext));
194 // TODO: Remove this once EAP can store span links. We currently only set this attribute so that we
195 // can obtain the previous trace information from the EAP store. Long-term, EAP will handle
196 // span links and then we should remove this again. Also throwing in a TODO(v11), to remind us
197 // to check this at v11 time :)
198 const sampledFlag = storedContext.sampled ? '1' : '0';
199 span.setAttribute(
200 'sentry.previous_trace',
201 `${storedContext.traceId}-${storedContext.spanId}-${sampledFlag}`,
202 );
203 }
204 }
205
206 try {
207 const result = Reflect.apply(target, thisArg, args);
208
209 if (isThenable(result)) {
210 return result.then(onFulfilled, onRejected);
211 } else {
212 return onFulfilled(result);
213 }
214 } catch (e) {
215 return onRejected(e);
216 }
217 });
218 };
219
220 if (rpcMeta) {
221 return continueTrace(

Callers 1

wrappedFunctionFunction · 0.85

Calls 10

startSpanFunction · 0.90
getStoredSpanContextFunction · 0.90
buildSpanLinksFunction · 0.90
isThenableFunction · 0.90
onFulfilledFunction · 0.85
onRejectedFunction · 0.85
addLinksMethod · 0.65
setAttributeMethod · 0.65
applyMethod · 0.45
thenMethod · 0.45

Tested by

no test coverage detected