Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const instrument = require('../../instrument.js'); const options = require('../../options.js'); const request = require('../../request.js'); const instrumentContext = require('../../utils/instrumentContext.js'); const instrumentEnv = require('./instrumentEnv.js'); function instrumentExportedHandlerFetch(handler, optionsCallback) { if (!("fetch" in handler) || typeof handler.fetch !== "function") { return; } handler.fetch = instrument.ensureInstrumented( handler.fetch, (original) => new Proxy(original, { apply(target, thisArg, args) { const [request$1, env, ctx] = args; if (request$1.method === "OPTIONS" || request$1.method === "HEAD") { return target.apply(thisArg, args); } const context = instrumentContext.instrumentContext(ctx); const options$1 = options.getFinalOptions(optionsCallback(env), env); args[1] = instrumentEnv.instrumentEnv(env, options$1); args[2] = context; return request.wrapRequestHandler({ options: options$1, request: request$1, context }, () => target.apply(thisArg, args)); } }) ); } function instrumentWorkerEntrypointFetch(instance, options, context) { if (!instance.fetch) { return; } const original = instance.fetch.bind(instance); instance.fetch = new Proxy(original, { apply(target, thisArg, args) { const [request$1] = args; if (request$1.method === "OPTIONS" || request$1.method === "HEAD") { return Reflect.apply(target, thisArg, args); } return request.wrapRequestHandler({ options, request: request$1, context }, () => Reflect.apply(target, thisArg, args)); } }); } exports.instrumentExportedHandlerFetch = instrumentExportedHandlerFetch; exports.instrumentWorkerEntrypointFetch = instrumentWorkerEntrypointFetch; //# sourceMappingURL=instrumentFetch.js.map