'use strict';

var async_hooks = require('async_hooks');

// src/observability/context-storage.ts
var spanContextStorage = new async_hooks.AsyncLocalStorage();
function getCurrentSpan() {
  return spanContextStorage.getStore();
}
async function executeWithContext(params) {
  const { span, fn } = params;
  const wrappedFn = span ? () => spanContextStorage.run(span, fn) : fn;
  if (span?.executeInContext) {
    return span.executeInContext(wrappedFn);
  }
  return wrappedFn();
}
function executeWithContextSync(params) {
  const { span, fn } = params;
  const wrappedFn = span ? () => spanContextStorage.run(span, fn) : fn;
  if (span?.executeInContextSync) {
    return span.executeInContextSync(wrappedFn);
  }
  return wrappedFn();
}

exports.executeWithContext = executeWithContext;
exports.executeWithContextSync = executeWithContextSync;
exports.getCurrentSpan = getCurrentSpan;
//# sourceMappingURL=chunk-DLBIUFZL.cjs.map
//# sourceMappingURL=chunk-DLBIUFZL.cjs.map