hud-sdk 1.6.6 → 1.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var o=t();for(var r in o)("object"==typeof exports?exports:e)[r]=o[r]}}(global,(()=>(()=>{"use strict";var e={857:e=>{e.exports=require("os")},870:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.limitedParallel=void 0,t.limitedParallel=async function(e,t,o,r=!1){const i=[],n=[];return await Promise.all(Array.from({length:t},(async function(){for(;e.length>0;){const t=e.shift();try{const e=await o(t);i.push(e)}catch(e){if(n.push(e),r)throw e}}}))),{results:i,errors:n}}},2030:e=>{e.exports=require("./instrument")},2305:e=>{e.exports=require("form-data")},2546:e=>{e.exports=require("./lib")},2784:e=>{e.exports=require("../native/_index")},3066:function(e,t,o){var r=this&&this.__createBinding||(Object.create?function(e,t,o,r){void 0===r&&(r=o);var i=Object.getOwnPropertyDescriptor(t,o);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,r,i)}:function(e,t,o,r){void 0===r&&(r=o),e[r]=t[o]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)"default"!==o&&Object.prototype.hasOwnProperty.call(e,o)&&r(t,e,o);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.requestRelentless=void 0;const a=o(2546),s=n(o(8938)),u=o(5231);t.requestRelentless=async function(e,t,o,r=3){for(let i=0;i<r;i++)try{return await s.default.post(e,t,o)}catch(t){if(t instanceof s.AxiosError&&401===t.response?.status)throw new a.HudClientUnauthorizedError(`Unauthorized request for ${e}`);(0,u.logToHud)(`Failed request to ${e}, attempt ${i+1} of ${r}. Error: ${t}`),await new Promise((e=>setTimeout(e,1)))}throw new a.HudClientExceededMaxRetries(`Exceeded max retries for ${e}`)}},3903:e=>{e.exports=require("uuid")},4414:function(e,t,o){var r=this&&this.__createBinding||(Object.create?function(e,t,o,r){void 0===r&&(r=o);var i=Object.getOwnPropertyDescriptor(t,o);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,r,i)}:function(e,t,o,r){void 0===r&&(r=o),e[r]=t[o]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)"default"!==o&&Object.prototype.hasOwnProperty.call(e,o)&&r(t,e,o);return i(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.uploadAllSourceMaps=t.uploadSourceMap=void 0;const s=o(2546),u=a(o(2305)),l=n(o(9896)),d=o(5231),c=o(870),f=o(3066);async function p(e){const{buildId:t,filePath:o,hudKey:r}=e,i=new u.default;i.append("build_id",t),i.append("token",r);try{const e=await l.promises.readFile(o,"utf8"),t=JSON.parse(e);delete t.sourcesContent,i.append("sourcemap",JSON.stringify(t),{filename:"sourcemap",contentType:"application/json"})}catch(e){return(0,d.logToHud)(`failed parsing source map, skipping upload. Error: ${e}`),void(0,d.logToUser)(s.UserErrorLogs.EsbuildFailedParsingSourcemap())}try{await(0,f.requestRelentless)(`${s.hudConfig.sink.url}/${s.hudConfig.endpoints.sourceMap}`,i,{headers:{"Content-Type":"multipart/form-data"},timeout:s.hudConfig.esbuildUploadSourceMapTimeout})}catch(e){if(e instanceof Error&&e.message.includes("Unauthorized"))throw e;(0,d.logToHud)(`failed uploading source map. File: ${o}, Error: ${e}`),(0,d.logToUser)(s.UserErrorLogs.EsbuildFailedUploadingSourcemap(o))}}t.uploadSourceMap=p,t.uploadAllSourceMaps=async function(e,t){if(process.env.HUD_SKIP_SOURCEMAP_UPLOAD)(0,d.logToHud)("Skipping source map upload due to env var");else{(0,d.logToHud)(`Uploading source maps for ${e.length} files`);try{const o=[];for(const{buildId:r,filepath:i}of e){const e=`${i}.map`;try{await l.promises.access(e,l.constants.F_OK),o.push({buildId:r,filePath:e,hudKey:t})}catch{(0,d.logToHud)(`No source map found for file: ${i}`)}}await(0,c.limitedParallel)(o,10,p,!0),(0,d.logToHud)("Finished uploading source maps")}catch{return(0,d.logToUser)(s.UserErrorLogs.EsbuildFailedUploadingSourcemapUnauthorized()),void(0,d.setDontSendLogs)()}}}},5231:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getShouldSendLogs=t.setDontSendLogs=t.exportBuildLogs=t.logToHud=t.logToHudDebug=t.logToUser=void 0;const r=o(2546),i=o(6982),n=o(870),a=o(3066),s=r.hudConfig.esbuildPluginMessagePrefix,u=(0,i.randomUUID)(),l=[];let d=!0;function c(e,t=!0){"true"===process.env.HUD_PLUGIN_VERBOSE&&(t&&(e=(0,r.formatLogMessage)(`${s}${e}`)),console.log(e)),l.push({message:e,SessionID:u,timestamp:Date.now()})}async function f(e){await(0,a.requestRelentless)(r.hudConfig.pluginsLogEndpoint,{messages:e},{headers:{"x-hudx-plugin":"true","Content-Type":"application/json"}})}t.logToUser=function(e){let t="";t="string"==typeof e?(0,r.formatLogMessage)(`${s}${e}`):(0,r.formatLogMessage)(`${s}${e.message}`,e.errCode,e.moreInfo),console.log(t),c(t,!1)},t.logToHudDebug=function(e,t=!0){"true"===process.env.HUD_PLUGIN_DEBUG&&c(e,t)},t.logToHud=c,t.exportBuildLogs=async function(e){const t=[];for(let o=0;o<l.length;o+=r.hudConfig.esbuildPluginLogsBatchSize){const i=l.slice(o,o+r.hudConfig.esbuildPluginLogsBatchSize).map((t=>({...t,accessToken:e})));t.push(i)}await(0,n.limitedParallel)(t,10,f)},t.setDontSendLogs=function(){d=!1},t.getShouldSendLogs=function(){return d}},6928:e=>{e.exports=require("path")},6932:function(e,t,o){var r=this&&this.__createBinding||(Object.create?function(e,t,o,r){void 0===r&&(r=o);var i=Object.getOwnPropertyDescriptor(t,o);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,r,i)}:function(e,t,o,r){void 0===r&&(r=o),e[r]=t[o]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)"default"!==o&&Object.prototype.hasOwnProperty.call(e,o)&&r(t,e,o);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.verifyFileContent=t.createMark=t.markFile=t.markFileAsHudModified=t.verifyAndMarkFinalFiles=t.HudBuildError=void 0;const a=o(2030),s=o(2546),u=n(o(2784)),l=o(3903),d=n(o(9154)),c=o(7085),f=o(5231);class p extends Error{}function g(e,t){return`/*modifiedByHudESBuildPlugin-${t}*/${e}`}function h(e,t){const o=t?"Start":"End";return`;globalThis && (globalThis.${s.hudConfig.esbuildGlobalVar}="${o}:${e}");`}function m(e,t,o){try{(0,f.logToHud)(`Verifying file content: ${t}, with marks`),new d.Script(e),(0,f.logToHud)(`Editing in splits file content: ${t}`);const{transformedCode:r,editedChunksSizes:i}=(0,a.editInSplits)(e,t,o,!0,(e=>!e.includes("node_modules")));if(!r)throw new p(`Failed verify file content, ${t}`);for(let e=0;e<i.length;e+=c.LOG_CHUNKS_SIZE_BATCH){const t=JSON.stringify(i.slice(e,e+c.LOG_CHUNKS_SIZE_BATCH));(0,f.logToHudDebug)(`Edited chunks sizes: ${t}`)}(0,f.logToHud)(`Verifying new file content: ${t}`),new d.Script(r),(0,f.logToHud)(`Verified new file content: ${t}`)}catch(e){throw(0,f.logToHud)(`Failed verify file content, ${t}, error: ${e}`),new p(`Failed verify file content, ${t}`)}}t.HudBuildError=p,t.verifyAndMarkFinalFiles=async function(e,t,o){const r=[];for(const i of e){if(!i.path.endsWith(".js")){t&&await(0,c.writeFileAndFolder)(i.path,i.contents);continue}if(!i.text.includes(s.hudConfig.esbuildGlobalVar)){t&&await(0,c.writeFileAndFolder)(i.path,i.contents);continue}const e=(0,l.v5)(i.contents,s.hudConfig.bundlerBuildUuidNamespace);r.push({filepath:i.path,buildId:e});const n=g(i.text,e);process.env.HUD_SKIP_FILE_VALIDATION||m(n,i.path,o),i.contents=new Uint8Array(Buffer.from(n,"utf8")),t&&await(0,c.writeFileAndFolder)(i.path,i.contents)}return r},t.markFileAsHudModified=g,t.markFile=function(e,t){const o=u.markFile(t,{data:{filename:e,format:"esm"},initialStatements:[h(e,!0)],suffixStatements:[h(e,!1)]});if(!o||!o.code||!o.map)throw new Error("Failed generating ast");return function(e,t){let o;return void 0===t?e:(o="string"==typeof t||t instanceof String?Buffer.from(t.toString()).toString("base64"):Buffer.from(JSON.stringify(t)).toString("base64"),e+`\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,${o}`)}(o.code,o.map)},t.createMark=h,t.verifyFileContent=m},6982:e=>{e.exports=require("crypto")},7085:function(e,t,o){var r=this&&this.__createBinding||(Object.create?function(e,t,o,r){void 0===r&&(r=o);var i=Object.getOwnPropertyDescriptor(t,o);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,r,i)}:function(e,t,o,r){void 0===r&&(r=o),e[r]=t[o]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)"default"!==o&&Object.prototype.hasOwnProperty.call(e,o)&&r(t,e,o);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.plugin=t.getModuleRoot=t.writeFileAndFolder=t.LOG_CHUNKS_SIZE_BATCH=void 0;const a=o(8528),s=o(2030),u=o(6982),l=n(o(9896)),d=n(o(857)),c=n(o(6928)),f=o(2546),p=o(9929),g=o(5231),h=o(6932),m=o(4414);async function b(e,t,o,r,i){if(!(o&&r&&i&&r.test(e)))return;const n=c.join(i,e),a=c.dirname(n);try{await l.promises.access(a)}catch{await l.promises.mkdir(a,{recursive:!0})}await l.promises.writeFile(n,t,"utf8");const s=await o(n);return s?.contents&&(t=s.contents),t}async function y(e){let t=c.dirname(e);for(let e=0;e<30&&"/"!==t;e++){const e=c.join(t,"package.json");try{return await l.promises.access(e),t}catch{t=c.dirname(t)}}}t.LOG_CHUNKS_SIZE_BATCH=f.hudConfig.esbuildPluginLogsChunkSize,t.writeFileAndFolder=async function(e,t){const o=c.dirname(e);try{await l.promises.stat(o)}catch{await l.promises.mkdir(o,{recursive:!0})}await l.promises.writeFile(e,t)},t.getModuleRoot=y;const v="hud-esbuild-plugin";t.plugin=e=>({name:v,async setup(t){if("node"!==t.initialOptions.platform)return void(0,g.logToUser)(f.UserErrorLogs.EsbuildUnsupportedPlatform());const o=e?.hudKey??process.env.HUD_KEY;if(!o)return void(0,g.logToUser)(f.UserErrorLogs.EsbuildMissingKey());const r=e?.includeModules??(0,f.getModulesToTraceFromEnv)()??[],i=(0,s.createCheckers)(r);(0,g.logToUser)("started running");const n=t.initialOptions.write??!0;t.initialOptions.write=!1;const w="esm"===t.initialOptions?.format?a.Format.esm:a.Format.cjs,{callback:_,filter:S,tempDir:T}=await async function(e){const t=e.initialOptions;if(!t.plugins)return;const o=t.plugins.findIndex((e=>e.name===v)),r=t.plugins[o+1];if(!r||"datadog-esbuild"!==r.name)return;let i;(0,g.logToHud)("datadog-esbuild plugin detected");const n={...e,onLoad:(...e)=>{i=e},onStart:()=>{},onEnd:()=>{},onResolve:()=>{},onDispose:()=>{}};if(r.setup(n),!i)return void(0,g.logToHud)("datadog-esbuild plugin detected but failed receive onLoad callback");const a=c.join(d.tmpdir(),`hud-${(0,u.randomUUID)()}`);try{return await l.promises.access(a),void(0,g.logToUser)("temp dir already exists, try rerunning the build.")}catch(e){}return(0,g.logToHud)(`creating temp dir to be used by datadog plugin.\n\tPath: ${a}`),await l.promises.mkdir(a,{recursive:!0}),{filter:i[0].filter,callback:i[1],tempDir:a}}(t)??{},O=new Set(t.initialOptions.external||[]),F=new Map;t.onResolve({filter:/.*/},(async e=>{if(e.pluginData?.hud?.calledFromHud)return;if(O.has(e.path))return;if(!f.hudConfig.frameworksToPatch.get(e.path)?.enableEsbuild)return;const o={...e};delete o.path;const r=await t.resolve(e.path,{...o,pluginData:{...e.pluginData,hud:{calledFromHud:!0}}}),i=await y(r.path);i&&(F.set(i,e.path),(0,g.logToHud)(`mapping framework: ${i} => ${e.path}`))})),t.onLoad({filter:/.*\.(js|ts)$/},(async e=>{try{const t=_?async t=>await _({...e,path:t}):void 0;if((0,s.skip)(e.path,i)){const o=await(0,p.getFrameworkContentSuffix)(e.path,F);if(!o)return;let r=await l.promises.readFile(e.path,"utf8");return r=await b(e.path,r,t,S,T)??r,r+=o,{contents:r,loader:e.path.endsWith("ts")?"ts":"js",resolveDir:c.dirname(e.path)}}let o=await l.promises.readFile(e.path,"utf8");return o=(0,h.markFile)(e.path,o),o=await b(e.path,o,t,S,T)??o,o+=await(0,p.getFrameworkContentSuffix)(e.path,F)??"",{contents:o,loader:e.path.endsWith("ts")?"ts":"js",resolveDir:c.dirname(e.path)}}catch(t){return(0,g.logToHud)(`failed patching file "${e.path}", fallbacking to original loader. Error: ${t}`),void(0,g.logToUser)(`failed patching file "${e.path}", fallbacking to original loader`)}})),t.onEnd((async e=>{if(!e?.outputFiles)return;let t;try{t=await(0,h.verifyAndMarkFinalFiles)(e.outputFiles,n,w),(0,g.logToUser)("finished")}catch(e){throw(0,g.logToHud)(`failed validating. Error: ${e}`),(0,g.logToUser)(f.UserErrorLogs.EsbuildFailedBundling()),e}finally{if(t)try{await(0,m.uploadAllSourceMaps)(t,o)}catch(e){(0,g.logToHud)(`failed uploading source maps. Shouldnt get here since we catch all errors in verifyAndMarkFinalFiles, error: ${e}`)}try{if(T)try{await l.promises.access(T),(0,g.logToHud)("cleaning temp dir"),await l.promises.rm(T,{recursive:!0,force:!0})}catch{}}catch(e){(0,g.logToHud)(`failed cleaning temp dir. Error: ${e}`)}try{!process.env.HUD_SKIP_BUILD_LOG_EXPORT&&(0,g.getShouldSendLogs)()&&await(0,g.exportBuildLogs)(o)}catch(e){"true"===process.env.HUD_PLUGIN_VERBOSE&&"true"===process.env.HUD_DEBUG&&(0,g.logToUser)(`Failed exporting build logs. Error: ${e}`)}}}))}})},8528:e=>{e.exports=require("./dto")},8938:e=>{e.exports=require("axios")},9154:e=>{e.exports=require("vm")},9896:e=>{e.exports=require("fs")},9929:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getFrameworkContentSuffix=void 0;const r=o(8528),i=o(2030),n=o(2546),a=o(7085),s=o(5231);t.getFrameworkContentSuffix=async function(e,t){const o=[...t.entries()].find((([t,o])=>e.startsWith(t)));if(!o)return;const[u,l]=o;let d=l+e.slice(u.length);(d.endsWith("index.js")||d.endsWith("index.ts"))&&(d=d.slice(0,d.length-9));const c=n.hudConfig.frameworksToPatch.get(d);if(!(c?.enableEsbuild&&c?.patcher&&c?.version))return;(0,s.logToHud)(`Patching framwork: ${d}`);const f=await(0,a.getModuleRoot)(e);if(!f)return void(0,s.logToHud)(`Failed to find package.json for ${d}`);const p=(0,i.extractModuleVersion)(f);if((0,s.logToHud)(`Patching framework ${d}, version: ${p}`),(0,i.getFrameworkPatcher)(c.patcher).isSupported(f,d,c.version,c.extraInfo))return`\n ;\n try {\n const { hudRITM, infoSafeLog: hudSafeLogger } = require("hud-sdk/instrument");\n if (globalThis.hudRunningMode === ${r.HudRunningMode.enabled}) {\n if (typeof hudRITM === "function") {\n if (typeof hudSafeLogger === "function") {\n hudSafeLogger("esbuild patching ${d}");\n }\n module.exports = hudRITM(module.exports, "${d}", "hud-esbuild-folder-should-not-exists");\n }\n }\n } catch (e) {\n try {\n const { errorSafeLog: hudSafeLogger } = require("hud-sdk/internal");\n if (typeof hudSafeLogger === "function") {\n hudSafeLogger(\`esbuild patching ${f} failed: \${e}\`);\n }\n } catch {}\n }\n `;(0,s.logToHud)(`Failed to patch ${d}, unsupported version: ${p}`)}}},t={};return function o(r){var i=t[r];if(void 0!==i)return i.exports;var n=t[r]={exports:{}};return e[r].call(n.exports,n,n.exports,o),n.exports}(7085)})()));
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var o=t();for(var r in o)("object"==typeof exports?exports:e)[r]=o[r]}}(global,(()=>(()=>{"use strict";var e={857:e=>{e.exports=require("os")},870:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.limitedParallel=void 0,t.limitedParallel=async function(e,t,o,r=!1){const i=[],n=[];return await Promise.all(Array.from({length:t},(async function(){for(;e.length>0;){const t=e.shift();try{const e=await o(t);i.push(e)}catch(e){if(n.push(e),r)throw e}}}))),{results:i,errors:n}}},2030:e=>{e.exports=require("./instrument")},2305:e=>{e.exports=require("form-data")},2546:e=>{e.exports=require("./lib")},2784:e=>{e.exports=require("../native/_index")},3066:function(e,t,o){var r=this&&this.__createBinding||(Object.create?function(e,t,o,r){void 0===r&&(r=o);var i=Object.getOwnPropertyDescriptor(t,o);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,r,i)}:function(e,t,o,r){void 0===r&&(r=o),e[r]=t[o]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)"default"!==o&&Object.prototype.hasOwnProperty.call(e,o)&&r(t,e,o);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.requestRelentless=void 0;const a=o(2546),s=n(o(8938)),u=o(5231);t.requestRelentless=async function(e,t,o,r=3){for(let i=0;i<r;i++)try{return await s.default.post(e,t,o)}catch(t){if(t instanceof s.AxiosError&&401===t.response?.status)throw new a.HudClientUnauthorizedError(`Unauthorized request for ${e}`);(0,u.logToHud)(`Failed request to ${e}, attempt ${i+1} of ${r}. Error: ${t}`),await new Promise((e=>setTimeout(e,1)))}throw new a.HudClientExceededMaxRetries(`Exceeded max retries for ${e}`)}},3903:e=>{e.exports=require("uuid")},4414:function(e,t,o){var r=this&&this.__createBinding||(Object.create?function(e,t,o,r){void 0===r&&(r=o);var i=Object.getOwnPropertyDescriptor(t,o);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,r,i)}:function(e,t,o,r){void 0===r&&(r=o),e[r]=t[o]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)"default"!==o&&Object.prototype.hasOwnProperty.call(e,o)&&r(t,e,o);return i(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.uploadAllSourceMaps=t.uploadSourceMap=void 0;const s=o(2546),u=a(o(2305)),l=n(o(9896)),d=o(5231),c=o(870),f=o(3066);async function p(e){const{buildId:t,filePath:o,hudKey:r}=e,i=new u.default;i.append("build_id",t),i.append("token",r);try{const e=await l.promises.readFile(o,"utf8"),t=JSON.parse(e);delete t.sourcesContent,i.append("sourcemap",JSON.stringify(t),{filename:"sourcemap",contentType:"application/json"})}catch(e){return(0,d.logToHud)(`failed parsing source map, skipping upload. Error: ${e}`),void(0,d.logToUser)(s.UserErrorLogs.EsbuildFailedParsingSourcemap())}try{await(0,f.requestRelentless)(`${s.hudConfig.sink.url}/${s.hudConfig.endpoints.sourceMap}`,i,{headers:{"Content-Type":"multipart/form-data"},timeout:s.hudConfig.esbuildUploadSourceMapTimeout})}catch(e){if(e instanceof Error&&e.message.includes("Unauthorized"))throw e;(0,d.logToHud)(`failed uploading source map. File: ${o}, Error: ${e}`),(0,d.logToUser)(s.UserErrorLogs.EsbuildFailedUploadingSourcemap(o))}}t.uploadSourceMap=p,t.uploadAllSourceMaps=async function(e,t){if(process.env.HUD_SKIP_SOURCEMAP_UPLOAD)(0,d.logToHud)("Skipping source map upload due to env var");else{(0,d.logToHud)(`Uploading source maps for ${e.length} files`);try{const o=[];for(const{buildId:r,filepath:i}of e){const e=`${i}.map`;try{await l.promises.access(e,l.constants.F_OK),o.push({buildId:r,filePath:e,hudKey:t})}catch{(0,d.logToHud)(`No source map found for file: ${i}`)}}await(0,c.limitedParallel)(o,10,p,!0),(0,d.logToHud)("Finished uploading source maps")}catch{return(0,d.logToUser)(s.UserErrorLogs.EsbuildFailedUploadingSourcemapUnauthorized()),void(0,d.setDontSendLogs)()}}}},5231:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getShouldSendLogs=t.setDontSendLogs=t.exportBuildLogs=t.logToHud=t.logToHudDebug=t.logToUser=void 0;const r=o(2546),i=o(6982),n=o(870),a=o(3066),s=r.hudConfig.esbuildPluginMessagePrefix,u=(0,i.randomUUID)(),l=[];let d=!0;function c(e,t=!0){"true"===process.env.HUD_PLUGIN_VERBOSE&&(t&&(e=(0,r.formatLogMessage)(`${s}${e}`)),console.log(e)),l.push({message:e,SessionID:u,timestamp:Date.now()})}async function f(e){await(0,a.requestRelentless)(r.hudConfig.pluginsLogEndpoint,{messages:e},{headers:{"x-hudx-plugin":"true","Content-Type":"application/json"}})}t.logToUser=function(e){let t="";t="string"==typeof e?(0,r.formatLogMessage)(`${s}${e}`):(0,r.formatLogMessage)(`${s}${e.message}`,e.errCode,e.moreInfo),console.log(t),c(t,!1)},t.logToHudDebug=function(e,t=!0){"true"===process.env.HUD_PLUGIN_DEBUG&&c(e,t)},t.logToHud=c,t.exportBuildLogs=async function(e){const t=[];for(let o=0;o<l.length;o+=r.hudConfig.esbuildPluginLogsBatchSize){const i=l.slice(o,o+r.hudConfig.esbuildPluginLogsBatchSize).map((t=>({...t,accessToken:e})));t.push(i)}await(0,n.limitedParallel)(t,10,f)},t.setDontSendLogs=function(){d=!1},t.getShouldSendLogs=function(){return d}},6928:e=>{e.exports=require("path")},6932:function(e,t,o){var r=this&&this.__createBinding||(Object.create?function(e,t,o,r){void 0===r&&(r=o);var i=Object.getOwnPropertyDescriptor(t,o);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,r,i)}:function(e,t,o,r){void 0===r&&(r=o),e[r]=t[o]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)"default"!==o&&Object.prototype.hasOwnProperty.call(e,o)&&r(t,e,o);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.verifyFileContent=t.createMark=t.markFile=t.markFileAsHudModified=t.verifyAndMarkFinalFiles=t.HudBuildError=void 0;const a=o(2030),s=o(2546),u=n(o(2784)),l=o(3903),d=n(o(9154)),c=o(7085),f=o(5231);class p extends Error{}function g(e,t){return`/*modifiedByHudESBuildPlugin-${t}*/${e}`}function h(e,t){const o=t?"Start":"End";return`;globalThis && (globalThis.${s.hudConfig.esbuildGlobalVar}="${o}:${e}");`}function m(e,t,o){try{(0,f.logToHud)(`Verifying file content: ${t}, with marks`),new d.Script(e),(0,f.logToHud)(`Editing in splits file content: ${t}`);const{transformedCode:r,editedChunksSizes:i}=(0,a.editInSplits)(e,t,o,!0,(e=>!e.includes("node_modules")));if(!r)throw new p(`Failed verify file content, ${t}`);for(let e=0;e<i.length;e+=c.LOG_CHUNKS_SIZE_BATCH){const t=JSON.stringify(i.slice(e,e+c.LOG_CHUNKS_SIZE_BATCH));(0,f.logToHudDebug)(`Edited chunks sizes: ${t}`)}(0,f.logToHud)(`Verifying new file content: ${t}`),new d.Script(r),(0,f.logToHud)(`Verified new file content: ${t}`)}catch(e){throw(0,f.logToHud)(`Failed verify file content, ${t}, error: ${e}`),new p(`Failed verify file content, ${t}`)}}t.HudBuildError=p,t.verifyAndMarkFinalFiles=async function(e,t,o){const r=[];for(const i of e){if(!i.path.endsWith(".js")){t&&await(0,c.writeFileAndFolder)(i.path,i.contents);continue}if(!i.text.includes(s.hudConfig.esbuildGlobalVar)){t&&await(0,c.writeFileAndFolder)(i.path,i.contents);continue}const e=(0,l.v5)(i.contents,s.hudConfig.bundlerBuildUuidNamespace);r.push({filepath:i.path,buildId:e});const n=g(i.text,e);process.env.HUD_SKIP_FILE_VALIDATION||m(n,i.path,o),i.contents=new Uint8Array(Buffer.from(n,"utf8")),t&&await(0,c.writeFileAndFolder)(i.path,i.contents)}return r},t.markFileAsHudModified=g,t.markFile=function(e,t){const o=u.markFile(t,{data:{filename:e,format:"esm"},initialStatements:[h(e,!0)],suffixStatements:[h(e,!1)]});if(!o||!o.code||!o.map)throw new Error("Failed generating ast");return function(e,t){let o;return void 0===t?e:(o="string"==typeof t||t instanceof String?Buffer.from(t.toString()).toString("base64"):Buffer.from(JSON.stringify(t)).toString("base64"),e+`\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,${o}`)}(o.code,o.map)},t.createMark=h,t.verifyFileContent=m},6982:e=>{e.exports=require("crypto")},7085:function(e,t,o){var r=this&&this.__createBinding||(Object.create?function(e,t,o,r){void 0===r&&(r=o);var i=Object.getOwnPropertyDescriptor(t,o);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,r,i)}:function(e,t,o,r){void 0===r&&(r=o),e[r]=t[o]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)"default"!==o&&Object.prototype.hasOwnProperty.call(e,o)&&r(t,e,o);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.plugin=t.getModuleRoot=t.writeFileAndFolder=t.LOG_CHUNKS_SIZE_BATCH=void 0;const a=o(8528),s=o(2030),u=o(6982),l=n(o(9896)),d=n(o(857)),c=n(o(6928)),f=o(2546),p=o(9929),g=o(5231),h=o(6932),m=o(4414);async function b(e,t,o,r,i){if(!(o&&r&&i&&r.test(e)))return;const n=c.join(i,e),a=c.dirname(n);try{await l.promises.access(a)}catch{await l.promises.mkdir(a,{recursive:!0})}await l.promises.writeFile(n,t,"utf8");const s=await o(n);return s?.contents&&(t=s.contents),t}async function y(e){let t=c.dirname(e);for(let e=0;e<30&&"/"!==t;e++){const e=c.join(t,"package.json");try{return await l.promises.access(e),t}catch{t=c.dirname(t)}}}t.LOG_CHUNKS_SIZE_BATCH=f.hudConfig.esbuildPluginLogsChunkSize,t.writeFileAndFolder=async function(e,t){const o=c.dirname(e);try{await l.promises.stat(o)}catch{await l.promises.mkdir(o,{recursive:!0})}await l.promises.writeFile(e,t)},t.getModuleRoot=y;const v="hud-esbuild-plugin";t.plugin=e=>({name:v,async setup(t){if("node"!==t.initialOptions.platform)return void(0,g.logToUser)(f.UserErrorLogs.EsbuildUnsupportedPlatform());if("win32"===d.platform())return void(0,g.logToUser)(f.UserErrorLogs.EsbuildUnsupportedWindows());const o=e?.hudKey??process.env.HUD_KEY;if(!o)return void(0,g.logToUser)(f.UserErrorLogs.EsbuildMissingKey());const r=e?.includeModules??(0,f.getModulesToTraceFromEnv)()??[],i=(0,s.createCheckers)(r);(0,g.logToUser)("started running");const n=t.initialOptions.write??!0;t.initialOptions.write=!1;const w="esm"===t.initialOptions?.format?a.Format.esm:a.Format.cjs,{callback:_,filter:S,tempDir:T}=await async function(e){const t=e.initialOptions;if(!t.plugins)return;const o=t.plugins.findIndex((e=>e.name===v)),r=t.plugins[o+1];if(!r||"datadog-esbuild"!==r.name)return;let i;(0,g.logToHud)("datadog-esbuild plugin detected");const n={...e,onLoad:(...e)=>{i=e},onStart:()=>{},onEnd:()=>{},onResolve:()=>{},onDispose:()=>{}};if(r.setup(n),!i)return void(0,g.logToHud)("datadog-esbuild plugin detected but failed receive onLoad callback");const a=c.join(d.tmpdir(),`hud-${(0,u.randomUUID)()}`);try{return await l.promises.access(a),void(0,g.logToUser)("temp dir already exists, try rerunning the build.")}catch(e){}return(0,g.logToHud)(`creating temp dir to be used by datadog plugin.\n\tPath: ${a}`),await l.promises.mkdir(a,{recursive:!0}),{filter:i[0].filter,callback:i[1],tempDir:a}}(t)??{},O=new Set(t.initialOptions.external||[]),F=new Map;t.onResolve({filter:/.*/},(async e=>{if(e.pluginData?.hud?.calledFromHud)return;if(O.has(e.path))return;if(!f.hudConfig.frameworksToPatch.get(e.path)?.enableEsbuild)return;const o={...e};delete o.path;const r=await t.resolve(e.path,{...o,pluginData:{...e.pluginData,hud:{calledFromHud:!0}}}),i=await y(r.path);i&&(F.set(i,e.path),(0,g.logToHud)(`mapping framework: ${i} => ${e.path}`))})),t.onLoad({filter:/.*\.(js|ts)$/},(async e=>{try{const t=_?async t=>await _({...e,path:t}):void 0;if((0,s.skip)(e.path,i)){const o=await(0,p.getFrameworkContentSuffix)(e.path,F);if(!o)return;let r=await l.promises.readFile(e.path,"utf8");return r=await b(e.path,r,t,S,T)??r,r+=o,{contents:r,loader:e.path.endsWith("ts")?"ts":"js",resolveDir:c.dirname(e.path)}}let o=await l.promises.readFile(e.path,"utf8");return o=(0,h.markFile)(e.path,o),o=await b(e.path,o,t,S,T)??o,o+=await(0,p.getFrameworkContentSuffix)(e.path,F)??"",{contents:o,loader:e.path.endsWith("ts")?"ts":"js",resolveDir:c.dirname(e.path)}}catch(t){return(0,g.logToHud)(`failed patching file "${e.path}", fallbacking to original loader. Error: ${t}`),void(0,g.logToUser)(`failed patching file "${e.path}", fallbacking to original loader`)}})),t.onEnd((async e=>{if(!e?.outputFiles)return;let t;try{t=await(0,h.verifyAndMarkFinalFiles)(e.outputFiles,n,w),(0,g.logToUser)("finished")}catch(e){throw(0,g.logToHud)(`failed validating. Error: ${e}`),(0,g.logToUser)(f.UserErrorLogs.EsbuildFailedBundling()),e}finally{if(t)try{await(0,m.uploadAllSourceMaps)(t,o)}catch(e){(0,g.logToHud)(`failed uploading source maps. Shouldnt get here since we catch all errors in verifyAndMarkFinalFiles, error: ${e}`)}try{if(T)try{await l.promises.access(T),(0,g.logToHud)("cleaning temp dir"),await l.promises.rm(T,{recursive:!0,force:!0})}catch{}}catch(e){(0,g.logToHud)(`failed cleaning temp dir. Error: ${e}`)}try{!process.env.HUD_SKIP_BUILD_LOG_EXPORT&&(0,g.getShouldSendLogs)()&&await(0,g.exportBuildLogs)(o)}catch(e){"true"===process.env.HUD_PLUGIN_VERBOSE&&"true"===process.env.HUD_DEBUG&&(0,g.logToUser)(`Failed exporting build logs. Error: ${e}`)}}}))}})},8528:e=>{e.exports=require("./dto")},8938:e=>{e.exports=require("axios")},9154:e=>{e.exports=require("vm")},9896:e=>{e.exports=require("fs")},9929:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getFrameworkContentSuffix=void 0;const r=o(8528),i=o(2030),n=o(2546),a=o(7085),s=o(5231);t.getFrameworkContentSuffix=async function(e,t){const o=[...t.entries()].find((([t,o])=>e.startsWith(t)));if(!o)return;const[u,l]=o;let d=l+e.slice(u.length);(d.endsWith("index.js")||d.endsWith("index.ts"))&&(d=d.slice(0,d.length-9));const c=n.hudConfig.frameworksToPatch.get(d);if(!(c?.enableEsbuild&&c?.patcher&&c?.version))return;(0,s.logToHud)(`Patching framwork: ${d}`);const f=await(0,a.getModuleRoot)(e);if(!f)return void(0,s.logToHud)(`Failed to find package.json for ${d}`);const p=(0,i.extractModuleVersion)(f);if((0,s.logToHud)(`Patching framework ${d}, version: ${p}`),(0,i.getFrameworkPatcher)(c.patcher).isSupported(f,d,c.version,c.extraInfo))return`\n ;\n try {\n const { hudRITM, infoSafeLog: hudSafeLogger } = require("hud-sdk/instrument");\n if (globalThis.hudRunningMode === ${r.HudRunningMode.enabled}) {\n if (typeof hudRITM === "function") {\n if (typeof hudSafeLogger === "function") {\n hudSafeLogger("esbuild patching ${d}");\n }\n module.exports = hudRITM(module.exports, "${d}", "hud-esbuild-folder-should-not-exists");\n }\n }\n } catch (e) {\n try {\n const { errorSafeLog: hudSafeLogger } = require("hud-sdk/internal");\n if (typeof hudSafeLogger === "function") {\n hudSafeLogger(\`esbuild patching ${f} failed: \${e}\`);\n }\n } catch {}\n }\n `;(0,s.logToHud)(`Failed to patch ${d}, unsupported version: ${p}`)}}},t={};return function o(r){var i=t[r];if(void 0!==i)return i.exports;var n=t[r]={exports:{}};return e[r].call(n.exports,n,n.exports,o),n.exports}(7085)})()));
2
2
  //# sourceMappingURL=esbuildPlugin.js.map
