@sentry/nextjs
Version:
Official Sentry SDK for Next.js
26 lines (23 loc) • 1.12 kB
JavaScript
import { context } from '@opentelemetry/api';
import { getRootSpan, getCapturedScopesOnSpan, getIsolationScope, getCurrentScope, setCapturedScopesOnSpan } from '@sentry/core';
import { getScopesFromContext } from '@sentry/opentelemetry';
import { ATTR_NEXT_SPAN_TYPE } from '../nextSpanAttributes.js';
function maybeForkIsolationScopeForRootSpan(span, spanAttributes) {
const spanType = spanAttributes?.[ATTR_NEXT_SPAN_TYPE];
if (spanType !== "BaseServer.handleRequest" && spanType !== "Middleware.execute" && spanType !== "Next.request") {
return;
}
if (span !== getRootSpan(span)) {
return;
}
const scopes = getCapturedScopesOnSpan(span);
const isolationScope = (scopes.isolationScope || getIsolationScope()).clone();
const scope = scopes.scope || getCurrentScope();
const currentScopesPointer = getScopesFromContext(context.active());
if (currentScopesPointer) {
currentScopesPointer.isolationScope = isolationScope;
}
setCapturedScopesOnSpan(span, scope, isolationScope);
}
export { maybeForkIsolationScopeForRootSpan };
//# sourceMappingURL=forkIsolationScopeForRootSpan.js.map