@sentry/core
Version:
Base implementation for all Sentry JavaScript SDKs
34 lines (31 loc) • 1.16 kB
JavaScript
import { getMainCarrier, getSentryCarrier } from '../carrier.js';
import { _setSpanForScope } from '../utils/spanOnScope.js';
import { getStackAsyncContextStrategy } from './stackStrategy.js';
function setAsyncContextStrategy(strategy) {
const registry = getMainCarrier();
const sentry = getSentryCarrier(registry);
sentry.acs = strategy;
}
function getAsyncContextStrategy(carrier) {
const sentry = getSentryCarrier(carrier);
if (sentry.acs) {
return sentry.acs;
}
return getStackAsyncContextStrategy();
}
function getTracingChannelBinding() {
return getAsyncContextStrategy(getMainCarrier()).getTracingChannelBinding?.();
}
function _INTERNAL_createTracingChannelBinding(asyncLocalStorage, getScopes) {
return {
asyncLocalStorage,
getStoreWithActiveSpan: (span) => {
const { scope, isolationScope } = getScopes();
const activeScope = scope.clone();
_setSpanForScope(activeScope, span);
return { scope: activeScope, isolationScope };
}
};
}
export { _INTERNAL_createTracingChannelBinding, getAsyncContextStrategy, getTracingChannelBinding, setAsyncContextStrategy };
//# sourceMappingURL=index.js.map