@@ -1,2 +1,2 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(global,(()=>(()=>{var e={336:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(2546),n=r(2822),s=r(8949),i=r(8901),a=r(714);class c extends a.FrameworkPatcher{_patch(e){return this._patchSendRequest(e),o.instrument_logger.info("Patched @codegenie/serverless-express/src/frameworks/express.js successfully"),e}_patchSendRequest(e){const t=e.sendRequest;e.sendRequest=function(e){let r,s;const a=i.HttpEndpointMetric.createUsableMetric();try{if(r=e.request,s=e.response,!r||!s)return t.call(this,e);a.start(),a.setRequestAttributes(r),r[o.hudConfig.metricSymbol]=a}catch(e){o.instrument_logger.error("Failed to start flowMetric during sendRequest patching",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}const c=(0,n.runWithInvestigation)((()=>t.call(this,e)));try{s.once("finish",(function(){try{(0,n.finishHttpInvestigation)(r,s,a),a.setResponseAttributes(s),a.end()}catch(e){o.instrument_logger.error("Failed to end flowMetric during sendRequest patching",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}))}catch(e){o.instrument_logger.error("Failed to end flowMetric during sendRequest patching",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return c},(0,s.copyPropertiesToTarget)(t,e.sendRequest)}}t.default=c},486:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(8269),n=r(2546),s=r(8949),i=r(828),a=r(714);class c extends a.FrameworkPatcher{_patch(e){return this._patchConsumer(e),n.instrument_logger.info("Patched KafkaJS successfully"),e}_patchConsumer(e){const t=e.Kafka.prototype.consumer;e.Kafka.prototype.consumer=function(...e){const r=t.apply(this,e);try{const t=new Map,o=[],a=[];!function(e,t){const r=e.subscribe;e.subscribe=async function(...e){const o=await r.apply(this,e);try{const r=e[0].topics;r?r.forEach((e=>{t.push(e)})):e[0].topic?t.push(e[0].topic):n.instrument_logger.warn("No topic found in KafkaJS.Consumer.subscribe",{args:e[0]})}catch(e){n.instrument_logger.error("Error in patching KafkaJS.Consumer.subscribe",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return o},(0,s.copyPropertiesToTarget)(r,e.subscribe)}(r,a),function(e,t,r,o,a){const c=e.run;function p(e,c){const p="eachBatch"===c;for(const e of a)f(e,o,t,r,c);const g=function(e,t,r){return o=>{const s=o[0],i=r?s.batch.topic:s.topic;return function(e,t,r,o){const s=e.get(d(r,o));if(s)return s;for(const e of t)if(e.isBatch===o&&e.pattern.test(r))return e.flowId;n.instrument_logger.warn("No flowId found for topic",{topicName:r,isBatch:o})}(e,t,i,r)}}(t,r,p),h=function(e){return(t,r,o)=>{const s=i.KafkaJSMetric.createUsableMetric();s.start(),s.setFlowId(t);const a=o[0];void 0!==a&&void 0!==a.message&&(a.message[n.hudConfig.metricSymbol]=s);const c=e?a.batch.partition:a.partition,u=e?a.batch.messages[0]?.timestamp:a.message?.timestamp;s.addPartition(c),s.addProducedTimestamp(u),r.flowMetric=s}}(p),m=(0,s.wrapFlow)(g,e[c],h,u,l);e[c]=m}e.run=async function(...e){try{const t=e[0];t.eachMessage&&p(t,"eachMessage"),t.eachBatch&&p(t,"eachBatch")}catch(e){n.instrument_logger.error("Error in patching KafkaJS.Consumer.run",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return await c.apply(this,e)},(0,s.copyPropertiesToTarget)(c,e.run)}(r,t,o,e[0].groupId,a)}catch(e){n.instrument_logger.error("Error in patching KafkaJS.Consumer",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return r},(0,s.copyPropertiesToTarget)(t,e.Kafka.prototype.consumer)}}function u(e,t){const r=t.flowMetric;r?r.end():n.instrument_logger.warn("No flowMetric found for message",{flowId:e})}function l(e,t,r){const o=t.flowMetric;o?(o.setError(r),o.end()):n.instrument_logger.warn("No flowMetric found for message",{flowId:e})}function d(e,t){return e+"|"+t}function f(e,t,r,s,i){const a=(0,n.generateKafkaFlowId)(e,t,i),c={flow_id:a,topic_name:e.toString(),group_id:t,pulling_type:i};(0,o.storeKafkaJSTopicDeclaration)(c),function(e,t,r,o,n){"string"==typeof r?e.set(d(r,o),n):t.push({pattern:r,isBatch:o,flowId:n})}(r,s,e,"eachBatch"===i,a)}t.default=c},646:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(2546),n=r(8949),s=r(714),i=r(3531);class a extends s.FrameworkPatcher{_patch(e){return this._patchCreate(e),o.instrument_logger.info("Patched NestJS RouterExecutionContext successfully"),e}_patchCreate(e){const t=e.RouterExecutionContext.prototype.create;e.RouterExecutionContext.prototype.create=function(...e){try{const t=e[0],r=e[1];if("function"==typeof t.constructor&&"function"==typeof r){const s=(0,i.generateKey)(t,r);s&&(e[1]=(0,n.wrapFlow)((()=>{try{const e=(0,i.getRequestByCallback)(s);if(!e)return void o.instrument_logger.error("No request object found for key",{key:s});const t=function(e){if(e&&!e.raw&&e.socket)return e[o.hudConfig.metricSymbol]?e[o.hudConfig.metricSymbol].getFlowId?e[o.hudConfig.metricSymbol].getFlowId():void o.instrument_logger.error("No getFlowId function found on metric object"):void o.instrument_logger.error("No metric found on nestjs request object")}(e);return t||o.instrument_logger.error("No flow id found for key",{key:s}),t}catch(e){o.instrument_logger.error("Error in NestJS getFlowId",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}),r))}else o.instrument_logger.error("Invalid args in NestJS RouterExecutionContext.create",{args:e})}catch(e){o.instrument_logger.error("Error in NestJS RouterExecutionContext patcher",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return t.apply(this,e)},(0,n.copyPropertiesToTarget)(t,e.RouterExecutionContext.prototype.create)}}t.default=a},714:function(e,t,r){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.getFrameworkPatcher=t.extractModuleVersion=t.isSupportedVersion=t.FrameworkPatcher=void 0;const i=r(2546),a=r(9896),c=s(r(6928)),u=r(8064);function l(e,t){return""===e||u.satisfies(u.coerce(e),t)}function d(e){try{const t=(0,a.readFileSync)(c.join(e,"package.json"),{encoding:"utf8"}),r=JSON.parse(t).version;return"string"==typeof r?r:""}catch(t){i.instrument_logger.info("Failed extracting version",{baseDir:e})}return""}t.FrameworkPatcher=class{patch(e,t,r,o,n=this.constructor.name){try{if(this.isSupported(t,n,r,o))return this._patch(e)}catch(e){i.instrument_logger.error("Unhandeled error during patching framework",{framework:n,error:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return e}isSupported(e,t,r,o){const n=d(e);return!!l(n,r)||(i.instrument_logger.warn("Unsupported version",{framework:t,version:n,supportedVersion:r,basedir:e}),i.customer_logger.log(i.UserErrorLogs.UnsupportedFrameworkVersion(t)),!1)}},t.isSupportedVersion=l,t.extractModuleVersion=d,t.getFrameworkPatcher=function(e){return new(r(2828)(`./${e}`).default)}},828:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.KafkaJSMetric=void 0;const o=r(2546),n=r(7131),s=r(9873);class i extends s.FlowMetric{partition;error;producedTimestamp;totalConsumeDuration;constructor(e){super(e)}_createUsableMetric(e){return this}end(){this.producedTimestamp&&(this.totalConsumeDuration=Number(Date.now()-this.producedTimestamp)*Number(1e6)),super.end()}addProducedTimestamp(e){void 0!==e&&(this.producedTimestamp=Number(e))}addPartition(e){this.partition=e}setError(e){this.error=(0,n.extractName)(e)}toRaw(){if(void 0!==this.partition)return{flow_id:this.flowId,type:"KafkaJSMetric",duration:this.duration,partition:this.partition,error:this.error,total_consume_duration:this.totalConsumeDuration};o.instrument_logger.warn("No partition found for message",{flowId:this.flowId})}}t.KafkaJSMetric=i},932:e=>{"use strict";e.exports=require("process")},1502:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(8528),n=r(8269),s=r(2546),i=r(8949),a=r(714);class c extends a.FrameworkPatcher{static koaModuleName="koa";static koaPatchedSymbol=Symbol.for(s.hudConfig.hudPatchedName);_patch(e){return this._patchAppUse(e),s.instrument_logger.info("Patched koa successfully"),e}_patchAppUse(e){const t=e.prototype.use;e.prototype.use=function(e){const r=t.apply(this,arguments);try{if(!arguments[0].router)return r;const e=arguments[0].router.stack;for(let t=0;t<e.length;t++)c._wrapRoute(e[t])}catch(e){s.instrument_logger.error("Failed to patch koa.use function",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return r},(0,i.copyPropertiesToTarget)(t,e.prototype.use)}static _wrapRoute(e){if(e.methods&&0===e.methods.length)return;if(!e.stack[0][c.koaPatchedSymbol]){const t=(0,i.wrapFlow)(p,e.stack[0],u);e.stack[0]=t,e.stack[0][c.koaPatchedSymbol]=!0}const t=(0,s.generateEndpointFlowId)(e.path,e.methods);(0,n.storeKoaEndpointDeclaration)(new o.EndpointDeclaration(t,e.methods,"koa",void 0,e.path));for(const r of e.methods)f(t,e.path,r)}}function u(e,t,r){if(!r[0])return void s.instrument_logger.error("No ctx object found in koa");const o=r[0].req;if(!o)return void s.instrument_logger.error("No req found in koa ctx");const n=o[s.hudConfig.metricSymbol];n?n.setFlowId(e):s.instrument_logger.error("No endpoint metric found in koa req")}function l(e,t){return e+"|"+t}t.default=c;const d=new Map;function f(e,t,r){d.set(l(t,r),e)}function p(e){if(0===e.length)return;const t=e[0]._matchedRoute,r=e[0].req?.method;return function(e,t){return d.get(l(e,t))}(t,r)}},2080:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqsMetric=void 0;const o=r(9873);class n extends o.FlowMetric{error;msgCount;e2eEpocStartTimeMS;e2eDurationNS;constructor(e){super(e)}end(){this.e2eEpocStartTimeMS&&(this.e2eDurationNS=Number(Date.now()-this.e2eEpocStartTimeMS)*Number(1e6)),super.end()}_createUsableMetric(e){return this}toRaw(){return{flow_id:this.flowId,type:"SqsMetric",duration:this.duration,e2e_duration:this.e2eDurationNS,msg_count:this.msgCount,error:this.error}}}t.SqsMetric=n},2197:function(e,t,r){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)},i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.koa=t.express=t.safeLog=t.registerHook=t.hudRITM=void 0;var a=r(5688);Object.defineProperty(t,"hudRITM",{enumerable:!0,get:function(){return a.hudRITM}}),Object.defineProperty(t,"registerHook",{enumerable:!0,get:function(){return a.registerHook}}),Object.defineProperty(t,"safeLog",{enumerable:!0,get:function(){return a.safeLog}}),s(r(3901),t),t.express=i(r(7127)),s(r(714),t),t.koa=i(r(1502)),s(r(7166),t)},2546:e=>{"use strict";e.exports=require("./lib")},2729:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(2546),n=r(2822),s=r(8949),i=r(8901),a=r(714);class c extends a.FrameworkPatcher{_patch(e){const t=this._patchGetFramework(e);return o.instrument_logger.info("Patched serverless-http/lib/framework/get-framework.js successfully"),t}_patchGetFramework(e){const t=e;return e=function(...e){const r=t.apply(t.this,e);async function a(e,...t){const s=i.HttpEndpointMetric.createUsableMetric();try{s.start(),s.setRequestAttributes(e),e[o.hudConfig.metricSymbol]=s}catch(e){o.instrument_logger.error("Failed to start flowMetric during framework serverless request handler patching",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}const a=await(0,n.runWithInvestigation)((()=>r.apply(r.this,[e,...t])));return a.once("finish",(function(){try{(0,n.finishHttpInvestigation)(e,a,s),s.setResponseAttributes(a),s.end()}catch(e){o.instrument_logger.error("Failed to end flowMetric during framework serverless request handler patching",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}})),a}return(0,s.copyPropertiesToTarget)(r,a),a},(0,s.copyPropertiesToTarget)(t,e),e}}t.default=c},2741:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(2546),n=r(6730),s=r(4815),i=r(7225),a=r(714);class c extends a.FrameworkPatcher{_patch(e){return i.isVerboseLoggingEnabled?((0,n.patchMethods)(e,"application_export"),(0,s.patchUse)(e,"application",!1),(0,i.logLazyRouter)(e),o.instrument_logger.info("Patched express.Application successfully"),e):(o.instrument_logger.info("Skipping express.Application patching, verbose logging is not enabled"),e)}}t.default=c},2784:e=>{"use strict";e.exports=require("../native/_index")},2822:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.finishHttpInvestigation=t.getStacktraceUniqString=t.storeInvestigation=t.closeInvestigation=t.runWithInvestigation=t.createNewInvestigation=t.getBaseInvestigationStorage=t.serializableInvestigation=void 0;const o=r(8528),n=r(8269),s=r(2546),i=r(7131),a=/(?:\n\s*at.*)+$/;function c(e){return{status:e.status,context:e.context,exceptions:Array.from(Array.from(e.exceptions?.values()??[]).map((({exception:e,executionFlow:t})=>{return{name:(0,i.extractNameOptional)(e),message:(0,i.extractMessage)(e),stackTrace:(r=e,r?.stack?.match(a)?.[0]),executionFlow:t};var r}))??[])}}function u(){return{status:o.InvestigationStatus.Open}}function l(){if(!globalThis.hudEnableInvestigation)return;const e=(0,i.getStorage)().getStore();return void 0!==e&&e.status===o.InvestigationStatus.Open?(e.status=o.InvestigationStatus.Closed,e):void 0}function d(e,t){e.context=t,(0,n.storeClosedInvestigation)(c(e))}t.serializableInvestigation=c,t.getBaseInvestigationStorage=u,t.createNewInvestigation=function(){globalThis.hudEnableInvestigation&&(0,i.getStorage)().enterWith(u())},t.runWithInvestigation=function(e){return globalThis.hudEnableInvestigation?(0,i.getStorage)().run(u(),e):e()},t.closeInvestigation=l,t.storeInvestigation=d;const f=/.*\((.*):(\d+):(\d+)\)/,p=/.*?(\S*):(\d+):(\d+)/;function g(e){const t=Error.prepareStackTrace;if(void 0===t||"function"!=typeof t)return;let r,o;try{Error.prepareStackTrace=(e,t)=>{r=t[0],o=t};const n=e.stack;if(void 0!==n&&void 0===r){const t=function(e){const t=e.indexOf("\n");if(-1===t)return;const r=e.indexOf("\n",t+1);return e.slice(t+1,-1===r?void 0:r)}(n);if(!t)return;const r=t.match(f);if(r&&r[1]&&r[2]&&r[3])return`${e.name}@${r[1]}:${r[2]}:${r[3]}`;const o=t.match(p);return o&&o[1]&&o[2]&&o[3]?`${e.name}@${o[1]}:${o[2]}:${o[3]}`:void 0}if(void 0===r||void 0===o)return;Object.defineProperty(e,"stack",{configurable:!0,enumerable:!1,get:()=>t(e,o)})}finally{Error.prepareStackTrace=t}try{return`${e.name}@${r.getFileName()}:${r.getLineNumber()}:${r.getColumnNumber()}`}catch{}}function h(e,t=s.hudConfig.investigation.maxObjectDepth){try{if("string"==typeof e)return e.length>s.hudConfig.investigation.maxStringLength?e.slice(0,s.hudConfig.investigation.maxStringLength)+"...":e;if(Array.isArray(e))return e.slice(0,s.hudConfig.investigation.maxArrayLength).map((e=>h(e,t-1)));if(null===e||["number","boolean"].includes(typeof e))return e;if("bigint"==typeof e)return e.toString();if("object"==typeof e){const r={...e};for(const o in e)r[o]=h(e[o],t-1);return r}}catch{}}t.getStacktraceUniqString=g,t.finishHttpInvestigation=function(e,t,r){const o=l();if(void 0===o)return;if(void 0===o.firstException)return;if(t.statusCode<500)return;if(n.globalInvestigationTracking>=s.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigations)return;const i=r.getFlowId();if(void 0===i)return;const a=g(o.firstException);if(void 0===a)return;if(((0,n.getInvestigationDedupingCache)(i).get(a)??0)+1>s.hudConfig.dynamicConfig.investigationRateLimits.maxSameInvestigations)return;(0,n.increaseGlobalInvestigationTracking)(),(0,n.increaseInvestigationDedupingCache)(i,a);const c=r.getMsStartTime();void 0!==r.route&&void 0!==r.method&&void 0!==c?d(o,{type:"http",endpoint_uuid:i,route:r.route,method:r.method,timestamp:c,params:e.params,query:e.query,request_body:h(e.body),status_code:t.statusCode}):s.app_logger.error("route, method, or reqTimestamp is undefined even though they shouldn't",{flowId:i,route:r.route,method:r.method,reqTimestamp:c})}},2828:(e,t,r)=>{var o={"./codeGenieServerlessExpress":336,"./codeGenieServerlessExpress.ts":336,"./express":7127,"./express.ts":7127,"./express/methods":6730,"./express/methods.ts":6730,"./express/route":2977,"./express/route.ts":2977,"./express/router":4815,"./express/router.ts":4815,"./express/verbosity":7225,"./express/verbosity.ts":7225,"./expressApplication":2741,"./expressApplication.ts":2741,"./flows/endpoints/metrics":8901,"./flows/endpoints/metrics.ts":8901,"./flows/flow":9873,"./flows/flow.ts":9873,"./flows/graphql":6504,"./flows/graphql.ts":6504,"./flows/kafkajs":828,"./flows/kafkajs.ts":828,"./flows/sqs":2080,"./flows/sqs.ts":2080,"./frameworkPatcher":714,"./frameworkPatcher.ts":714,"./graphql":7214,"./graphql.ts":7214,"./http":5459,"./http.ts":5459,"./kafkajs":486,"./kafkajs.ts":486,"./koa":1502,"./koa.ts":1502,"./nestjsInterceptor":3531,"./nestjsInterceptor.ts":3531,"./nestjsRouterExecutionContext":646,"./nestjsRouterExecutionContext.ts":646,"./nestjsRpcContextCreator":4290,"./nestjsRpcContextCreator.ts":4290,"./router":5946,"./router.ts":5946,"./serverlessHttp":2729,"./serverlessHttp.ts":2729,"./sqsConsumer":5150,"./sqsConsumer.ts":5150};function n(e){var t=s(e);return r(t)}function s(e){if(!r.o(o,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return o[e]}n.keys=function(){return Object.keys(o)},n.resolve=s,e.exports=n,n.id=2828},2977:function(e,t,r){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.patchRoute=void 0;const i=r(8528),a=r(8269),c=r(2546),u=s(r(6982)),l=r(8949),d=r(6730),f=r(5673);function p(e,t,r,o){!function(e,t,r,o){e[c.hudConfig.express.layerStateSymbol]||(e[c.hudConfig.express.layerStateSymbol]={}),e[c.hudConfig.express.layerStateSymbol][t]?e[c.hudConfig.express.layerStateSymbol][t].methods.push(r):e[c.hudConfig.express.layerStateSymbol][t]={layerPath:o,methods:[r]}}(e,t,r,o),function(e,t,r){const o=new i.EndpointDeclaration(e,[t],"express",void 0,void 0,r);(0,a.storePartialEndpointDeclaration)(o),(0,a.storeExpressEndpointDeclaration)(o)}(t,r,o)}function g(e,t,r){const o=new i.EndpointDeclaration(e,t,"express",void 0,r,void 0);(0,a.storeExpressEndpointDeclaration)(o)}function h(e,t){if(e&&!(e.length<1)){if(c.hudConfig.express.wrapAllCallbacks)for(let r=0;r<e.length;r++){const o=(0,l.wrapFlow)(_(t),e[r],y);e[r]=o}else{const r=(0,l.wrapFlow)(_(t),e[e.length-1],y);e[e.length-1]=r}return t}}function m(e){return(0,a.getLinkedConsistentFlowId)(e,!1)||(c.instrument_logger.warn("No consistent flowId found, returning temporary flow id",{flowId:e}),e)}function _(e){return e?function(){return m(e)}:function(e){const t=e[0]?.route[c.hudConfig.express.layerStateSymbol],r=e[0]?.url;if(t)for(const[e,o]of Object.entries(t)){if(o.layerPath instanceof RegExp&&o.layerPath.test(r))return m(e);if(r.includes(o.layerPath))return m(e)}c.instrument_logger.warn("No flowId found for path",{states:t,url:r.split("?")[0]})}}function y(e,t,r){let o=0;if(4===r.length)o=1;else if(3!==r.length)return void c.instrument_logger.error("Invalid number of arguments in express request",{length:r.length});if(!r[o])return void c.instrument_logger.error("No request object in express request");const n=r[o][c.hudConfig.metricSymbol];n?n.setFlowId(e):c.instrument_logger.error("No endpoint metric found in express request")}t.patchRoute=function(e){const t=(0,d.getMethods)();t.concat("all").forEach((function(r){const o=e.prototype[r];e.prototype[r]=function(){let e;try{e=f(Array.prototype.slice.call(arguments));let o=function(e){const t=e[0][c.hudConfig.express.layerStateSymbol];if(t)return t.flowId}(e);const n=function(e){const t=e[0][c.hudConfig.express.layerStateSymbol];if(t)return t.kind}(e),s=function(e){const t=e[0][c.hudConfig.express.layerStateSymbol];return!!t&&t.allMethod}(e);if(o||(o=[u.randomUUID()]),"application"===n)if(Array.isArray(this.path)){h(e,void 0);for(let e=0;e<this.path.length;e++)g(o[e],s?t:[r],this.path[e])}else h(e,o[0]),g(o[0],s?t:[r],this.path);else if("router"===n)if(Array.isArray(this.path)){h(e,void 0);for(let e=0;e<this.path.length;e++)p(this,o[e],r,this.path[e])}else h(e,o[0]),p(this,o[0],r,this.path);else h(e,o[0]),p(this,o[0],r,this.path)}catch(e){c.instrument_logger.error("Failed to patch express.Route.route",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return o.apply(this,e||arguments)}}))}},3176:e=>{"use strict";e.exports=require("buffer-crc32")},3339:e=>{"use strict";e.exports=require("module")},3531:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.generateKey=t.getRequestByCallback=void 0;const o=r(2546);r(3702);const n=r(8949),s=r(714),i=new Map;function a(e,t){const r=Reflect.getMetadata("path",t)??Reflect.getMetadata("microservices:pattern",t);if(!r)return void o.instrument_logger.error("No callback path found on callback",{callback:t});const n=e.constructor.CONTROLLER_ID;if(n)return`${n}.${r}`;o.instrument_logger.error("No controller id found on controller",{controller:e})}t.getRequestByCallback=function(e){const t=i.get(e);return t&&i.delete(e),t},t.generateKey=a;class c extends s.FrameworkPatcher{_patch(e){return this._patchIntercept(e),o.instrument_logger.info("Patched NestJS intercept successfully"),e}_patchIntercept(e){const t=e.InterceptorsConsumer.prototype.intercept;e.InterceptorsConsumer.prototype.intercept=async function(...e){return function(e){try{const t=e[2],r=e[3];if("function"==typeof t.constructor&&"function"==typeof r){let o;if("rpc"===e[5])o=e[1][1].args[0];else if(o=e[1][0],!o||o.raw)return;const n=a(t,r);if(!n)return;i.set(n,o)}else o.instrument_logger.error("Invalid args in NestJS InterceptorsConsumer.intercept",{args:e})}catch(e){o.instrument_logger.error("Error in NestJS intercept patcher",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}(e),await t.apply(this,e)},(0,n.copyPropertiesToTarget)(t,e.InterceptorsConsumer.prototype.intercept)}}t.default=c},3702:e=>{"use strict";e.exports=require("reflect-metadata")},3868:e=>{"use strict";e.exports=require("@jridgewell/sourcemap-codec")},3901:function(e,t,r){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return n(t,e),t},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.incrementInstrumentedFunctionsCount=t.edit=t.editInSplits=t.splitCode=t.getFunctionWrapperTemplate=void 0;const a=i(r(3176)),c=r(3903),u=r(2546),l=r(8528),d=r(8269),f=r(2546),p=r(3868),g=s(r(2784)),h=/([0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12})/;function m(){return u.SDK_MODULE_NAME+"/wrap"}function _(e,t,r=!1){const o=`${e}_hudTemp`,n="BODY_PLACEHOLDER",s="FUNCTION_ID_PLACEHOLDER",i="AWAITABLE_PLACEHOLDER";let a;return a=r?[]:t===l.Format.esm?[`import { createRequire as ${e}_createRequire } from "module";`,`const ${e}_require = ${e}_createRequire(import.meta.url);`,`let ${e}_temp;`,`try { ${e}_temp = ${e}_require("${f.myRequire.resolve(m())}"); } catch (e) { ${e}_temp = { wrapperInitial: () => {}, wrapperCatch: () => {}, wrapperFinally: () => {}, fixStack: () => {} }; }`,`const { wrapperInitial: ${e}_wi, wrapperCatch: ${e}_wc, wrapperFinally: ${e}_wf, fixStack: ${e}_fs, asyncIteratorWrapper: ${e}_aiw } = ${e}_temp;`]:[`let ${e}_temp;`,`try { ${e}_temp = require("${f.myRequire.resolve(m())}"); } catch (e) { ${e}_temp = { wrapperInitial: () => {}, wrapperCatch: () => {}, wrapperFinally: () => {}, fixStack: () => {} }; }`,`const { wrapperInitial: ${e}_wi, wrapperCatch: ${e}_wc, wrapperFinally: ${e}_wf, fixStack: ${e}_fs, asyncIteratorWrapper: ${e}_aiw } = ${e}_temp;`],{functionWrapper:`{\n let ${o};\n const ${u.hudConfig.functionIdVarName} = ${s};\n const ${e}_cc = {};\n try {\n ${e}_wi(${u.hudConfig.functionIdVarName}, ${e}_cc);\n } catch (e) {\n globalThis._hud_SI = { value: 0 };\n globalThis._hud_S = [];\n }\n try {\n ${n}\n } catch (e) {\n try {\n ${e}_wc(${u.hudConfig.functionIdVarName}, ${e}_cc, e);\n } catch (e) {}\n throw e;\n } finally {\n try {\n ${e}_wf(${u.hudConfig.functionIdVarName}, ${e}_cc);\n } catch (e) {}\n }\n }`,awaitWrapper:`(${o} = ${i}, _hud_SI.value--, _hud_F = "", ${e}_cc.ff = true, ${o} = await ${o}, _hud_S[++_hud_SI.value] = ${u.hudConfig.functionIdVarName}, _hud_F = ${e}_cc.currentFlowId, ${e}_cc.ff= false, ${o})`,yieldWrapper:`\n function* ${e}_generatorWrapper() {\n return (${o} = ${i}, _hud_SI.value--, _hud_F = "", ${e}_cc.ff = true, ${o} = yield ${o}, _hud_S[++_hud_SI.value] = ${u.hudConfig.functionIdVarName}, _hud_F = ${e}_cc.currentFlowId, ${e}_cc.ff= false, ${o})\n }`,yieldStarWrapper:`\n function* ${e}_generatorWrapper() {\n return (${o} = ${i}, _hud_SI.value--, _hud_F = "", ${e}_cc.ff = true, ${o} = yield* ${o}, _hud_S[++_hud_SI.value] = ${u.hudConfig.functionIdVarName}, _hud_F = ${e}_cc.currentFlowId, ${e}_cc.ff= false, ${o})\n }`,initialStatements:a,bodyPlaceholder:n,functionIdPlaceholder:s,awaitablePlaceholder:i,fixStackFunction:`\n try{\n ${e}_fs(${u.hudConfig.functionIdVarName}, ${e}_cc)\n }catch(e){};`,asyncIteratorWrapper:`${e}_aiw`,awaitableVariable:o}}function y(e,t,r=!0,o=!1){const n=Error.prepareStackTrace;let s=!1,i=function(e){const t=e.match(`${u.hudConfig.bundlerBuildIdVarName}="${h.source}"`);if(t&&t.length>0)return t[1]}(e);i||(i=function(e){return(0,c.v5)(e,u.hudConfig.bundlerBuildUuidNamespace)}(e),s=!0);const l=(0,c.v5)(e,u.hudConfig.functionUuidNamespace),d=(0,a.default)(t.filename).readUInt32BE(),f=(0,a.default)(e).readUInt32BE(),p={data:t,bundlerBuildId:i,prefix:u.hudConfig.wrapVarPrefix,..._(u.hudConfig.wrapVarPrefix,t.format,o),uuidNamespace:u.hudConfig.functionUuidNamespace,fileHash:l,useInputSourcemap:r},m=g.transform(e,p);return O(m.functionsIds.length),Error.prepareStackTrace=n,u.instrument_logger.debug(`Successfully transformed ${t.filename}`),{code:m.code,map:m.map,functionIds:m.functionsIds,filename:t.filename,hasInputMap:m.isInputSourcemap,bundlerBuildId:i,bundlerBuildIdGenerated:s,file_path_checksum:d,file_checksum:f,sourceCodeHash:l,moduleBase:m.moduleBase}}t.getFunctionWrapperTemplate=_;class b extends Error{}function v(e,t){if(e&&t)throw new b("Start mark found inside mark");if(!e&&!t)throw new b("End mark found outside mark")}function w(e,t,r,o){const n=e.split("\n");let s=r,i=o;return s+=n.length-1,s+=t.split("\n").length-1,s===r?i+=n.pop()?.length||0:i=n.pop()?.length||0,{lineOffset:s,columnOffset:i}}function*k(e){let t=!1,r=0,o=0,n=!1,s=0,i=0;const a=new RegExp(`globalThis\\s*?&&\\s*?\\(globalThis\\.${u.hudConfig.esbuildGlobalVar}\\s*?=\\s*?"(Start|End):(?<fileName>.*?)"\\);?`,"g");for(const c of e.matchAll(a)){if(n=!0,!c.groups)throw new b("No groups found in match");const{fileName:a}=c.groups,[u,l]=c,d="Start"===l;v(d,t);let f="";if(t){const t=c.index+u.length;f=e.slice(r,t);const n=o+Buffer.byteLength(f,"utf8");yield{edit:!0,code:f,fileName:a,lineOffset:s,columnOffset:i,indexOffset:o,indexOffsetEnd:n},r=t,o=n}else{const t=c.index;f=e.slice(r,t),o+=Buffer.byteLength(f,"utf8"),r=t,yield{edit:!1,code:f}}t=!!d,({lineOffset:s,columnOffset:i}=w(f,u,s,i))}if(t)throw new b("End mark found outside mark");n?r<e.length&&(yield{edit:!1,code:e.slice(r)}):yield{edit:!1,code:e}}function S(e,t,r){u.instrument_logger.debug("Edit chunk",{fileName:e.fileName,size:e.code.length,edit:t}),r?.push({fileName:e.fileName,size:e.code.length,edit:t})}function E(e,t,r){const o=y(e.code,{filename:t,format:r},!1,!0),n=o.code;return o.mapRelativeToChunk=o.map,o.map=function(e,t,r){"string"==typeof e&&(e=JSON.parse(e));const o=(0,p.decode)(e.mappings);return o.forEach((e=>{e.forEach((e=>{e.length>=4&&"number"==typeof e[2]&&("number"==typeof e[3]&&0===e[2]&&(e[3]+=r),e[2]+=t)}))})),JSON.stringify({...e,mappings:(0,p.encode)(o),sourcesContent:void 0})}(o.map,e.lineOffset,e.columnOffset),{codeToAppend:n,metadata:{...o,filename:t,lineOffset:e.lineOffset,columnOffset:e.columnOffset}}}function M(e,t,r,o=!1,n=()=>!0){let s="",i=0,a=0;const c=[];let l=0;const d=o?[]:void 0,f=_(u.hudConfig.wrapVarPrefix,r).initialStatements.join("\n"),p=function(e){return e.slice(u.hudConfig.esbuildMark.length,u.hudConfig.esbuildMark.length+36)}(e);for(const o of k(e)){l++;try{let e="",u=!1;if(o.edit&&(u=n(o.fileName),d&&S(o,u,d)),o.edit&&u){const n=E(o,t,r);e=n.codeToAppend,c.push({...n.metadata,bundlerBuildId:p,transformedLineOffset:i,transformedColumnOffset:a,indexOffset:o.indexOffset,indexOffsetEnd:o.indexOffsetEnd})}else e=0===s.length?x(o.code,f):o.code;({transformedCodeLineOffset:i,transformedCodeColumnOffset:a}=C(e,i,a)),s+=e}catch(r){return u.instrument_logger.error("Failed to patch index",{index:l,filename:t,msg:r instanceof Error?r.message:void 0,stack:r instanceof Error?r.stack:void 0}),{transformedCode:e,metadatas:[],editedChunksSizes:d}}}return{transformedCode:s,metadatas:c,editedChunksSizes:d}}function x(e,t){let r="";return e.startsWith('"use strict";')?(r+='"use strict";',r+=t,r+=e.slice(13),r):(r+=t,r+=e,r)}function C(e,t,r){const o=e.split("\n");return o.length>1?(t+=o.length-1,r=o.pop()?.length||0):r+=e.length,{transformedCodeLineOffset:t,transformedCodeColumnOffset:r}}t.splitCode=k,t.editInSplits=M,t.edit=function(e,t,r){if(e.startsWith(u.hudConfig.esbuildMark))return u.instrument_logger.info("Editing in splits"),M(e,t,r,!1);{const o=y(e,{filename:t,format:r},u.hudConfig.userConfig.disableSourceMapsResolution?.value??!0);return{transformedCode:o.code,metadatas:[o]}}};let I=0;function O(e){I+=e;const t=u.hudConfig.userConfig?.maxMappedFunctions?.value??0;I>=t&&(u.customer_logger.log(u.UserErrorLogs.InstrumentedFunctionCountExceeded(t)),u.app_logger.error("Instrumented function count exceeded",{instrumentedFunctionsCount:I,maxMappedFunctions:t}),(0,d.detachHud)(!1,!1))}t.incrementInstrumentedFunctionsCount=O},3903:e=>{"use strict";e.exports=require("uuid")},4290:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(2546),n=r(8949),s=r(714),i=r(3531);class a extends s.FrameworkPatcher{_patch(e){return this._patchCreate(e),o.instrument_logger.info("Patched NestJS RpcContextCreator successfully"),e}_patchCreate(e){const t=e.RpcContextCreator.prototype.create;e.RpcContextCreator.prototype.create=function(...e){try{const t=e[0],r=e[1];if("function"==typeof t.constructor&&"function"==typeof r){const s=(0,i.generateKey)(t,r);s&&(e[1]=(0,n.wrapFlow)((()=>{try{const e=(0,i.getRequestByCallback)(s);if(!e)return void o.instrument_logger.error("No msg object found for key",{key:s});const t=function(e){if(e)return e[o.hudConfig.metricSymbol]?e[o.hudConfig.metricSymbol].getFlowId?e[o.hudConfig.metricSymbol].getFlowId():void o.instrument_logger.error("No getFlowId function found on metric object"):void o.instrument_logger.error("No metric found on nestjs msg object")}(e);return t||o.instrument_logger.error("No flow id found for key",{key:s}),t}catch(e){o.instrument_logger.error("Error in NestJS getFlowId",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}),r))}else o.instrument_logger.error("Invalid args in NestJS RpcContextCreator.create",{args:e})}catch(e){o.instrument_logger.error("Error in NestJS RpcContextCreator patcher",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return t.apply(this,e)},(0,n.copyPropertiesToTarget)(t,e.RpcContextCreator.prototype.create)}}t.default=a},4815:function(e,t,r){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.extractEndpointsFromRouter=t.patchUse=void 0;const i=r(8528),a=r(2546),c=s(r(6982)),u=r(8949),l=r(7225),d=r(5673);function f(e){e[a.hudConfig.express.markedSymbol]||(globalThis.hudExpressState.push(e),e[a.hudConfig.express.markedSymbol]=!0)}function p(e,t){const r=[];for(const[o,n]of Object.entries(e.route[a.hudConfig.express.layerStateSymbol]))r.push(new i.EndpointDeclaration(o,n.methods,"express",t,n.layerPath));return Array.from(r.values())}t.patchUse=function(e,t,r=!0){const o=e.use;e.use=function(e){const n=o.apply(this,arguments);try{let o=this[l.uuidSymbol];!o&&l.isVerboseLoggingEnabled&&(o=c.randomUUID(),this[l.uuidSymbol]=o,a.instrument_logger.info("Express use setting uuid",{kind:t,uuid:o})),"application"===t?function(e,t,r,o){try{r&&(e._router?f(e._router):e.router?f(e.router):a.instrument_logger.warn("Express application doesn't have router or _router")),o&&l.isVerboseLoggingEnabled&&a.instrument_logger.info("Express use app",{parent:o,child:t[1]?.[l.uuidSymbol]||"no uuid",path:t[0]})}catch(e){a.instrument_logger.error("Failed to save express app router",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}(this,arguments,r,o):"router"===t&&function(e,t,r,o,n){try{if(!e.stack)return void a.instrument_logger.error("Express router without stack");if(0===e.stack.length)return void a.instrument_logger.warn("Express router with an empty stack");"query"===e.stack[0].name?f(e):l.isVerboseLoggingEnabled&&!l.skipLayerNamesLogs.has(e.stack[0].name)&&(l.skipLayerNamesLogs.add(e.stack[0].name),a.instrument_logger.warn("Found unknown stack name",{stack:e.stack[0].name}));const{path:s,offset:i}=function(e){let t=0,r="/";if("function"!=typeof e){let o=e;for(;Array.isArray(o)&&0!==o.length;)o=o[0];"function"!=typeof o&&(t=1,r=e)}return{path:r,offset:t}}(n),u=d(Array.prototype.slice.call(t,i));for(let t=0;t<u.length&&t<e.stack.length;t++){const n=e.stack[e.stack.length-t-1],i=u[u.length-t-1];"router"===n.name?(i&&!i[l.uuidSymbol]&&l.isVerboseLoggingEnabled&&(i[l.uuidSymbol]=c.randomUUID(),a.instrument_logger.info("Express handle router setting uuid",{uuid:i[l.uuidSymbol]})),r&&(n[a.hudConfig.express.routeNamesSymbol]=s)):l.isVerboseLoggingEnabled&&!l.skipLayerNamesLogs.has(n.name)&&(l.skipLayerNamesLogs.add(n.name),a.instrument_logger.warn("Found unknown layer name",{layer:n.name,parent:o,child:i[l.uuidSymbol]||"no uuid",path:s}))}}catch(e){a.instrument_logger.error("Failed to patch router.use function",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}(this,arguments,r,o,e)}catch(e){a.instrument_logger.error("Failed to patch express.use function",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return n},(0,u.copyPropertiesToTarget)(o,e.use)},t.extractEndpointsFromRouter=function e(t,r){let o=[];if(!r.stack)return a.instrument_logger.error("Router without stack - bad OTEL version",{router:r}),o;for(const n of r.stack)if("router"===n.name){if(!n[a.hudConfig.express.routeNamesSymbol]){a.instrument_logger.error("Router layer without routes",{layer:n});continue}const r=t+n[a.hudConfig.express.routeNamesSymbol];o=o.concat(e(r,n.handle))}else n.route&&n.route[a.hudConfig.express.layerStateSymbol]?o=o.concat(p(n,t)):l.isVerboseLoggingEnabled&&!l.skipLayerNamesLogs.has(n.name)&&(l.skipLayerNamesLogs.add(n.name),a.instrument_logger.warn("Found unknown layer name when extracting endpoints",{layer:n.name}));return o}},5150:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(8269),n=r(2546),s=r(7131),i=r(8949),a=r(2080),c=r(714);class u extends c.FrameworkPatcher{isSupported(e,t,r,o){const s=n.hudConfig.userConfig.enableDapulse?.value?o.mondayVersion:o.bbcVersion,i=(0,c.extractModuleVersion)(e);return!!(0,c.isSupportedVersion)(i,s)||(n.instrument_logger.warn("Unsupported sqs-consumer version",{framework:"SqsConsumer",version:i,supportedVersion:s,basedir:e,isDapulse:n.hudConfig.userConfig.enableDapulse?.value}),n.customer_logger.log(n.UserErrorLogs.UnsupportedFrameworkVersion("sqs-consumer")),!1)}_patch(e){return function(e){const t=e.Consumer.create;e.Consumer.create=function(...e){const r=t.apply(this,e);try{!function(e){const t=e.queueUrl;if(!t)throw new n.HudNoQueueUrlInSqsConsumer;const r=l(t);if(e.handleMessageBatch&&"function"==typeof e.handleMessageBatch){const t="handleMessageBatch",s=(0,n.generateSqsFlowId)(r,t);(0,o.storeSqsQueueDeclaration)({flow_id:s,queue_name:r,handle_type:t});const a=e.handleMessageBatch,c=(0,i.wrapFlow)((()=>s),a,d,p,g);e.handleMessageBatch=c}else if(e.handleMessage&&"function"==typeof e.handleMessage){const t="handleMessage",s=(0,n.generateSqsFlowId)(r,t);(0,o.storeSqsQueueDeclaration)({flow_id:s,queue_name:r,handle_type:t});const a=e.handleMessage,c=(0,i.wrapFlow)((()=>s),a,d,p,g);e.handleMessage=c}else n.instrument_logger.warn("Unable to getFlowId - No handleMessage or handleMessageBatch found in SqsConsumer.Consumer",{queueName:r})}(r),function(e){const t=e.on;e.on=function(...r){try{const t=r[0];if(!t||"string"!=typeof t)throw new n.HudNoEventTypeInSqsConsumerOn;const s=r[1];if(!s||"function"!=typeof s)throw new n.HudNoCallbackInSqsConsumerOn;const a=l(e.queueUrl),c="event",u=(0,n.generateSqsFlowId)(a,c,t);(0,o.storeSqsQueueDeclaration)({flow_id:u,queue_name:a,handle_type:c,event_type:t}),r[1]=(0,i.wrapFlow)((()=>u),s,f,p,g)}catch(e){n.instrument_logger.error("Error in SqsConsumer.Consumer.on patched logic",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return t.apply(this,r)}}(r)}catch(e){n.instrument_logger.error("Error in patching SqsConsumer.Consumer",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return r},(0,i.copyPropertiesToTarget)(t,e.Consumer.create)}(e),n.instrument_logger.info("Patched sqs-consumer successfully",{isDapulse:n.hudConfig.userConfig.enableDapulse?.value}),e}}function l(e){const t=e.split("/").pop();if(!t)throw new n.HudFailExtractSqsQueueName(`Url: ${e}`);return t}function d(e,t,r){const o=a.SqsMetric.createUsableMetric(e);o.start();const s=r[0];if(!s)return n.instrument_logger.warn("No messages pass to sqs handler",{flowId:e}),void(t.flowMetric=o);if(Array.isArray(s)){if(o.msgCount=s.length,s[0]?.Attributes?.SentTimestamp){const t=s.reduce(((e,t)=>{const r=Number.parseInt(t?.Attributes?.SentTimestamp);return isNaN(r)?e:Math.min(e,r)}),1/0);t!==1/0?o.e2eEpocStartTimeMS=t:n.instrument_logger.warn("No valid SentTimestamp found eventhough the first element had SentTimestamp",{flowId:e})}}else o.msgCount=1,s?.Attributes?.SentTimestamp&&(o.e2eEpocStartTimeMS=s.Attributes.SentTimestamp);t.flowMetric=o}function f(e,t,r){const o=a.SqsMetric.createUsableMetric(e);o.start(),t.flowMetric=o}function p(e,t){const r=t.flowMetric;r?r.end():n.instrument_logger.warn("No flowMetric found for message during catch",{flowId:e})}function g(e,t,r){const o=t.flowMetric;o?(o.error=(0,s.extractName)(r),o.end()):n.instrument_logger.warn("No flowMetric found for message during catch",{flowId:e})}t.default=u},5459:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(2546),n=r(2822),s=r(8949),i=r(8901),a=r(714);class c extends a.FrameworkPatcher{_patch(e){return this._patchEmit(e),o.instrument_logger.info("Patched http successfully"),e}_patchEmit(e){const t=e.Server.prototype.emit;e.Server.prototype.emit=function(e,...r){if("request"!==e)return t.apply(this,[e,...r]);try{const e=r[0],t=r[1],s=i.HttpEndpointMetric.createUsableMetric();s.start(),(0,n.createNewInvestigation)(),s.setRequestAttributes(e),t.once("finish",(function(){try{(0,n.finishHttpInvestigation)(e,t,s),s.setResponseAttributes(t),s.end()}catch(e){o.instrument_logger.error("Failed to set response attributes",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}})),e[o.hudConfig.metricSymbol]=s}catch(e){o.instrument_logger.error("Failed to patch http.Server.prototype.emit",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return t.apply(this,[e,...r])},(0,s.copyPropertiesToTarget)(t,e.Server.prototype.emit)}}t.default=c},5673:e=>{"use strict";e.exports=require("array-flatten")},5688:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.registerHook=t.safeLog=t.hudRITM=void 0;const o=r(8269),n=r(2546),s=r(7166);function i(){n.instrument_logger.warn("Init timeout disabling hud!"),n.customer_logger.log(n.UserErrorLogs.InitTimeout(globalThis.hudIsRunningFromSetup)),(0,o.detachHud)(!1)}t.hudRITM=s.onRequireFn,t.safeLog=function(e){try{n.app_logger.debug(e)}catch(e){return}},t.registerHook=function(){if(n.app_logger.info("HUD is required"),process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE){if(n.app_logger.info("Running in Lambda environment"),parseInt(process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE)<n.hudConfig.lambdaMinimunMemory){const e=process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE;return n.app_logger.warn("Lambda function memory size is less than required, Hud will not run",{memorySize:e}),n.customer_logger.log(n.UserErrorLogs.UnsupportedLambdaMemory()),!1}globalThis.hudRuningInsideLambda=!0}return(0,o.initGlobals)(),n.app_logger.debug("InitGlobals done"),!(globalThis.hudStartFromAutoInit&&!(0,o.validateAndGetUserInput)()||(n.instrument_logger.isValid()?globalThis.hudRanOnRequire?(n.instrument_logger.warn("Already ran onRequire!"),1):(globalThis.hudRanOnRequire=!0,n.instrument_logger.info("Using module",{name:n.SDK_MODULE_NAME}),(0,s.onRequire)(),n.instrument_logger.debug("onRequire done"),globalThis.hudInitGuard=setTimeout(i,n.hudConfig.userConfig.maxTimeUntilInitSessionMs?.value??0),globalThis.hudInitGuard.unref(),0):((0,o.detachHud)(!1),1)))}},5946:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(2546),n=r(6730),s=r(4815),i=r(714);class a extends i.FrameworkPatcher{_patch(e){return(0,s.patchUse)(e.prototype,"router"),(0,n.patchMethods)(e.prototype,"router"),o.instrument_logger.info("Patched router successfully"),e}}t.default=a},6093:e=>{"use strict";e.exports=require("@cspotcode/source-map-support")},6504:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GraphQLMetric=void 0;const o=r(9873);class n extends o.FlowMetric{constructor(e){super(e)}_createUsableMetric(e){return this}toRaw(){return{flow_id:this.flowId,type:"GraphQLMetric",duration:this.duration}}}t.GraphQLMetric=n},6730:function(e,t,r){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.patchMethods=t.getMethods=void 0;const i=r(2546),a=s(r(6982)),c=r(8949),u=r(7225);function l(){const e=r(8611);return e.METHODS&&e.METHODS.map((function(e){return e.toLowerCase()}))||["get","post","put","head","delete","options","trace","copy","lock","mkcol","move","purge","propfind","proppatch","unlock","report","mkactivity","checkout","merge","m-search","notify","subscribe","unsubscribe","patch","search","connect"]}t.getMethods=l,t.patchMethods=function(e,t){l().concat("all").forEach((function(r){const o=e[r];if(!o)return void(u.isVerboseLoggingEnabled&&i.instrument_logger.warn("Method not found",{method:r}));const n="all"===r;e[r]=function(){try{if(arguments.length<2)return o.apply(this,arguments);let e=this[u.uuidSymbol];u.isVerboseLoggingEnabled&&(e||(e=a.randomUUID(),this[u.uuidSymbol]=e,i.instrument_logger.info("Express method setting uuid",{uuid:e,kind:t})),i.instrument_logger.info("Express added new method",{method:r,uuid:e,path:arguments[0]}));const s=Array.prototype.slice.call(arguments);if(s[1][i.hudConfig.express.layerStateSymbol]={flowId:[],kind:t,allMethod:n},Array.isArray(s[0]))for(const e of s[0]){const e=a.randomUUID();s[1][i.hudConfig.express.layerStateSymbol].flowId.push(e)}else s[1][i.hudConfig.express.layerStateSymbol].flowId.push(a.randomUUID());const c=o.apply(this,s);try{delete s[1][i.hudConfig.express.layerStateSymbol]}catch(e){}return c}catch(e){i.instrument_logger.error("Failed to patch method",{kind:t,method:r,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return o.apply(this,arguments)},(0,c.copyPropertiesToTarget)(o,e[r])}))}},6928:e=>{"use strict";e.exports=require("path")},6982:e=>{"use strict";e.exports=require("crypto")},7127:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(2546),n=r(6730),s=r(2977),i=r(4815),a=r(7225),c=r(714);class u extends c.FrameworkPatcher{_patch(e){return(0,s.patchRoute)(e.Route),(0,i.patchUse)(e.application,"application"),(0,n.patchMethods)(e.application,"application"),a.isVerboseLoggingEnabled&&(0,a.logLazyRouter)(e.application),e.Router.use?((0,i.patchUse)(e.Router,"router"),(0,n.patchMethods)(e.Router,"router")):o.instrument_logger.warn("Skipping express.Router patching"),o.instrument_logger.info("Patched express successfully"),e}}t.default=u},7131:e=>{"use strict";e.exports=require("./wrap")},7166:function(e,t,r){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.onRequire=t.skip=t.updateModuleChecker=t.createCheckers=t.patchRequire=t.onRequireFn=t.patchCompile=t.patch=t.supportSourceMapInstall=void 0;const i=s(r(9896)),a=s(r(6928)),c=r(8528),u=r(2546),l=r(3901),d=r(8528),f=r(2546),p=r(9063),g=r(714),h=function(){const e=f.SDK_MODULE_NAME;try{return a.dirname(a.dirname(f.myRequire.resolve(e)))}catch(t){return u.instrument_logger.error("Failed to resolve own path",{moduleName:e,msg:t instanceof Error?t.message:void 0,stack:t instanceof Error?t.stack:void 0}),null}}();function m(e){const t=globalThis.HudSourceMapCache.get(e);return t?{map:JSON.parse(t)}:null}function _(){r(6093).install({handleUncaughtExceptions:!1,hookRequire:!1,environment:"node",retrieveSourceMap:m})}function y(e,t,r,o){const n={code:e,map:void 0};try{if(globalThis.hudRunningMode===d.HudRunningMode.detached)return n;if(r===c.Format.esm&&!o)throw new f.HudError("MessagePort is required for patching ESM modules");if(F(t));else if(e.length>(f.hudConfig.userConfig.maxFileSizeBytes?.value??0)&&!e.startsWith(f.hudConfig.esbuildMark))u.instrument_logger.info("Skipping large file",{filename:t,size:e.length});else{const s=Date.now(),c=(0,l.edit)(e,t,r),d=c.metadatas;if(n.code=c.transformedCode,n.map=d,u.instrument_logger.debug("Patched",{filename:t,time:Date.now()-s}),o)for(const e of d)o.postMessage({key:"HudModulePatch",hudPatched:t,hudProcessedFiles:e});else globalThis.hudPatched.add(t),globalThis.hudProcessedFiles.push(...d),globalThis.hudDeclarationsFound=!0,globalThis.hudInstrumentationIndicator&&(clearTimeout(globalThis.hudInstrumentationIndicator),globalThis.hudInstrumentationIndicator=void 0);f.hudConfig.writePatched&&function(e,t){const r=a.parse(e);let o=`${r.dir}/patched.${r.base}`;r.dir.includes("dist")&&(o=a.join(`${r.dir.replace("dist","patched")}`,r.base)),i.existsSync(a.dirname(o))||i.mkdirSync(a.dirname(o),{recursive:!0}),i.writeFileSync(o,t,"utf8"),u.instrument_logger.debug("Dumped patched file",{filename:e,patchedPath:o})}(t,c.transformedCode)}}catch(e){u.instrument_logger.error("Failed to patch",{filename:t,format:r,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return n}t.supportSourceMapInstall=_,t.patch=y;let b="",v=!0,w=!1;function k(){if(!(0,f.isSupportedNative)())return;const e=r(3339),t=(0,u.shouldSupportSourceMap)();w&&u.instrument_logger.warn("PatchCompile ran twice"),0===Object.keys(globalThis.hudLoadedModules).length&&(globalThis.hudLoadedModules=Object.keys(f.myRequire.cache));const o=e.prototype._compile;e.prototype._compile=function(e,r){if(r===b){try{const e=v?u.instrument_logger.warn.bind(u.instrument_logger):u.instrument_logger.debug.bind(u.instrument_logger);v=!1,e("Skipping compile since already ran",{filename:r})}catch{}return o.call(this,e,r)}b=r,u.instrument_logger.verbose("Compiling requirement",{filename:r});const n=y(e,r,c.Format.cjs);try{if(t&&n.map){const e=(0,u.combineSourceMaps)(n.map,r);e&&globalThis.HudSourceMapCache.set(r,e)}}catch(e){u.instrument_logger.error("Failed to combine source maps",{filename:r,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}const s=o.call(this,n.code,r);return b="",s},w=!0,u.instrument_logger.debug("Patched _compile")}function S(e,t,r){try{const o=f.hudConfig.frameworksToPatch.get(t);return o?.patcher&&o.version?(0,g.getFrameworkPatcher)(o.patcher).patch(e,r,o.version,o.extraInfo,t):e}catch(e){u.instrument_logger.error("Failed to patch framework",{name:t,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return e}function E(){new p.Hook(Array.from(f.hudConfig.frameworksToPatch.keys()),{internals:!0},S)}function M(e){return{isAllowdModule:new RegExp("/node_modules/"+e.split(".").join("\\.").split("*").join(".*?")+"/",""),isAllowdModuleSubModule:new RegExp("/node_modules/"+e.split("*").join(".*?")+"/node_modules/","")}}function x(e,t){return!!t.isAllowdModule.test(e)&&!t.isAllowdModuleSubModule.test(e)}function C(e,t){return e.includes(`node_modules/${t}/`)&&!e.includes(`node_modules/${t}/node_modules`)}function I(e){const t=[];for(const r of e){let e;if(r.includes("*")){const t=M(r);e=e=>x(e,t)}else e=e=>C(e,r);t.push(e)}return t}t.patchCompile=k,t.onRequireFn=S,t.patchRequire=E,t.createCheckers=I;let O=[];function P(){O=I(f.hudConfig.userConfig.includeModules?.value??[])}function F(e,t){if(!f.hudConfig.allowedEditExtensions.includes(a.extname(e)))return u.instrument_logger.warn("Skipping non-allowed extension",{filename:e}),!0;const r=t??O;return"/var/runtime/index.mjs"===e?(u.instrument_logger.debug("Skipping lambda runtime",{filename:e}),!0):e.includes("node_modules")&&!function(e,t){for(const r of t)if(r(e))return!0;return!1}(e,r)||e.includes(".yarn")?(u.instrument_logger.debug("Skipping non-monitored imported module",{filename:e}),!0):!(h&&!e.includes(h)||(u.instrument_logger.debug("Skipping hud internal module",{filename:e}),0))}t.updateModuleChecker=P,t.skip=F,t.onRequire=function(){try{P();try{k()}catch(e){u.instrument_logger.error("Failed to patch compile",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}try{(0,u.shouldSupportSourceMap)()&&_()}catch(e){u.instrument_logger.error("Failed to install source map support",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}try{E()}catch(e){u.instrument_logger.error("Failed to patch require",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}catch(e){u.instrument_logger.error("Something went wrong in onRequire",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}},7214:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(8528),n=r(8269),s=r(2546),i=r(8949),a=r(6504),c=r(714);class u extends c.FrameworkPatcher{static graphQLPatchedSymbol=Symbol.for(s.hudConfig.hudPatchedName);_patch(e){return this.patchGraphql(e),s.instrument_logger.info("Patched GraphQL successfully"),e}patchGraphql(e){const t=e.execute;e.execute=function(e){!function(e){try{e&&!e[u.graphQLPatchedSymbol]&&(l(e._queryType),l(e._mutationType),e[u.graphQLPatchedSymbol]=!0,s.instrument_logger.info("Patched GraphQL schema successfully"))}catch(e){s.instrument_logger.error("Failed to patch GraphQL schema",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}(e.schema);const r=process.hrtime.bigint();return function(e,t,r){return"function"==typeof e.then?e.then((e=>(g(t,r),e))):(g(t,r),e)}(t.apply(this,arguments),e.document,r)},(0,i.copyPropertiesToTarget)(t,e.execute)}}function l(e){if(!e)return;const t=e._fields;Object.keys(t).forEach((r=>{const c=t[r];!function(e,t,r){if(e.resolve&&!e.resolve[u.graphQLPatchedSymbol]){const o=(0,s.generateGraphqlFlowId)(r,t);(0,n.storeResolverDeclaration)({id:o,operation:t,name:r});const c=e.resolve;e.resolve=(0,i.wrapFlow)(p,c,((e,t)=>{const r=a.GraphQLMetric.createUsableMetric();r.start(),r.setFlowId(e),t.flowMetric=r}),((e,t)=>{const r=t.flowMetric;r?r.end():s.instrument_logger.warn("No flowMetric found for resolver",{flowId:e})}),((e,t)=>{const r=t.flowMetric;r?r.end():s.instrument_logger.warn("No flowMetric found for resolver",{flowId:e})})),e.resolve[u.graphQLPatchedSymbol]=!0,(0,n.storeResolverIdBySelectionName)(o,r)}}(c,o.GraphQLSupportedOperations[e.name.toLowerCase()],r),c.type._fields&&f(c.type)}))}t.default=u;const d=new WeakSet;function f(e){e&&e._fields&&!d.has(e)&&(d.add(e),Object.keys(e._fields).forEach((t=>{const r=e._fields[t];if(!r||!r.type)return;!function(e){const t=e.resolve;t&&!e.resolve[u.graphQLPatchedSymbol]&&(e.resolve=(0,i.wrapFlow)(p,t),e.resolve[u.graphQLPatchedSymbol]=!0)}(r);let o=r.type;for(;o.ofType;)o=o.ofType;f(o)})))}function p(e){if(void 0===e[2]||void 0===e[3])return void s.instrument_logger.warn("GraphQL resolver arguments are unknown",{args:e});const t=e[3].path;if(t&&!t.prev){const r=t.key,o=(0,n.getResolverIdBySelectionName)(r);return e[2][u.graphQLPatchedSymbol]=o,o}if(e[2][u.graphQLPatchedSymbol])return e[2][u.graphQLPatchedSymbol];s.instrument_logger.warn("GraphQL No functionId found for resolver",{args:e})}function g(e,t){try{new n.GraphQLDocumentMetadata(e,Number(process.hrtime.bigint()-t)).save()}catch(e){s.instrument_logger.error("Failed to save document metadata",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}},7225:function(e,t,r){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.logLazyRouter=t.skipStackNamesLogs=t.skipLayerNamesLogs=t.isVerboseLoggingEnabled=t.uuidSymbol=void 0;const i=r(2546),a=s(r(6982)),c=r(932),u=r(8949);t.uuidSymbol=Symbol.for("__hud_uuid__"),t.isVerboseLoggingEnabled="true"===c.env.HUD_LOG_EXPRESS,t.skipLayerNamesLogs=new Set(["query","expressInit","mounted_app"]),t.skipStackNamesLogs=new Set(["router"]),t.logLazyRouter=function(e){const r=e.lazyrouter;e.lazyrouter=function(){let e=!1;try{this._router||(e=!0)}catch(e){i.instrument_logger.error("Failed to check this._router",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}const o=r.apply(this,arguments);try{if(e){let e=this[t.uuidSymbol];e||(e=a.randomUUID(),this[t.uuidSymbol]=e,i.instrument_logger.info("Express lazy router setting uuid",{uuid:e})),i.instrument_logger.info("Express lazy router",{parent:e,child:this._router?.[t.uuidSymbol]})}}catch(e){i.instrument_logger.error("Failed to patch express.lazyRouter function",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return o},(0,u.copyPropertiesToTarget)(r,e.lazyrouter)}},7707:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncFunction=void 0,t.AsyncFunction=(async()=>{}).constructor},8064:e=>{"use strict";e.exports=require("semver")},8269:e=>{"use strict";e.exports=require("./globalstate")},8528:e=>{"use strict";e.exports=require("./dto")},8611:e=>{"use strict";e.exports=require("http")},8901:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HttpEndpointMetric=void 0;const o=r(9873);class n extends o.FlowMetric{statusCode;route;method;constructor(e){super(e)}_createUsableMetric(e){return this}setRequestAttributes(e){const t=e.url||e.path;this.route=t?.split("?")[0],this.method=e.method}setResponseAttributes(e){this.statusCode=e.statusCode}toRaw(){if(this.statusCode&&this.route&&this.method)return{flow_id:this.flowId,type:"EndpointMetric",duration:this.duration,status_code:this.statusCode,route:this.route,method:this.method}}}t.HttpEndpointMetric=n},8949:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.copyPropertiesToTarget=t.wrapFlow=void 0;const o=r(8528),n=r(2546),s=r(7707);function i(e,t){const r=Object.getOwnPropertyDescriptors(e),o=Reflect.ownKeys(r);Object.setPrototypeOf(t,e),o.forEach((e=>{try{Object.defineProperty(t,e,r[e])}catch(e){}}))}t.wrapFlow=function(e,t,r,a,c){let u;return u=t instanceof s.AsyncFunction?async function(...s){let i;try{i=e(s)}catch(e){n.instrument_logger.error("Failed to get flowId",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}if(!i||hudRunningMode!==o.HudRunningMode.enabled)return await t.apply(this,s);_hud_F=i,hudShouldLinkFunction=!0;const u={};if(r)try{r(i,u,s)}catch(e){n.instrument_logger.error("Failed to execute beforeCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}try{const e=t.apply(this,s);_hud_F="";const r=await e;if(a)try{a(i,u)}catch(e){n.instrument_logger.error("Failed to execute afterCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return r}catch(e){if(c)try{c(i,u,e)}catch(e){n.instrument_logger.error("Failed to execute catchCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}throw e}finally{_hud_F="",hudShouldLinkFunction=!1}}:function(...s){let i;try{i=e(s)}catch(e){n.instrument_logger.error("Failed to get flowId",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}if(!i||hudRunningMode!==o.HudRunningMode.enabled)return t.apply(this,s);_hud_F=i,hudShouldLinkFunction=!0;const u={};if(r)try{r(i,u,s)}catch(e){n.instrument_logger.error("Failed to execute beforeCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}try{const e=t.apply(this,s);if(a)if(e instanceof Promise)e.then((()=>{try{a(i,u)}catch(e){n.instrument_logger.error("Failed to execute afterCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}));else try{a(i,u)}catch(e){n.instrument_logger.error("Failed to execute afterCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return e}catch(e){if(c)try{c(i,u,e)}catch(e){n.instrument_logger.error("Failed to execute catchCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}throw e}finally{_hud_F="",hudShouldLinkFunction=!1}},i(t,u),u},t.copyPropertiesToTarget=i},9063:e=>{"use strict";e.exports=require("require-in-the-middle")},9873:function(e,t,r){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FlowMetric=void 0;const n=r(8528),s=r(8269),i=o(r(932));t.FlowMetric=class{_state;flowId;duration;_startTime;_msStartTime;constructor(e){this.flowId=e,this.duration=0,this._state="usable"}static createUsableMetric(e){return new this(e)._createUsableMetric(e)}setFlowId(e){this.flowId=e}getFlowId(){return this.flowId}getMsStartTime(){return this._msStartTime}start(){this._startTime=i.default.hrtime.bigint(),this._msStartTime=Date.now()}end(){this._startTime&&(this.duration=Number(i.default.hrtime.bigint()-this._startTime)),this.#e(),this._state="unusable"}#e(){if(hudRunningMode===n.HudRunningMode.enabled){const e=this.toRaw();e&&(0,s.storeFlowMetric)(e)}}}},9896:e=>{"use strict";e.exports=require("fs")}},t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var s=t[o]={exports:{}};return e[o].call(s.exports,s,s.exports,r),s.exports}return r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r(2197)})()));
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(global,(()=>(()=>{var e={336:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(2546),n=r(2822),s=r(8949),i=r(8901),a=r(714);class c extends a.FrameworkPatcher{_patch(e){return this._patchSendRequest(e),o.instrument_logger.info("Patched @codegenie/serverless-express/src/frameworks/express.js successfully"),e}_patchSendRequest(e){const t=e.sendRequest;e.sendRequest=function(e){let r,s;const a=i.HttpEndpointMetric.createUsableMetric();try{if(r=e.request,s=e.response,!r||!s)return t.call(this,e);a.start(),a.setRequestAttributes(r),r[o.hudConfig.metricSymbol]=a}catch(e){o.instrument_logger.error("Failed to start flowMetric during sendRequest patching",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}const c=(0,n.runWithInvestigation)((()=>t.call(this,e)));try{s.once("finish",(function(){try{(0,n.finishHttpInvestigation)(r,s,a),a.setResponseAttributes(s),a.end()}catch(e){o.instrument_logger.error("Failed to end flowMetric during sendRequest patching",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}))}catch(e){o.instrument_logger.error("Failed to end flowMetric during sendRequest patching",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return c},(0,s.copyPropertiesToTarget)(t,e.sendRequest)}}t.default=c},486:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(8269),n=r(2546),s=r(8949),i=r(828),a=r(714);class c extends a.FrameworkPatcher{_patch(e){return this._patchConsumer(e),n.instrument_logger.info("Patched KafkaJS successfully"),e}_patchConsumer(e){const t=e.Kafka.prototype.consumer;e.Kafka.prototype.consumer=function(...e){const r=t.apply(this,e);try{const t=new Map,o=[],a=[];!function(e,t){const r=e.subscribe;e.subscribe=async function(...e){const o=await r.apply(this,e);try{const r=e[0].topics;r?r.forEach((e=>{t.push(e)})):e[0].topic?t.push(e[0].topic):n.instrument_logger.warn("No topic found in KafkaJS.Consumer.subscribe",{args:e[0]})}catch(e){n.instrument_logger.error("Error in patching KafkaJS.Consumer.subscribe",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return o},(0,s.copyPropertiesToTarget)(r,e.subscribe)}(r,a),function(e,t,r,o,a){const c=e.run;function p(e,c){const p="eachBatch"===c;for(const e of a)f(e,o,t,r,c);const g=function(e,t,r){return o=>{const s=o[0],i=r?s.batch.topic:s.topic;return function(e,t,r,o){const s=e.get(d(r,o));if(s)return s;for(const e of t)if(e.isBatch===o&&e.pattern.test(r))return e.flowId;n.instrument_logger.warn("No flowId found for topic",{topicName:r,isBatch:o})}(e,t,i,r)}}(t,r,p),h=function(e){return(t,r,o)=>{const s=i.KafkaJSMetric.createUsableMetric();s.start(),s.setFlowId(t);const a=o[0];void 0!==a&&void 0!==a.message&&(a.message[n.hudConfig.metricSymbol]=s);const c=e?a.batch.partition:a.partition,u=e?a.batch.messages[0]?.timestamp:a.message?.timestamp;s.addPartition(c),s.addProducedTimestamp(u),r.flowMetric=s}}(p),m=(0,s.wrapFlow)(g,e[c],h,u,l);e[c]=m}e.run=async function(...e){try{const t=e[0];t.eachMessage&&p(t,"eachMessage"),t.eachBatch&&p(t,"eachBatch")}catch(e){n.instrument_logger.error("Error in patching KafkaJS.Consumer.run",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return await c.apply(this,e)},(0,s.copyPropertiesToTarget)(c,e.run)}(r,t,o,e[0].groupId,a)}catch(e){n.instrument_logger.error("Error in patching KafkaJS.Consumer",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return r},(0,s.copyPropertiesToTarget)(t,e.Kafka.prototype.consumer)}}function u(e,t){const r=t.flowMetric;r?r.end():n.instrument_logger.warn("No flowMetric found for message",{flowId:e})}function l(e,t,r){const o=t.flowMetric;o?(o.setError(r),o.end()):n.instrument_logger.warn("No flowMetric found for message",{flowId:e})}function d(e,t){return e+"|"+t}function f(e,t,r,s,i){const a=(0,n.generateKafkaFlowId)(e,t,i),c={flow_id:a,topic_name:e.toString(),group_id:t,pulling_type:i};(0,o.storeKafkaJSTopicDeclaration)(c),function(e,t,r,o,n){"string"==typeof r?e.set(d(r,o),n):t.push({pattern:r,isBatch:o,flowId:n})}(r,s,e,"eachBatch"===i,a)}t.default=c},646:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(2546),n=r(8949),s=r(714),i=r(3531);class a extends s.FrameworkPatcher{_patch(e){return this._patchCreate(e),o.instrument_logger.info("Patched NestJS RouterExecutionContext successfully"),e}_patchCreate(e){const t=e.RouterExecutionContext.prototype.create;e.RouterExecutionContext.prototype.create=function(...e){try{const t=e[0],r=e[1];if("function"==typeof t.constructor&&"function"==typeof r){const s=(0,i.generateKey)(t,r);s&&(e[1]=(0,n.wrapFlow)((()=>{try{const e=(0,i.getRequestByCallback)(s);if(!e)return void o.instrument_logger.error("No request object found for key",{key:s});const t=function(e){if(e&&!e.raw&&e.socket)return e[o.hudConfig.metricSymbol]?e[o.hudConfig.metricSymbol].getFlowId?e[o.hudConfig.metricSymbol].getFlowId():void o.instrument_logger.error("No getFlowId function found on metric object"):void o.instrument_logger.error("No metric found on nestjs request object")}(e);return t||o.instrument_logger.error("No flow id found for key",{key:s}),t}catch(e){o.instrument_logger.error("Error in NestJS getFlowId",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}),r))}else o.instrument_logger.error("Invalid args in NestJS RouterExecutionContext.create",{args:e})}catch(e){o.instrument_logger.error("Error in NestJS RouterExecutionContext patcher",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return t.apply(this,e)},(0,n.copyPropertiesToTarget)(t,e.RouterExecutionContext.prototype.create)}}t.default=a},714:function(e,t,r){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.getFrameworkPatcher=t.extractModuleVersion=t.isSupportedVersion=t.FrameworkPatcher=void 0;const i=r(2546),a=r(9896),c=s(r(6928)),u=r(8064);function l(e,t){return""===e||u.satisfies(u.coerce(e),t)}function d(e){try{const t=(0,a.readFileSync)(c.join(e,"package.json"),{encoding:"utf8"}),r=JSON.parse(t).version;return"string"==typeof r?r:""}catch(t){i.instrument_logger.info("Failed extracting version",{baseDir:e})}return""}t.FrameworkPatcher=class{patch(e,t,r,o,n=this.constructor.name){try{if(this.isSupported(t,n,r,o))return this._patch(e)}catch(e){i.instrument_logger.error("Unhandeled error during patching framework",{framework:n,error:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return e}isSupported(e,t,r,o){const n=d(e);return!!l(n,r)||(i.instrument_logger.warn("Unsupported version",{framework:t,version:n,supportedVersion:r,basedir:e}),i.customer_logger.log(i.UserErrorLogs.UnsupportedFrameworkVersion(t)),!1)}},t.isSupportedVersion=l,t.extractModuleVersion=d,t.getFrameworkPatcher=function(e){return new(r(2828)(`./${e}`).default)}},828:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.KafkaJSMetric=void 0;const o=r(2546),n=r(7131),s=r(9873);class i extends s.FlowMetric{partition;error;producedTimestamp;totalConsumeDuration;constructor(e){super(e)}_createUsableMetric(e){return this}end(){this.producedTimestamp&&(this.totalConsumeDuration=Number(Date.now()-this.producedTimestamp)*Number(1e6)),super.end()}addProducedTimestamp(e){void 0!==e&&(this.producedTimestamp=Number(e))}addPartition(e){this.partition=e}setError(e){this.error=(0,n.extractName)(e)}toRaw(){if(void 0!==this.partition)return{flow_id:this.flowId,type:"KafkaJSMetric",duration:this.duration,partition:this.partition,error:this.error,total_consume_duration:this.totalConsumeDuration};o.instrument_logger.warn("No partition found for message",{flowId:this.flowId})}}t.KafkaJSMetric=i},932:e=>{"use strict";e.exports=require("process")},1502:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(8528),n=r(8269),s=r(2546),i=r(8949),a=r(714);class c extends a.FrameworkPatcher{static koaModuleName="koa";static koaPatchedSymbol=Symbol.for(s.hudConfig.hudPatchedName);_patch(e){return this._patchAppUse(e),s.instrument_logger.info("Patched koa successfully"),e}_patchAppUse(e){const t=e.prototype.use;e.prototype.use=function(e){const r=t.apply(this,arguments);try{if(!arguments[0].router)return r;const e=arguments[0].router.stack;for(let t=0;t<e.length;t++)c._wrapRoute(e[t])}catch(e){s.instrument_logger.error("Failed to patch koa.use function",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return r},(0,i.copyPropertiesToTarget)(t,e.prototype.use)}static _wrapRoute(e){if(e.methods&&0===e.methods.length)return;if(!e.stack[0][c.koaPatchedSymbol]){const t=(0,i.wrapFlow)(p,e.stack[0],u);e.stack[0]=t,e.stack[0][c.koaPatchedSymbol]=!0}const t=(0,s.generateEndpointFlowId)(e.path,e.methods);(0,n.storeKoaEndpointDeclaration)(new o.EndpointDeclaration(t,e.methods,"koa",void 0,e.path));for(const r of e.methods)f(t,e.path,r)}}function u(e,t,r){if(!r[0])return void s.instrument_logger.error("No ctx object found in koa");const o=r[0].req;if(!o)return void s.instrument_logger.error("No req found in koa ctx");const n=o[s.hudConfig.metricSymbol];n?n.setFlowId(e):s.instrument_logger.error("No endpoint metric found in koa req")}function l(e,t){return e+"|"+t}t.default=c;const d=new Map;function f(e,t,r){d.set(l(t,r),e)}function p(e){if(0===e.length)return;const t=e[0]._matchedRoute,r=e[0].req?.method;return function(e,t){return d.get(l(e,t))}(t,r)}},2080:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqsMetric=void 0;const o=r(9873);class n extends o.FlowMetric{error;msgCount;e2eEpocStartTimeMS;e2eDurationNS;constructor(e){super(e)}end(){this.e2eEpocStartTimeMS&&(this.e2eDurationNS=Number(Date.now()-this.e2eEpocStartTimeMS)*Number(1e6)),super.end()}_createUsableMetric(e){return this}toRaw(){return{flow_id:this.flowId,type:"SqsMetric",duration:this.duration,e2e_duration:this.e2eDurationNS,msg_count:this.msgCount,error:this.error}}}t.SqsMetric=n},2197:function(e,t,r){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)},i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.koa=t.express=t.safeLog=t.registerHook=t.hudRITM=void 0;var a=r(5688);Object.defineProperty(t,"hudRITM",{enumerable:!0,get:function(){return a.hudRITM}}),Object.defineProperty(t,"registerHook",{enumerable:!0,get:function(){return a.registerHook}}),Object.defineProperty(t,"safeLog",{enumerable:!0,get:function(){return a.safeLog}}),s(r(3901),t),t.express=i(r(7127)),s(r(714),t),t.koa=i(r(1502)),s(r(7166),t)},2546:e=>{"use strict";e.exports=require("./lib")},2729:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(2546),n=r(2822),s=r(8949),i=r(8901),a=r(714);class c extends a.FrameworkPatcher{_patch(e){const t=this._patchGetFramework(e);return o.instrument_logger.info("Patched serverless-http/lib/framework/get-framework.js successfully"),t}_patchGetFramework(e){const t=e;return e=function(...e){const r=t.apply(t.this,e);async function a(e,...t){const s=i.HttpEndpointMetric.createUsableMetric();try{s.start(),s.setRequestAttributes(e),e[o.hudConfig.metricSymbol]=s}catch(e){o.instrument_logger.error("Failed to start flowMetric during framework serverless request handler patching",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}const a=await(0,n.runWithInvestigation)((()=>r.apply(r.this,[e,...t])));return a.once("finish",(function(){try{(0,n.finishHttpInvestigation)(e,a,s),s.setResponseAttributes(a),s.end()}catch(e){o.instrument_logger.error("Failed to end flowMetric during framework serverless request handler patching",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}})),a}return(0,s.copyPropertiesToTarget)(r,a),a},(0,s.copyPropertiesToTarget)(t,e),e}}t.default=c},2741:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(2546),n=r(6730),s=r(4815),i=r(7225),a=r(714);class c extends a.FrameworkPatcher{_patch(e){return i.isVerboseLoggingEnabled?((0,n.patchMethods)(e,"application_export"),(0,s.patchUse)(e,"application",!1),(0,i.logLazyRouter)(e),o.instrument_logger.info("Patched express.Application successfully"),e):(o.instrument_logger.info("Skipping express.Application patching, verbose logging is not enabled"),e)}}t.default=c},2784:e=>{"use strict";e.exports=require("../native/_index")},2822:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.finishHttpInvestigation=t.getStacktraceUniqString=t.storeInvestigation=t.closeInvestigation=t.runWithInvestigation=t.createNewInvestigation=t.getBaseInvestigationStorage=t.serializableInvestigation=void 0;const o=r(8528),n=r(8269),s=r(2546),i=r(7131),a=/(?:\n\s*at.*)+$/;function c(e){return{status:e.status,context:e.context,exceptions:Array.from(Array.from(e.exceptions?.values()??[]).map((({exception:e,executionFlow:t})=>{return{name:(0,i.extractNameOptional)(e),message:(0,i.extractMessage)(e),stackTrace:(r=e,r?.stack?.match(a)?.[0]),executionFlow:t};var r}))??[])}}function u(){return{status:o.InvestigationStatus.Open}}function l(){if(!globalThis.hudEnableInvestigation)return;const e=(0,i.getStorage)().getStore();return void 0!==e&&e.status===o.InvestigationStatus.Open?(e.status=o.InvestigationStatus.Closed,e):void 0}function d(e,t){e.context=t,(0,n.storeClosedInvestigation)(c(e))}t.serializableInvestigation=c,t.getBaseInvestigationStorage=u,t.createNewInvestigation=function(){globalThis.hudEnableInvestigation&&(0,i.getStorage)().enterWith(u())},t.runWithInvestigation=function(e){return globalThis.hudEnableInvestigation?(0,i.getStorage)().run(u(),e):e()},t.closeInvestigation=l,t.storeInvestigation=d;const f=/.*\((.*):(\d+):(\d+)\)/,p=/.*?(\S*):(\d+):(\d+)/;function g(e){const t=Error.prepareStackTrace;if(void 0===t||"function"!=typeof t)return;let r,o;try{Error.prepareStackTrace=(e,t)=>{r=t[0],o=t};const n=e.stack;if(void 0!==n&&void 0===r){const t=function(e){const t=e.indexOf("\n");if(-1===t)return;const r=e.indexOf("\n",t+1);return e.slice(t+1,-1===r?void 0:r)}(n);if(!t)return;const r=t.match(f);if(r&&r[1]&&r[2]&&r[3])return`${e.name}@${r[1]}:${r[2]}:${r[3]}`;const o=t.match(p);return o&&o[1]&&o[2]&&o[3]?`${e.name}@${o[1]}:${o[2]}:${o[3]}`:void 0}if(void 0===r||void 0===o)return;Object.defineProperty(e,"stack",{configurable:!0,enumerable:!1,get:()=>t(e,o)})}finally{Error.prepareStackTrace=t}try{return`${e.name}@${r.getFileName()}:${r.getLineNumber()}:${r.getColumnNumber()}`}catch{}}function h(e,t=s.hudConfig.investigation.maxObjectDepth){try{if("string"==typeof e)return e.length>s.hudConfig.investigation.maxStringLength?e.slice(0,s.hudConfig.investigation.maxStringLength)+"...":e;if(Array.isArray(e))return e.slice(0,s.hudConfig.investigation.maxArrayLength).map((e=>h(e,t-1)));if(null===e||["number","boolean"].includes(typeof e))return e;if("bigint"==typeof e)return e.toString();if("object"==typeof e){const r={...e};for(const o in e)r[o]=h(e[o],t-1);return r}}catch{}}t.getStacktraceUniqString=g,t.finishHttpInvestigation=function(e,t,r){const o=l();if(void 0===o)return;if(void 0===o.firstException)return;if(t.statusCode<500)return;if(n.globalInvestigationTracking>=s.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigations)return;const i=r.getFlowId();if(void 0===i)return;const a=g(o.firstException);if(void 0===a)return;if(((0,n.getInvestigationDedupingCache)(i).get(a)??0)+1>s.hudConfig.dynamicConfig.investigationRateLimits.maxSameInvestigations)return;(0,n.increaseGlobalInvestigationTracking)(),(0,n.increaseInvestigationDedupingCache)(i,a);const c=r.getMsStartTime();void 0!==r.route&&void 0!==r.method&&void 0!==c?d(o,{type:"http",endpoint_uuid:i,route:r.route,method:r.method,timestamp:c,params:e.params,query:e.query,request_body:h(e.body),status_code:t.statusCode}):s.app_logger.error("route, method, or reqTimestamp is undefined even though they shouldn't",{flowId:i,route:r.route,method:r.method,reqTimestamp:c})}},2828:(e,t,r)=>{var o={"./codeGenieServerlessExpress":336,"./codeGenieServerlessExpress.ts":336,"./express":7127,"./express.ts":7127,"./express/methods":6730,"./express/methods.ts":6730,"./express/route":2977,"./express/route.ts":2977,"./express/router":4815,"./express/router.ts":4815,"./express/verbosity":7225,"./express/verbosity.ts":7225,"./expressApplication":2741,"./expressApplication.ts":2741,"./flows/endpoints/metrics":8901,"./flows/endpoints/metrics.ts":8901,"./flows/flow":9873,"./flows/flow.ts":9873,"./flows/graphql":6504,"./flows/graphql.ts":6504,"./flows/kafkajs":828,"./flows/kafkajs.ts":828,"./flows/sqs":2080,"./flows/sqs.ts":2080,"./frameworkPatcher":714,"./frameworkPatcher.ts":714,"./graphql":7214,"./graphql.ts":7214,"./http":5459,"./http.ts":5459,"./kafkajs":486,"./kafkajs.ts":486,"./koa":1502,"./koa.ts":1502,"./nestjsInterceptor":3531,"./nestjsInterceptor.ts":3531,"./nestjsRouterExecutionContext":646,"./nestjsRouterExecutionContext.ts":646,"./nestjsRpcContextCreator":4290,"./nestjsRpcContextCreator.ts":4290,"./router":5946,"./router.ts":5946,"./serverlessHttp":2729,"./serverlessHttp.ts":2729,"./sqsConsumer":5150,"./sqsConsumer.ts":5150};function n(e){var t=s(e);return r(t)}function s(e){if(!r.o(o,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return o[e]}n.keys=function(){return Object.keys(o)},n.resolve=s,e.exports=n,n.id=2828},2977:function(e,t,r){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.patchRoute=void 0;const i=r(8528),a=r(8269),c=r(2546),u=s(r(6982)),l=r(8949),d=r(6730),f=r(5673);function p(e,t,r,o){!function(e,t,r,o){e[c.hudConfig.express.layerStateSymbol]||(e[c.hudConfig.express.layerStateSymbol]={}),e[c.hudConfig.express.layerStateSymbol][t]?e[c.hudConfig.express.layerStateSymbol][t].methods.push(r):e[c.hudConfig.express.layerStateSymbol][t]={layerPath:o,methods:[r]}}(e,t,r,o),function(e,t,r){const o=new i.EndpointDeclaration(e,[t],"express",void 0,void 0,r);(0,a.storePartialEndpointDeclaration)(o),(0,a.storeExpressEndpointDeclaration)(o)}(t,r,o)}function g(e,t,r){const o=new i.EndpointDeclaration(e,t,"express",void 0,r,void 0);(0,a.storeExpressEndpointDeclaration)(o)}function h(e,t){if(e&&!(e.length<1)){if(c.hudConfig.express.wrapAllCallbacks)for(let r=0;r<e.length;r++){const o=(0,l.wrapFlow)(_(t),e[r],y);e[r]=o}else{const r=(0,l.wrapFlow)(_(t),e[e.length-1],y);e[e.length-1]=r}return t}}function m(e){return(0,a.getLinkedConsistentFlowId)(e,!1)||(c.instrument_logger.warn("No consistent flowId found, returning temporary flow id",{flowId:e}),e)}function _(e){return e?function(){return m(e)}:function(e){const t=e[0]?.route[c.hudConfig.express.layerStateSymbol],r=e[0]?.url;if(t)for(const[e,o]of Object.entries(t)){if(o.layerPath instanceof RegExp&&o.layerPath.test(r))return m(e);if(r.includes(o.layerPath))return m(e)}c.instrument_logger.warn("No flowId found for path",{states:t,url:r.split("?")[0]})}}function y(e,t,r){let o=0;if(4===r.length)o=1;else if(3!==r.length)return void c.instrument_logger.error("Invalid number of arguments in express request",{length:r.length});if(!r[o])return void c.instrument_logger.error("No request object in express request");const n=r[o][c.hudConfig.metricSymbol];n?n.setFlowId(e):c.instrument_logger.error("No endpoint metric found in express request")}t.patchRoute=function(e){const t=(0,d.getMethods)();t.concat("all").forEach((function(r){const o=e.prototype[r];e.prototype[r]=function(){let e;try{e=f(Array.prototype.slice.call(arguments));let o=function(e){const t=e[0][c.hudConfig.express.layerStateSymbol];if(t)return t.flowId}(e);const n=function(e){const t=e[0][c.hudConfig.express.layerStateSymbol];if(t)return t.kind}(e),s=function(e){const t=e[0][c.hudConfig.express.layerStateSymbol];return!!t&&t.allMethod}(e);if(o||(o=[u.randomUUID()]),"application"===n)if(Array.isArray(this.path)){h(e,void 0);for(let e=0;e<this.path.length;e++)g(o[e],s?t:[r],this.path[e])}else h(e,o[0]),g(o[0],s?t:[r],this.path);else if("router"===n)if(Array.isArray(this.path)){h(e,void 0);for(let e=0;e<this.path.length;e++)p(this,o[e],r,this.path[e])}else h(e,o[0]),p(this,o[0],r,this.path);else h(e,o[0]),p(this,o[0],r,this.path)}catch(e){c.instrument_logger.error("Failed to patch express.Route.route",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return o.apply(this,e||arguments)}}))}},3176:e=>{"use strict";e.exports=require("buffer-crc32")},3339:e=>{"use strict";e.exports=require("module")},3531:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.generateKey=t.getRequestByCallback=void 0;const o=r(2546);r(3702);const n=r(8949),s=r(714),i=new Map;function a(e,t){const r=Reflect.getMetadata("path",t)??Reflect.getMetadata("microservices:pattern",t);if(!r)return void o.instrument_logger.error("No callback path found on callback",{callback:t});const n=e.constructor.CONTROLLER_ID;if(n)return`${n}.${r}`;o.instrument_logger.error("No controller id found on controller",{controller:e})}t.getRequestByCallback=function(e){const t=i.get(e);return t&&i.delete(e),t},t.generateKey=a;class c extends s.FrameworkPatcher{_patch(e){return this._patchIntercept(e),o.instrument_logger.info("Patched NestJS intercept successfully"),e}_patchIntercept(e){const t=e.InterceptorsConsumer.prototype.intercept;e.InterceptorsConsumer.prototype.intercept=async function(...e){return function(e){try{const t=e[2],r=e[3];if("function"==typeof t.constructor&&"function"==typeof r){let o;if("rpc"===e[5]){if("win32"===process.platform)return;o=e[1][1].args[0]}else if(o=e[1][0],!o||o.raw)return;const n=a(t,r);if(!n)return;i.set(n,o)}else o.instrument_logger.error("Invalid args in NestJS InterceptorsConsumer.intercept",{args:e})}catch(e){o.instrument_logger.error("Error in NestJS intercept patcher",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}(e),await t.apply(this,e)},(0,n.copyPropertiesToTarget)(t,e.InterceptorsConsumer.prototype.intercept)}}t.default=c},3702:e=>{"use strict";e.exports=require("reflect-metadata")},3868:e=>{"use strict";e.exports=require("@jridgewell/sourcemap-codec")},3901:function(e,t,r){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return n(t,e),t},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.incrementInstrumentedFunctionsCount=t.edit=t.editInSplits=t.splitCode=t.getFunctionWrapperTemplate=void 0;const a=i(r(3176)),c=r(3903),u=r(2546),l=r(8528),d=r(8269),f=r(2546),p=r(3868),g=s(r(2784)),h=/([0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12})/;function m(e,t,r=!1){const o=`${e}_hudTemp`,n="BODY_PLACEHOLDER",s="FUNCTION_ID_PLACEHOLDER",i="AWAITABLE_PLACEHOLDER";let a;const c=f.myRequire.resolve(u.SDK_MODULE_NAME+"/wrap").replace(/\\/g,"\\\\");return a=r?[]:t===l.Format.esm?[`import { createRequire as ${e}_createRequire } from "module";`,`const ${e}_require = ${e}_createRequire(import.meta.url);`,`let ${e}_temp;`,`try { ${e}_temp = ${e}_require("${c}"); } catch (e) { ${e}_temp = { wrapperInitial: () => {}, wrapperCatch: () => {}, wrapperFinally: () => {}, fixStack: () => {} }; }`,`const { wrapperInitial: ${e}_wi, wrapperCatch: ${e}_wc, wrapperFinally: ${e}_wf, fixStack: ${e}_fs, asyncIteratorWrapper: ${e}_aiw } = ${e}_temp;`]:[`let ${e}_temp;`,`try { ${e}_temp = require("${c}"); } catch (e) { ${e}_temp = { wrapperInitial: () => {}, wrapperCatch: () => {}, wrapperFinally: () => {}, fixStack: () => {} }; }`,`const { wrapperInitial: ${e}_wi, wrapperCatch: ${e}_wc, wrapperFinally: ${e}_wf, fixStack: ${e}_fs, asyncIteratorWrapper: ${e}_aiw } = ${e}_temp;`],{functionWrapper:`{\n let ${o};\n const ${u.hudConfig.functionIdVarName} = ${s};\n const ${e}_cc = {};\n try {\n ${e}_wi(${u.hudConfig.functionIdVarName}, ${e}_cc);\n } catch (e) {\n globalThis._hud_SI = { value: 0 };\n globalThis._hud_S = [];\n }\n try {\n ${n}\n } catch (e) {\n try {\n ${e}_wc(${u.hudConfig.functionIdVarName}, ${e}_cc, e);\n } catch (e) {}\n throw e;\n } finally {\n try {\n ${e}_wf(${u.hudConfig.functionIdVarName}, ${e}_cc);\n } catch (e) {}\n }\n }`,awaitWrapper:`(${o} = ${i}, _hud_SI.value--, _hud_F = "", ${e}_cc.ff = true, ${o} = await ${o}, _hud_S[++_hud_SI.value] = ${u.hudConfig.functionIdVarName}, _hud_F = ${e}_cc.currentFlowId, ${e}_cc.ff= false, ${o})`,yieldWrapper:`\n function* ${e}_generatorWrapper() {\n return (${o} = ${i}, _hud_SI.value--, _hud_F = "", ${e}_cc.ff = true, ${o} = yield ${o}, _hud_S[++_hud_SI.value] = ${u.hudConfig.functionIdVarName}, _hud_F = ${e}_cc.currentFlowId, ${e}_cc.ff= false, ${o})\n }`,yieldStarWrapper:`\n function* ${e}_generatorWrapper() {\n return (${o} = ${i}, _hud_SI.value--, _hud_F = "", ${e}_cc.ff = true, ${o} = yield* ${o}, _hud_S[++_hud_SI.value] = ${u.hudConfig.functionIdVarName}, _hud_F = ${e}_cc.currentFlowId, ${e}_cc.ff= false, ${o})\n }`,initialStatements:a,bodyPlaceholder:n,functionIdPlaceholder:s,awaitablePlaceholder:i,fixStackFunction:`\n try{\n ${e}_fs(${u.hudConfig.functionIdVarName}, ${e}_cc)\n }catch(e){};`,asyncIteratorWrapper:`${e}_aiw`,awaitableVariable:o}}function _(e,t,r=!0,o=!1){const n=Error.prepareStackTrace;let s=!1,i=function(e){const t=e.match(`${u.hudConfig.bundlerBuildIdVarName}="${h.source}"`);if(t&&t.length>0)return t[1]}(e);i||(i=function(e){return(0,c.v5)(e,u.hudConfig.bundlerBuildUuidNamespace)}(e),s=!0);const l=(0,c.v5)(e,u.hudConfig.functionUuidNamespace),d=(0,a.default)(t.filename).readUInt32BE(),f=(0,a.default)(e).readUInt32BE(),p={data:t,bundlerBuildId:i,prefix:u.hudConfig.wrapVarPrefix,...m(u.hudConfig.wrapVarPrefix,t.format,o),uuidNamespace:u.hudConfig.functionUuidNamespace,fileHash:l,useInputSourcemap:r},_=g.transform(e,p);return I(_.functionsIds.length),Error.prepareStackTrace=n,u.instrument_logger.debug(`Successfully transformed ${t.filename}`),{code:_.code,map:_.map,functionIds:_.functionsIds,filename:t.filename,hasInputMap:_.isInputSourcemap,bundlerBuildId:i,bundlerBuildIdGenerated:s,file_path_checksum:d,file_checksum:f,sourceCodeHash:l,moduleBase:_.moduleBase}}t.getFunctionWrapperTemplate=m;class y extends Error{}function b(e,t){if(e&&t)throw new y("Start mark found inside mark");if(!e&&!t)throw new y("End mark found outside mark")}function v(e,t,r,o){const n=e.split("\n");let s=r,i=o;return s+=n.length-1,s+=t.split("\n").length-1,s===r?i+=n.pop()?.length||0:i=n.pop()?.length||0,{lineOffset:s,columnOffset:i}}function*w(e){let t=!1,r=0,o=0,n=!1,s=0,i=0;const a=new RegExp(`globalThis\\s*?&&\\s*?\\(globalThis\\.${u.hudConfig.esbuildGlobalVar}\\s*?=\\s*?"(Start|End):(?<fileName>.*?)"\\);?`,"g");for(const c of e.matchAll(a)){if(n=!0,!c.groups)throw new y("No groups found in match");const{fileName:a}=c.groups,[u,l]=c,d="Start"===l;b(d,t);let f="";if(t){const t=c.index+u.length;f=e.slice(r,t);const n=o+Buffer.byteLength(f,"utf8");yield{edit:!0,code:f,fileName:a,lineOffset:s,columnOffset:i,indexOffset:o,indexOffsetEnd:n},r=t,o=n}else{const t=c.index;f=e.slice(r,t),o+=Buffer.byteLength(f,"utf8"),r=t,yield{edit:!1,code:f}}t=!!d,({lineOffset:s,columnOffset:i}=v(f,u,s,i))}if(t)throw new y("End mark found outside mark");n?r<e.length&&(yield{edit:!1,code:e.slice(r)}):yield{edit:!1,code:e}}function k(e,t,r){u.instrument_logger.debug("Edit chunk",{fileName:e.fileName,size:e.code.length,edit:t}),r?.push({fileName:e.fileName,size:e.code.length,edit:t})}function S(e,t,r){const o=_(e.code,{filename:t,format:r},!1,!0),n=o.code;return o.mapRelativeToChunk=o.map,o.map=function(e,t,r){"string"==typeof e&&(e=JSON.parse(e));const o=(0,p.decode)(e.mappings);return o.forEach((e=>{e.forEach((e=>{e.length>=4&&"number"==typeof e[2]&&("number"==typeof e[3]&&0===e[2]&&(e[3]+=r),e[2]+=t)}))})),JSON.stringify({...e,mappings:(0,p.encode)(o),sourcesContent:void 0})}(o.map,e.lineOffset,e.columnOffset),{codeToAppend:n,metadata:{...o,filename:t,lineOffset:e.lineOffset,columnOffset:e.columnOffset}}}function E(e,t,r,o=!1,n=()=>!0){let s="",i=0,a=0;const c=[];let l=0;const d=o?[]:void 0,f=m(u.hudConfig.wrapVarPrefix,r).initialStatements.join("\n"),p=function(e){return e.slice(u.hudConfig.esbuildMark.length,u.hudConfig.esbuildMark.length+36)}(e);for(const o of w(e)){l++;try{let e="",u=!1;if(o.edit&&(u=n(o.fileName),d&&k(o,u,d)),o.edit&&u){const n=S(o,t,r);e=n.codeToAppend,c.push({...n.metadata,bundlerBuildId:p,transformedLineOffset:i,transformedColumnOffset:a,indexOffset:o.indexOffset,indexOffsetEnd:o.indexOffsetEnd})}else e=0===s.length?M(o.code,f):o.code;({transformedCodeLineOffset:i,transformedCodeColumnOffset:a}=x(e,i,a)),s+=e}catch(r){return u.instrument_logger.error("Failed to patch index",{index:l,filename:t,msg:r instanceof Error?r.message:void 0,stack:r instanceof Error?r.stack:void 0}),{transformedCode:e,metadatas:[],editedChunksSizes:d}}}return{transformedCode:s,metadatas:c,editedChunksSizes:d}}function M(e,t){let r="";return e.startsWith('"use strict";')?(r+='"use strict";',r+=t,r+=e.slice(13),r):(r+=t,r+=e,r)}function x(e,t,r){const o=e.split("\n");return o.length>1?(t+=o.length-1,r=o.pop()?.length||0):r+=e.length,{transformedCodeLineOffset:t,transformedCodeColumnOffset:r}}t.splitCode=w,t.editInSplits=E,t.edit=function(e,t,r){if(e.startsWith(u.hudConfig.esbuildMark))return u.instrument_logger.info("Editing in splits"),E(e,t,r,!1);{const o=_(e,{filename:t,format:r},u.hudConfig.userConfig.disableSourceMapsResolution?.value??!0);return{transformedCode:o.code,metadatas:[o]}}};let C=0;function I(e){C+=e;const t=u.hudConfig.userConfig?.maxMappedFunctions?.value??0;C>=t&&(u.customer_logger.log(u.UserErrorLogs.InstrumentedFunctionCountExceeded(t)),u.app_logger.error("Instrumented function count exceeded",{instrumentedFunctionsCount:C,maxMappedFunctions:t}),(0,d.detachHud)(!1,!1))}t.incrementInstrumentedFunctionsCount=I},3903:e=>{"use strict";e.exports=require("uuid")},4290:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(2546),n=r(8949),s=r(714),i=r(3531);class a extends s.FrameworkPatcher{_patch(e){return this._patchCreate(e),o.instrument_logger.info("Patched NestJS RpcContextCreator successfully"),e}_patchCreate(e){const t=e.RpcContextCreator.prototype.create;e.RpcContextCreator.prototype.create=function(...e){try{const t=e[0],r=e[1];if("function"==typeof t.constructor&&"function"==typeof r){const s=(0,i.generateKey)(t,r);s&&(e[1]=(0,n.wrapFlow)((()=>{try{const e=(0,i.getRequestByCallback)(s);if(!e)return void o.instrument_logger.error("No msg object found for key",{key:s});const t=function(e){if(e)return e[o.hudConfig.metricSymbol]?e[o.hudConfig.metricSymbol].getFlowId?e[o.hudConfig.metricSymbol].getFlowId():void o.instrument_logger.error("No getFlowId function found on metric object"):void o.instrument_logger.error("No metric found on nestjs msg object")}(e);return t||o.instrument_logger.error("No flow id found for key",{key:s}),t}catch(e){o.instrument_logger.error("Error in NestJS getFlowId",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}),r))}else o.instrument_logger.error("Invalid args in NestJS RpcContextCreator.create",{args:e})}catch(e){o.instrument_logger.error("Error in NestJS RpcContextCreator patcher",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return t.apply(this,e)},(0,n.copyPropertiesToTarget)(t,e.RpcContextCreator.prototype.create)}}t.default=a},4815:function(e,t,r){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.extractEndpointsFromRouter=t.patchUse=void 0;const i=r(8528),a=r(2546),c=s(r(6982)),u=r(8949),l=r(7225),d=r(5673);function f(e){e[a.hudConfig.express.markedSymbol]||(globalThis.hudExpressState.push(e),e[a.hudConfig.express.markedSymbol]=!0)}function p(e,t){const r=[];for(const[o,n]of Object.entries(e.route[a.hudConfig.express.layerStateSymbol]))r.push(new i.EndpointDeclaration(o,n.methods,"express",t,n.layerPath));return Array.from(r.values())}t.patchUse=function(e,t,r=!0){const o=e.use;e.use=function(e){const n=o.apply(this,arguments);try{let o=this[l.uuidSymbol];!o&&l.isVerboseLoggingEnabled&&(o=c.randomUUID(),this[l.uuidSymbol]=o,a.instrument_logger.info("Express use setting uuid",{kind:t,uuid:o})),"application"===t?function(e,t,r,o){try{r&&(e._router?f(e._router):e.router?f(e.router):a.instrument_logger.warn("Express application doesn't have router or _router")),o&&l.isVerboseLoggingEnabled&&a.instrument_logger.info("Express use app",{parent:o,child:t[1]?.[l.uuidSymbol]||"no uuid",path:t[0]})}catch(e){a.instrument_logger.error("Failed to save express app router",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}(this,arguments,r,o):"router"===t&&function(e,t,r,o,n){try{if(!e.stack)return void a.instrument_logger.error("Express router without stack");if(0===e.stack.length)return void a.instrument_logger.warn("Express router with an empty stack");"query"===e.stack[0].name?f(e):l.isVerboseLoggingEnabled&&!l.skipLayerNamesLogs.has(e.stack[0].name)&&(l.skipLayerNamesLogs.add(e.stack[0].name),a.instrument_logger.warn("Found unknown stack name",{stack:e.stack[0].name}));const{path:s,offset:i}=function(e){let t=0,r="/";if("function"!=typeof e){let o=e;for(;Array.isArray(o)&&0!==o.length;)o=o[0];"function"!=typeof o&&(t=1,r=e)}return{path:r,offset:t}}(n),u=d(Array.prototype.slice.call(t,i));for(let t=0;t<u.length&&t<e.stack.length;t++){const n=e.stack[e.stack.length-t-1],i=u[u.length-t-1];"router"===n.name?(i&&!i[l.uuidSymbol]&&l.isVerboseLoggingEnabled&&(i[l.uuidSymbol]=c.randomUUID(),a.instrument_logger.info("Express handle router setting uuid",{uuid:i[l.uuidSymbol]})),r&&(n[a.hudConfig.express.routeNamesSymbol]=s)):l.isVerboseLoggingEnabled&&!l.skipLayerNamesLogs.has(n.name)&&(l.skipLayerNamesLogs.add(n.name),a.instrument_logger.warn("Found unknown layer name",{layer:n.name,parent:o,child:i[l.uuidSymbol]||"no uuid",path:s}))}}catch(e){a.instrument_logger.error("Failed to patch router.use function",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}(this,arguments,r,o,e)}catch(e){a.instrument_logger.error("Failed to patch express.use function",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return n},(0,u.copyPropertiesToTarget)(o,e.use)},t.extractEndpointsFromRouter=function e(t,r){let o=[];if(!r.stack)return a.instrument_logger.error("Router without stack - bad OTEL version",{router:r}),o;for(const n of r.stack)if("router"===n.name){if(!n[a.hudConfig.express.routeNamesSymbol]){a.instrument_logger.error("Router layer without routes",{layer:n});continue}const r=t+n[a.hudConfig.express.routeNamesSymbol];o=o.concat(e(r,n.handle))}else n.route&&n.route[a.hudConfig.express.layerStateSymbol]?o=o.concat(p(n,t)):l.isVerboseLoggingEnabled&&!l.skipLayerNamesLogs.has(n.name)&&(l.skipLayerNamesLogs.add(n.name),a.instrument_logger.warn("Found unknown layer name when extracting endpoints",{layer:n.name}));return o}},5150:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(8269),n=r(2546),s=r(7131),i=r(8949),a=r(2080),c=r(714);class u extends c.FrameworkPatcher{isSupported(e,t,r,o){const s=n.hudConfig.userConfig.enableDapulse?.value?o.mondayVersion:o.bbcVersion,i=(0,c.extractModuleVersion)(e);return!!(0,c.isSupportedVersion)(i,s)||(n.instrument_logger.warn("Unsupported sqs-consumer version",{framework:"SqsConsumer",version:i,supportedVersion:s,basedir:e,isDapulse:n.hudConfig.userConfig.enableDapulse?.value}),n.customer_logger.log(n.UserErrorLogs.UnsupportedFrameworkVersion("sqs-consumer")),!1)}_patch(e){return function(e){const t=e.Consumer.create;e.Consumer.create=function(...e){const r=t.apply(this,e);try{!function(e){const t=e.queueUrl;if(!t)throw new n.HudNoQueueUrlInSqsConsumer;const r=l(t);if(e.handleMessageBatch&&"function"==typeof e.handleMessageBatch){const t="handleMessageBatch",s=(0,n.generateSqsFlowId)(r,t);(0,o.storeSqsQueueDeclaration)({flow_id:s,queue_name:r,handle_type:t});const a=e.handleMessageBatch,c=(0,i.wrapFlow)((()=>s),a,d,p,g);e.handleMessageBatch=c}else if(e.handleMessage&&"function"==typeof e.handleMessage){const t="handleMessage",s=(0,n.generateSqsFlowId)(r,t);(0,o.storeSqsQueueDeclaration)({flow_id:s,queue_name:r,handle_type:t});const a=e.handleMessage,c=(0,i.wrapFlow)((()=>s),a,d,p,g);e.handleMessage=c}else n.instrument_logger.warn("Unable to getFlowId - No handleMessage or handleMessageBatch found in SqsConsumer.Consumer",{queueName:r})}(r),function(e){const t=e.on;e.on=function(...r){try{const t=r[0];if(!t||"string"!=typeof t)throw new n.HudNoEventTypeInSqsConsumerOn;const s=r[1];if(!s||"function"!=typeof s)throw new n.HudNoCallbackInSqsConsumerOn;const a=l(e.queueUrl),c="event",u=(0,n.generateSqsFlowId)(a,c,t);(0,o.storeSqsQueueDeclaration)({flow_id:u,queue_name:a,handle_type:c,event_type:t}),r[1]=(0,i.wrapFlow)((()=>u),s,f,p,g)}catch(e){n.instrument_logger.error("Error in SqsConsumer.Consumer.on patched logic",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return t.apply(this,r)}}(r)}catch(e){n.instrument_logger.error("Error in patching SqsConsumer.Consumer",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return r},(0,i.copyPropertiesToTarget)(t,e.Consumer.create)}(e),n.instrument_logger.info("Patched sqs-consumer successfully",{isDapulse:n.hudConfig.userConfig.enableDapulse?.value}),e}}function l(e){const t=e.split("/").pop();if(!t)throw new n.HudFailExtractSqsQueueName(`Url: ${e}`);return t}function d(e,t,r){const o=a.SqsMetric.createUsableMetric(e);o.start();const s=r[0];if(!s)return n.instrument_logger.warn("No messages pass to sqs handler",{flowId:e}),void(t.flowMetric=o);if(Array.isArray(s)){if(o.msgCount=s.length,s[0]?.Attributes?.SentTimestamp){const t=s.reduce(((e,t)=>{const r=Number.parseInt(t?.Attributes?.SentTimestamp);return isNaN(r)?e:Math.min(e,r)}),1/0);t!==1/0?o.e2eEpocStartTimeMS=t:n.instrument_logger.warn("No valid SentTimestamp found eventhough the first element had SentTimestamp",{flowId:e})}}else o.msgCount=1,s?.Attributes?.SentTimestamp&&(o.e2eEpocStartTimeMS=s.Attributes.SentTimestamp);t.flowMetric=o}function f(e,t,r){const o=a.SqsMetric.createUsableMetric(e);o.start(),t.flowMetric=o}function p(e,t){const r=t.flowMetric;r?r.end():n.instrument_logger.warn("No flowMetric found for message during catch",{flowId:e})}function g(e,t,r){const o=t.flowMetric;o?(o.error=(0,s.extractName)(r),o.end()):n.instrument_logger.warn("No flowMetric found for message during catch",{flowId:e})}t.default=u},5459:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(2546),n=r(2822),s=r(8949),i=r(8901),a=r(714);class c extends a.FrameworkPatcher{_patch(e){return this._patchEmit(e),o.instrument_logger.info("Patched http successfully"),e}_patchEmit(e){const t=e.Server.prototype.emit;e.Server.prototype.emit=function(e,...r){if("request"!==e)return t.apply(this,[e,...r]);try{const e=r[0],t=r[1],s=i.HttpEndpointMetric.createUsableMetric();s.start(),(0,n.createNewInvestigation)(),s.setRequestAttributes(e),t.once("finish",(function(){try{(0,n.finishHttpInvestigation)(e,t,s),s.setResponseAttributes(t),s.end()}catch(e){o.instrument_logger.error("Failed to set response attributes",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}})),e[o.hudConfig.metricSymbol]=s}catch(e){o.instrument_logger.error("Failed to patch http.Server.prototype.emit",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return t.apply(this,[e,...r])},(0,s.copyPropertiesToTarget)(t,e.Server.prototype.emit)}}t.default=c},5673:e=>{"use strict";e.exports=require("array-flatten")},5688:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.registerHook=t.safeLog=t.hudRITM=void 0;const o=r(8269),n=r(2546),s=r(7166);function i(){n.instrument_logger.warn("Init timeout disabling hud!"),n.customer_logger.log(n.UserErrorLogs.InitTimeout(globalThis.hudIsRunningFromSetup)),(0,o.detachHud)(!1)}t.hudRITM=s.onRequireFn,t.safeLog=function(e){try{n.app_logger.debug(e)}catch(e){return}},t.registerHook=function(){if(n.app_logger.info("HUD is required"),process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE){if(n.app_logger.info("Running in Lambda environment"),parseInt(process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE)<n.hudConfig.lambdaMinimunMemory){const e=process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE;return n.app_logger.warn("Lambda function memory size is less than required, Hud will not run",{memorySize:e}),n.customer_logger.log(n.UserErrorLogs.UnsupportedLambdaMemory()),!1}globalThis.hudRuningInsideLambda=!0}return(0,o.initGlobals)(),n.app_logger.debug("InitGlobals done"),!(globalThis.hudStartFromAutoInit&&!(0,o.validateAndGetUserInput)()||(n.instrument_logger.isValid()?globalThis.hudRanOnRequire?(n.instrument_logger.warn("Already ran onRequire!"),1):(globalThis.hudRanOnRequire=!0,n.instrument_logger.info("Using module",{name:n.SDK_MODULE_NAME}),(0,s.onRequire)(),n.instrument_logger.debug("onRequire done"),globalThis.hudInitGuard=setTimeout(i,n.hudConfig.userConfig.maxTimeUntilInitSessionMs?.value??0),globalThis.hudInitGuard.unref(),0):((0,o.detachHud)(!1),1)))}},5946:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(2546),n=r(6730),s=r(4815),i=r(714);class a extends i.FrameworkPatcher{_patch(e){return(0,s.patchUse)(e.prototype,"router"),(0,n.patchMethods)(e.prototype,"router"),o.instrument_logger.info("Patched router successfully"),e}}t.default=a},6093:e=>{"use strict";e.exports=require("@cspotcode/source-map-support")},6504:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GraphQLMetric=void 0;const o=r(9873);class n extends o.FlowMetric{constructor(e){super(e)}_createUsableMetric(e){return this}toRaw(){return{flow_id:this.flowId,type:"GraphQLMetric",duration:this.duration}}}t.GraphQLMetric=n},6730:function(e,t,r){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.patchMethods=t.getMethods=void 0;const i=r(2546),a=s(r(6982)),c=r(8949),u=r(7225);function l(){const e=r(8611);return e.METHODS&&e.METHODS.map((function(e){return e.toLowerCase()}))||["get","post","put","head","delete","options","trace","copy","lock","mkcol","move","purge","propfind","proppatch","unlock","report","mkactivity","checkout","merge","m-search","notify","subscribe","unsubscribe","patch","search","connect"]}t.getMethods=l,t.patchMethods=function(e,t){l().concat("all").forEach((function(r){const o=e[r];if(!o)return void(u.isVerboseLoggingEnabled&&i.instrument_logger.warn("Method not found",{method:r}));const n="all"===r;e[r]=function(){try{if(arguments.length<2)return o.apply(this,arguments);let e=this[u.uuidSymbol];u.isVerboseLoggingEnabled&&(e||(e=a.randomUUID(),this[u.uuidSymbol]=e,i.instrument_logger.info("Express method setting uuid",{uuid:e,kind:t})),i.instrument_logger.info("Express added new method",{method:r,uuid:e,path:arguments[0]}));const s=Array.prototype.slice.call(arguments);if(s[1][i.hudConfig.express.layerStateSymbol]={flowId:[],kind:t,allMethod:n},Array.isArray(s[0]))for(const e of s[0]){const e=a.randomUUID();s[1][i.hudConfig.express.layerStateSymbol].flowId.push(e)}else s[1][i.hudConfig.express.layerStateSymbol].flowId.push(a.randomUUID());const c=o.apply(this,s);try{delete s[1][i.hudConfig.express.layerStateSymbol]}catch(e){}return c}catch(e){i.instrument_logger.error("Failed to patch method",{kind:t,method:r,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return o.apply(this,arguments)},(0,c.copyPropertiesToTarget)(o,e[r])}))}},6928:e=>{"use strict";e.exports=require("path")},6982:e=>{"use strict";e.exports=require("crypto")},7127:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(2546),n=r(6730),s=r(2977),i=r(4815),a=r(7225),c=r(714);class u extends c.FrameworkPatcher{_patch(e){return(0,s.patchRoute)(e.Route),(0,i.patchUse)(e.application,"application"),(0,n.patchMethods)(e.application,"application"),a.isVerboseLoggingEnabled&&(0,a.logLazyRouter)(e.application),e.Router.use?((0,i.patchUse)(e.Router,"router"),(0,n.patchMethods)(e.Router,"router")):o.instrument_logger.warn("Skipping express.Router patching"),o.instrument_logger.info("Patched express successfully"),e}}t.default=u},7131:e=>{"use strict";e.exports=require("./wrap")},7166:function(e,t,r){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.onRequire=t.skip=t.updateModuleChecker=t.createCheckers=t.patchRequire=t.onRequireFn=t.patchCompile=t.patch=t.supportSourceMapInstall=void 0;const i=s(r(9896)),a=s(r(6928)),c=r(8528),u=r(2546),l=r(3901),d=r(8528),f=r(2546),p=r(9063),g=r(714),h=function(){const e=f.SDK_MODULE_NAME;try{return a.dirname(a.dirname(f.myRequire.resolve(e)))}catch(t){return u.instrument_logger.error("Failed to resolve own path",{moduleName:e,msg:t instanceof Error?t.message:void 0,stack:t instanceof Error?t.stack:void 0}),null}}();function m(e){const t=globalThis.HudSourceMapCache.get(e);return t?{map:JSON.parse(t)}:null}function _(){r(6093).install({handleUncaughtExceptions:!1,hookRequire:!1,environment:"node",retrieveSourceMap:m})}function y(e,t,r,o){const n={code:e,map:void 0};try{if(globalThis.hudRunningMode===d.HudRunningMode.detached)return n;if(r===c.Format.esm&&!o)throw new f.HudError("MessagePort is required for patching ESM modules");if(F(t));else if(e.length>(f.hudConfig.userConfig.maxFileSizeBytes?.value??0)&&!e.startsWith(f.hudConfig.esbuildMark))u.instrument_logger.info("Skipping large file",{filename:t,size:e.length});else{const s=Date.now(),c=(0,l.edit)(e,t,r),d=c.metadatas;if(n.code=c.transformedCode,n.map=d,u.instrument_logger.debug("Patched",{filename:t,time:Date.now()-s}),o)for(const e of d)o.postMessage({key:"HudModulePatch",hudPatched:t,hudProcessedFiles:e});else globalThis.hudPatched.add(t),globalThis.hudProcessedFiles.push(...d),globalThis.hudDeclarationsFound=!0,globalThis.hudInstrumentationIndicator&&(clearTimeout(globalThis.hudInstrumentationIndicator),globalThis.hudInstrumentationIndicator=void 0);f.hudConfig.writePatched&&function(e,t){const r=a.parse(e);let o=`${r.dir}/patched.${r.base}`;r.dir.includes("dist")&&(o=a.join(`${r.dir.replace("dist","patched")}`,r.base)),i.existsSync(a.dirname(o))||i.mkdirSync(a.dirname(o),{recursive:!0}),i.writeFileSync(o,t,"utf8"),u.instrument_logger.debug("Dumped patched file",{filename:e,patchedPath:o})}(t,c.transformedCode)}}catch(e){u.instrument_logger.error("Failed to patch",{filename:t,format:r,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return n}t.supportSourceMapInstall=_,t.patch=y;let b="",v=!0,w=!1;function k(){if(!(0,f.isSupportedNative)())return;const e=r(3339),t=(0,u.shouldSupportSourceMap)();w&&u.instrument_logger.warn("PatchCompile ran twice"),0===Object.keys(globalThis.hudLoadedModules).length&&(globalThis.hudLoadedModules=Object.keys(f.myRequire.cache));const o=e.prototype._compile;e.prototype._compile=function(e,r){if(r===b){try{const e=v?u.instrument_logger.warn.bind(u.instrument_logger):u.instrument_logger.debug.bind(u.instrument_logger);v=!1,e("Skipping compile since already ran",{filename:r})}catch{}return o.call(this,e,r)}b=r,u.instrument_logger.verbose("Compiling requirement",{filename:r});const n=y(e,r,c.Format.cjs);try{if(t&&n.map){const e=(0,u.combineSourceMaps)(n.map,r);e&&globalThis.HudSourceMapCache.set(r,e)}}catch(e){u.instrument_logger.error("Failed to combine source maps",{filename:r,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}const s=o.call(this,n.code,r);return b="",s},w=!0,u.instrument_logger.debug("Patched _compile")}function S(e,t,r){try{const o=f.hudConfig.frameworksToPatch.get(t);return o?.patcher&&o.version?(0,g.getFrameworkPatcher)(o.patcher).patch(e,r,o.version,o.extraInfo,t):e}catch(e){u.instrument_logger.error("Failed to patch framework",{name:t,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return e}function E(){new p.Hook(Array.from(f.hudConfig.frameworksToPatch.keys()),{internals:!0},S)}function M(e){const t=a.sep.replace(/\\/g,"\\\\"),r=a.join(e),o=t+"node_modules"+t;return{isAllowdModule:new RegExp(o+r.split(".").join("\\.").split("*").join(".*?")+t,""),isAllowdModuleSubModule:new RegExp(o+r.split("*").join(".*?")+o,"")}}function x(e,t){return!!t.isAllowdModule.test(e)&&!t.isAllowdModuleSubModule.test(e)}function C(e,t){return e.includes(`node_modules${a.sep}${t}${a.sep}`)&&!e.includes(`node_modules${a.sep}${t}${a.sep}node_modules`)}function I(e){const t=[];for(const r of e){let e;if(r.includes("*")){const t=M(r);e=e=>x(e,t)}else e=e=>C(e,r);t.push(e)}return t}t.patchCompile=k,t.onRequireFn=S,t.patchRequire=E,t.createCheckers=I;let O=[];function P(){O=I(f.hudConfig.userConfig.includeModules?.value??[])}function F(e,t){if(!f.hudConfig.allowedEditExtensions.includes(a.extname(e)))return u.instrument_logger.warn("Skipping non-allowed extension",{filename:e}),!0;const r=t??O;return"/var/runtime/index.mjs"===e?(u.instrument_logger.debug("Skipping lambda runtime",{filename:e}),!0):e.includes("node_modules")&&!function(e,t){for(const r of t)if(r(e))return!0;return!1}(e,r)||e.includes(".yarn")?(u.instrument_logger.debug("Skipping non-monitored imported module",{filename:e}),!0):!(h&&!e.includes(h)||(u.instrument_logger.debug("Skipping hud internal module",{filename:e}),0))}t.updateModuleChecker=P,t.skip=F,t.onRequire=function(){try{P();try{k()}catch(e){u.instrument_logger.error("Failed to patch compile",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}try{(0,u.shouldSupportSourceMap)()&&_()}catch(e){u.instrument_logger.error("Failed to install source map support",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}try{E()}catch(e){u.instrument_logger.error("Failed to patch require",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}catch(e){u.instrument_logger.error("Something went wrong in onRequire",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}},7214:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=r(8528),n=r(8269),s=r(2546),i=r(8949),a=r(6504),c=r(714);class u extends c.FrameworkPatcher{static graphQLPatchedSymbol=Symbol.for(s.hudConfig.hudPatchedName);_patch(e){return this.patchGraphql(e),s.instrument_logger.info("Patched GraphQL successfully"),e}patchGraphql(e){const t=e.execute;e.execute=function(e){!function(e){try{e&&!e[u.graphQLPatchedSymbol]&&(l(e._queryType),l(e._mutationType),e[u.graphQLPatchedSymbol]=!0,s.instrument_logger.info("Patched GraphQL schema successfully"))}catch(e){s.instrument_logger.error("Failed to patch GraphQL schema",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}(e.schema);const r=process.hrtime.bigint();return function(e,t,r){return"function"==typeof e.then?e.then((e=>(g(t,r),e))):(g(t,r),e)}(t.apply(this,arguments),e.document,r)},(0,i.copyPropertiesToTarget)(t,e.execute)}}function l(e){if(!e)return;const t=e._fields;Object.keys(t).forEach((r=>{const c=t[r];!function(e,t,r){if(e.resolve&&!e.resolve[u.graphQLPatchedSymbol]){const o=(0,s.generateGraphqlFlowId)(r,t);(0,n.storeResolverDeclaration)({id:o,operation:t,name:r});const c=e.resolve;e.resolve=(0,i.wrapFlow)(p,c,((e,t)=>{const r=a.GraphQLMetric.createUsableMetric();r.start(),r.setFlowId(e),t.flowMetric=r}),((e,t)=>{const r=t.flowMetric;r?r.end():s.instrument_logger.warn("No flowMetric found for resolver",{flowId:e})}),((e,t)=>{const r=t.flowMetric;r?r.end():s.instrument_logger.warn("No flowMetric found for resolver",{flowId:e})})),e.resolve[u.graphQLPatchedSymbol]=!0,(0,n.storeResolverIdBySelectionName)(o,r)}}(c,o.GraphQLSupportedOperations[e.name.toLowerCase()],r),c.type._fields&&f(c.type)}))}t.default=u;const d=new WeakSet;function f(e){e&&e._fields&&!d.has(e)&&(d.add(e),Object.keys(e._fields).forEach((t=>{const r=e._fields[t];if(!r||!r.type)return;!function(e){const t=e.resolve;t&&!e.resolve[u.graphQLPatchedSymbol]&&(e.resolve=(0,i.wrapFlow)(p,t),e.resolve[u.graphQLPatchedSymbol]=!0)}(r);let o=r.type;for(;o.ofType;)o=o.ofType;f(o)})))}function p(e){if(void 0===e[2]||void 0===e[3])return void s.instrument_logger.warn("GraphQL resolver arguments are unknown",{args:e});const t=e[3].path;if(t&&!t.prev){const r=t.key,o=(0,n.getResolverIdBySelectionName)(r);return e[2][u.graphQLPatchedSymbol]=o,o}if(e[2][u.graphQLPatchedSymbol])return e[2][u.graphQLPatchedSymbol];s.instrument_logger.warn("GraphQL No functionId found for resolver",{args:e})}function g(e,t){try{new n.GraphQLDocumentMetadata(e,Number(process.hrtime.bigint()-t)).save()}catch(e){s.instrument_logger.error("Failed to save document metadata",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}},7225:function(e,t,r){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.logLazyRouter=t.skipStackNamesLogs=t.skipLayerNamesLogs=t.isVerboseLoggingEnabled=t.uuidSymbol=void 0;const i=r(2546),a=s(r(6982)),c=r(932),u=r(8949);t.uuidSymbol=Symbol.for("__hud_uuid__"),t.isVerboseLoggingEnabled="true"===c.env.HUD_LOG_EXPRESS,t.skipLayerNamesLogs=new Set(["query","expressInit","mounted_app"]),t.skipStackNamesLogs=new Set(["router"]),t.logLazyRouter=function(e){const r=e.lazyrouter;e.lazyrouter=function(){let e=!1;try{this._router||(e=!0)}catch(e){i.instrument_logger.error("Failed to check this._router",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}const o=r.apply(this,arguments);try{if(e){let e=this[t.uuidSymbol];e||(e=a.randomUUID(),this[t.uuidSymbol]=e,i.instrument_logger.info("Express lazy router setting uuid",{uuid:e})),i.instrument_logger.info("Express lazy router",{parent:e,child:this._router?.[t.uuidSymbol]})}}catch(e){i.instrument_logger.error("Failed to patch express.lazyRouter function",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return o},(0,u.copyPropertiesToTarget)(r,e.lazyrouter)}},7707:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncFunction=void 0,t.AsyncFunction=(async()=>{}).constructor},8064:e=>{"use strict";e.exports=require("semver")},8269:e=>{"use strict";e.exports=require("./globalstate")},8528:e=>{"use strict";e.exports=require("./dto")},8611:e=>{"use strict";e.exports=require("http")},8901:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HttpEndpointMetric=void 0;const o=r(9873);class n extends o.FlowMetric{statusCode;route;method;constructor(e){super(e)}_createUsableMetric(e){return this}setRequestAttributes(e){const t=e.url||e.path;this.route=t?.split("?")[0],this.method=e.method}setResponseAttributes(e){this.statusCode=e.statusCode}toRaw(){if(this.statusCode&&this.route&&this.method)return{flow_id:this.flowId,type:"EndpointMetric",duration:this.duration,status_code:this.statusCode,route:this.route,method:this.method}}}t.HttpEndpointMetric=n},8949:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.copyPropertiesToTarget=t.wrapFlow=void 0;const o=r(8528),n=r(2546),s=r(7707);function i(e,t){const r=Object.getOwnPropertyDescriptors(e),o=Reflect.ownKeys(r);Object.setPrototypeOf(t,e),o.forEach((e=>{try{Object.defineProperty(t,e,r[e])}catch(e){}}))}t.wrapFlow=function(e,t,r,a,c){let u;return u=t instanceof s.AsyncFunction?async function(...s){let i;try{i=e(s)}catch(e){n.instrument_logger.error("Failed to get flowId",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}if(!i||hudRunningMode!==o.HudRunningMode.enabled)return await t.apply(this,s);_hud_F=i,hudShouldLinkFunction=!0;const u={};if(r)try{r(i,u,s)}catch(e){n.instrument_logger.error("Failed to execute beforeCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}try{const e=t.apply(this,s);_hud_F="";const r=await e;if(a)try{a(i,u)}catch(e){n.instrument_logger.error("Failed to execute afterCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return r}catch(e){if(c)try{c(i,u,e)}catch(e){n.instrument_logger.error("Failed to execute catchCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}throw e}finally{_hud_F="",hudShouldLinkFunction=!1}}:function(...s){let i;try{i=e(s)}catch(e){n.instrument_logger.error("Failed to get flowId",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}if(!i||hudRunningMode!==o.HudRunningMode.enabled)return t.apply(this,s);_hud_F=i,hudShouldLinkFunction=!0;const u={};if(r)try{r(i,u,s)}catch(e){n.instrument_logger.error("Failed to execute beforeCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}try{const e=t.apply(this,s);if(a)if(e instanceof Promise)e.then((()=>{try{a(i,u)}catch(e){n.instrument_logger.error("Failed to execute afterCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}));else try{a(i,u)}catch(e){n.instrument_logger.error("Failed to execute afterCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return e}catch(e){if(c)try{c(i,u,e)}catch(e){n.instrument_logger.error("Failed to execute catchCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}throw e}finally{_hud_F="",hudShouldLinkFunction=!1}},i(t,u),u},t.copyPropertiesToTarget=i},9063:e=>{"use strict";e.exports=require("require-in-the-middle")},9873:function(e,t,r){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FlowMetric=void 0;const n=r(8528),s=r(8269),i=o(r(932));t.FlowMetric=class{_state;flowId;duration;_startTime;_msStartTime;constructor(e){this.flowId=e,this.duration=0,this._state="usable"}static createUsableMetric(e){return new this(e)._createUsableMetric(e)}setFlowId(e){this.flowId=e}getFlowId(){return this.flowId}getMsStartTime(){return this._msStartTime}start(){this._startTime=i.default.hrtime.bigint(),this._msStartTime=Date.now()}end(){this._startTime&&(this.duration=Number(i.default.hrtime.bigint()-this._startTime)),this.#e(),this._state="unusable"}#e(){if(hudRunningMode===n.HudRunningMode.enabled){const e=this.toRaw();e&&(0,s.storeFlowMetric)(e)}}}},9896:e=>{"use strict";e.exports=require("fs")}},t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var s=t[o]={exports:{}};return e[o].call(s.exports,s,s.exports,r),s.exports}return r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r(2197)})()));
2
2
  //# sourceMappingURL=instrument.js.map