hud-sdk 1.6.38 → 1.6.39

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,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var t=n();for(var i in t)("object"==typeof exports?exports:e)[i]=t[i]}}(global,()=>(()=>{"use strict";var e={1569:e=>{e.exports=require("zod")},2210:(e,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SDK_MODULE_NAME=void 0,n.SDK_MODULE_NAME="hud-sdk"},2509:function(e,n,t){var i=this&&this.__createBinding||(Object.create?function(e,n,t,i){void 0===i&&(i=t);var a=Object.getOwnPropertyDescriptor(n,t);a&&!("get"in a?!n.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return n[t]}}),Object.defineProperty(e,i,a)}:function(e,n,t,i){void 0===i&&(i=t),e[i]=n[t]}),a=this&&this.__exportStar||function(e,n){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(n,t)||i(n,e,t)};Object.defineProperty(n,"__esModule",{value:!0}),n.SDK_VERSION=n.SDK_MODULE_NAME=void 0,a(t(2887),n),a(t(2570),n);var r=t(2210);Object.defineProperty(n,"SDK_MODULE_NAME",{enumerable:!0,get:function(){return r.SDK_MODULE_NAME}}),a(t(7089),n);var o=t(5453);Object.defineProperty(n,"SDK_VERSION",{enumerable:!0,get:function(){return o.SDK_VERSION}})},2570:(e,n,t)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.updateDynamicConfig=function(e,n,t){const r=i.HudDynamicConfigSchema.deepPartial().safeParse(e);if(!r.success)return t.error("Dynamic configuration not updated - Invalid configuration override",{remoteConfigParseResult:r,remoteConfig:e}),n.dynamicConfig;const o=a(n.dynamicConfig,r.data);return void 0!==o.enableInvestigation&&o.enableInvestigation!==n.dynamicConfig.enableInvestigation&&(t.info("Dynamic configuration updated - enableInvestigation",{hudEnableInvestigation:o.enableInvestigation}),n.isInvestigationEnabledByEnv||(globalThis.hudEnableInvestigation=o.enableInvestigation)),void 0!==o.enableInvestigationArgsSending&&o.enableInvestigationArgsSending!==n.dynamicConfig.enableInvestigationArgsSending&&(t.info("Dynamic configuration updated - enableInvestigationArgsSending",{hudEnableInvestigationArgsSending:o.enableInvestigationArgsSending}),globalThis.hudEnableInvestigationArgsSending=o.enableInvestigationArgsSending),o};const i=t(2887);function a(e,n){if(null===n||"object"!=typeof n)return n;if(Array.isArray(e)&&Array.isArray(n))return n;const t={...e};for(const i in n){const r=e[i],o=n[i];t[i]=a(r,o)}return t}},2887:function(e,n,t){var i,a=this&&this.__createBinding||(Object.create?function(e,n,t,i){void 0===i&&(i=t);var a=Object.getOwnPropertyDescriptor(n,t);a&&!("get"in a?!n.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return n[t]}}),Object.defineProperty(e,i,a)}:function(e,n,t,i){void 0===i&&(i=t),e[i]=n[t]}),r=this&&this.__setModuleDefault||(Object.create?function(e,n){Object.defineProperty(e,"default",{enumerable:!0,value:n})}:function(e,n){e.default=n}),o=this&&this.__importStar||(i=function(e){return i=Object.getOwnPropertyNames||function(e){var n=[];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[n.length]=t);return n},i(e)},function(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var t=i(e),o=0;o<t.length;o++)"default"!==t[o]&&a(n,e,t[o]);return r(n,e),n});Object.defineProperty(n,"__esModule",{value:!0}),n.HudFailedReadConfigError=n.hudConfig=n.HudDynamicConfigSchema=void 0,n.getModulesToTraceFromEnv=function(){const e=process.env.HUD_MONITOR_MODULES||process.env.HUD_INCLUDE_MODULES;if(e)return e.split(",")},n.getFrameworksToEnableFromEnv=function(){const e=process.env.HUD_ENABLE_FRAMEWORKS;let n;if(e)try{n=s.availableFrameworksSchema.parse(JSON.parse(e))}catch{n=new Map}return n},n.isValidParam=function(e){return null!=e&&""!==e&&"string"==typeof e},n.updateInvestigationRateLimitGlobals=function(){globalThis.hudMaxSameInvestigations=n.hudConfig.dynamicConfig.investigationRateLimits.maxSameInvestigations,globalThis.hudMaxTotalInvestigations=n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigations,globalThis.hudSameInvestigationTimeWindowNs=BigInt(n.hudConfig.dynamicConfig.investigationRateLimits.sameInvestigationTimeWindowMs)*BigInt(1e6),globalThis.hudTotalInvestigationTimeWindowNs=BigInt(n.hudConfig.dynamicConfig.investigationRateLimits.totalInvestigationTimeWindowMs)*BigInt(1e6)},n.getConfigContent=function(){if(process.env.HUD_CONFIG)return{content:process.env.HUD_CONFIG,source:"HUD_CONFIG"};const e=function(){try{const e=process.env.HUD_CONFIG_PATH;if(e)return l.existsSync(e)?e:void 0;let n=__dirname,t=0;for(;"/"!==n&&t<10;){const e=`${n}/hud.config`;if(l.existsSync(e))return e;n=d.dirname(n),t++}}catch{return}}();if(e)try{return{content:l.readFileSync(e,"utf8"),source:e}}catch(n){throw new f(e,n.code)}};const s=t(8528),l=o(t(9896)),d=o(t(6928)),u=t(3903),c=t(1569),m="globalThis._hudMark";n.HudDynamicConfigSchema=c.z.object({aggregationInterval:c.z.number(),aggregationFirstSendTimeout:c.z.number(),investigationInterval:c.z.number(),investigationFirstSendTimeout:c.z.number(),enableInvestigation:c.z.boolean(),enableInvestigationArgsSending:c.z.boolean(),investigationRateLimits:c.z.object({maxSameInvestigations:c.z.number().int().positive(),sameInvestigationTimeWindowMs:c.z.number().int().positive(),maxTotalInvestigations:c.z.number().int().positive(),maxTotalInvestigationsErrorBased:c.z.number().int().positive(),maxTotalInvestigationsDurationBased:c.z.number().int().positive(),totalInvestigationTimeWindowMs:c.z.number().int().positive(),maxUniqLogs:c.z.number().int().positive()}),machineMetricsInterval:c.z.number().int().positive(),blacklistParams:c.z.array(c.z.string()),forensicsBlacklistFields:c.z.array(c.z.string()),forensicsWhitelistFields:c.z.array(c.z.string()),censorshipRegexes:c.z.array(c.z.object({regex:c.z.string(),replacement:c.z.string()})),reingestInterval:c.z.number().int().positive(),extraHeaders:c.z.array(c.z.string()),performanceMetricsInterval:c.z.number().int().positive(),enableOutboundData:c.z.boolean(),maxTotalOutbounds:c.z.number().int().positive(),maxOutboundCountWithData:c.z.number().int().positive(),maxHTTPRequestBodySize:c.z.number().int().positive(),maxHTTPResponseBodySize:c.z.number().int().positive()});const g=process.env.HUD_ENABLE_INVESTIGATION,p="_HUD",v="94a210f3-861c-4e18-ab27-6b6c19437c9d",b={sink:{url:process.env.HUD_HOST||"https://api-prod.hud.io",timeout:5e3,session_attr:"X-Session-ID"},endpoints:{init:"sink/init",send:"sink/send",batch:"sink/batch",logs:"sink/logs",sessionslessLogs:"sink/sessionless-logs",fatalError:"sink/redline",getMode:"sink/getMode",getRemoteConfig:"sink/remote-config/get",fileDeclarations:"sink/file-declarations",sourceMap:"sink/sourcemap",storeObject:"sink/objects/store",getUploadUrls:"sink/registry/get-upload-urls",triggerReingest:"sink/registry/reingest",validateToken:"sink/registry/validate",fileDeclarationsCi:"sink/registry/file-declarations",completed:"sink/registry/completed",endpointsDurationsInvestigationThresholds:"sink/endpoint-configuration"},logger:{default:{levels:{app:"warning",worker:"warning",instrument:"warning"}},debug:{levels:{app:"debug",worker:"debug",instrument:"debug"}}},investigation:{objectVersion:"1.0.2",store:{type:"s3"},limits:{executionFlowMaxLength:20,exceptionMaxLength:20},maxStringLength:1024,maxArrayLength:10,maxObjectDepth:3,maxKeyLength:30},userConfig:{minPodMemoryMB:{value:250,source:"DEFAULT"},maxMappedFunctions:{value:5e4,source:"DEFAULT"},maxFileSizeBytes:{value:2831155,source:"DEFAULT"},maxTimeUntilInitSessionMs:{value:3e4,source:"DEFAULT"},includeModules:{value:[],source:"DEFAULT"},disableRuntimeInstrumentation:{value:!1,source:"DEFAULT"},disableParametersExtraction:{value:!1,source:"DEFAULT"}},loggerWorkerPortSizeLimit:1e4,customerLoggerLevel:"info",logDirectory:process.env.HUD_LOG_DIR,invocationSampling:new Map([[[300n,null],100],[[200n,300n],50],[[100n,200n],25],[[0n,100n],10]]),callerResetInterval:36e5,modeInterval:3e5,logsSendInterval:6e4,endpointsInterval:3e4,endpointsFirstSendWaitTime:12e4,lazyEndpointsInterval:18e5,staticNextJsEndpointsInterval:1e4,staticNextJsEndpointsMaxAttempts:12,huddBinWidth:1.2,endpointsDurationsInvestigationThresholdsInterval:6e5,workerGrace:6e4,workerTimeout:2e4,timeoutOnRegister:6e4,timeoutOnMetrics:6e4,workerMessageTimeout:1e4,communicationBatchSize:100,writePatched:!1,defaultOff:!0,disableOnBadApiKey:!0,disableOnBadServiceName:!0,cpuTimeCollection:!1,workloadMetadata:{sendInterval:3e5,aws:{imds:{baseURL:"http://169.254.169.254/latest",tokenURI:"/api/token",identityURI:"/dynamic/instance-identity/document",lifeCycleURI:"/meta-data/instance-life-cycle",requestTimeout:5e3},metadataFile:"/run/cloud-init/instance-data.json"},kubernetes:{namespaceFile:"/var/run/secrets/kubernetes.io/serviceaccount/namespace",uuidFile:"/sys/class/dmi/id/product_uuid",podMemoryLimitFile:"/sys/fs/cgroup/memory/memory.stat",podCPULimitFile:"/sys/fs/cgroup/cpuacct/cpu.shares"}},deleteLogsAfterSending:!0,supportSourceMap:!0,editInline:!0,bundlerBuildIdVarName:"hudFileBuildID",bundlerBuildUuidNamespace:"00c1e90b-af75-4d8e-9935-68485877f759",functionUuidNamespace:v,wrapVarPrefix:p,functionIdVarName:`${p}_fid`,frameworksToPatch:new Map([["express",{framework:s.availableFrameworks.express,enable:!0,version:"<=5",patcher:"express",enableEsbuild:!0}],[d.join("express","lib","application.js"),{framework:s.availableFrameworks.express,enable:!0,version:"<=5",patcher:"expressApplication",enableEsbuild:!0}],["router",{framework:s.availableFrameworks.express,enable:!0,version:"^2.0.0",patcher:"router",enableEsbuild:!0}],["koa",{framework:s.availableFrameworks.koa,enable:!0,version:"^2.0.0",patcher:"koa"}],["graphql/execution/execute",{framework:s.availableFrameworks.graphql,enable:!1,version:"14 - 16",patcher:"graphql"}],["http",{framework:s.availableFrameworks.http,enable:!0,version:"*",patcher:"http"}],["https",{framework:s.availableFrameworks.https,enable:!0,version:"*",patcher:"http"}],["next/dist/server/base-server",{framework:s.availableFrameworks.nextjs,enable:!1,version:">=13.4.0",patcher:"nextjs"}],["next/dist/server/lib/module-loader/route-module-loader",{framework:s.availableFrameworks.nextjs,enable:!1,version:">=13.4.0",patcher:"nextJsModuleLoader"}],["next/dist/compiled/next-server/pages-api.runtime.prod",{framework:s.availableFrameworks.nextjs,enable:!1,version:">=13.4.0",patcher:"nextJsRouteModule"}],["next/dist/server/config",{framework:s.availableFrameworks.nextjs,enable:!1,version:">=13.4.0",patcher:"nextJsConfig"}],["@nestjs/core/router/router-execution-context",{framework:s.availableFrameworks.nestjs,enable:!0,version:"*",patcher:"nestjsRouterExecutionContext"}],["kafkajs",{framework:s.availableFrameworks.kafkajs,enable:"win32"!==process.platform,version:">=1.4.0",patcher:"kafkajs"}],["@confluentinc/kafka-javascript",{framework:s.availableFrameworks.confluentKafkaJs,enable:!1,version:">=1.4.0",patcher:"confluentKafkaJs"}],["@nestjs/microservices/context/rpc-context-creator",{framework:s.availableFrameworks.nestjs,enable:"win32"!==process.platform,version:">=7.0.0",patcher:"nestjsRpcContextCreator"}],[["@codegenie/serverless-express","src","frameworks","express.js"].join(d.sep),{framework:s.availableFrameworks.codegenieServerlessExpress,enable:!0,version:"^4.1.0",patcher:"codeGenieServerlessExpress",enableEsbuild:!0}],["@codegenie/serverless-express",{framework:s.availableFrameworks.codegenieServerlessExpress,enable:!0,enableEsbuild:!0}],["sqs-consumer",{framework:s.availableFrameworks.sqs,enable:!0,version:"*",patcher:"sqsConsumer",extraInfo:{mondayVersion:">=6.1.0",bbcVersion:">=7.5.0"}}],["serverless-http",{framework:s.availableFrameworks.serverlessHttp,enable:!0,enableEsbuild:!0}],[d.join("serverless-http","lib","framework","get-framework.js"),{framework:s.availableFrameworks.serverlessHttp,enable:!0,version:"^2.7.0",patcher:"serverlessHttp",enableEsbuild:!0}],["axios",{framework:s.availableFrameworks.axios,enable:!0,version:"^1.0.0",patcher:"outbound/axios",mainFilePath:"axios/dist/node/axios.cjs"}],["node-fetch",{framework:s.availableFrameworks.nodeFetch,enable:!0,version:"^2.0.0",patcher:"outbound/nodeFetch",mainFilePath:"node-fetch/lib/index.js"}],["pg",{framework:s.availableFrameworks.pg,enable:!0,version:"^8.8.0",patcher:"outbound/pg"}]]),communicationKeepalive:!1,communicationKeepaliveGrace:5e3,express:{routeNamesSymbol:Symbol.for("hudRoutes"),layerStateSymbol:Symbol.for("hudState"),markedSymbol:Symbol.for("hudMarked"),wrapAllCallbacks:!0},supportedNodeVersions:["18","20","21","22","24"],hudPatchedName:"hudPatched",metricSymbol:Symbol.for("hudMetric"),dynamicConfig:{aggregationInterval:3e5,aggregationFirstSendTimeout:3e4,investigationInterval:5e3,investigationFirstSendTimeout:3e4,enableInvestigation:"true"===g,enableInvestigationArgsSending:!0,investigationRateLimits:{maxSameInvestigations:2,sameInvestigationTimeWindowMs:36e5,maxTotalInvestigations:25,maxTotalInvestigationsErrorBased:25,maxTotalInvestigationsDurationBased:20,totalInvestigationTimeWindowMs:216e5,maxUniqLogs:2},machineMetricsInterval:1e4,performanceMetricsInterval:6e4,reingestInterval:3e4,extraHeaders:[],enableOutboundData:"true"===process.env.HUD_ENABLE_OUTBOUND_DATA,maxHTTPRequestBodySize:1024,maxHTTPResponseBodySize:5120,blacklistParams:[],censorshipRegexes:[],forensicsBlacklistFields:[],forensicsWhitelistFields:[],maxOutboundCountWithData:process.env.HUD_MAX_OUTBOUND_WITH_DATA?parseInt(process.env.HUD_MAX_OUTBOUND_WITH_DATA):10,maxTotalOutbounds:20},machineMetricsSavedLength:2,isInvestigationEnabledByEnv:void 0!==g,suppressTraces:!0,lambdaMinimunMemory:1024,lambdaBaseGivenTime:400,lambdaExtraGivenTimePerRequest:50,lambdaMaxGivenTime:700,throttleStatusCode:202,axiosFunctionId:(0,u.v5)("axios",v),nodeFetchFunctionId:(0,u.v5)("node-fetch",v),nodeFetchBodiesFunctionIds:{json:(0,u.v5)("node-fetch-body-json",v),text:(0,u.v5)("node-fetch-body-text",v),arrayBuffer:(0,u.v5)("node-fetch-body-arrayBuffer",v),blob:(0,u.v5)("node-fetch-body-blob",v)},pgConnectFunctionId:(0,u.v5)("pg-connect",v),pgQueryFunctionId:(0,u.v5)("pg-query",v),pgEndFunctionId:(0,u.v5)("pg-end",v),functionsToInstrument:[{moduleName:"typeorm",fileToFunctionsMapping:{[d.join(d.sep,"typeorm","repository","Repository.js")]:["hasId","getId","create","merge","preload","save","remove","softRemove","recover","insert","update","upsert","delete","softDelete","restore","exist","exists","existsBy","count","countBy","sum","average","minimum","maximum","find","findBy","findAndCount","findAndCountBy","findByIds","findOne","findOneBy","findOneById","findOneOrFail","findOneByOrFail","query","clear","increment","decrement","extend"]}}],esbuildGlobalVar:"hudSGV",esbuildPluginMessagePrefix:"ESBuild plugin ",esbuildMark:"/*modifiedByHudESBuildPlugin-",esbuildMarkLength:67,esbuildUploadSourceMapTimeout:15e3,esbuildPluginLogsChunkSize:100,esbuildPluginLogsBatchSize:10,pluginsLogEndpoint:"https://yqp37dddrsewm6wdwwpwfraxqm0shdmx.lambda-url.eu-central-1.on.aws/",uninstrumentedFilesLogThreshold:2,tsNodeConfigTimeout:1e4,allowedEditExtensions:[".ts",".cts",".mts",".js",".cjs",".mjs"],nextJsMarkVarName:m,nextJsMarkStatement:`${m} = "a"`,timeoutOnNextJsPlugin:3e4,logIntervals:{instrumentedFilesCount:5e3,sentEventsCount:12e4},cliBuildIdVarName:"hudCliBuildId",cliSdkVersionVarName:"hudCliSdkVersion"};n.hudConfig=function(e={}){return{...b,...e}}({logger:{default:{levels:{app:"info",worker:"info",instrument:"info"}},debug:{levels:{app:"debug",worker:"debug",instrument:"debug"}}},deleteLogsAfterSending:!1,communicationKeepalive:!0}),n.default=n.hudConfig;class f extends Error{path;code;constructor(e,n){super(),this.path=e,this.code=n}}n.HudFailedReadConfigError=f},3903:e=>{e.exports=require("uuid")},5453:(e,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SDK_VERSION=void 0,n.SDK_VERSION="1.6.38"},6928:e=>{e.exports=require("path")},7089:(e,n,t)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ObjectStoreConfigSchema=void 0;const i=t(1569),a=i.z.object({type:i.z.literal("s3")}),r=i.z.object({type:i.z.literal("disk"),path:i.z.string()});n.ObjectStoreConfigSchema=i.z.union([a,r])},8528:e=>{e.exports=require("./dto")},9896:e=>{e.exports=require("fs")}},n={};return function t(i){var a=n[i];if(void 0!==a)return a.exports;var r=n[i]={exports:{}};return e[i].call(r.exports,r,r.exports,t),r.exports}(2509)})());
1
+ !function(e,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var t=n();for(var i in t)("object"==typeof exports?exports:e)[i]=t[i]}}(global,()=>(()=>{"use strict";var e={1569:e=>{e.exports=require("zod")},2210:(e,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SDK_MODULE_NAME=void 0,n.SDK_MODULE_NAME="hud-sdk"},2509:function(e,n,t){var i=this&&this.__createBinding||(Object.create?function(e,n,t,i){void 0===i&&(i=t);var a=Object.getOwnPropertyDescriptor(n,t);a&&!("get"in a?!n.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return n[t]}}),Object.defineProperty(e,i,a)}:function(e,n,t,i){void 0===i&&(i=t),e[i]=n[t]}),a=this&&this.__exportStar||function(e,n){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(n,t)||i(n,e,t)};Object.defineProperty(n,"__esModule",{value:!0}),n.SDK_VERSION=n.SDK_MODULE_NAME=void 0,a(t(2887),n),a(t(2570),n);var o=t(2210);Object.defineProperty(n,"SDK_MODULE_NAME",{enumerable:!0,get:function(){return o.SDK_MODULE_NAME}}),a(t(7089),n);var r=t(5453);Object.defineProperty(n,"SDK_VERSION",{enumerable:!0,get:function(){return r.SDK_VERSION}})},2570:(e,n,t)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.updateDynamicConfig=function(e,n,t){const o=i.HudDynamicConfigSchema.deepPartial().safeParse(e);if(!o.success)return t.error("Dynamic configuration not updated - Invalid configuration override",{remoteConfigParseResult:o,remoteConfig:e}),n.dynamicConfig;const r=a(n.dynamicConfig,o.data);return void 0!==r.enableInvestigation&&r.enableInvestigation!==n.dynamicConfig.enableInvestigation&&(t.info("Dynamic configuration updated - enableInvestigation",{hudEnableInvestigation:r.enableInvestigation}),n.isInvestigationEnabledByEnv||(globalThis.hudEnableInvestigation=r.enableInvestigation)),void 0!==r.enableInvestigationArgsSending&&r.enableInvestigationArgsSending!==n.dynamicConfig.enableInvestigationArgsSending&&(t.info("Dynamic configuration updated - enableInvestigationArgsSending",{hudEnableInvestigationArgsSending:r.enableInvestigationArgsSending}),globalThis.hudEnableInvestigationArgsSending=r.enableInvestigationArgsSending),void 0!==r?.investigationRateLimits?.executionFlowMaxLength&&r?.investigationRateLimits?.executionFlowMaxLength!==n.dynamicConfig.investigationRateLimits.executionFlowMaxLength&&(globalThis.hudExecutionFlowMaxLength=r.investigationRateLimits.executionFlowMaxLength),void 0!==r?.investigationRateLimits?.exceptionMaxLength&&r?.investigationRateLimits?.exceptionMaxLength!==n.dynamicConfig.investigationRateLimits.exceptionMaxLength&&(globalThis.hudExceptionMaxLength=r.investigationRateLimits.exceptionMaxLength),r};const i=t(2887);function a(e,n){if(null===n||"object"!=typeof n)return n;if(Array.isArray(e)&&Array.isArray(n))return n;const t={...e};for(const i in n){const o=e[i],r=n[i];t[i]=a(o,r)}return t}},2887:function(e,n,t){var i,a=this&&this.__createBinding||(Object.create?function(e,n,t,i){void 0===i&&(i=t);var a=Object.getOwnPropertyDescriptor(n,t);a&&!("get"in a?!n.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return n[t]}}),Object.defineProperty(e,i,a)}:function(e,n,t,i){void 0===i&&(i=t),e[i]=n[t]}),o=this&&this.__setModuleDefault||(Object.create?function(e,n){Object.defineProperty(e,"default",{enumerable:!0,value:n})}:function(e,n){e.default=n}),r=this&&this.__importStar||(i=function(e){return i=Object.getOwnPropertyNames||function(e){var n=[];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[n.length]=t);return n},i(e)},function(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var t=i(e),r=0;r<t.length;r++)"default"!==t[r]&&a(n,e,t[r]);return o(n,e),n});Object.defineProperty(n,"__esModule",{value:!0}),n.HudFailedReadConfigError=n.hudConfig=n.HudDynamicConfigSchema=void 0,n.getModulesToTraceFromEnv=function(){const e=process.env.HUD_MONITOR_MODULES||process.env.HUD_INCLUDE_MODULES;if(e)return e.split(",")},n.getFrameworksToEnableFromEnv=function(){const e=process.env.HUD_ENABLE_FRAMEWORKS;let n;if(e)try{n=s.availableFrameworksSchema.parse(JSON.parse(e))}catch{n=new Map}return n},n.isValidParam=function(e){return null!=e&&""!==e&&"string"==typeof e},n.updateInvestigationRateLimitGlobals=function(){globalThis.hudMaxSameInvestigations=n.hudConfig.dynamicConfig.investigationRateLimits.maxSameInvestigations,globalThis.hudMaxTotalInvestigations=n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigations,globalThis.hudSameInvestigationTimeWindowNs=BigInt(n.hudConfig.dynamicConfig.investigationRateLimits.sameInvestigationTimeWindowMs)*BigInt(1e6),globalThis.hudTotalInvestigationTimeWindowNs=BigInt(n.hudConfig.dynamicConfig.investigationRateLimits.totalInvestigationTimeWindowMs)*BigInt(1e6)},n.getConfigContent=function(){if(process.env.HUD_CONFIG)return{content:process.env.HUD_CONFIG,source:"HUD_CONFIG"};const e=function(){try{const e=process.env.HUD_CONFIG_PATH;if(e)return l.existsSync(e)?e:void 0;let n=__dirname,t=0;for(;"/"!==n&&t<10;){const e=`${n}/hud.config`;if(l.existsSync(e))return e;n=u.dirname(n),t++}}catch{return}}();if(e)try{return{content:l.readFileSync(e,"utf8"),source:e}}catch(n){throw new f(e,n.code)}};const s=t(8528),l=r(t(9896)),u=r(t(6928)),d=t(3903),c=t(1569),m="globalThis._hudMark";n.HudDynamicConfigSchema=c.z.object({aggregationInterval:c.z.number(),aggregationFirstSendTimeout:c.z.number(),investigationInterval:c.z.number(),investigationFirstSendTimeout:c.z.number(),enableInvestigation:c.z.boolean(),enableInvestigationArgsSending:c.z.boolean(),investigationRateLimits:c.z.object({maxSameInvestigations:c.z.number().int().positive(),sameInvestigationTimeWindowMs:c.z.number().int().positive(),maxTotalInvestigations:c.z.number().int().positive(),maxTotalInvestigationsErrorBased:c.z.number().int().positive(),maxTotalInvestigationsDurationBased:c.z.number().int().positive(),totalInvestigationTimeWindowMs:c.z.number().int().positive(),maxUniqLogs:c.z.number().int().positive(),maxStringLength:c.z.number().int().positive(),maxArrayLength:c.z.number().int().positive(),maxObjectDepth:c.z.number().int().positive(),maxKeyLength:c.z.number().int().positive(),executionFlowMaxLength:c.z.number().int().positive(),exceptionMaxLength:c.z.number().int().positive()}),machineMetricsInterval:c.z.number().int().positive(),blacklistParams:c.z.array(c.z.string()),forensicsBlacklistFields:c.z.array(c.z.string()),forensicsWhitelistFields:c.z.array(c.z.string()),censorshipRegexes:c.z.array(c.z.object({regex:c.z.string(),replacement:c.z.string()})),reingestInterval:c.z.number().int().positive(),extraHeaders:c.z.array(c.z.string()),performanceMetricsInterval:c.z.number().int().positive(),enableOutboundData:c.z.boolean(),maxTotalOutbounds:c.z.number().int().positive(),maxOutboundCountWithData:c.z.number().int().positive(),maxHTTPRequestBodySize:c.z.number().int().positive(),maxHTTPResponseBodySize:c.z.number().int().positive()});const g=process.env.HUD_ENABLE_INVESTIGATION,p="_HUD",v="94a210f3-861c-4e18-ab27-6b6c19437c9d",b={sink:{url:process.env.HUD_HOST||"https://api-prod.hud.io",timeout:5e3,session_attr:"X-Session-ID"},endpoints:{init:"sink/init",send:"sink/send",batch:"sink/batch",logs:"sink/logs",sessionslessLogs:"sink/sessionless-logs",fatalError:"sink/redline",getMode:"sink/getMode",getRemoteConfig:"sink/remote-config/get",fileDeclarations:"sink/file-declarations",sourceMap:"sink/sourcemap",storeObject:"sink/objects/store",getUploadUrls:"sink/registry/get-upload-urls",triggerReingest:"sink/registry/reingest",validateToken:"sink/registry/validate",fileDeclarationsCi:"sink/registry/file-declarations",completed:"sink/registry/completed",endpointsDurationsInvestigationThresholds:"sink/endpoint-configuration"},logger:{default:{levels:{app:"warning",worker:"warning",instrument:"warning"}},debug:{levels:{app:"debug",worker:"debug",instrument:"debug"}}},investigation:{objectVersion:"1.0.2",store:{type:"s3"}},userConfig:{minPodMemoryMB:{value:250,source:"DEFAULT"},maxMappedFunctions:{value:5e4,source:"DEFAULT"},maxFileSizeBytes:{value:2831155,source:"DEFAULT"},maxTimeUntilInitSessionMs:{value:3e4,source:"DEFAULT"},includeModules:{value:[],source:"DEFAULT"},disableRuntimeInstrumentation:{value:!1,source:"DEFAULT"},disableParametersExtraction:{value:!1,source:"DEFAULT"}},loggerWorkerPortSizeLimit:1e4,customerLoggerLevel:"info",logDirectory:process.env.HUD_LOG_DIR,invocationSampling:new Map([[[300n,null],100],[[200n,300n],50],[[100n,200n],25],[[0n,100n],10]]),callerResetInterval:36e5,modeInterval:3e5,logsSendInterval:6e4,endpointsInterval:3e4,endpointsFirstSendWaitTime:12e4,lazyEndpointsInterval:18e5,staticNextJsEndpointsInterval:1e4,staticNextJsEndpointsMaxAttempts:12,huddBinWidth:1.2,endpointsDurationsInvestigationThresholdsInterval:6e5,workerGrace:6e4,workerTimeout:2e4,timeoutOnRegister:6e4,timeoutOnMetrics:6e4,workerMessageTimeout:1e4,communicationBatchSize:100,writePatched:!1,defaultOff:!0,disableOnBadApiKey:!0,disableOnBadServiceName:!0,cpuTimeCollection:!1,workloadMetadata:{sendInterval:3e5,aws:{imds:{baseURL:"http://169.254.169.254/latest",tokenURI:"/api/token",identityURI:"/dynamic/instance-identity/document",lifeCycleURI:"/meta-data/instance-life-cycle",requestTimeout:5e3},metadataFile:"/run/cloud-init/instance-data.json"},kubernetes:{namespaceFile:"/var/run/secrets/kubernetes.io/serviceaccount/namespace",uuidFile:"/sys/class/dmi/id/product_uuid",podMemoryLimitFile:"/sys/fs/cgroup/memory/memory.stat",podCPULimitFile:"/sys/fs/cgroup/cpuacct/cpu.shares"}},deleteLogsAfterSending:!0,supportSourceMap:!0,editInline:!0,bundlerBuildIdVarName:"hudFileBuildID",bundlerBuildUuidNamespace:"00c1e90b-af75-4d8e-9935-68485877f759",functionUuidNamespace:v,wrapVarPrefix:p,functionIdVarName:`${p}_fid`,frameworksToPatch:new Map([["express",{framework:s.availableFrameworks.express,enable:!0,version:"<=5",patcher:"express",enableEsbuild:!0}],[u.join("express","lib","application.js"),{framework:s.availableFrameworks.express,enable:!0,version:"<=5",patcher:"expressApplication",enableEsbuild:!0}],["router",{framework:s.availableFrameworks.express,enable:!0,version:"^2.0.0",patcher:"router",enableEsbuild:!0}],["koa",{framework:s.availableFrameworks.koa,enable:!0,version:"^2.0.0",patcher:"koa"}],["graphql/execution/execute",{framework:s.availableFrameworks.graphql,enable:!1,version:"14 - 16",patcher:"graphql"}],["http",{framework:s.availableFrameworks.http,enable:!0,version:"*",patcher:"http"}],["https",{framework:s.availableFrameworks.https,enable:!0,version:"*",patcher:"http"}],["next/dist/server/base-server",{framework:s.availableFrameworks.nextjs,enable:!1,version:">=13.4.0",patcher:"nextjs"}],["next/dist/server/lib/module-loader/route-module-loader",{framework:s.availableFrameworks.nextjs,enable:!1,version:">=13.4.0",patcher:"nextJsModuleLoader"}],["next/dist/compiled/next-server/pages-api.runtime.prod",{framework:s.availableFrameworks.nextjs,enable:!1,version:">=13.4.0",patcher:"nextJsRouteModule"}],["next/dist/server/config",{framework:s.availableFrameworks.nextjs,enable:!1,version:">=13.4.0",patcher:"nextJsConfig"}],["@nestjs/core/router/router-execution-context",{framework:s.availableFrameworks.nestjs,enable:!0,version:"*",patcher:"nestjsRouterExecutionContext"}],["kafkajs",{framework:s.availableFrameworks.kafkajs,enable:"win32"!==process.platform,version:">=1.4.0",patcher:"kafkajs"}],["@confluentinc/kafka-javascript",{framework:s.availableFrameworks.confluentKafkaJs,enable:!1,version:">=1.4.0",patcher:"confluentKafkaJs"}],["@nestjs/microservices/context/rpc-context-creator",{framework:s.availableFrameworks.nestjs,enable:"win32"!==process.platform,version:">=7.0.0",patcher:"nestjsRpcContextCreator"}],[["@codegenie/serverless-express","src","frameworks","express.js"].join(u.sep),{framework:s.availableFrameworks.codegenieServerlessExpress,enable:!0,version:"^4.1.0",patcher:"codeGenieServerlessExpress",enableEsbuild:!0}],["@codegenie/serverless-express",{framework:s.availableFrameworks.codegenieServerlessExpress,enable:!0,enableEsbuild:!0}],["sqs-consumer",{framework:s.availableFrameworks.sqs,enable:!0,version:"*",patcher:"sqsConsumer",extraInfo:{mondayVersion:">=6.1.0",bbcVersion:">=7.5.0"}}],["serverless-http",{framework:s.availableFrameworks.serverlessHttp,enable:!0,enableEsbuild:!0}],[u.join("serverless-http","lib","framework","get-framework.js"),{framework:s.availableFrameworks.serverlessHttp,enable:!0,version:"^2.7.0",patcher:"serverlessHttp",enableEsbuild:!0}],["axios",{framework:s.availableFrameworks.axios,enable:!0,version:"^1.0.0",patcher:"outbound/axios",mainFilePath:"axios/dist/node/axios.cjs"}],["node-fetch",{framework:s.availableFrameworks.nodeFetch,enable:!0,version:"^2.0.0",patcher:"outbound/nodeFetch",mainFilePath:"node-fetch/lib/index.js"}],["pg",{framework:s.availableFrameworks.pg,enable:!0,version:"^8.8.0",patcher:"outbound/pg"}]]),communicationKeepalive:!1,communicationKeepaliveGrace:5e3,express:{routeNamesSymbol:Symbol.for("hudRoutes"),layerStateSymbol:Symbol.for("hudState"),markedSymbol:Symbol.for("hudMarked"),wrapAllCallbacks:!0},supportedNodeVersions:["18","20","21","22","24"],hudPatchedName:"hudPatched",metricSymbol:Symbol.for("hudMetric"),dynamicConfig:{aggregationInterval:3e5,aggregationFirstSendTimeout:3e4,investigationInterval:5e3,investigationFirstSendTimeout:3e4,enableInvestigation:"true"===g,enableInvestigationArgsSending:!0,investigationRateLimits:{maxSameInvestigations:2,sameInvestigationTimeWindowMs:36e5,maxTotalInvestigations:25,maxTotalInvestigationsErrorBased:25,maxTotalInvestigationsDurationBased:20,totalInvestigationTimeWindowMs:216e5,maxUniqLogs:2,executionFlowMaxLength:20,exceptionMaxLength:20,maxStringLength:1024,maxArrayLength:10,maxObjectDepth:3,maxKeyLength:30},machineMetricsInterval:1e4,performanceMetricsInterval:6e4,reingestInterval:3e4,extraHeaders:[],enableOutboundData:"true"===process.env.HUD_ENABLE_OUTBOUND_DATA,maxHTTPRequestBodySize:1024,maxHTTPResponseBodySize:5120,blacklistParams:[],censorshipRegexes:[],forensicsBlacklistFields:[],forensicsWhitelistFields:[],maxOutboundCountWithData:process.env.HUD_MAX_OUTBOUND_WITH_DATA?parseInt(process.env.HUD_MAX_OUTBOUND_WITH_DATA):10,maxTotalOutbounds:20},machineMetricsSavedLength:2,isInvestigationEnabledByEnv:void 0!==g,suppressTraces:!0,lambdaMinimunMemory:1024,lambdaBaseGivenTime:400,lambdaExtraGivenTimePerRequest:50,lambdaMaxGivenTime:700,throttleStatusCode:202,axiosFunctionId:(0,d.v5)("axios",v),nodeFetchFunctionId:(0,d.v5)("node-fetch",v),nodeFetchBodiesFunctionIds:{json:(0,d.v5)("node-fetch-body-json",v),text:(0,d.v5)("node-fetch-body-text",v),arrayBuffer:(0,d.v5)("node-fetch-body-arrayBuffer",v),blob:(0,d.v5)("node-fetch-body-blob",v)},pgConnectFunctionId:(0,d.v5)("pg-connect",v),pgQueryFunctionId:(0,d.v5)("pg-query",v),pgEndFunctionId:(0,d.v5)("pg-end",v),functionsToInstrument:[{moduleName:"typeorm",fileToFunctionsMapping:{[u.join(u.sep,"typeorm","repository","Repository.js")]:["hasId","getId","create","merge","preload","save","remove","softRemove","recover","insert","update","upsert","delete","softDelete","restore","exist","exists","existsBy","count","countBy","sum","average","minimum","maximum","find","findBy","findAndCount","findAndCountBy","findByIds","findOne","findOneBy","findOneById","findOneOrFail","findOneByOrFail","query","clear","increment","decrement","extend"]}}],esbuildGlobalVar:"hudSGV",esbuildPluginMessagePrefix:"ESBuild plugin ",esbuildMark:"/*modifiedByHudESBuildPlugin-",esbuildMarkLength:67,esbuildUploadSourceMapTimeout:15e3,esbuildPluginLogsChunkSize:100,esbuildPluginLogsBatchSize:10,pluginsLogEndpoint:"https://yqp37dddrsewm6wdwwpwfraxqm0shdmx.lambda-url.eu-central-1.on.aws/",uninstrumentedFilesLogThreshold:2,tsNodeConfigTimeout:1e4,allowedEditExtensions:[".ts",".cts",".mts",".js",".cjs",".mjs"],nextJsMarkVarName:m,nextJsMarkStatement:`${m} = "a"`,timeoutOnNextJsPlugin:3e4,logIntervals:{instrumentedFilesCount:5e3,sentEventsCount:12e4},cliBuildIdVarName:"hudCliBuildId",cliSdkVersionVarName:"hudCliSdkVersion"};n.hudConfig=function(e={}){return{...b,...e}}({logger:{default:{levels:{app:"info",worker:"info",instrument:"info"}},debug:{levels:{app:"debug",worker:"debug",instrument:"debug"}}},deleteLogsAfterSending:!1,communicationKeepalive:!0}),n.default=n.hudConfig;class f extends Error{path;code;constructor(e,n){super(),this.path=e,this.code=n}}n.HudFailedReadConfigError=f},3903:e=>{e.exports=require("uuid")},5453:(e,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SDK_VERSION=void 0,n.SDK_VERSION="1.6.39"},6928:e=>{e.exports=require("path")},7089:(e,n,t)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ObjectStoreConfigSchema=void 0;const i=t(1569),a=i.z.object({type:i.z.literal("s3")}),o=i.z.object({type:i.z.literal("disk"),path:i.z.string()});n.ObjectStoreConfigSchema=i.z.union([a,o])},8528:e=>{e.exports=require("./dto")},9896:e=>{e.exports=require("fs")}},n={};return function t(i){var a=n[i];if(void 0!==a)return a.exports;var o=n[i]={exports:{}};return e[i].call(o.exports,o,o.exports,t),o.exports}(2509)})());
2
2
  //# sourceMappingURL=config.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 n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(global,()=>(()=>{"use strict";var e={290:e=>{e.exports=require("async_hooks")},395:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addReingestValue=function(e){n.add(e)},t.getAndClearReingestValues=function(){const e=new Set;for(const t of n)o.has(t)||e.add(t);for(const t of e)o.add(t);return n=new Set,e};let n=new Set;const o=new Set},523:e=>{e.exports=require("./logger")},754:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.storeEndpointDeclaration=function(e){n.push(e)},t.getEndpointDeclarationsFromStorage=function(){const e=n;return n=[],e};let n=[]},820:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),r(n(7764),t),r(n(4583),t),r(n(2314),t),r(n(3025),t),r(n(8714),t),r(n(4988),t),r(n(2525),t),r(n(3973),t),r(n(1757),t),r(n(1364),t),r(n(7398),t),r(n(8708),t),r(n(7918),t),r(n(395),t)},1364:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.initGlobals=function(){globalThis.hudGlobalInitGuard||(globalThis.hudGlobalInitGuard=!0,globalThis.hudRunMutex=!1,globalThis.hudRanOnRequire=!1,globalThis.hudRanOnImport=!1,globalThis.hudInitGuard=void 0,globalThis.hudInstrumentationIndicator=void 0,globalThis.hudMetricsIndicator=void 0,globalThis.hudInstrumentationOccured=!1,globalThis.hudNextJsPluginIndicator=void 0,globalThis.hudStartTime=new Date,globalThis.hudCalls={},globalThis.hudRunningMode=r.HudRunningMode.enabled,globalThis.hudExecutionFlowMaxLength=o.hudConfig.investigation.limits.executionFlowMaxLength,globalThis.hudExceptionMaxLength=o.hudConfig.investigation.limits.exceptionMaxLength,globalThis.hudEnableInvestigation=o.hudConfig.dynamicConfig.enableInvestigation,globalThis.hudEnableInvestigationArgsSending=o.hudConfig.dynamicConfig.enableInvestigationArgsSending,(0,s.setInvestigationStorage)(new u.AsyncLocalStorage),(0,s.setFlowStateStorage)(new u.AsyncLocalStorage),function(){globalThis.hudSampleTable=[];const e=[[10,1],[30,2],[100,3],[500,11],[1e3,23],[5e3,53]];let t=0;for(const[n,o]of e){for(let e=t;e<n;e++)globalThis.hudSampleTable.push(e%o===0);t=n}}(),d())},t.resetGlobals=d,t.hookMessageChannel=function(){const{port1:e,port2:t}=new c.MessageChannel;return e.on("message",e=>{"HudModulePatch"===e.key?(globalThis.hudPatched.add(e.hudPatched),globalThis.hudProcessedFiles.push(e.hudProcessedFiles)):"HudRetrieveFileCache"===e.key&&globalThis.HudSourceMapCache.set(e.filename,e.content)}),e.unref(),globalThis.hudHookPort=e,t},t.clearInitGuard=l,t.clearMetricsIndicator=g,t.clearInstrumentationIndicator=h,t.clearUserIndicatorsTimeouts=function(){l(),g(),h()},t.detachHud=f,t.forceHudEnable=function(){globalThis.forceHudEnable=!0},t.saveHudRunningFromSetup=function(){globalThis.hudIsRunningFromSetup=!0},t.saveInstrumentationIndicator=function(e){globalThis.hudInstrumentationIndicator=e,globalThis.hudInstrumentationIndicator.unref()},t.validateAndGetUserInput=function(){return o.hudConfig.userConfig.key||o.hudConfig.userConfig.service?o.hudConfig.userConfig.key?(0,o.isValidParam)(o.hudConfig.userConfig.key.value)?o.hudConfig.userConfig.service?(0,o.isValidParam)(o.hudConfig.userConfig.service.value)?{apiKey:o.hudConfig.userConfig.key.value,service:o.hudConfig.userConfig.service.value}:(a.app_logger.critical("Service name is invalid - SDK cannot initialize",{source:o.hudConfig.userConfig.service.source}),o.hudConfig.disableOnBadServiceName&&f(!1),void a.customer_logger.log(i.UserErrorLogs.HudServiceInvalid(o.hudConfig.userConfig.service.source))):(a.app_logger.critical("Service name is missing - SDK cannot initialize"),o.hudConfig.disableOnBadServiceName&&f(!1),void a.customer_logger.log(i.UserErrorLogs.HudServiceNotSet(globalThis.hudStartFromAutoInit))):(a.app_logger.critical("API key is invalid - SDK cannot initialize",{source:o.hudConfig.userConfig.key.source}),o.hudConfig.disableOnBadApiKey&&f(!1),void a.customer_logger.log(i.UserErrorLogs.HudApiKeyInvalid(o.hudConfig.userConfig.key.source))):(a.app_logger.critical("API key is missing - SDK cannot initialize"),o.hudConfig.disableOnBadApiKey&&f(!1),void a.customer_logger.log(i.UserErrorLogs.HudApiKeyNotSet(globalThis.hudStartFromAutoInit))):(a.app_logger.critical("Both API key and service name are missing - SDK cannot initialize"),(o.hudConfig.disableOnBadApiKey||o.hudConfig.disableOnBadServiceName)&&f(!1),void a.customer_logger.log(i.UserErrorLogs.BothApiKeyAndServiceNotSet(globalThis.hudStartFromAutoInit)))};const o=n(5809),r=n(8528),i=n(2546),a=n(523),s=n(7131),u=n(290),c=n(8167);function d(){globalThis.hudProcessedFiles=[],globalThis._hud_S=new Array(1e3).fill(""),globalThis._hud_SI={value:0},globalThis.hudLoadedModules=[],globalThis.hudPatched=new Set,globalThis.HudSourceMapCache=new Map,globalThis.hudExpressState=[]}function l(){clearTimeout(globalThis.hudInitGuard),globalThis.hudInitGuard=void 0}function g(){clearTimeout(globalThis.hudMetricsIndicator),globalThis.hudMetricsIndicator=void 0}function h(){clearTimeout(globalThis.hudInstrumentationIndicator),globalThis.hudInstrumentationIndicator=void 0,globalThis.hudInstrumentationOccured=!0}function f(e=!0,t=!1){if(a.app_logger.warning("Detaching hud"),t||e&&hudRunningMode!==r.HudRunningMode.detached){const e=(0,i.getFirstError)();a.customer_logger.log(i.UserErrorLogs.ShutdownGracefully(e))}globalThis.hudRunningMode=r.HudRunningMode.detached}},1757:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.markShouldFlushOnInit=function(e){r=e},t.storeCredentials=function(e,t){n=e,o=t},t.storeSessionInfo=function(e){i=e},t.getSessionInfo=function(){return i},t.getStoredApiKey=function(){return n},t.getStoredService=function(){return o},t.getShouldFlushOnInit=function(){return r};let n,o,r=!1,i=null},2314:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fullEndpointFlowIdMap=void 0,t.getLinkedConsistentFlowId=u,t.getFlowIdFromMappings=c,t.linkTemporaryToConsistenFlowId=d,t.clearFlowIdMappings=function(){t.fullEndpointFlowIdMap.clear(),s.clear()},t.swapTempToConstFlowId=function(e){e.forEach(e=>{"express"===e.framework&&(e.flow_id=u(e.flow_id,!0)??e.flow_id)})};const o=n(2546),r=n(523),i=n(7930),a=n(8590);t.fullEndpointFlowIdMap=new Map;const s=new Map;function u(e,t){let n=c(e,!1);return n?n.flowId:(d(t),n=c(e,!0),n?(n.isPartial&&!t&&r.app_logger.warning("Found partial endpoint for flow id even though partial aren't allowd",{flowId:e,consistentFlowId:n.flowId}),n.flowId):void 0)}function c(e,n){let o=t.fullEndpointFlowIdMap.get(e);return o?{flowId:o,isPartial:!1}:n?(o=s.get(e),o?{flowId:o,isPartial:!0}:void 0):void 0}function d(e){const n=[];globalThis.hudExpressState.forEach(e=>{try{n.push(...(0,i.extractEndpointsFromRouter)("",e))}catch(e){r.app_logger.error("Failed to extract endpoints from express",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}),n.forEach(e=>{if(e.partial_path)return;const n=e.flow_id;let r=t.fullEndpointFlowIdMap.get(n);r||(r=(0,o.generateEndpointFlowId)(e.path,e.methods),t.fullEndpointFlowIdMap.set(n,r))}),(0,a.getPartialEndpointDeclarationsFromStorage)().forEach(n=>{const r=n.flow_id;let i=t.fullEndpointFlowIdMap.get(r);i||(i=s.get(r),i||(i=(0,o.generateEndpointFlowId)(n.partial_path,n.methods),e?s.set(r,i):t.fullEndpointFlowIdMap.set(r,i)))})}},2525:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getSqsQueues=function(){const e=n;return n=[],e},t.storeSqsQueueDeclaration=function(e){n.push(e)};let n=[]},2546:e=>{e.exports=require("./lib")},2987:e=>{e.exports=require("perf_hooks")},3025:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getGraphQLOperations=function(){const e=n;return n={},e},t.storeGraphQLOperation=function(e){n[e.flow_id]||(n[e.flow_id]=e)};let n={}},3973:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getFlowMetrics=function(e){const t=(new Date).toISOString(),n={};for(const o in s){const i=[];let a;for(const n in s[o]){const r=s[o][n];a||(a=r.getEventVersion()),i.push(r.finalize(u,t,e))}delete s[o],a?n[o]={eventVersion:a,metrics:i}:r.app_logger.error("No event version found for metric type",o)}return n},t.storeFlowMetric=function(e){const t=function(e){if(void 0!==e.flow_id)switch(e.type){case"EndpointMetric":{const t=e;return`${e.flow_id}|${t.route}|${t.method}|${t.status_code}`}case"KafkaJSMetric":{const t=e;return`${e.flow_id}|${t.partition}|${t.error}`}case"GraphQLMetric":{const t=e;return`${e.flow_id}|${t.status_code}|${t.error_occurred}`}default:return e.flow_id}}(e);if(!t)return;s[e.type]||(s[e.type]={});const n=s[e.type][t];if(n)n.update(e,u);else{const n=a.MetricFactory.createMetric(e,u);s[e.type][t]=n}};const o=n(5809),r=n(523),i=n(7131),a=n(7859),s={},u=new i.SketchManager(o.hudConfig.huddBinWidth)},4583:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getExpressEndpointDeclarations=function(){let e=[];globalThis.hudExpressState.forEach(t=>{try{e=e.concat((0,i.extractEndpointsFromRouter)("",t))}catch(e){o.app_logger.error("Failed to extract endpoints from express",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}),e=e.concat((0,a.getRouterlessEndpointDeclarationsFromStorage)());const t=new Set;e.forEach(e=>{e.partial_path||t.add(e.flow_id)});const n=e.filter(e=>!e.partial_path||!t.has(e.flow_id)&&(o.app_logger.info("Partial endpoint without full endpoint",{endpoint:e}),!0)),s=new Map;for(const e of n){const t=`${e.path||e.partial_path||""}|${[...e.methods].sort().join(",")}`;s.has(t)||s.set(t,e)}const u=Array.from(s.values());return(0,r.swapTempToConstFlowId)(u),u};const o=n(523),r=n(2314),i=n(7930),a=n(8590)},4988:function(e,t,n){var o,r=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||(o=function(e){return o=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},o(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=o(e),a=0;a<n.length;a++)"default"!==n[a]&&r(t,e,n[a]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.pageManifest=t.apiManifest=void 0,t.setNextConfig=function(e){g=e,h=!0},t.getNextConfig=function(){return g},t.isNextConfigExtracted=function(){return h},t.extractNextEndpointDeclarations=async function(e){const n=[];if(!e)return n;d.worker_logger.info("Extracting next.js endpoint declarations in worker");const o=e.distDir,r=s.join(o,t.apiManifest),i=await(0,c.readFile)(r);if(i){const e=JSON.parse(i),t=await async function(e,t){const n=[];for(const o of Object.keys(t))if(o.endsWith("/route")){const r=s.join(e,"server",t[o]),i=await f(r),a=p(o,"/route");for(const e of i){const t=(0,c.generateEndpointFlowId)(a,[e]);n.push(new u.EndpointDeclaration(t,[e],"nextjs","",a))}}else if(o.endsWith("/page")){const e=["GET"],t=p(o,"/page"),r=(0,c.generateEndpointFlowId)(t,e);n.push(new u.EndpointDeclaration(r,e,"nextjs","",t))}else d.worker_logger.warning("Unknown Next.js manifest key type",{key:o});return n}(o,e);n.push(...t)}const a=s.join(o,t.pageManifest),g=await(0,c.readFile)(a);if(g){const e=JSON.parse(g),t=await async function(e,t){const n=[];for(const e of Object.keys(t))if(e.startsWith("/api/")){const t=(0,c.generateEndpointFlowId)(e,l);n.push(new u.EndpointDeclaration(t,l,"nextjs","",e))}else{const t=["GET"],o=(0,c.generateEndpointFlowId)(e,t);n.push(new u.EndpointDeclaration(o,t,"nextjs","",e))}return n}(0,e);n.push(...t)}return n};const s=a(n(6928)),u=n(8528),c=n(2546),d=n(523),l=["GET","POST","PUT","DELETE","PATCH","OPTIONS","HEAD"];let g;t.apiManifest="server/app-paths-manifest.json",t.pageManifest="server/pages-manifest.json";let h=!1;async function f(e){const t=await(0,c.readFile)(e);if(!t)return[];const n=new RegExp(`\\b(${l.join("|")})\\b`,"g"),o=t.matchAll(n),r=Array.from(o,e=>e[1]);return Array.from(new Set(r))}function p(e,t){return e.length===t.length?"/":e.length>t.length?e.slice(0,0-t.length):e}},5809:e=>{e.exports=require("./config")},6928:e=>{e.exports=require("path")},7131:e=>{e.exports=require("./wrap")},7398:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.globalInvestigationTracking=void 0,t.getClosedInvestigations=function(){const e=i;return i=[],e},t.storeClosedInvestigation=function(e){i.push(e)},t.setGlobalInvestigationTracking=function(e){t.globalInvestigationTracking=e},t.increaseGlobalInvestigationTracking=function(){t.globalInvestigationTracking++},t.getGlobalInvestigationTracking=function(){return t.globalInvestigationTracking},t.increaseInvestigationDedupingCache=function(e,t){const n=a.get(e)??new Map,o=(n.get(t)??0)+1;n.set(t,o),a.set(e,n)},t.resetInvestigationDedupingCache=function(){a.clear()},t.getInvestigationDedupingCache=function(e){return a.get(e)??new Map},t.saveMachineMetric=function(){const e=process.cpuUsage(),t=r.performance.eventLoopUtilization();s.push({cpuUsage:e,elu:t,timestamp:Date.now()}),s.length>o.hudConfig.machineMetricsSavedLength&&s.shift()},t.getLastMetrics=function(){return s[0]},t.setInvestigationDurationThresholds=function(e){u=e},t.getFlowIdDurationThresholdAndCount=function(e){return u[e]},t.increaseInvestigationDurationCount=function(e){const t=c.get(e)??0;c.set(e,t+1)},t.getInvestigationDurationCount=function(e){return c.get(e)??0},t.resetInvestigationDurationCounts=function(){c.clear()},t.increaseTotalInvestigationsErrorBased=function(){d++},t.getTotalInvestigationsErrorBased=function(){return d},t.resetTotalInvestigationsErrorBased=function(){d=0},t.increaseTotalInvestigationsDurationBased=function(){l++},t.getTotalInvestigationsDurationBased=function(){return l},t.resetTotalInvestigationsDurationBased=function(){l=0};const o=n(5809),r=n(2987);let i=[];t.globalInvestigationTracking=0;const a=new Map,s=[];let u={};const c=new Map;let d=0,l=0},7764:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),r(n(754),t),r(n(3025),t),r(n(8714),t),r(n(4988),t),r(n(4583),t),r(n(8590),t)},7859:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MetricFactory=t.BaseMetric=void 0;class n{}class o extends n{flowId;count;sumDuration;sumSquaredDuration;sketchBuilder;errorBreakdown;constructor(e,t){super(),this.flowId=e.flow_id,this.count=1,this.sumDuration=e.duration,this.sumSquaredDuration=e.duration**2,this.sketchBuilder=t.newSketchDataWithValue(e.duration),this.errorBreakdown=new Map,e.error_breakdown&&this.updateErrorBreakdown(e.error_breakdown)}getEventVersion(){return"1.0.0"}updateErrorBreakdown(e){let t=this.errorBreakdown.get(e.key);void 0===t&&(t={errors:e.errors,count:0,caught:e.caught,key:e.key},this.errorBreakdown.set(e.key,t)),t.count+=1}update(e,t){this.sumDuration+=e.duration,this.sumSquaredDuration+=e.duration**2,this.count+=1,t.add(this.sketchBuilder,e.duration),void 0!==e.error_breakdown&&this.updateErrorBreakdown(e.error_breakdown)}finalize(e,t,n){return{flow_id:this.flowId,count:this.count,sum_duration:this.sumDuration,sum_squared_duration:this.sumSquaredDuration,timestamp:t,timeslice:n,sketch:e.encode(this.sketchBuilder),error_breakdown:Array.from(this.errorBreakdown.values()).map(e=>({errors:e.errors,count:e.count,caught:e.caught}))}}}t.BaseMetric=o;class r{static registry={};static registerMetric(e,t){r.registry[e]=t}static createMetric(e,t){const n=r.registry[e.type];if(!n)throw new Error(`Unknown metric type: ${e.type}`);return new n(e,t)}}t.MetricFactory=r,r.registerMetric("EndpointMetric",class extends o{method;statusCode;constructor(e,t){super(e,t),this.method=e.method,this.statusCode=e.status_code}getEventVersion(){return"1.0.2"}finalize(e,t,n){return{...super.finalize(e,t,n),method:this.method,status_code:this.statusCode}}}),r.registerMetric("GraphQLMetric",class extends o{statusCode;errorOccurred;constructor(e,t){super(e,t),this.statusCode=e.status_code,this.errorOccurred=e.error_occurred}finalize(e,t,n){return{...super.finalize(e,t,n),status_code:this.statusCode,error_occurred:this.errorOccurred}}}),r.registerMetric("KafkaJSMetric",class extends o{partition;error;ConsumeSketchBuilder;sumConsumedDuration;sumSquaredConsumedDuration;constructor(e,t){super(e,t),this.partition=e.partition,this.error=e.error,e.total_consume_duration&&(this.ConsumeSketchBuilder=t.newSketchDataWithValue(e.total_consume_duration)),this.sumConsumedDuration=e.total_consume_duration??0,this.sumSquaredConsumedDuration=(e.total_consume_duration??0)**2}update(e,t){super.update(e,t),e.total_consume_duration&&(this.sumConsumedDuration+=e.total_consume_duration,this.sumSquaredConsumedDuration+=e.total_consume_duration**2,this.ConsumeSketchBuilder?t.add(this.ConsumeSketchBuilder,e.total_consume_duration):this.ConsumeSketchBuilder=t.newSketchDataWithValue(e.total_consume_duration))}finalize(e,t,n){return{...super.finalize(e,t,n),partition:this.partition,error:this.error,sum_consumed_duration:this.sumConsumedDuration,sum_squared_consumed_duration:this.sumSquaredConsumedDuration,sketch_consume:e.encode(this.ConsumeSketchBuilder)}}}),r.registerMetric("SqsMetric",class extends o{msgCount;errors;e2eData;constructor(e,t){super(e,t),this.msgCount=e.msg_count,this.errors=e.errors,e.e2e_duration&&(this.e2eData={duration:e.e2e_duration,squaredDuration:e.e2e_duration**2,sketchBuilder:t.newSketchDataWithValue(e.e2e_duration)})}update(e,t){super.update(e,t),this.msgCount&&e.msg_count&&(this.msgCount+=e.msg_count),e.errors.forEach((e,t)=>{this.errors.set(t,(this.errors.get(t)??0)+e)}),this.e2eData&&e.e2e_duration&&(this.e2eData.duration+=e.e2e_duration,this.e2eData.squaredDuration+=e.e2e_duration**2,t.add(this.e2eData.sketchBuilder,e.e2e_duration))}getEventVersion(){return"1.0.2"}finalize(e,t,n){return{...super.finalize(e,t,n),errors:Object.fromEntries(this.errors),msg_count:this.msgCount,...this.e2eData?{e2e_sum_duration:this.e2eData.duration,e2e_sum_squared_duration:this.e2eData.squaredDuration,e2e_sketch:e.encode(this.e2eData.sketchBuilder)}:{}}}})},7918:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.storeLoadedOutbound=function(e){n.push(e)},t.getLoadedOutboundsFromStorage=function(){const e=n;return n=[],e};let n=[]},7930:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.extractEndpointsFromRouter=function e(t,n){let r=[];const u="true"===process.env.HUD_LOG_EXPRESS;if(!n.stack)return i.app_logger.error("Router without stack - bad OTEL version",{router:n}),r;for(const c of n.stack)if("router"===c.name){if(!c[o.hudConfig.express.routeNamesSymbol]){i.app_logger.error("Router layer without routes",{layer:c});continue}const n=t+c[o.hudConfig.express.routeNamesSymbol];r=r.concat(e(n,c.handle))}else c.route&&c.route[o.hudConfig.express.layerStateSymbol]?r=r.concat(a(c,t)):u&&!s.has(c.name)&&(s.add(c.name),i.app_logger.warning("Found unknown layer name when extracting endpoints",{layer:c.name}));return r};const o=n(5809),r=n(8528),i=n(523);function a(e,t){const n=[];for(const[i,a]of Object.entries(e.route[o.hudConfig.express.layerStateSymbol]))n.push(new r.EndpointDeclaration(i,a.methods,"express",t,a.layerPath));return Array.from(n.values())}const s=new Set(["query","expressInit","mounted_app"])},8167:e=>{e.exports=require("worker_threads")},8528:e=>{e.exports=require("./dto")},8590:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getRouterlessEndpointDeclarationsFromStorage=function(){const e=i;return i=[],e},t.storePartialEndpointDeclaration=function(e){a.push(e)},t.getPartialEndpointDeclarationsFromStorage=function(){const e=a;return a=[],e},t.storeExpressEndpointDeclaration=function(e){if(!r.fullEndpointFlowIdMap.has(e.flow_id)){if(e.path){const t=(0,o.generateEndpointFlowId)(e.path,e.methods);r.fullEndpointFlowIdMap.set(e.flow_id,t)}i.push(e)}};const o=n(2546),r=n(2314);let i=[],a=[]},8708:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setLambdaExtensionId=function(e){r&&o.app_logger.warning("Lambda extension id already set"),r=e},t.getLambdaExtensionId=function(){return r};const o=n(523);let r},8714:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getKafkaJSTopics=function(){const e=n;return n=[],e},t.storeKafkaJSTopicDeclaration=function(e){n.push(e)};let n=[]}},t={};return function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={exports:{}};return e[o].call(i.exports,i,i.exports,n),i.exports}(820)})());
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 n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(global,()=>(()=>{"use strict";var e={290:e=>{e.exports=require("async_hooks")},395:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addReingestValue=function(e){n.add(e)},t.getAndClearReingestValues=function(){const e=new Set;for(const t of n)o.has(t)||e.add(t);for(const t of e)o.add(t);return n=new Set,e};let n=new Set;const o=new Set},523:e=>{e.exports=require("./logger")},754:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.storeEndpointDeclaration=function(e){n.push(e)},t.getEndpointDeclarationsFromStorage=function(){const e=n;return n=[],e};let n=[]},820:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),r(n(7764),t),r(n(4583),t),r(n(2314),t),r(n(3025),t),r(n(8714),t),r(n(4988),t),r(n(2525),t),r(n(3973),t),r(n(1757),t),r(n(1364),t),r(n(7398),t),r(n(8708),t),r(n(7918),t),r(n(395),t)},1364:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.initGlobals=function(){globalThis.hudGlobalInitGuard||(globalThis.hudGlobalInitGuard=!0,globalThis.hudRunMutex=!1,globalThis.hudRanOnRequire=!1,globalThis.hudRanOnImport=!1,globalThis.hudInitGuard=void 0,globalThis.hudInstrumentationIndicator=void 0,globalThis.hudMetricsIndicator=void 0,globalThis.hudInstrumentationOccured=!1,globalThis.hudNextJsPluginIndicator=void 0,globalThis.hudStartTime=new Date,globalThis.hudCalls={},globalThis.hudRunningMode=r.HudRunningMode.enabled,globalThis.hudExecutionFlowMaxLength=o.hudConfig.dynamicConfig.investigationRateLimits.executionFlowMaxLength,globalThis.hudExceptionMaxLength=o.hudConfig.dynamicConfig.investigationRateLimits.exceptionMaxLength,globalThis.hudEnableInvestigation=o.hudConfig.dynamicConfig.enableInvestigation,globalThis.hudEnableInvestigationArgsSending=o.hudConfig.dynamicConfig.enableInvestigationArgsSending,(0,s.setInvestigationStorage)(new u.AsyncLocalStorage),(0,s.setFlowStateStorage)(new u.AsyncLocalStorage),function(){globalThis.hudSampleTable=[];const e=[[10,1],[30,2],[100,3],[500,11],[1e3,23],[5e3,53]];let t=0;for(const[n,o]of e){for(let e=t;e<n;e++)globalThis.hudSampleTable.push(e%o===0);t=n}}(),d())},t.resetGlobals=d,t.hookMessageChannel=function(){const{port1:e,port2:t}=new c.MessageChannel;return e.on("message",e=>{"HudModulePatch"===e.key?(globalThis.hudPatched.add(e.hudPatched),globalThis.hudProcessedFiles.push(e.hudProcessedFiles)):"HudRetrieveFileCache"===e.key&&globalThis.HudSourceMapCache.set(e.filename,e.content)}),e.unref(),globalThis.hudHookPort=e,t},t.clearInitGuard=l,t.clearMetricsIndicator=g,t.clearInstrumentationIndicator=h,t.clearUserIndicatorsTimeouts=function(){l(),g(),h()},t.detachHud=f,t.forceHudEnable=function(){globalThis.forceHudEnable=!0},t.saveHudRunningFromSetup=function(){globalThis.hudIsRunningFromSetup=!0},t.saveInstrumentationIndicator=function(e){globalThis.hudInstrumentationIndicator=e,globalThis.hudInstrumentationIndicator.unref()},t.validateAndGetUserInput=function(){return o.hudConfig.userConfig.key||o.hudConfig.userConfig.service?o.hudConfig.userConfig.key?(0,o.isValidParam)(o.hudConfig.userConfig.key.value)?o.hudConfig.userConfig.service?(0,o.isValidParam)(o.hudConfig.userConfig.service.value)?{apiKey:o.hudConfig.userConfig.key.value,service:o.hudConfig.userConfig.service.value}:(a.app_logger.critical("Service name is invalid - SDK cannot initialize",{source:o.hudConfig.userConfig.service.source}),o.hudConfig.disableOnBadServiceName&&f(!1),void a.customer_logger.log(i.UserErrorLogs.HudServiceInvalid(o.hudConfig.userConfig.service.source))):(a.app_logger.critical("Service name is missing - SDK cannot initialize"),o.hudConfig.disableOnBadServiceName&&f(!1),void a.customer_logger.log(i.UserErrorLogs.HudServiceNotSet(globalThis.hudStartFromAutoInit))):(a.app_logger.critical("API key is invalid - SDK cannot initialize",{source:o.hudConfig.userConfig.key.source}),o.hudConfig.disableOnBadApiKey&&f(!1),void a.customer_logger.log(i.UserErrorLogs.HudApiKeyInvalid(o.hudConfig.userConfig.key.source))):(a.app_logger.critical("API key is missing - SDK cannot initialize"),o.hudConfig.disableOnBadApiKey&&f(!1),void a.customer_logger.log(i.UserErrorLogs.HudApiKeyNotSet(globalThis.hudStartFromAutoInit))):(a.app_logger.critical("Both API key and service name are missing - SDK cannot initialize"),(o.hudConfig.disableOnBadApiKey||o.hudConfig.disableOnBadServiceName)&&f(!1),void a.customer_logger.log(i.UserErrorLogs.BothApiKeyAndServiceNotSet(globalThis.hudStartFromAutoInit)))};const o=n(5809),r=n(8528),i=n(2546),a=n(523),s=n(7131),u=n(290),c=n(8167);function d(){globalThis.hudProcessedFiles=[],globalThis._hud_S=new Array(1e3).fill(""),globalThis._hud_SI={value:0},globalThis.hudLoadedModules=[],globalThis.hudPatched=new Set,globalThis.HudSourceMapCache=new Map,globalThis.hudExpressState=[]}function l(){clearTimeout(globalThis.hudInitGuard),globalThis.hudInitGuard=void 0}function g(){clearTimeout(globalThis.hudMetricsIndicator),globalThis.hudMetricsIndicator=void 0}function h(){clearTimeout(globalThis.hudInstrumentationIndicator),globalThis.hudInstrumentationIndicator=void 0,globalThis.hudInstrumentationOccured=!0}function f(e=!0,t=!1){if(a.app_logger.warning("Detaching hud"),t||e&&hudRunningMode!==r.HudRunningMode.detached){const e=(0,i.getFirstError)();a.customer_logger.log(i.UserErrorLogs.ShutdownGracefully(e))}globalThis.hudRunningMode=r.HudRunningMode.detached}},1757:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.markShouldFlushOnInit=function(e){r=e},t.storeCredentials=function(e,t){n=e,o=t},t.storeSessionInfo=function(e){i=e},t.getSessionInfo=function(){return i},t.getStoredApiKey=function(){return n},t.getStoredService=function(){return o},t.getShouldFlushOnInit=function(){return r};let n,o,r=!1,i=null},2314:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fullEndpointFlowIdMap=void 0,t.getLinkedConsistentFlowId=u,t.getFlowIdFromMappings=c,t.linkTemporaryToConsistenFlowId=d,t.clearFlowIdMappings=function(){t.fullEndpointFlowIdMap.clear(),s.clear()},t.swapTempToConstFlowId=function(e){e.forEach(e=>{"express"===e.framework&&(e.flow_id=u(e.flow_id,!0)??e.flow_id)})};const o=n(2546),r=n(523),i=n(7930),a=n(8590);t.fullEndpointFlowIdMap=new Map;const s=new Map;function u(e,t){let n=c(e,!1);return n?n.flowId:(d(t),n=c(e,!0),n?(n.isPartial&&!t&&r.app_logger.warning("Found partial endpoint for flow id even though partial aren't allowd",{flowId:e,consistentFlowId:n.flowId}),n.flowId):void 0)}function c(e,n){let o=t.fullEndpointFlowIdMap.get(e);return o?{flowId:o,isPartial:!1}:n?(o=s.get(e),o?{flowId:o,isPartial:!0}:void 0):void 0}function d(e){const n=[];globalThis.hudExpressState.forEach(e=>{try{n.push(...(0,i.extractEndpointsFromRouter)("",e))}catch(e){r.app_logger.error("Failed to extract endpoints from express",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}),n.forEach(e=>{if(e.partial_path)return;const n=e.flow_id;let r=t.fullEndpointFlowIdMap.get(n);r||(r=(0,o.generateEndpointFlowId)(e.path,e.methods),t.fullEndpointFlowIdMap.set(n,r))}),(0,a.getPartialEndpointDeclarationsFromStorage)().forEach(n=>{const r=n.flow_id;let i=t.fullEndpointFlowIdMap.get(r);i||(i=s.get(r),i||(i=(0,o.generateEndpointFlowId)(n.partial_path,n.methods),e?s.set(r,i):t.fullEndpointFlowIdMap.set(r,i)))})}},2525:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getSqsQueues=function(){const e=n;return n=[],e},t.storeSqsQueueDeclaration=function(e){n.push(e)};let n=[]},2546:e=>{e.exports=require("./lib")},2987:e=>{e.exports=require("perf_hooks")},3025:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getGraphQLOperations=function(){const e=n;return n={},e},t.storeGraphQLOperation=function(e){n[e.flow_id]||(n[e.flow_id]=e)};let n={}},3973:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getFlowMetrics=function(e){const t=(new Date).toISOString(),n={};for(const o in s){const i=[];let a;for(const n in s[o]){const r=s[o][n];a||(a=r.getEventVersion()),i.push(r.finalize(u,t,e))}delete s[o],a?n[o]={eventVersion:a,metrics:i}:r.app_logger.error("No event version found for metric type",o)}return n},t.storeFlowMetric=function(e){const t=function(e){if(void 0!==e.flow_id)switch(e.type){case"EndpointMetric":{const t=e;return`${e.flow_id}|${t.route}|${t.method}|${t.status_code}`}case"KafkaJSMetric":{const t=e;return`${e.flow_id}|${t.partition}|${t.error}`}case"GraphQLMetric":{const t=e;return`${e.flow_id}|${t.status_code}|${t.error_occurred}`}default:return e.flow_id}}(e);if(!t)return;s[e.type]||(s[e.type]={});const n=s[e.type][t];if(n)n.update(e,u);else{const n=a.MetricFactory.createMetric(e,u);s[e.type][t]=n}};const o=n(5809),r=n(523),i=n(7131),a=n(7859),s={},u=new i.SketchManager(o.hudConfig.huddBinWidth)},4583:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getExpressEndpointDeclarations=function(){let e=[];globalThis.hudExpressState.forEach(t=>{try{e=e.concat((0,i.extractEndpointsFromRouter)("",t))}catch(e){o.app_logger.error("Failed to extract endpoints from express",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}),e=e.concat((0,a.getRouterlessEndpointDeclarationsFromStorage)());const t=new Set;e.forEach(e=>{e.partial_path||t.add(e.flow_id)});const n=e.filter(e=>!e.partial_path||!t.has(e.flow_id)&&(o.app_logger.info("Partial endpoint without full endpoint",{endpoint:e}),!0)),s=new Map;for(const e of n){const t=`${e.path||e.partial_path||""}|${[...e.methods].sort().join(",")}`;s.has(t)||s.set(t,e)}const u=Array.from(s.values());return(0,r.swapTempToConstFlowId)(u),u};const o=n(523),r=n(2314),i=n(7930),a=n(8590)},4988:function(e,t,n){var o,r=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||(o=function(e){return o=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},o(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=o(e),a=0;a<n.length;a++)"default"!==n[a]&&r(t,e,n[a]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.pageManifest=t.apiManifest=void 0,t.setNextConfig=function(e){g=e,h=!0},t.getNextConfig=function(){return g},t.isNextConfigExtracted=function(){return h},t.extractNextEndpointDeclarations=async function(e){const n=[];if(!e)return n;d.worker_logger.info("Extracting next.js endpoint declarations in worker");const o=e.distDir,r=s.join(o,t.apiManifest),i=await(0,c.readFile)(r);if(i){const e=JSON.parse(i),t=await async function(e,t){const n=[];for(const o of Object.keys(t))if(o.endsWith("/route")){const r=s.join(e,"server",t[o]),i=await f(r),a=p(o,"/route");for(const e of i){const t=(0,c.generateEndpointFlowId)(a,[e]);n.push(new u.EndpointDeclaration(t,[e],"nextjs","",a))}}else if(o.endsWith("/page")){const e=["GET"],t=p(o,"/page"),r=(0,c.generateEndpointFlowId)(t,e);n.push(new u.EndpointDeclaration(r,e,"nextjs","",t))}else d.worker_logger.warning("Unknown Next.js manifest key type",{key:o});return n}(o,e);n.push(...t)}const a=s.join(o,t.pageManifest),g=await(0,c.readFile)(a);if(g){const e=JSON.parse(g),t=await async function(e,t){const n=[];for(const e of Object.keys(t))if(e.startsWith("/api/")){const t=(0,c.generateEndpointFlowId)(e,l);n.push(new u.EndpointDeclaration(t,l,"nextjs","",e))}else{const t=["GET"],o=(0,c.generateEndpointFlowId)(e,t);n.push(new u.EndpointDeclaration(o,t,"nextjs","",e))}return n}(0,e);n.push(...t)}return n};const s=a(n(6928)),u=n(8528),c=n(2546),d=n(523),l=["GET","POST","PUT","DELETE","PATCH","OPTIONS","HEAD"];let g;t.apiManifest="server/app-paths-manifest.json",t.pageManifest="server/pages-manifest.json";let h=!1;async function f(e){const t=await(0,c.readFile)(e);if(!t)return[];const n=new RegExp(`\\b(${l.join("|")})\\b`,"g"),o=t.matchAll(n),r=Array.from(o,e=>e[1]);return Array.from(new Set(r))}function p(e,t){return e.length===t.length?"/":e.length>t.length?e.slice(0,0-t.length):e}},5809:e=>{e.exports=require("./config")},6928:e=>{e.exports=require("path")},7131:e=>{e.exports=require("./wrap")},7398:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.globalInvestigationTracking=void 0,t.getClosedInvestigations=function(){const e=i;return i=[],e},t.storeClosedInvestigation=function(e){i.push(e)},t.setGlobalInvestigationTracking=function(e){t.globalInvestigationTracking=e},t.increaseGlobalInvestigationTracking=function(){t.globalInvestigationTracking++},t.getGlobalInvestigationTracking=function(){return t.globalInvestigationTracking},t.increaseInvestigationDedupingCache=function(e,t){const n=a.get(e)??new Map,o=(n.get(t)??0)+1;n.set(t,o),a.set(e,n)},t.resetInvestigationDedupingCache=function(){a.clear()},t.getInvestigationDedupingCache=function(e){return a.get(e)??new Map},t.saveMachineMetric=function(){const e=process.cpuUsage(),t=r.performance.eventLoopUtilization();s.push({cpuUsage:e,elu:t,timestamp:Date.now()}),s.length>o.hudConfig.machineMetricsSavedLength&&s.shift()},t.getLastMetrics=function(){return s[0]},t.setInvestigationDurationThresholds=function(e){u=e},t.getFlowIdDurationThresholdAndCount=function(e){return u[e]},t.increaseInvestigationDurationCount=function(e){const t=c.get(e)??0;c.set(e,t+1)},t.getInvestigationDurationCount=function(e){return c.get(e)??0},t.resetInvestigationDurationCounts=function(){c.clear()},t.increaseTotalInvestigationsErrorBased=function(){d++},t.getTotalInvestigationsErrorBased=function(){return d},t.resetTotalInvestigationsErrorBased=function(){d=0},t.increaseTotalInvestigationsDurationBased=function(){l++},t.getTotalInvestigationsDurationBased=function(){return l},t.resetTotalInvestigationsDurationBased=function(){l=0};const o=n(5809),r=n(2987);let i=[];t.globalInvestigationTracking=0;const a=new Map,s=[];let u={};const c=new Map;let d=0,l=0},7764:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,r)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),r(n(754),t),r(n(3025),t),r(n(8714),t),r(n(4988),t),r(n(4583),t),r(n(8590),t)},7859:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MetricFactory=t.BaseMetric=void 0;class n{}class o extends n{flowId;count;sumDuration;sumSquaredDuration;sketchBuilder;errorBreakdown;constructor(e,t){super(),this.flowId=e.flow_id,this.count=1,this.sumDuration=e.duration,this.sumSquaredDuration=e.duration**2,this.sketchBuilder=t.newSketchDataWithValue(e.duration),this.errorBreakdown=new Map,e.error_breakdown&&this.updateErrorBreakdown(e.error_breakdown)}getEventVersion(){return"1.0.0"}updateErrorBreakdown(e){let t=this.errorBreakdown.get(e.key);void 0===t&&(t={errors:e.errors,count:0,caught:e.caught,key:e.key},this.errorBreakdown.set(e.key,t)),t.count+=1}update(e,t){this.sumDuration+=e.duration,this.sumSquaredDuration+=e.duration**2,this.count+=1,t.add(this.sketchBuilder,e.duration),void 0!==e.error_breakdown&&this.updateErrorBreakdown(e.error_breakdown)}finalize(e,t,n){return{flow_id:this.flowId,count:this.count,sum_duration:this.sumDuration,sum_squared_duration:this.sumSquaredDuration,timestamp:t,timeslice:n,sketch:e.encode(this.sketchBuilder),error_breakdown:Array.from(this.errorBreakdown.values()).map(e=>({errors:e.errors,count:e.count,caught:e.caught}))}}}t.BaseMetric=o;class r{static registry={};static registerMetric(e,t){r.registry[e]=t}static createMetric(e,t){const n=r.registry[e.type];if(!n)throw new Error(`Unknown metric type: ${e.type}`);return new n(e,t)}}t.MetricFactory=r,r.registerMetric("EndpointMetric",class extends o{method;statusCode;constructor(e,t){super(e,t),this.method=e.method,this.statusCode=e.status_code}getEventVersion(){return"1.0.2"}finalize(e,t,n){return{...super.finalize(e,t,n),method:this.method,status_code:this.statusCode}}}),r.registerMetric("GraphQLMetric",class extends o{statusCode;errorOccurred;constructor(e,t){super(e,t),this.statusCode=e.status_code,this.errorOccurred=e.error_occurred}finalize(e,t,n){return{...super.finalize(e,t,n),status_code:this.statusCode,error_occurred:this.errorOccurred}}}),r.registerMetric("KafkaJSMetric",class extends o{partition;error;ConsumeSketchBuilder;sumConsumedDuration;sumSquaredConsumedDuration;constructor(e,t){super(e,t),this.partition=e.partition,this.error=e.error,e.total_consume_duration&&(this.ConsumeSketchBuilder=t.newSketchDataWithValue(e.total_consume_duration)),this.sumConsumedDuration=e.total_consume_duration??0,this.sumSquaredConsumedDuration=(e.total_consume_duration??0)**2}update(e,t){super.update(e,t),e.total_consume_duration&&(this.sumConsumedDuration+=e.total_consume_duration,this.sumSquaredConsumedDuration+=e.total_consume_duration**2,this.ConsumeSketchBuilder?t.add(this.ConsumeSketchBuilder,e.total_consume_duration):this.ConsumeSketchBuilder=t.newSketchDataWithValue(e.total_consume_duration))}finalize(e,t,n){return{...super.finalize(e,t,n),partition:this.partition,error:this.error,sum_consumed_duration:this.sumConsumedDuration,sum_squared_consumed_duration:this.sumSquaredConsumedDuration,sketch_consume:e.encode(this.ConsumeSketchBuilder)}}}),r.registerMetric("SqsMetric",class extends o{msgCount;errors;e2eData;constructor(e,t){super(e,t),this.msgCount=e.msg_count,this.errors=e.errors,e.e2e_duration&&(this.e2eData={duration:e.e2e_duration,squaredDuration:e.e2e_duration**2,sketchBuilder:t.newSketchDataWithValue(e.e2e_duration)})}update(e,t){super.update(e,t),this.msgCount&&e.msg_count&&(this.msgCount+=e.msg_count),e.errors.forEach((e,t)=>{this.errors.set(t,(this.errors.get(t)??0)+e)}),this.e2eData&&e.e2e_duration&&(this.e2eData.duration+=e.e2e_duration,this.e2eData.squaredDuration+=e.e2e_duration**2,t.add(this.e2eData.sketchBuilder,e.e2e_duration))}getEventVersion(){return"1.0.2"}finalize(e,t,n){return{...super.finalize(e,t,n),errors:Object.fromEntries(this.errors),msg_count:this.msgCount,...this.e2eData?{e2e_sum_duration:this.e2eData.duration,e2e_sum_squared_duration:this.e2eData.squaredDuration,e2e_sketch:e.encode(this.e2eData.sketchBuilder)}:{}}}})},7918:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.storeLoadedOutbound=function(e){n.push(e)},t.getLoadedOutboundsFromStorage=function(){const e=n;return n=[],e};let n=[]},7930:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.extractEndpointsFromRouter=function e(t,n){let r=[];const u="true"===process.env.HUD_LOG_EXPRESS;if(!n.stack)return i.app_logger.error("Router without stack - bad OTEL version",{router:n}),r;for(const c of n.stack)if("router"===c.name){if(!c[o.hudConfig.express.routeNamesSymbol]){i.app_logger.error("Router layer without routes",{layer:c});continue}const n=t+c[o.hudConfig.express.routeNamesSymbol];r=r.concat(e(n,c.handle))}else c.route&&c.route[o.hudConfig.express.layerStateSymbol]?r=r.concat(a(c,t)):u&&!s.has(c.name)&&(s.add(c.name),i.app_logger.warning("Found unknown layer name when extracting endpoints",{layer:c.name}));return r};const o=n(5809),r=n(8528),i=n(523);function a(e,t){const n=[];for(const[i,a]of Object.entries(e.route[o.hudConfig.express.layerStateSymbol]))n.push(new r.EndpointDeclaration(i,a.methods,"express",t,a.layerPath));return Array.from(n.values())}const s=new Set(["query","expressInit","mounted_app"])},8167:e=>{e.exports=require("worker_threads")},8528:e=>{e.exports=require("./dto")},8590:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getRouterlessEndpointDeclarationsFromStorage=function(){const e=i;return i=[],e},t.storePartialEndpointDeclaration=function(e){a.push(e)},t.getPartialEndpointDeclarationsFromStorage=function(){const e=a;return a=[],e},t.storeExpressEndpointDeclaration=function(e){if(!r.fullEndpointFlowIdMap.has(e.flow_id)){if(e.path){const t=(0,o.generateEndpointFlowId)(e.path,e.methods);r.fullEndpointFlowIdMap.set(e.flow_id,t)}i.push(e)}};const o=n(2546),r=n(2314);let i=[],a=[]},8708:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setLambdaExtensionId=function(e){r&&o.app_logger.warning("Lambda extension id already set"),r=e},t.getLambdaExtensionId=function(){return r};const o=n(523);let r},8714:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getKafkaJSTopics=function(){const e=n;return n=[],e},t.storeKafkaJSTopicDeclaration=function(e){n.push(e)};let n=[]}},t={};return function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={exports:{}};return e[o].call(i.exports,i,i.exports,n),i.exports}(820)})());
2
2
  //# sourceMappingURL=globalstate.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 n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(global,()=>(()=>{var e={336:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(7131),i=r(2822),s=r(8949),a=r(4393),u=r(714);class c extends u.FrameworkPatcher{_patch(e){return this._patchSendRequest(e),n.instrument_logger.info("Patched @codegenie/serverless-express/src/frameworks/express.js successfully"),e}_patchSendRequest(e){const t=e.sendRequest;e.sendRequest=function(e){const r=e?.request,s=e?.response;if(!r||!s)return t.call(this,e);const u=a.HttpEndpointMetric.createUsableMetric(),c=(0,o.getFlowStateStorage)(),d=()=>{try{u.start(),u.setRequestAttributes(r)}catch(e){n.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 o=(0,i.runWithInvestigation)(()=>t.call(this,e));try{s.once("finish",function(){try{u.calculateDuration(),(0,i.finishHttpInvestigation)(r,s,u),u.setResponseAttributes(s),u.end()}catch(e){n.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){n.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 o};return c?c.run({httpMetric:u},d):d()},(0,s.copyPropertiesToTarget)(t,e.sendRequest)}}t.default=c},486:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8544);class o extends n.BaseKafkaJSPatcher{getExportsRoot(e){return e}getGroupId(e){return e[0].groupId}moduleName(){return"KafkaJS"}}t.default=o},523:e=>{"use strict";e.exports=require("./logger")},646:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(8949),i=r(5128),s=r(714);class a extends s.FrameworkPatcher{_patch(e){return this._patchCreate(e),n.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];"function"==typeof t.constructor&&"function"==typeof r?e[1]=(0,i.wrapLinkedFunction)(r):n.instrument_logger.error("Invalid args in NestJS RouterExecutionContext.create",{args:e})}catch(e){n.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,o.copyPropertiesToTarget)(t,e.RouterExecutionContext.prototype.create)}}t.default=a},714:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=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||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.FrameworkPatcher=void 0,t.isSupportedVersion=f,t.extractModuleVersion=g,t.getFrameworkPatcher=function(e){return new(r(2828)(`./${e}`).default)};const a=r(2546),u=r(523),c=r(9896),d=s(r(6928)),l=r(8064);function f(e,t){return""===e||l.satisfies(l.coerce(e),t)}function g(e){try{const t=(0,c.readFileSync)(d.join(e,"package.json"),{encoding:"utf8"}),r=JSON.parse(t).version;return"string"==typeof r?r:""}catch{u.instrument_logger.info("Failed extracting version",{baseDir:e})}return""}t.FrameworkPatcher=class{patch(e,t,r,n,o=this.constructor.name){try{if(this.isSupported(t,o,r,n))return this._patch(e)}catch(e){u.instrument_logger.error("Unhandeled error during patching framework",{framework:o,error:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return e}isSupported(e,t,r,n){const o=g(e);return!!f(o,r)||(u.instrument_logger.warning("Unsupported version",{framework:t,version:o,supportedVersion:r,basedir:e}),u.customer_logger.log(a.UserErrorLogs.UnsupportedFrameworkVersion(t)),!1)}}},828:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.KafkaJSMetric=void 0;const n=r(523),o=r(7131),i=r(9873);class s extends i.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,o.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,error_breakdown:this.errorBreakdown};n.instrument_logger.warning("No partition found for message",{flowId:this.flowId})}}t.KafkaJSMetric=s},857:e=>{"use strict";e.exports=require("os")},932:e=>{"use strict";e.exports=require("process")},1326:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(2546),i=r(523),s=r(8949),a=r(714),u=n(r(9589));class c extends a.FrameworkPatcher{static nextJSHudMarked=Symbol.for("hudNextJSMarked");_patch(e){return(0,o.setIsNextJsApp)(!0),this._pathLoad(e),i.instrument_logger.info("Patched Next.js successfully"),e}_pathLoad(e){try{const t=e.RouteModuleLoader;if(t[c.nextJSHudMarked])return e;const r=t.load;t.load=async function(...e){const t=await r.apply(this,e);try{if(t){const e=t.definition?.pathname;e&&!t[c.nextJSHudMarked]&&(u.default._detectAndPatchSupportedMethods(t,e),t[c.nextJSHudMarked]=!0)}}catch(e){i.instrument_logger.error("Failed to patch Next.js route module",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return t},t[c.nextJSHudMarked]=!0,(0,s.copyPropertiesToTarget)(r,t.load)}catch(e){i.instrument_logger.error("Failed to patch Next.js base server",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return e}}t.default=c},1427:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getSystemInfo=function(){return{pod_name:c(),node_name:d()}};const o=n(r(9896)),i=n(r(857)),s=Symbol("not found");let a,u;function c(){if(a!==s){if(a)return a;try{return a=i.default.hostname(),a}catch{return void(a=s)}}}function d(){if(u!==s){if(u)return u;try{const e=o.default.readFileSync("/etc/machine-id","utf8").trim();return u=e,u}catch{return void(u=s)}}}},1502:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(5809),o=r(8528),i=r(8269),s=r(2546),a=r(523),u=r(8949),c=r(714);class d extends c.FrameworkPatcher{static koaModuleName="koa";static koaPatchedSymbol=Symbol.for(n.hudConfig.hudPatchedName);_patch(e){return this._patchAppUse(e),a.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++)d._wrapRoute(e[t])}catch(e){a.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,u.copyPropertiesToTarget)(t,e.prototype.use)}static _wrapRoute(e){if(e.methods&&0===e.methods.length)return;if(!e.stack[0][d.koaPatchedSymbol]){const t=(0,u.wrapFlow)(p,e.stack[0],!0);e.stack[0]=t,e.stack[0][d.koaPatchedSymbol]=!0}const t=(0,s.generateEndpointFlowId)(e.path,e.methods);(0,i.storeEndpointDeclaration)(new o.EndpointDeclaration(t,e.methods,"koa",void 0,e.path));for(const r of e.methods)g(t,e.path,r)}}function l(e,t){return e+"|"+t}t.default=d;const f=new Map;function g(e,t,r){f.set(l(t,r),e)}function p(e,t){if(0===t.length)return;const r=t[0]._matchedRoute,n=t[0].req?.method;return function(e,t){return f.get(l(e,t))}(r,n)}},2080:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqsMetric=void 0;const n=r(9873);class o extends n.FlowMetric{errors;msgCount;e2eEpocStartTimeMS;e2eDurationNS;_finishedMessageCount;constructor(e){super(e),this._finishedMessageCount=0,this.errors=new Map}addError(e,t=1){this.errors.set(e,(this.errors.get(e)??0)+t)}increaseAndShouldEnd(e=1){return this._finishedMessageCount+=e,!(this.msgCount&&this._finishedMessageCount<this.msgCount)}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,errors:this.errors,error_breakdown:this.errorBreakdown}}}t.SqsMetric=o},2197:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=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)},a=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.serializableInvestigation=t.koa=t.express=t.safeLog=t.registerHook=t.hudRITM=void 0;var u=r(5688);Object.defineProperty(t,"hudRITM",{enumerable:!0,get:function(){return u.hudRITM}}),Object.defineProperty(t,"registerHook",{enumerable:!0,get:function(){return u.registerHook}}),Object.defineProperty(t,"safeLog",{enumerable:!0,get:function(){return u.safeLog}}),s(r(3901),t),t.express=a(r(7127)),s(r(714),t),t.koa=a(r(1502)),s(r(7166),t);var c=r(2822);Object.defineProperty(t,"serializableInvestigation",{enumerable:!0,get:function(){return c.serializableInvestigation}})},2546:e=>{"use strict";e.exports=require("./lib")},2729:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(7131),i=r(2822),s=r(8949),a=r(4393),u=r(714);class c extends u.FrameworkPatcher{_patch(e){const t=this._patchGetFramework(e);return n.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 u(e,...t){const s=a.HttpEndpointMetric.createUsableMetric(),u=(0,o.getFlowStateStorage)(),c=async()=>{try{s.start(),s.setRequestAttributes(e)}catch(e){n.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 o=await(0,i.runWithInvestigation)(()=>r.apply(r.this,[e,...t]));return o.once("finish",function(){try{s.calculateDuration(),(0,i.finishHttpInvestigation)(e,o,s),s.setResponseAttributes(o),s.end()}catch(e){n.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})}}),o};return u?await u.run({httpMetric:s},c):await c()}return(0,s.copyPropertiesToTarget)(r,u),u},(0,s.copyPropertiesToTarget)(t,e),e}}t.default=c},2741:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(6730),i=r(4815),s=r(7225),a=r(714);class u extends a.FrameworkPatcher{_patch(e){return s.isVerboseLoggingEnabled?((0,o.patchMethods)(e,"application_export"),(0,i.patchUse)(e,"application",!1),(0,s.logLazyRouter)(e),n.instrument_logger.info("Patched express.Application successfully"),e):(n.instrument_logger.info("Skipping express.Application patching, verbose logging is not enabled"),e)}}t.default=u},2784:e=>{"use strict";e.exports=require("../native/_index")},2822:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getStackTraceWithoutMessage=f,t.limitedLogger=p,t.serializableInvestigation=h,t.getBaseInvestigationStorage=m,t.createNewInvestigation=function(){if(!globalThis.hudEnableInvestigation)return;const e=(0,a.getInvestigationStorage)();void 0!==e&&e.enterWith(m())},t.runWithInvestigation=function(e){if(!globalThis.hudEnableInvestigation)return e();const t=(0,a.getInvestigationStorage)();return void 0===t?e():t.run(m(),e)},t.closeInvestigation=y,t.storeInvestigation=_,t.getInvestigationDedupingKey=v,t.minimizeObject=k,t.finishHttpInvestigation=function(e,t,r){r.apiProtocol!==u.ApiProtocol.GraphQL?function(e,t,r){const n=function(e,t){return e.statusCode>=500?"Error":!!x(t,o.InvestigationType.HTTP)&&"Duration"}(t,r);if(!1===n)return;const i=S(r,n,o.InvestigationType.HTTP);if(void 0===i)return;try{p("http requests headers",{headers:Object.keys(e.headers)})}catch{p("failed to log http requests headers")}const s=r.getFlowId(),a=r.getMsStartTime(),u=r.apiProtocolAttributes;void 0!==s&&u&&void 0!==u.route&&void 0!==u.method&&void 0!==a?_(i,{type:o.InvestigationType.HTTP,endpoint_uuid:s,route:u.route,method:u.method,timestamp:a,params:e.params,query:e.query,request_body:k(e.body),status_code:t.statusCode,machine_metrics:(0,c.getMachineMetrics)(),observability_identifiers:(0,d.getObservabilityIdentifiersHttp)(e),extra_headers:(0,d.getExtraHeaders)(e),system_info:(0,l.getSystemInfo)()}):p("route, method, or reqTimestamp are undefined even though they shouldn't",{flowId:s,route:u.route,method:u.method,reqTimestamp:a})}(e,t,r):function(e,t,r){const n=function(e,t){const r=t.apiProtocolAttributes;return e.statusCode>=500||r&&r.errorOccurred?"Error":!!x(t,o.InvestigationType.GraphQL)&&"Duration"}(t,r);if(!1===n)return;const i=S(r,n,o.InvestigationType.GraphQL);if(void 0===i)return void p("finishHttpInvestigation: base investigation return undefined");const s=r.getFlowId(),a=r.getMsStartTime();void 0!==s&&void 0!==a?_(i,{type:o.InvestigationType.GraphQL,flow_id:s,timestamp:a,request_body:k(e.body),graphql_errors:k(r.apiProtocolAttributes?.errors),status_code:t.statusCode,machine_metrics:(0,c.getMachineMetrics)(),observability_identifiers:(0,d.getObservabilityIdentifiersHttp)(e),system_info:(0,l.getSystemInfo)()}):p("flowId or reqTimestamp are undefined even though they shouldn't",{flowId:s,reqTimestamp:a})}(e,t,r)},t.finishSqsInvestigation=function(e,t){const r=function(e){return e.errors.size>0?"Error":!!x(e,o.InvestigationType.SQS)&&"Duration"}(t);if(!1===r)return;const n=S(t,r,o.InvestigationType.SQS);if(void 0===n)return;const i=t.getFlowId(),s=t.getMsStartTime();void 0!==s&&void 0!==i?_(n,{type:o.InvestigationType.SQS,timestamp:s,flow_id:i,messages:k(e),machine_metrics:(0,c.getMachineMetrics)(),system_info:(0,l.getSystemInfo)()}):p("reqTimestamp is undefined even though it shouldn't",{flowId:i})},t.finishKafkaJSInvestigation=function(e,t,r,n){const i=function(e){return void 0!==e.error?"Error":!!x(e,o.InvestigationType.Kafka)&&"Duration"}(t);if(!1===i)return;const s=S(t,i,o.InvestigationType.Kafka);if(void 0===s)return;const a=t.getFlowId(),u=t.getMsStartTime();if(void 0===u||void 0===a)return void p("reqTimestamp is undefined even though it shouldn't",{flowId:a});const f=e.map(e=>{let t=e.value;t instanceof Buffer&&(t=t.toString());try{t=JSON.parse(t)}catch{}return{key:e.key,value:t,timestamp:e.timestamp,offset:e.offset,headers:e.headers,attributes:e.attributes}});_(s,{type:o.InvestigationType.Kafka,timestamp:u,topic:r,partition:n,flow_id:a,messages:k(f),machine_metrics:(0,c.getMachineMetrics)(),system_info:(0,l.getSystemInfo)(),observability_identifiers:(0,d.getObservabilityIdentifiers)()})},t.getErrorRecordsFromInvestigation=E;const n=r(5809),o=r(8528),i=r(8269),s=r(523),a=r(7131),u=r(4393),c=r(7808),d=r(7603),l=r(1427);function f(e,t){if(void 0===t)return;const r=function(e){let t=0;for(let r=0;r<e.length;r++)"\n"===e[r]&&t++;return t}(e)+1;let n=-1;for(let e=0;e<r;e++)if(n=t.indexOf("\n",n+1)??-1,-1===n)return;return-1!==n?t.slice(n+1):void 0}const g={};function p(e,...t){let r="debug";(void 0===g[e]||g[e]<n.hudConfig.dynamicConfig.investigationRateLimits.maxUniqLogs)&&(r="warning",g[e]=g[e]+1||1),s.app_logger.logLevel(r,e,...t)}function h(e){return{status:e.status,context:e.context,exceptions:Array.from(e.exceptions.values()).map(({exception:e,executionFlow:t,caught:r})=>({name:(0,a.extractName)(e),message:(0,a.extractMessage)(e),stackTrace:e instanceof Error?f(e.message,e.stack):void 0,executionFlow:t.map(e=>({function_id:e.function_id,caller_id:e.caller_id,args:void 0!==e.args?k(e.args,n.hudConfig.investigation.maxObjectDepth+2):void 0})),caught:r})),userContext:e.userContext,caught:e.caught,triggerType:e.triggerType,duration:e.duration,durationThreshold:e.durationThreshold,outbounds:e.outbounds.map(e=>function(e){try{return{function_id:e.function_id,caller_id:e.caller_id,type:e.type,duration:e.duration?Number(e.duration):void 0,timestamp:e.timestamp,args:k(e.args),result:k(e.result),error:e.error?{type:"string"==typeof e.error?e.error:(0,a.extractName)(e.error),message:(0,a.extractMessage)(e.error)}:void 0,...e.type===o.OutboundType.HTTP?{bodyDuration:e.bodyDuration,bodyError:e.bodyError?{type:"string"==typeof e.bodyError?e.bodyError:(0,a.extractName)(e.bodyError),message:(0,a.extractMessage)(e.bodyError)}:void 0}:{}}}catch(e){return void p("error serializing outbound",e)}}(e)).filter(e=>void 0!==e)}}function m(){return{triggerType:void 0,duration:0,status:o.InvestigationStatus.Open,caught:!0,exceptions:new Map,outbounds:[]}}function y(){if(!globalThis.hudEnableInvestigation)return;const e=(0,a.getInvestigationStorage)();if(void 0===e)return;const t=e.getStore();return void 0!==t&&t.status===o.InvestigationStatus.Open?(t.status=o.InvestigationStatus.Closed,t):void 0}function _(e,t){e.context=t,(0,i.storeClosedInvestigation)(h(e))}function b(e){for(const t of e)if(!t.is_outbound_function)return t.function_id}function v(e,t){let r="";for(const t of e)r+=`${t.error_type}-${t.function_id}|`;return r+=`${t}`,r}let w=null;function k(e,t=n.hudConfig.investigation.maxObjectDepth,o=new WeakSet){try{if(null===w&&(w=r(8611).IncomingMessage),null!==e&&"object"==typeof e){if(o.has(e))return"[Circular Reference]";if(w&&e instanceof w)return"[Http Request]";o.add(e)}if(null==e||["number","boolean"].includes(typeof e))return e;if("string"==typeof e)return e.length>n.hudConfig.investigation.maxStringLength?e.slice(0,n.hudConfig.investigation.maxStringLength)+"...":e;if(e instanceof Buffer)return e.length>n.hudConfig.investigation.maxStringLength?e.subarray(0,n.hudConfig.investigation.maxStringLength).toString()+"...":e.toString();if(e instanceof ArrayBuffer){const t=Buffer.from(e);return t.length>n.hudConfig.investigation.maxStringLength?t.subarray(0,n.hudConfig.investigation.maxStringLength).toString()+"...":t.toString()}if(["bigint","symbol"].includes(typeof e))return k(e.toString(),t-1,o);if("function"==typeof e)return`[Function: ${e.name||"anonymous"}]`;if(void 0===e)return;if(Array.isArray(e))return t<=0?"[Array]":e.slice(0,n.hudConfig.investigation.maxArrayLength).map(e=>k(e,t-1,o));if(e instanceof Map)return t<=0?"[Map]":{"[Map]":Array.from(e.entries()).slice(0,n.hudConfig.investigation.maxArrayLength).map(([e,r])=>[k(e,t-1,o),k(r,t-1,o)])};if(e instanceof Set)return t<=0?"[Set]":{"[Set]":Array.from(e.values()).slice(0,n.hudConfig.investigation.maxArrayLength).map(e=>k(e,t-1,o))};if(e instanceof Date){let r;try{r=e.toISOString()}catch{}return k(r,t-1,o)}if(e instanceof RegExp)return k(e.toString(),t-1,o);if(e&&"Proxy"===e[Symbol.toStringTag])return k(e.target||e,t-1,o);if(e&&e[Symbol.toStringTag])return`[${e[Symbol.toStringTag]}]`;if("object"==typeof e){if(t<=0)return"[Object]";const r={},i=Object.getOwnPropertyNames(e),s=Object.getOwnPropertySymbols(e);for(const s of i.slice(0,n.hudConfig.investigation.maxArrayLength))try{r[s.slice(0,n.hudConfig.investigation.maxKeyLength)]=k(e[s],t-1,o)}catch{}for(const i of s.slice(0,n.hudConfig.investigation.maxArrayLength))try{r[i.toString()]=k(e[i],t-1,o)}catch{}return r}}catch{}}function S(e,t,r){let o;if(o="Error"===t?function(e){const t=y();if(void 0===t)return void p("finishErrorInvestigation: investigation is undefined");const r=e.getFlowId();if(void 0===r)return void p("finishErrorInvestigation: flowId is undefined");const o=E(t),s=v(o,t.caught);if(e.setErrorBreakdown({key:s,errors:o,caught:t.caught}),(0,i.getGlobalInvestigationTracking)()>=n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigations)return void p("finishErrorInvestigation: globalInvestigationTracking is greater than maxTotalInvestigations",{globalInvestigationTracking:(0,i.getGlobalInvestigationTracking)(),maxTotalInvestigations:n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigations});if((0,i.getTotalInvestigationsErrorBased)()>=n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigationsErrorBased)return void p("finishErrorInvestigation: currentTotalInvestigationsErrorBased is greater than maxTotalInvestigationsErrorBased");const a=(0,i.getInvestigationDedupingCache)(r).get(s)??0;if(!(a>=n.hudConfig.dynamicConfig.investigationRateLimits.maxSameInvestigations))return(0,i.increaseGlobalInvestigationTracking)(),(0,i.increaseTotalInvestigationsErrorBased)(),(0,i.increaseInvestigationDedupingCache)(r,s),t;p("finishErrorInvestigation: investigationCount is greater than maxSameInvestigations",{investigationCount:a,maxSameInvestigations:n.hudConfig.dynamicConfig.investigationRateLimits.maxSameInvestigations})}(e):function(e,t){const r=e.getFlowId();if(void 0===r)return void p("finishDurationInvestigation: flowId is undefined");if((0,i.getGlobalInvestigationTracking)()>=n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigations)return void p("finishDurationInvestigation: currentTotalInvestigationsGlobal is greater than maxTotalInvestigations");if((0,i.getTotalInvestigationsDurationBased)()>=n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigationsDurationBased)return void p("finishDurationInvestigation: currentTotalInvestigationsDurationBased is greater than maxTotalInvestigationsDurationBased");const o=C(r,t);if(void 0!==o)return(0,i.getInvestigationDurationCount)(r)>=o.number_of_dumps?(p("finishDurationInvestigation: currentInvestigationCount is greater than durationThresholdAndCount.count"),void s.app_logger.debug("finishDurationInvestigation: currentInvestigationCount is greater than durationThresholdAndCount.count")):((0,i.increaseInvestigationDurationCount)(r),(0,i.increaseGlobalInvestigationTracking)(),(0,i.increaseTotalInvestigationsDurationBased)(),y());p("finishDurationInvestigation: durationThresholdAndCount is undefined")}(e,r),void 0!==o)return o.triggerType=t,o.duration=e.duration,o.durationThreshold=C(e.getFlowId()??"",r)?.duration,o;p("finishInvestigation: error investigation return undefined")}function C(e,t){const r=(0,i.getFlowIdDurationThresholdAndCount)(e);return void 0===r?(0,i.getFlowIdDurationThresholdAndCount)(`default-${t}`):r}function x(e,t){const r=e.getFlowId();if(void 0===r)return!1;const n=C(r,t);return void 0!==n&&n.duration<e.duration}function E(e){const t=new Set,r=[];for(const n of e.exceptions.values()){const e=(0,a.extractName)(n.exception),o=b(n.executionFlow)??"",i=`${e}-${o}`;if(t.has(i))continue;t.add(i);const s={error_type:e,function_id:o};r.push(s)}return r}},2828:(e,t,r)=>{var n={"./baseKafkaJsPatcher":8544,"./baseKafkaJsPatcher.ts":8544,"./codeGenieServerlessExpress":336,"./codeGenieServerlessExpress.ts":336,"./confluentKafkaJs":7276,"./confluentKafkaJs.ts":7276,"./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/flow":9873,"./flows/flow.ts":9873,"./flows/http":4393,"./flows/http.ts":4393,"./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,"./nestjsRouterExecutionContext":646,"./nestjsRouterExecutionContext.ts":646,"./nestjsRpcContextCreator":4290,"./nestjsRpcContextCreator.ts":4290,"./nextJsConfig":9723,"./nextJsConfig.ts":9723,"./nextJsModuleLoader":1326,"./nextJsModuleLoader.ts":1326,"./nextJsRouteModule":8840,"./nextJsRouteModule.ts":8840,"./nextjs":9589,"./nextjs.ts":9589,"./outbound/axios":5354,"./outbound/axios.ts":5354,"./outbound/nodeFetch":8564,"./outbound/nodeFetch.ts":8564,"./outbound/pg":7427,"./outbound/pg.ts":7427,"./outbound/wrapOutbound":9938,"./outbound/wrapOutbound.ts":9938,"./router":5946,"./router.ts":5946,"./serverlessHttp":2729,"./serverlessHttp.ts":2729,"./sqsConsumer":5150,"./sqsConsumer.ts":5150};function o(e){var t=i(e);return r(t)}function i(e){if(!r.o(n,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return n[e]}o.keys=function(){return Object.keys(n)},o.resolve=i,e.exports=o,o.id=2828},2977:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=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||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.patchRoute=function(e){const t=(0,g.getMethods)();t.concat("all").forEach(function(r){const n=e.prototype[r];e.prototype[r]=function(){let e;try{e=p(Array.prototype.slice.call(arguments));let n=function(e){const t=e[0][a.hudConfig.express.layerStateSymbol];if(t)return t.flowId}(e);const o=function(e){const t=e[0][a.hudConfig.express.layerStateSymbol];if(t)return t.kind}(e),i=function(e){const t=e[0][a.hudConfig.express.layerStateSymbol];return!!t&&t.allMethod}(e);if(n||(n=[l.randomUUID()]),"application"===o)if(Array.isArray(this.path)){y(e,void 0);for(let e=0;e<this.path.length;e++)m(n[e],i?t:[r],this.path[e])}else y(e,n[0]),m(n[0],i?t:[r],this.path);else if("router"===o)if(Array.isArray(this.path)){y(e,void 0);for(let e=0;e<this.path.length;e++)h(this,n[e],r,this.path[e])}else y(e,n[0]),h(this,n[0],r,this.path);else y(e,n[0]),h(this,n[0],r,this.path)}catch(e){d.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 n.apply(this,e||arguments)}})};const a=r(5809),u=r(8528),c=r(8269),d=r(523),l=s(r(6982)),f=r(8949),g=r(6730),p=r(5673);function h(e,t,r,n){!function(e,t,r,n){e[a.hudConfig.express.layerStateSymbol]||(e[a.hudConfig.express.layerStateSymbol]={}),e[a.hudConfig.express.layerStateSymbol][t]?e[a.hudConfig.express.layerStateSymbol][t].methods.push(r):e[a.hudConfig.express.layerStateSymbol][t]={layerPath:n,methods:[r]}}(e,t,r,n),function(e,t,r){const n=new u.EndpointDeclaration(e,[t],"express",void 0,void 0,r);(0,c.storePartialEndpointDeclaration)(n),(0,c.storeExpressEndpointDeclaration)(n)}(t,r,n)}function m(e,t,r){const n=new u.EndpointDeclaration(e,t,"express",void 0,r,void 0);(0,c.storeExpressEndpointDeclaration)(n)}function y(e,t){if(e&&!(e.length<1)){if(a.hudConfig.express.wrapAllCallbacks)for(let r=0;r<e.length;r++){const n=(0,f.wrapFlow)(b(t),e[r],!0);e[r]=n}else{const r=(0,f.wrapFlow)(b(t),e[e.length-1],!0);e[e.length-1]=r}return t}}function _(e){return(0,c.getLinkedConsistentFlowId)(e,!1)||(d.instrument_logger.warning("No consistent flowId found, returning temporary flow id",{flowId:e}),e)}function b(e){return e?function(){return _(e)}:function(e,t){const r=t[0]?.route[a.hudConfig.express.layerStateSymbol],n=t[0]?.url;if(r)for(const[e,t]of Object.entries(r)){if(t.layerPath instanceof RegExp&&t.layerPath.test(n))return _(e);if(n.includes(t.layerPath))return _(e)}d.instrument_logger.warning("No flowId found for path",{states:r,url:n.split("?")[0]})}}},2987:e=>{"use strict";e.exports=require("perf_hooks")},3176:e=>{"use strict";e.exports=require("buffer-crc32")},3339:e=>{"use strict";e.exports=require("module")},3868:e=>{"use strict";e.exports=require("@jridgewell/sourcemap-codec")},3901:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=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||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);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.getFunctionWrapperTemplate=v,t.splitCode=x,t.editInSplits=M,t.editWithCliBuildId=function(e,t,r,n){let{transformedCode:o,metadatas:i}=T(e,t,r,[],!0);return o+=`\n//# sourceMappingURL=${_.default.basename(t)}.map`,o+=`\n//"${n}";${d.hudConfig.cliSdkVersionVarName}="${d.SDK_VERSION}";${d.hudConfig.cliBuildIdVarName}`,{transformedCode:o,metadatas:i}},t.edit=T,t.incrementInstrumentedFunctionsCount=N;const u=a(r(3176)),c=r(3903),d=r(5809),l=r(2546),f=r(523),g=r(8528),p=r(8269),h=r(2546),m=r(3868),y=s(r(2784)),_=a(r(6928)),b=/([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 v(e,t,r=!1,n=!1){const o=`${e}_hudTemp`,i="BODY_PLACEHOLDER",s="FUNCTION_ID_PLACEHOLDER",a="AWAITABLE_PLACEHOLDER",u="EXCEPTION_VARIABLE_PLACEHOLDER",c="ARGS_ARRAY_PLACEHOLDER",l=function(e,t,r=!1){const n=[];if(r)return n;let o;t===g.Format.cjs?o="require":t===g.Format.esm&&(n.push(`import { createRequire as ${e}_createRequire } from "module";`,`const ${e}_require = ${e}_createRequire(import.meta.url);`),o=`${e}_require`);const i=h.myRequire.resolve(d.SDK_MODULE_NAME+"/wrap");return n.push(`let ${e}_temp;`,`try { ${e}_temp = ${o}(String.raw\`${i}\`); } catch (e) { ${e}_temp = { wrapperInitial: () => {}, wrapperCatch: () => {}, wrapperFinally: () => {}, fixStack: () => {}, wrapperUserCatch: () => {} }; globalThis._hud_SI = globalThis._hud_SI || { value: 0 }; globalThis._hud_S = globalThis._hud_S || [];\n }`,`const { wrapperInitial: ${e}_wi, wrapperCatch: ${e}_wc, wrapperFinally: ${e}_wf, fixStack: ${e}_fs, asyncIteratorWrapper: ${e}_aiw, wrapperUserCatch: ${e}_wuc } = ${e}_temp;`),n}(e,t,r),f=`${e}_cc.io = true;`;return{functionWrapper:`{\n let ${o};\n const ${d.hudConfig.functionIdVarName} = ${s};\n const ${e}_cc = {}; ${n?f:""}\n try {\n ${e}_wi(${d.hudConfig.functionIdVarName}, ${e}_cc);\n } catch (e) {\n globalThis._hud_SI = { value: 0 };\n globalThis._hud_S = [];\n }\n try {\n ${i}\n } catch (e) {\n try {\n ${e}_wc(${d.hudConfig.functionIdVarName}, ${e}_cc, e, ${c});\n } catch (e) {}\n throw e;\n } finally {\n try {\n ${e}_wf(${d.hudConfig.functionIdVarName}, ${e}_cc);\n } catch (e) {}\n }\n }`,awaitWrapper:`(${o} = ${a}, _hud_SI.value--, ${e}_cc.ff = true, ${o} = await ${o}, _hud_S[++_hud_SI.value] = ${d.hudConfig.functionIdVarName}, ${e}_cc.ff= false, ${o})`,yieldWrapper:`\n function* ${e}_generatorWrapper() {\n return (${o} = ${a}, _hud_SI.value--, ${e}_cc.ff = true, ${o} = yield ${o}, _hud_S[++_hud_SI.value] = ${d.hudConfig.functionIdVarName}, ${e}_cc.ff= false, ${o})\n }`,yieldStarWrapper:`\n function* ${e}_generatorWrapper() {\n return (${o} = ${a}, _hud_SI.value--, ${e}_cc.ff = true, ${o} = yield* ${o}, _hud_S[++_hud_SI.value] = ${d.hudConfig.functionIdVarName}, ${e}_cc.ff= false, ${o})\n }`,initialStatements:l,bodyPlaceholder:i,functionIdPlaceholder:s,awaitablePlaceholder:a,argsArrayPlaceholder:c,fixStackFunction:`\n try{\n ${e}_fs(${d.hudConfig.functionIdVarName}, ${e}_cc)\n }catch(e){};`,exceptionVariablePlaceholder:u,wrapperUserCatch:`\n try {\n ${e}_wuc(${d.hudConfig.functionIdVarName}, ${e}_cc, ${u}, ${c});\n } catch(e){};`,asyncIteratorWrapper:`${e}_aiw`,awaitableVariable:o}}function w(e,t,r,n=!0,o=!1,i){const s=Error.prepareStackTrace;let a=!1,l=function(e){const t=e.match(`${d.hudConfig.bundlerBuildIdVarName}="${b.source}"`);if(t&&t.length>0)return t[1]}(e);l||(l=function(e){return(0,c.v5)(e,d.hudConfig.bundlerBuildUuidNamespace)}(e),a=!0);const g=(0,c.v5)(e,d.hudConfig.functionUuidNamespace),p=(0,u.default)(t.filename).readUInt32BE(),m=(0,u.default)(e).readUInt32BE(),_=(0,h.isNextJsApp)(),w={data:t,bundlerBuildId:l,prefix:d.hudConfig.wrapVarPrefix,...v(d.hudConfig.wrapVarPrefix,t.format,o,r.length>0),uuidNamespace:d.hudConfig.functionUuidNamespace,fileHash:g,functionsToInstrument:r,useInputSourcemap:n,isNextJsFile:_,markCode:d.hudConfig.nextJsMarkVarName,enableForAwaitInstrumentation:!i,disableParametersExtraction:d.hudConfig.userConfig.disableParametersExtraction?.value},k=y.transform(e,w);return N(k.functionsIds.length,i),_&&k.marksCount!==k.functionsIds.length&&f.instrument_logger.warning("Marks count mismatch while instrumenting functions",{marksCount:k.marksCount,functionsIdsLength:k.functionsIds.length,filename:t.filename}),globalThis.hudNextJsPluginIndicator&&_&&(k.marksCount>0||k.functionsIds.length>0)&&(clearTimeout(globalThis.hudNextJsPluginIndicator),globalThis.hudNextJsPluginIndicator=void 0),Error.prepareStackTrace=s,f.instrument_logger.debug(`Successfully transformed ${t.filename}`),{code:k.code,map:k.map,functionIds:k.functionsIds,totalFunctionsCountIncludeUninstrumented:k.totalFunctionsCountIncludeUninstrumented,filename:t.filename,hasInputMap:k.isInputSourcemap,bundlerBuildId:l,bundlerBuildIdGenerated:a,file_path_checksum:p,file_checksum:m,sourceCodeHash:g,moduleBase:k.moduleBase,isNextJsApp:_,marksCount:k.marksCount,detectedForAwaitLoops:k.detectedForAwaitLoops}}class k extends Error{}function S(e,t){if(e&&t)throw new k("Start mark found inside mark");if(!e&&!t)throw new k("End mark found outside mark")}function C(e,t,r,n){const o=e.split("\n");let i=r,s=n;return i+=o.length-1,i+=t.split("\n").length-1,i===r?s+=o.pop()?.length||0:s=o.pop()?.length||0,{lineOffset:i,columnOffset:s}}function*x(e){let t=!1,r=0,n=0,o=!1,i=0,s=0;const a=new RegExp(`globalThis\\s*?&&\\s*?\\(globalThis\\.${d.hudConfig.esbuildGlobalVar}\\s*?=\\s*?"(Start|End):(?<fileName>.*?)"\\);?`,"g");for(const u of e.matchAll(a)){if(o=!0,!u.groups)throw new k("No groups found in match");const{fileName:a}=u.groups,[c,d]=u,l="Start"===d;S(l,t);let f="";if(t){const t=u.index+c.length;f=e.slice(r,t);const o=n+Buffer.byteLength(f,"utf8");yield{edit:!0,code:f,fileName:a,lineOffset:i,columnOffset:s,indexOffset:n,indexOffsetEnd:o},r=t,n=o}else{const t=u.index;f=e.slice(r,t),n+=Buffer.byteLength(f,"utf8"),r=t,yield{edit:!1,code:f}}t=!!l,({lineOffset:i,columnOffset:s}=C(f,c,i,s))}if(t)throw new k("End mark found outside mark");o?r<e.length&&(yield{edit:!1,code:e.slice(r)}):yield{edit:!1,code:e}}function E(e,t,r){f.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 I(e,t,r){const n=w(e.code,{filename:t,format:r},[],!1,!0,!1),o=n.code;return n.mapRelativeToChunk=n.map,n.map=function(e,t,r){"string"==typeof e&&(e=JSON.parse(e));const n=(0,m.decode)(e.mappings);return n.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,m.encode)(n),sourcesContent:void 0})}(n.map,e.lineOffset,e.columnOffset),{codeToAppend:o,metadata:{...n,filename:t,lineOffset:e.lineOffset,columnOffset:e.columnOffset}}}function M(e,t,r,n=!1,o=!1,i=()=>!0){const s=e.slice(-1e3);if(!o&&null!==y.getSourceMap(t,s))return f.instrument_logger.critical("Source map found for esbuild split",{filename:t}),f.customer_logger.log(l.UserErrorLogs.EsbuildSourceMapFound()),(0,p.detachHud)(!1,!1),{transformedCode:e,metadatas:[],editedChunksSizes:void 0};let a="",u=0,c=0;const g=[];let h=0;const m=n?[]:void 0,_=v(d.hudConfig.wrapVarPrefix,r).initialStatements.join("\n"),b=function(e){return e.slice(d.hudConfig.esbuildMark.length,d.hudConfig.esbuildMark.length+36)}(e);for(const n of x(e)){h++;try{let e="",o=!1;if(n.edit&&(o=i(n.fileName),m&&E(n,o,m)),n.edit&&o){const o=I(n,t,r);e=o.codeToAppend,g.push({...o.metadata,bundlerBuildId:b,transformedLineOffset:u,transformedColumnOffset:c,indexOffset:n.indexOffset,indexOffsetEnd:n.indexOffsetEnd})}else e=0===a.length?P(n.code,_):n.code;({transformedCodeLineOffset:u,transformedCodeColumnOffset:c}=O(e,u,c)),a+=e}catch(r){return f.instrument_logger.error("Failed to patch index",{index:h,filename:t,msg:r instanceof Error?r.message:void 0,stack:r instanceof Error?r.stack:void 0}),{transformedCode:e,metadatas:[],editedChunksSizes:m}}}return{transformedCode:a,metadatas:g,editedChunksSizes:m}}function P(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 O(e,t,r){const n=e.split("\n");return n.length>1?(t+=n.length-1,r=n.pop()?.length||0):r+=e.length,{transformedCodeLineOffset:t,transformedCodeColumnOffset:r}}function T(e,t,r,n,o){if(e.startsWith(d.hudConfig.esbuildMark))return f.instrument_logger.info("Editing in splits"),M(e,t,r,!1);{const i=w(e,{filename:t,format:r},n,d.hudConfig.userConfig.disableSourceMapsResolution?.value??!0,!1,o);return{transformedCode:i.code,metadatas:[i]}}}let F=0;function N(e,t){F+=e;const r=d.hudConfig.userConfig?.maxMappedFunctions?.value??0;F>=r&&(t||f.customer_logger.log(l.UserErrorLogs.InstrumentedFunctionCountExceeded(r)),f.app_logger.error("Instrumented function count exceeded",{instrumentedFunctionsCount:F,maxMappedFunctions:r}),(0,p.detachHud)(!1,!1))}},3903:e=>{"use strict";e.exports=require("uuid")},4290:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(8949),i=r(5128),s=r(714);class a extends s.FrameworkPatcher{_patch(e){return this._patchCreate(e),n.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];"function"==typeof t.constructor&&"function"==typeof r?e[1]=(0,i.wrapLinkedFunction)(r):n.instrument_logger.error("Invalid args in NestJS RpcContextCreator.create",{args:e})}catch(e){n.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,o.copyPropertiesToTarget)(t,e.RpcContextCreator.prototype.create)}}t.default=a},4393:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HttpEndpointMetric=t.ApiProtocol=void 0;const n=r(9873);var o;!function(e){e.REST="rest",e.GraphQL="graphql"}(o||(t.ApiProtocol=o={}));class i extends n.FlowMetric{statusCode;apiProtocol;apiProtocolAttributes;constructor(e){super(e)}_createUsableMetric(e){return this}setRequestAttributes(e){const t=e.url||e.path;this.apiProtocol=o.REST,this.apiProtocolAttributes={route:t?.split("?")[0],method:e.method}}setGraphQLAttributes(e,t){this.apiProtocol=o.GraphQL,this.apiProtocolAttributes={errorOccurred:e,errors:t}}setResponseAttributes(e){this.statusCode=e.statusCode}toRaw(){if(!this.statusCode)return;if(this.apiProtocol===o.GraphQL){const e=this.apiProtocolAttributes;return{flow_id:this.flowId,type:"GraphQLMetric",duration:this.duration,status_code:this.statusCode,error_occurred:e.errorOccurred,error_breakdown:this.errorBreakdown}}if(this.apiProtocol!==o.REST)return;const e=this.apiProtocolAttributes;return e.route&&e.method?{flow_id:this.flowId,type:"EndpointMetric",duration:this.duration,status_code:this.statusCode,route:e.route,method:e.method,error_breakdown:this.errorBreakdown}:void 0}}t.HttpEndpointMetric=i},4815:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=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||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.patchUse=function(e,t,r=!0){const n=e.use;e.use=function(e){const o=n.apply(this,arguments);try{let n=this[f.uuidSymbol];!n&&f.isVerboseLoggingEnabled&&(n=d.randomUUID(),this[f.uuidSymbol]=n,c.instrument_logger.info("Express use setting uuid",{kind:t,uuid:n})),"application"===t?function(e,t,r,n){try{r&&(e._router?p(e._router):e.router?p(e.router):c.instrument_logger.warning("Express application doesn't have router or _router")),n&&f.isVerboseLoggingEnabled&&c.instrument_logger.info("Express use app",{parent:n,child:t[1]?.[f.uuidSymbol]||"no uuid",path:t[0]})}catch(e){c.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,n):"router"===t&&function(e,t,r,n,o){try{if(!e.stack)return void c.instrument_logger.error("Express router without stack");if(0===e.stack.length)return void c.instrument_logger.warning("Express router with an empty stack");"query"===e.stack[0].name?p(e):f.isVerboseLoggingEnabled&&!f.skipLayerNamesLogs.has(e.stack[0].name)&&(f.skipLayerNamesLogs.add(e.stack[0].name),c.instrument_logger.warning("Found unknown stack name",{stack:e.stack[0].name}));const{path:i,offset:s}=function(e){let t=0,r="/";if("function"!=typeof e){let n=e;for(;Array.isArray(n)&&0!==n.length;)n=n[0];"function"!=typeof n&&(t=1,r=e)}return{path:r,offset:t}}(o),u=g(Array.prototype.slice.call(t,s));for(let t=0;t<u.length&&t<e.stack.length;t++){const o=e.stack[e.stack.length-t-1],s=u[u.length-t-1];"router"===o.name?(s&&!s[f.uuidSymbol]&&f.isVerboseLoggingEnabled&&(s[f.uuidSymbol]=d.randomUUID(),c.instrument_logger.info("Express handle router setting uuid",{uuid:s[f.uuidSymbol]})),r&&(o[a.hudConfig.express.routeNamesSymbol]=i)):f.isVerboseLoggingEnabled&&!f.skipLayerNamesLogs.has(o.name)&&(f.skipLayerNamesLogs.add(o.name),c.instrument_logger.warning("Found unknown layer name",{layer:o.name,parent:n,child:s[f.uuidSymbol]||"no uuid",path:i}))}}catch(e){c.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,n,e)}catch(e){c.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 o},(0,l.copyPropertiesToTarget)(n,e.use)},t.extractEndpointsFromRouter=function e(t,r){let n=[];if(!r.stack)return c.instrument_logger.error("Router without stack - bad OTEL version",{router:r}),n;for(const o of r.stack)if("router"===o.name){if(!o[a.hudConfig.express.routeNamesSymbol]){c.instrument_logger.error("Router layer without routes",{layer:o});continue}const r=t+o[a.hudConfig.express.routeNamesSymbol];n=n.concat(e(r,o.handle))}else o.route&&o.route[a.hudConfig.express.layerStateSymbol]?n=n.concat(h(o,t)):f.isVerboseLoggingEnabled&&!f.skipLayerNamesLogs.has(o.name)&&(f.skipLayerNamesLogs.add(o.name),c.instrument_logger.warning("Found unknown layer name when extracting endpoints",{layer:o.name}));return n};const a=r(5809),u=r(8528),c=r(523),d=s(r(6982)),l=r(8949),f=r(7225),g=r(5673);function p(e){e[a.hudConfig.express.markedSymbol]||(globalThis.hudExpressState.push(e),e[a.hudConfig.express.markedSymbol]=!0)}function h(e,t){const r=[];for(const[n,o]of Object.entries(e.route[a.hudConfig.express.layerStateSymbol]))r.push(new u.EndpointDeclaration(n,o.methods,"express",t,o.layerPath));return Array.from(r.values())}},5128:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHudLfMarked=void 0,t.wrapLinkedFunction=function(e){if(e[t.isHudLfMarked])return e;let r;e[t.isHudLfMarked]=!0;const a=(0,i.getFlowStateStorage)();return a?(r=e instanceof s.AsyncFunction?async function(...t){if(hudRunningMode!==n.HudRunningMode.enabled)return await e.apply(this,t);let r;try{r=a.getStore()}catch(r){return o.instrument_logger.error("Failed to get flowState",{msg:r instanceof Error?r.message:void 0,stack:r instanceof Error?r.stack:void 0}),await e.apply(this,t)}return r?(r.shouldLinkFunction=!0,await e.apply(this,t)):await e.apply(this,t)}:function(...t){if(hudRunningMode!==n.HudRunningMode.enabled)return e.apply(this,t);let r;try{r=a.getStore()}catch(r){return o.instrument_logger.error("Failed to get flowState",{msg:r instanceof Error?r.message:void 0,stack:r instanceof Error?r.stack:void 0}),e.apply(this,t)}return r?(r.shouldLinkFunction=!0,e.apply(this,t)):e.apply(this,t)},(0,s.copyPropertiesToTarget)(e,r),r):e};const n=r(8528),o=r(523),i=r(7131),s=r(8949);t.isHudLfMarked=Symbol.for("isHudLfMarked")},5150:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(5809),o=r(8269),i=r(2546),s=r(523),a=r(7131),u=r(2822),c=r(8949),d=r(2080),l=r(714);class f extends l.FrameworkPatcher{isSupported(e,t,r,o){const a=n.hudConfig.userConfig.enableDapulse?.value?o.mondayVersion:o.bbcVersion,u=(0,l.extractModuleVersion)(e);return!!(0,l.isSupportedVersion)(u,a)||(s.instrument_logger.warning("Unsupported sqs-consumer version",{framework:"SqsConsumer",version:u,supportedVersion:a,basedir:e,isDapulse:n.hudConfig.userConfig.enableDapulse?.value}),s.customer_logger.log(i.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 i.HudNoQueueUrlInSqsConsumer;const r=h(t);if(e.handleMessageBatch&&"function"==typeof e.handleMessageBatch){const t="handleMessageBatch",n=(0,i.generateSqsFlowId)(r,t);(0,o.storeSqsQueueDeclaration)({flow_id:n,queue_name:r,handle_type:t,batch_size:e.batchSize});const s=e.handleMessageBatch,a=(0,c.wrapFlow)(()=>n,s,!0,m);return void(e.handleMessageBatch=a)}if(e.handleMessage&&"function"==typeof e.handleMessage){const t="handleMessage",n=(0,i.generateSqsFlowId)(r,t);(0,o.storeSqsQueueDeclaration)({flow_id:n,queue_name:r,handle_type:t});const s=e.handleMessage,a=(0,c.wrapFlow)(()=>n,s,!0,m);return void(e.handleMessage=a)}s.instrument_logger.warning("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 i.HudNoEventTypeInSqsConsumerOn;const n=r[1];if(!n||"function"!=typeof n)throw new i.HudNoCallbackInSqsConsumerOn;const s=h(e.queueUrl),a="event",u=(0,i.generateSqsFlowId)(s,a,t);(0,o.storeSqsQueueDeclaration)({flow_id:u,queue_name:s,handle_type:a,event_type:t}),r[1]=(0,c.wrapFlow)(()=>u,n,!0,y,_,b)}catch(e){s.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)},(0,c.copyPropertiesToTarget)(t,e.on)}(r),function(e){const t=e.emit;e.emit=function(...e){return function(e){try{const t=e[0];if(!t||"string"!=typeof t)throw new i.HudNoEventTypeInSqsConsumerEmit;let r,o;if("message_processed"===t&&(r=1),["error","timeout_error","processing_error"].includes(t)&&(o=1,r=2),void 0===r)return;const c=e[r];if(!c)throw new i.HudNoMessageInSqsConsumerEmit;let d;if(void 0!==o){const t=e[o];if(!(t&&t instanceof Error))throw new i.HudNoErrorInSqsConsumerEmit;d=(0,a.extractName)(t),"StandardError"===d&&t.cause&&t.cause instanceof Error&&(d=(0,a.extractName)(t.cause))}const l=(e,t)=>{const r=e[n.hudConfig.metricSymbol];r?(d&&r.addError(d,t),r.increaseAndShouldEnd(t)&&(r.calculateDuration(),(0,u.finishSqsInvestigation)(Array.isArray(c)?c:[c],r),r.end())):p||(p=!0,s.instrument_logger.warning("No metric found for message"))};Array.isArray(c)&&c.length>=1?l(c[0],c.length):l(c,1)}catch(e){g||(g=!0,s.instrument_logger.error("Error in SqsConsumer.Consumer.emit patched logic",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0}))}}(e),t.apply(this,e)},(0,c.copyPropertiesToTarget)(t,e.emit)}(r)}catch(e){s.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,c.copyPropertiesToTarget)(t,e.Consumer.create)}(e),s.instrument_logger.info("Patched sqs-consumer successfully",{isDapulse:n.hudConfig.userConfig.enableDapulse?.value}),e}}t.default=f;let g=!1,p=!1;function h(e){const t=e.split("/").pop();if(!t)throw new i.HudFailExtractSqsQueueName(`Url: ${e}`);return t}function m(e,t,r){const o=d.SqsMetric.createUsableMetric(e);o.start();const i=r[0];if(!i)return s.instrument_logger.warning("No messages pass to sqs handler",{flowId:e}),void(t.flowMetric=o);if(Array.isArray(i)){if(o.msgCount=i.length,i.forEach(e=>{e[n.hudConfig.metricSymbol]=o}),i[0]?.Attributes?.SentTimestamp){const t=i.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:s.instrument_logger.warning("No valid SentTimestamp found eventhough the first element had SentTimestamp",{flowId:e})}}else o.msgCount=1,i[n.hudConfig.metricSymbol]=o,i?.Attributes?.SentTimestamp&&(o.e2eEpocStartTimeMS=i.Attributes.SentTimestamp);t.flowMetric=o,(0,u.createNewInvestigation)()}function y(e,t,r){const n=d.SqsMetric.createUsableMetric(e);n.start(),t.flowMetric=n}function _(e,t){const r=t.flowMetric;r?r.end():s.instrument_logger.warning("No flowMetric found for message during catch",{flowId:e})}function b(e,t,r){const n=t.flowMetric;n?(n.addError((0,a.extractName)(r)),n.end()):s.instrument_logger.warning("No flowMetric found for message during catch",{flowId:e})}},5354:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(714),i=r(5809),s=r(8528),a=r(8269),u=r(9938);class c extends o.FrameworkPatcher{_patch(e){return n.instrument_logger.info("Patching axios"),this._patchRequest(e),this._createAxiosDeclaration(),n.instrument_logger.info("Patched axios successfully"),e}_patchRequest(e){const t=e.Axios.prototype.request;e.Axios.prototype.request=(0,u.wrapOutboundFunction)(t,i.hudConfig.axiosFunctionId,e=>{const t=e[0];return{url:"string"==typeof t.url?t.url:void 0,method:t.method,body:t.data}},(e,t,r)=>{(0,u.reduceRequestArgsIfNeeded)(e,r,e=>Number.parseInt(e?.request?._contentLength));const n=Number.parseInt(e.headers.get("content-length")),o=isNaN(n)||0===n?void 0:n;return{status_code:e.status,body:(0,u.getReducedBody)(e.data,o,i.hudConfig.dynamicConfig.maxHTTPResponseBodySize),bodySize:o}},s.OutboundType.HTTP)}_createAxiosDeclaration(){(0,a.storeLoadedOutbound)("axios")}}t.default=c},5459:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(7131),i=r(2822),s=r(8949),a=r(4393),u=r(714);class c extends u.FrameworkPatcher{_patch(e){return this._patchEmit(e),n.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]);const s=(0,o.getFlowStateStorage)(),u=r?.[0],c=r?.[1],d=a.HttpEndpointMetric.createUsableMetric(),l=()=>{try{d.start(),(0,i.createNewInvestigation)(),d.setRequestAttributes(u),c.once("finish",function(){try{d.calculateDuration(),(0,i.finishHttpInvestigation)(u,c,d),d.setResponseAttributes(c),d.end()}catch(e){n.instrument_logger.error("Failed to set response attributes",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}})}catch(e){n.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])};return s?s.run({httpMetric:d},l):l()},(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.hudRITM=void 0,t.safeLog=function(e){try{s.app_logger.debug(e)}catch{return}},t.registerHook=function(){if(s.app_logger.info("HUD is required"),process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE){if(s.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 s.app_logger.warning("Lambda function memory size is less than required, Hud will not run",{memorySize:e,requiredMemory:n.hudConfig.lambdaMinimunMemory}),s.customer_logger.log(i.UserErrorLogs.UnsupportedLambdaMemory(n.hudConfig.lambdaMinimunMemory)),!1}globalThis.hudRuningInsideLambda=!0}return(0,o.initGlobals)(),s.app_logger.debug("InitGlobals done"),!(globalThis.hudStartFromAutoInit&&!(0,o.validateAndGetUserInput)())&&(s.instrument_logger.isValid()?globalThis.hudRanOnRequire?(s.instrument_logger.warning("Already ran onRequire!"),!1):(globalThis.hudRanOnRequire=!0,s.instrument_logger.info("Using module",{name:n.SDK_MODULE_NAME}),n.hudConfig.userConfig.enableFrameworks&&s.instrument_logger.info("User enabled frameworks",{frameworks:(0,a.getEnabledFrameworks)()}),(0,a.onRequire)(),(0,i.detectNextJsApp)(),s.instrument_logger.debug("onRequire done"),globalThis.hudInitGuard=setTimeout(u,n.hudConfig.userConfig.maxTimeUntilInitSessionMs?.value??0),globalThis.hudInitGuard.unref(),!0):((0,o.detachHud)(!1),!1))};const n=r(5809),o=r(8269),i=r(2546),s=r(523),a=r(7166);function u(){s.instrument_logger.critical("Init timeout reached - disabling hud"),s.customer_logger.log(i.UserErrorLogs.InitTimeout(globalThis.hudIsRunningFromSetup)),(0,o.detachHud)(!1)}t.hudRITM=a.onRequireFn},5809:e=>{"use strict";e.exports=require("./config")},5946:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(6730),i=r(4815),s=r(714);class a extends s.FrameworkPatcher{_patch(e){return(0,i.patchUse)(e.prototype,"router"),(0,o.patchMethods)(e.prototype,"router"),n.instrument_logger.info("Patched router successfully"),e}}t.default=a},6093:e=>{"use strict";e.exports=require("@cspotcode/source-map-support")},6730:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=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||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.getMethods=f,t.patchMethods=function(e,t){f().concat("all").forEach(function(r){const n=e[r];if(!n)return void(l.isVerboseLoggingEnabled&&u.instrument_logger.warning("Method not found",{method:r}));const o="all"===r;e[r]=function(){try{if(arguments.length<2)return n.apply(this,arguments);let e=this[l.uuidSymbol];l.isVerboseLoggingEnabled&&(e||(e=c.randomUUID(),this[l.uuidSymbol]=e,u.instrument_logger.info("Express method setting uuid",{uuid:e,kind:t})),u.instrument_logger.info("Express added new method",{method:r,uuid:e,path:arguments[0]}));const i=Array.prototype.slice.call(arguments);if(i[1][a.hudConfig.express.layerStateSymbol]={flowId:[],kind:t,allMethod:o},Array.isArray(i[0]))for(const e of i[0]){const e=c.randomUUID();i[1][a.hudConfig.express.layerStateSymbol].flowId.push(e)}else i[1][a.hudConfig.express.layerStateSymbol].flowId.push(c.randomUUID());const s=n.apply(this,i);try{delete i[1][a.hudConfig.express.layerStateSymbol]}catch{}return s}catch(e){u.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 n.apply(this,arguments)},(0,d.copyPropertiesToTarget)(n,e[r])})};const a=r(5809),u=r(523),c=s(r(6982)),d=r(8949),l=r(7225);function f(){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"]}},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 n=r(523),o=r(6730),i=r(2977),s=r(4815),a=r(7225),u=r(714);class c extends u.FrameworkPatcher{_patch(e){return(0,i.patchRoute)(e.Route),(0,s.patchUse)(e.application,"application"),(0,o.patchMethods)(e.application,"application"),a.isVerboseLoggingEnabled&&(0,a.logLazyRouter)(e.application),e.Router.use?((0,s.patchUse)(e.Router,"router"),(0,o.patchMethods)(e.Router,"router")):n.instrument_logger.warning("Skipping express.Router patching"),n.instrument_logger.info("Patched express successfully"),e}}t.default=c},7131:e=>{"use strict";e.exports=require("./wrap")},7166:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=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||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.parseCliInstrumentationPattern=k,t.supportSourceMapInstall=S,t.patch=C,t.patchCompile=M,t.onRequireFn=P,t.patchRequire=O,t.isFrameworkEnabled=T,t.getEnabledFrameworks=function(){const e=new Map;for(const[t,r]of g.hudConfig.frameworksToPatch)e.set(r.framework,T(r,g.hudConfig.userConfig.enableFrameworks));return Object.fromEntries(e)},t.getFunctionsToInstrument=R,t.createCheckers=D,t.updateModuleChecker=L,t.skip=q,t.onRequire=function(){try{(0,d.setInstrumentedFilesCountInterval)(),L();try{M()}catch(e){l.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,d.shouldSupportSourceMap)()&&S()}catch(e){l.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{O()}catch(e){l.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){l.instrument_logger.error("Something went wrong in onRequire",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}try{(0,h.saveMachineMetric)()}catch(e){l.instrument_logger.error("Failed to add metric",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}};const a=s(r(9896)),u=s(r(6928)),c=r(8528),d=r(2546),l=r(523),f=r(3901),g=r(5809),p=r(8528),h=r(8269),m=r(2546),y=r(9063),_=r(714),b=function(){const e=g.SDK_MODULE_NAME;try{return u.dirname(u.dirname(m.myRequire.resolve(e)))}catch(t){return l.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 v(e){const t=globalThis.HudSourceMapCache.get(e);return t?{map:JSON.parse(t)}:null}const w=new RegExp(`//"([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})";${g.hudConfig.cliSdkVersionVarName}="([^"]+)";${g.hudConfig.cliBuildIdVarName}`);function k(e){if(e.slice(-g.hudConfig.cliBuildIdVarName.length)!==g.hudConfig.cliBuildIdVarName)return null;const t=Math.min(100,e.length),r=e.slice(-t).match(w);return r?{buildId:r[1],sdkVersion:r[2],fullPattern:r[0]}:null}function S(){r(6093).install({handleUncaughtExceptions:!1,hookRequire:!1,environment:"node",retrieveSourceMap:v})}function C(e,t,r,n){const o={code:e,map:void 0};try{if(globalThis.hudRunningMode===p.HudRunningMode.detached)return o;if(r===c.Format.esm&&!n)throw new m.HudError("MessagePort is required for patching ESM modules");const i=k(e);if(i)return i.sdkVersion!==g.SDK_VERSION?(l.instrument_logger.critical("SDK version mismatch detected, disabling SDK",{filename:t,cliSdkVersion:i.sdkVersion,currentSdkVersion:g.SDK_VERSION}),(0,h.detachHud)(!1,!1),o):((0,h.addReingestValue)(i.buildId),globalThis.hudInstrumentationIndicator&&(0,h.clearInstrumentationIndicator)(),o);if(g.hudConfig.userConfig.disableRuntimeInstrumentation?.value)return o;const s=R(t);if(q(t,void 0,s))return o;if(e.length>(g.hudConfig.userConfig.maxFileSizeBytes?.value??0)&&!e.startsWith(g.hudConfig.esbuildMark))return l.instrument_logger.info("Skipping large file",{filename:t,size:e.length}),o;const y=(0,f.edit)(e,t,r,s,!1),_=y.metadatas;if(o.code=y.transformedCode,o.map=_,n)for(const e of _)n.postMessage({key:"HudModulePatch",hudPatched:t,hudProcessedFiles:(0,d.sourceFileMetadataToTransferSourceFileMetadata)(e)});else globalThis.hudPatched.add(t),globalThis.hudProcessedFiles.push(..._.map(e=>(0,d.sourceFileMetadataToTransferSourceFileMetadata)(e)));for(const e of _)e.functionIds.length>0&&(globalThis.hudInstrumentationOccured=!0,globalThis.hudInstrumentationIndicator&&(0,h.clearInstrumentationIndicator)());g.hudConfig.writePatched&&function(e,t){const r=u.parse(e);let n=`${r.dir}/patched.${r.base}`;r.dir.includes("dist")&&(n=u.join(`${r.dir.replace("dist","patched")}`,r.base)),a.existsSync(u.dirname(n))||a.mkdirSync(u.dirname(n),{recursive:!0}),a.writeFileSync(n,t,"utf8"),l.instrument_logger.debug("Dumped patched file",{filename:e,patchedPath:n})}(t,y.transformedCode)}catch(e){l.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 o}let x="",E=!0,I=!1;function M(){if(!(0,m.isSupportedNative)())return;const e=r(3339),t=(0,d.shouldSupportSourceMap)();I&&l.instrument_logger.warning("PatchCompile ran twice"),0===Object.keys(globalThis.hudLoadedModules).length&&(globalThis.hudLoadedModules=Object.keys(m.myRequire.cache));const n=e.prototype._compile;e.prototype._compile=function(e,r){const o=process.hrtime.bigint();let i=0,s=0,a=0,u=!1;try{if(r===x){try{const e=E?l.instrument_logger.warning.bind(l.instrument_logger):l.instrument_logger.debug.bind(l.instrument_logger);E=!1,e("Skipping compile since already ran",{filename:r})}catch{}const t=process.hrtime.bigint(),o=n.call(this,e,r);return i=Number(process.hrtime.bigint()-t),o}x=r,l.instrument_logger.debug("Compiling requirement",{filename:r});const o=C(e,r,c.Format.cjs);o.map&&(u=!0),s=o.map?.reduce((e,t)=>e+t.functionIds.length,0)??0,a=o.map?.reduce((e,t)=>e+t.totalFunctionsCountIncludeUninstrumented,0)??0;try{if(t&&o.map){const e=(0,d.combineSourceMaps)(o.map,r);e&&globalThis.HudSourceMapCache.set(r,e)}}catch(e){l.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 f=process.hrtime.bigint(),g=n.call(this,o.code,r);return i=Number(process.hrtime.bigint()-f),x="",g}finally{const t=Number(process.hrtime.bigint()-o)-i;u&&l.instrument_logger.debug("Patched",{filename:r,time:t}),(0,d.incrementInstrumentedStats)(u,t,i,e.length,s,a)}},I=!0,l.instrument_logger.debug("Patched _compile")}function P(e,t,r){try{const n=g.hudConfig.frameworksToPatch.get(t);return T(n,g.hudConfig.userConfig.enableFrameworks)&&n?.patcher&&n.version?(0,_.getFrameworkPatcher)(n.patcher).patch(e,r,n.version,n.extraInfo,t):e}catch(e){l.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 O(){const e=Array.from(g.hudConfig.frameworksToPatch.entries()).filter(([e,t])=>T(t,g.hudConfig.userConfig.enableFrameworks)).map(([e])=>e);new y.Hook(Array.from(e),{internals:!0},P)}function T(e,t){return!!e&&(t&&t.value?.has(e.framework)?t.value.get(e.framework)||!1:e.enable)}function F(e){const t=u.sep.replace(/\\/g,"\\\\"),r=u.join(e).split(".").join("\\.").split("*").join(".*?"),n=t+"node_modules"+t;return{isAllowdModule:new RegExp(n+r+`(?:${t}|$)`),isAllowdModuleSubModule:new RegExp(n+r+n)}}function N(e,t){return!!t.isAllowdModule.test(e)&&!t.isAllowdModuleSubModule.test(e)}function j(e,t){const r=t.replace(/\//g,u.sep);return e.includes(`node_modules${u.sep}${r}${u.sep}`)&&!e.includes(`node_modules${u.sep}${r}${u.sep}node_modules`)}function R(e){return(0,m.getInstrumentedThirdPartyModuleInfo)(e)?.functions||[]}function D(e){const t=[];for(const r of e){let e;if(r.includes("*")){const t=F(r);e=e=>N(e,t)}else e=e=>j(e,r);t.push(e)}return t}let A=[];function L(){A=D(g.hudConfig.userConfig.includeModules?.value??[])}function q(e,t,r=[]){if(!g.hudConfig.allowedEditExtensions.includes(u.extname(e))&&!e.endsWith(u.sep))return l.instrument_logger.warning("Skipping non-allowed extension",{filename:e}),!0;const n=t??A;return"/var/runtime/index.mjs"===e?(l.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,n)&&0===r.length||e.includes(".yarn")?(l.instrument_logger.debug("Skipping non-monitored imported module",{filename:e}),!0):!(b&&!e.includes(b)||(l.instrument_logger.debug("Skipping hud internal module",{filename:e}),0))}},7214:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(5809),o=r(8269),i=r(2546),s=r(523),a=r(7131),u=r(8949),c=r(714);class d extends c.FrameworkPatcher{static graphQLPatchedSymbol=Symbol.for(n.hudConfig.hudPatchedName);_patch(e){return this.patchExecute(e),s.instrument_logger.info("Patched GraphQL successfully"),e}patchExecute(e){const t=e.execute,r=(0,u.wrapFlow)(function(e,t){let r;if(e.operation)return e.operation.flow_id;try{if(t.length<1)return;const n=t[0];if(n.document.definitions.length>1){if(n.operationName)for(const t of n.document.definitions)if(r=l(e,t,n.operationName),r)break}else r=l(e,n.document.definitions[0])}catch(e){s.instrument_logger.error("Failed to store graphql operations",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return r?.flow_id},t,!1,void 0,function(e,t,r){return function(e,t){return"function"==typeof e.then?e.then(e=>(f(e,t),e)):(f(e,t),e)}(r,t.operation)});e.execute=r}}function l(e,t,r){const n=function(e){return e&&e.name?e.name.value:"anonymous"}(t),s=function(e){return e&&e.operation?e.operation:"query"}(t);if(!r||r===n){const t={flow_id:(0,i.generateGraphqlFlowId)(n,s),operation_name:n,operation_type:s};return(0,o.storeGraphQLOperation)(t),e.operation=t,t}}function f(e,t){try{if(!t)return;const r=(0,a.getHttpMetricFromFlowState)();if(!r)return void s.instrument_logger.warning("No http metric found for graphql operation",{operation_name:t.operation_name,operation_type:t.operation_type});r.setFlowId(t.flow_id),r.setGraphQLAttributes(!!e.errors&&e.errors.length>0,e.errors)}catch(e){s.instrument_logger.error("Failed to set flowId and graphql attributes in http metric",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}t.default=d},7225:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=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||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.skipStackNamesLogs=t.skipLayerNamesLogs=t.isVerboseLoggingEnabled=t.uuidSymbol=void 0,t.logLazyRouter=function(e){const r=e.lazyrouter;e.lazyrouter=function(){let e=!1;try{this._router||(e=!0)}catch(e){a.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 n=r.apply(this,arguments);try{if(e){let e=this[t.uuidSymbol];e||(e=u.randomUUID(),this[t.uuidSymbol]=e,a.instrument_logger.info("Express lazy router setting uuid",{uuid:e})),a.instrument_logger.info("Express lazy router",{parent:e,child:this._router?.[t.uuidSymbol]})}}catch(e){a.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 n},(0,d.copyPropertiesToTarget)(r,e.lazyrouter)};const a=r(523),u=s(r(6982)),c=r(932),d=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"])},7276:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8544);class o extends n.BaseKafkaJSPatcher{getExportsRoot(e){return e.KafkaJS}getGroupId(e){return e[0].kafkaJS.groupId}moduleName(){return"@confluentinc/kafka-javascript.KafkaJS"}}t.default=o},7427:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(714),i=r(5809),s=r(8528),a=r(8269),u=r(9938);class c extends o.FrameworkPatcher{_patch(e){return n.instrument_logger.info("Patching pg"),this._patchConnect(e),this._patchQuery(e),this._patchEnd(e),this._createPgDeclaration(),n.instrument_logger.info("Patched pg successfully"),e}_patchConnect(e){const t=e.Client.prototype.connect;e.Client.prototype.connect=(0,u.wrapOutboundFunction)(t,i.hudConfig.pgConnectFunctionId,void 0,void 0,s.OutboundType.DB)}_patchEnd(e){const t=e.Client.prototype.end;e.Client.prototype.end=(0,u.wrapOutboundFunction)(t,i.hudConfig.pgEndFunctionId,void 0,void 0,s.OutboundType.DB)}_patchQuery(e){const t=e.Client.prototype.query;e.Client.prototype.query=(0,u.wrapOutboundFunction)(t,i.hudConfig.pgQueryFunctionId,e=>({query:e[0],params:e[1]}),e=>({rowsCount:e.rowCount}),s.OutboundType.DB)}_createPgDeclaration(){(0,a.storeLoadedOutbound)("pg")}}t.default=c},7603:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getObservabilityIdentifiers=s,t.getObservabilityIdentifiersHttp=function(e){return{...s(),w3c_trace_context:a(e),w3c_baggage:c(e,"baggage"),amazon_trace_id:c(e,"x-amzn-trace-id"),b3_propagation:u(e),jaeger_trace_id:c(e,"uber-trace-id")}},t.getExtraHeaders=function(e){const t={};for(const r of n.hudConfig.dynamicConfig.extraHeaders){const n=c(e,r);void 0!==n&&(t[r]=n)}return t},t.getDatadogIds=f,t.getOtelTraceId=p;const n=r(5809),o=r(2546),i=r(523);function s(){const e=f();return{datadog_trace_id:e?.trace_id,datadog_span_id:e?.span_id,otel_trace_id:p()}}function a(e){try{return{traceparent:c(e,"traceparent"),tracestate:c(e,"tracestate")}}catch{return}}function u(e){try{return{full:c(e,"b3"),trace_id:c(e,"x-b3-traceid"),span_id:c(e,"x-b3-spanid"),parent_span_id:c(e,"x-b3-parentspanid")}}catch{return}}function c(e,t){try{return e.headers[t]}catch{return}}function d(e){let t;return()=>(void 0===t&&(t=function(e){try{const t=o.myRequire.resolve(e),r=o.myRequire.cache[t];return void 0===r?(i.instrument_logger.info("requireFromCache: codeModule is undefined",{path:e,fullPath:t}),null):"object"!=typeof r.exports?(i.instrument_logger.warning("requireFromCache: codeModule.exports is not an object",{path:e}),null):r.exports}catch(t){return i.instrument_logger.warning("requireFromCache: error",{path:e,error:t}),null}}(e)),t)}const l=d("dd-trace/packages/datadog-core");function f(){try{const e=l();if(null===e)return;const{storage:t}=e,r=t("legacy").getStore();return{trace_id:r.span._spanContext.toTraceId(),span_id:r.span._spanContext.toSpanId()}}catch{return}}const g=d("@opentelemetry/api");function p(){try{const e=g();if(null===e)return;const{trace:t}=e;return t.getActiveSpan()?.spanContext().traceId}catch{return}}},7808:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getMachineMetrics=function(){try{const e=(0,o.getLastMetrics)();return{cpu_usage:e.cpuUsage?l(e.cpuUsage,e.timestamp):void 0,memory_usage:d(),event_loop_utilization:e.elu?c(e.elu):void 0}}catch(e){return void s.app_logger.error("Error getting machine metrics",e)}},t.getCpuUsage=l;const o=r(8269),i=r(2546),s=r(523),a=n(r(857)),u=r(2987);function c(e){try{return u.performance.eventLoopUtilization(e).utilization}catch(e){return void s.app_logger.error("Error getting event loop utilization",e)}}function d(){try{const e=process.memoryUsage(),t=a.default.totalmem();return{rss:e.rss,heap_total:e.heapTotal,heap_used:e.heapUsed,external:e.external,system_memory:t,rss_percentage:e.rss/t*100}}catch(e){return void s.app_logger.error("Error getting memory usage",e)}}function l(e,t){try{const r=process.cpuUsage(),n=1e3*(Date.now()-t),o=(0,i.getCpuLimit)(s.app_logger),a=(r.user-e.user)/n,u=(r.system-e.system)/n;return{user_time:a,system_time:u,limit:o,user_percent_of_limit:"number"==typeof o?a/o*100:void 0,system_percent_of_limit:"number"==typeof o?u/o*100:void 0}}catch(e){return void s.app_logger.error("Error getting cpu usage",e)}}},8064:e=>{"use strict";e.exports=require("semver")},8269:e=>{"use strict";e.exports=require("./globalstate")},8528:e=>{"use strict";e.exports=require("./dto")},8544:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BaseKafkaJSPatcher=void 0;const n=r(8269),o=r(2546),i=r(523),s=r(2822),a=r(8949),u=r(828),c=r(714);class d extends c.FrameworkPatcher{_patch(e){const t=this.getExportsRoot(e);return this._patchConsumer(t),i.instrument_logger.info(`Patched ${this.moduleName()} successfully`),e}_patchConsumer(e){const t=e.Kafka.prototype.consumer;if(!t)return void i.instrument_logger.error("DD presumably ran before HUD - exports.Kafka.prototype.consumer is undefined");const r=this.getGroupId.bind(this);e.Kafka.prototype.consumer=function(...e){const n=t.apply(this,e);try{const t=new Map,o=[],c=[];!function(e,t){const r=e.subscribe;e.subscribe=async function(...e){const n=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):i.instrument_logger.warning("No topic found in KafkaJS.Consumer.subscribe",{args:e[0]})}catch(e){i.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 n},(0,a.copyPropertiesToTarget)(r,e.subscribe)}(n,c),function(e,t,r,n,o){const c=e.run;function d(e,c){const d="eachBatch"===c;for(const e of o)p(e,n,t,r,c);const h=function(e,t,r){return(n,o)=>{const s=o[0],a=r?s.batch.topic:s.topic;return function(e,t,r,n){const o=e.get(g(r,n));if(o)return o;for(const e of t)if(e.isBatch===n&&e.pattern.test(r))return e.flowId;i.instrument_logger.warning("No flowId found for topic",{topicName:r,isBatch:n})}(e,t,a,r)}}(t,r,d),m=function(e){return(t,r,n)=>{const o=u.KafkaJSMetric.createUsableMetric();o.start(),o.setFlowId(t),(0,s.createNewInvestigation)();const i=n[0],a=e?i.batch.partition:i.partition,c=e?i.batch.messages[0]?.timestamp:i.message?.timestamp;o.addPartition(a),o.addProducedTimestamp(c),r.topic=e?i.batch.topic:i.topic,r.partition=e?i.batch.partition:i.partition,r.messages=e?i.batch.messages:[i.message],r.flowMetric=o}}(d),y=(0,a.wrapFlow)(h,e[c],!0,m,l,f);e[c]=y}e.run=async function(...e){try{const t=e[0];t.eachMessage&&d(t,"eachMessage"),t.eachBatch&&d(t,"eachBatch")}catch(e){i.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,a.copyPropertiesToTarget)(c,e.run)}(n,t,o,r(e),c)}catch(e){i.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 n},(0,a.copyPropertiesToTarget)(t,e.Kafka.prototype.consumer)}}function l(e,t){const r=t.flowMetric;r?(r.calculateDuration(),(0,s.finishKafkaJSInvestigation)(t.messages,r,t.topic,t.partition),r.end()):i.instrument_logger.warning("No flowMetric found for message",{flowId:e})}function f(e,t,r){const n=t.flowMetric;n?(n.setError(r),n.calculateDuration(),(0,s.finishKafkaJSInvestigation)(t.messages,n,t.topic,t.partition),n.end()):i.instrument_logger.warning("No flowMetric found for message",{flowId:e})}function g(e,t){return e+"|"+t}function p(e,t,r,i,s){const a=(0,o.generateKafkaFlowId)(e,t,s),u={flow_id:a,topic_name:e.toString(),group_id:t,pulling_type:s};(0,n.storeKafkaJSTopicDeclaration)(u),function(e,t,r,n,o){"string"==typeof r?e.set(g(r,n),o):t.push({pattern:r,isBatch:n,flowId:o})}(r,i,e,"eachBatch"===s,a)}t.BaseKafkaJSPatcher=d},8564:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(714),i=r(5809),s=r(8528),a=r(8269),u=r(9938),c=Symbol.for("_HUD_outboundIndex");class d extends o.FrameworkPatcher{_patch(e){return n.instrument_logger.info("Patching node-fetch"),e=this._patchFetch(e),this._patchBody(e),this._createNodeFetchDeclaration(),n.instrument_logger.info("Patched node-fetch successfully"),e}_patchFetch(e){return(0,u.wrapOutboundFunction)(e,i.hudConfig.nodeFetchFunctionId,e=>{const t=e[1]?.body,r=(0,u.getBodySize)(t);return{url:e[0],method:e[1]?.method?.toLowerCase()??"get",body:(0,u.getReducedBody)(t,r,i.hudConfig.dynamicConfig.maxHTTPRequestBodySize),bodySize:r}},(e,t)=>(e[c]=t,{status_code:e.status}),s.OutboundType.HTTP)}_patchBody(e){for(const[t,r]of Object.entries(i.hudConfig.nodeFetchBodiesFunctionIds)){const n=e.Response.prototype[t];e.Response.prototype[t]=(0,u.wrapOutboundBodyFunction)(n,r,(e,t)=>e[c],(e,t)=>{const r=Number.parseInt(e.headers.get("content-length")),n=isNaN(r)||0===r?void 0:r;return{body:(0,u.getReducedBody)(t,n,i.hudConfig.dynamicConfig.maxHTTPResponseBodySize),bodySize:n}})}}_createNodeFetchDeclaration(){(0,a.storeLoadedOutbound)("node-fetch")}}t.default=d},8611:e=>{"use strict";e.exports=require("http")},8840:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(523),i=r(8949),s=r(714),a=n(r(9589));class u extends s.FrameworkPatcher{static nextJSHudMarked=Symbol.for("hudNextJSMarked");_patch(e){const t=e.PagesAPIRouteModule||e.default;if(!t||t[u.nextJSHudMarked])return e;const r=this._wrapConstructor(t);t[u.nextJSHudMarked]=!0,o.instrument_logger.info("Patched Next.js route module constructor successfully");const n=Object.create(Object.getPrototypeOf(e));return Object.defineProperty(n,"PagesAPIRouteModule",{enumerable:!0,get:function(){return r}}),e.default===t&&Object.defineProperty(n,"default",{enumerable:!0,get:function(){return r}}),(0,i.copyPropertiesToTarget)(e,n),n}_wrapConstructor(e){const t=function(...t){const r=new e(...t);try{const e=r.definition?.pathname;e&&!r[u.nextJSHudMarked]&&(a.default._detectAndPatchSupportedMethods(r,e),r[u.nextJSHudMarked]=!0)}catch(e){o.instrument_logger.error("Failed to patch Next.js Pages API route module instance",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return r};return(0,i.copyPropertiesToTarget)(e,t),t}}t.default=u},8949:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncFunction=void 0,t.wrapFlow=function(e,r,u=!0,c,d,l){let f;const g=(0,i.getFlowStateStorage)();if(!g)return r;try{if(r[s])return r}catch{return r}return f=r instanceof t.AsyncFunction?async function(...t){let s;const a={};try{s=e(a,t)}catch(e){o.instrument_logger.error("Failed to get flowId",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}if(!s||hudRunningMode!==n.HudRunningMode.enabled)return await r.apply(this,t);if(c)try{c(s,a,t)}catch(e){o.instrument_logger.error("Failed to execute beforeCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}const f=(0,i.getHttpMetricFromFlowState)();f?.setFlowId(s);try{const e=g.run({flowId:s,shouldLinkFunction:u,httpMetric:f},Reflect.apply,r,this,t),n=await e;if(d)try{d(s,a,n)}catch(e){o.instrument_logger.error("Failed to execute afterCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return n}catch(e){if(l)try{l(s,a,e)}catch(e){o.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}}:function(...t){let s;const a={};try{s=e(a,t)}catch(e){o.instrument_logger.error("Failed to get flowId",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}if(!s||hudRunningMode!==n.HudRunningMode.enabled)return r.apply(this,t);if(c)try{c(s,a,t)}catch(e){o.instrument_logger.error("Failed to execute beforeCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}const f=(0,i.getHttpMetricFromFlowState)();f?.setFlowId(s);try{const e=g.run({flowId:s,shouldLinkFunction:u,httpMetric:f},Reflect.apply,r,this,t);if(d||l)if(e instanceof Promise)e.catch(e=>{try{l&&l(s,a,e)}catch(e){o.instrument_logger.error("Failed to execute catchCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}).then(()=>{try{d&&d(s,a,e)}catch(e){o.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{d&&d(s,a,e)}catch(e){o.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(l)try{l(s,a,e)}catch(e){o.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}},a(r,f),f[s]=!0,f},t.copyPropertiesToTarget=a;const n=r(8528),o=r(523),i=r(7131);t.AsyncFunction=(async()=>{}).constructor;const s=Symbol.for("hudMarked");function a(e,t){const r=Object.getOwnPropertyDescriptors(e),n=Reflect.ownKeys(r);Object.setPrototypeOf(t,e),n.forEach(e=>{try{Object.defineProperty(t,e,r[e])}catch{}})}},9063:e=>{"use strict";e.exports=require("require-in-the-middle")},9589:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8528),o=r(8269),i=r(2546),s=r(523),a=r(8949),u=r(714);class c extends u.FrameworkPatcher{static nextJSHudMarked=Symbol.for("hudNextJSMarked");static routeInfoSymbol=Symbol.for("hudNextJSRouteInfo");static standardMethods=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"];_patch(e){return(0,i.setIsNextJsApp)(!0),this._patchBaseServer(e),s.instrument_logger.info("Patched Next.js successfully"),e}_patchBaseServer(e){try{const t=e.default;if(t[c.nextJSHudMarked])return e;const r=t.prototype.renderToResponseWithComponentsImpl;if(!r)return s.instrument_logger.error("Could not find renderToResponseWithComponentsImpl on BaseServer.prototype"),e;t.prototype.renderToResponseWithComponentsImpl=async function(e,t,...n){try{const r=t.components;if(r&&r.routeModule&&!r.routeModule[c.nextJSHudMarked]){const t=r.routeModule,n=t.definition?.pathname||e.pathname;c._detectAndPatchSupportedMethods(t,n),t[c.nextJSHudMarked]=!0}}catch(e){s.instrument_logger.error("Failed to patch Next.js route module",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return await r.apply(this,[e,t,...n])},t[c.nextJSHudMarked]=!0,(0,a.copyPropertiesToTarget)(r,t.prototype.renderToResponseWithComponentsImpl)}catch(e){s.instrument_logger.error("Failed to patch Next.js base server",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return e}static _detectAndPatchSupportedMethods(e,t){try{switch(s.instrument_logger.debug("Patching Next.js route module",{pathname:t,kind:e.definition?.kind||"unknown"}),e.definition.kind){case"APP_ROUTE":case"PAGES_API":c._patchApiModule(e,t);break;case"PAGES":case"APP_PAGE":c._patchPageModule(e,t);break;default:s.instrument_logger.warning("Unknown Next.js route module kind",{pathname:t,kind:e.definition?.kind||"unknown"})}}catch(e){s.instrument_logger.error("Error detecting and patching supported methods",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}static _patchApiModule(e,t){if(e.methods)for(const r of c.standardMethods)if("function"==typeof e.methods[r]&&"function"==typeof e.userland?.[r]){const u=(0,i.generateEndpointFlowId)(t,[r]);(0,o.storeEndpointDeclaration)(new n.EndpointDeclaration(u,[r],"nextjs","",t));try{const t=e.methods[r];e.methods[r]=(0,a.wrapFlow)(()=>u,t,!0)}catch(e){s.instrument_logger.error("Failed to patch Next.js App Route method",{method:r,pathname:t,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}if(e.userland?.default){const r=c.standardMethods.filter(t=>!e.methods?.[t]),s=(0,i.generateEndpointFlowId)(t,r);(0,o.storeEndpointDeclaration)(new n.EndpointDeclaration(s,r,"nextjs","",t));const u=e.userland.default;e.userland={...e.userland,default:(0,a.wrapFlow)(()=>s,u,!0)}}}static _patchPageModule(e,t){const r=(0,i.generateEndpointFlowId)(t,["GET"]);if((0,o.storeEndpointDeclaration)(new n.EndpointDeclaration(r,["GET"],"nextjs","",t)),e.render&&"function"==typeof e.render&&!e.render[this.nextJSHudMarked])try{const n=e.render;e.render=function(...e){try{const n=e[2]?.renderOpts?.Component;if(n&&"function"==typeof n){const t=(0,a.wrapFlow)(()=>r,n,!0);e[2].renderOpts.Component=t}const o=e[2]?.renderOpts?.ComponentMod;if(o){for(const t of Object.keys(o))if(o[t]&&"function"==typeof o[t]){const n=(0,a.wrapFlow)(()=>r,o[t],!0);e[2].renderOpts.ComponentMod[t]=n}}else s.instrument_logger.error("No Component found on Next.js page component",{pathname:t})}catch{}return n.apply(this,e)},(0,a.copyPropertiesToTarget)(n,e.render),e.render[this.nextJSHudMarked]=!0}catch(e){s.instrument_logger.error("Failed to patch Next.js Page render method",{pathname:t,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}if(e.userland?.loaderTree)try{l(e.userland.loaderTree,r)}catch(e){s.instrument_logger.error("Failed to patch App Router page component",{pathname:t,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}else s.instrument_logger.info("No loader tree found on Next.js page component, functions will be patched by the render function",{pathname:t})}}function d(e,t,r){return(...n)=>{const o=e(...n),i=e=>{if(e&&"function"==typeof e.default){try{e.default.a}catch{return e}const n=(0,a.wrapFlow)(()=>r,e.default,t);e={...e,default:n}}return e};return o&&"function"==typeof o.then?o.then(i):i(o)}}function l(e,t){const[,r,n]=e;for(const e of Object.keys(n))try{const r=n[e];if(Array.isArray(r)&&"function"==typeof r[0]){const n="page"===e,o=r[0];r[0]=d(o,n,t),(0,a.copyPropertiesToTarget)(o,r[0])}}catch(e){s.instrument_logger.error("Failed to iterate on Next.js components",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}for(const e of Object.values(r))try{l(e,t)}catch(e){s.instrument_logger.error("Failed to walk on Next.js parallel routes",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}t.default=c},9723:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=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||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0});const a=r(8269),u=r(2546),c=r(523),d=r(9896),l=s(r(6928)),f=r(8949),g=r(714);class p extends g.FrameworkPatcher{_patch(e){(0,u.setIsNextJsApp)(!0);const t=this._patchLoadConfig(e);return c.instrument_logger.info("Patched next.js config successfully"),t}_patchLoadConfig(e){const t=e.default,r=async function(...e){const r=await t.call(this,...e);if(!r)return r;try{const t=e[1],n=l.join(t,r.distDir||".next"),o=l.join(n,a.apiManifest),i=l.join(n,a.pageManifest),s=await d.promises.access(o).then(()=>!0).catch(()=>!1),u=await d.promises.access(i).then(()=>!0).catch(()=>!1);(0,a.isNextConfigExtracted)()||!s&&!u||(c.instrument_logger.info("Extracted next.js config successfully"),(0,a.setNextConfig)(r))}catch(e){c.instrument_logger.error("Failed to patch next.js loadConfig",{msg:e instanceof Error?e.message:String(e),stack:e instanceof Error?e.stack:void 0})}return r};(0,f.copyPropertiesToTarget)(t,r);const n=Object.create(Object.getPrototypeOf(e));return Object.defineProperty(n,"default",{enumerable:!0,get:function(){return r}}),(0,f.copyPropertiesToTarget)(e,n),n}}t.default=p},9873:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FlowMetric=void 0;const o=r(8528),i=r(8269),s=n(r(932));t.FlowMetric=class{_state;flowId;duration;_startTime;_msStartTime;errorBreakdown;constructor(e){this.flowId=e,this.duration=-1,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(){hudRunningMode===o.HudRunningMode.enabled&&(this._startTime=s.default.hrtime.bigint(),this._msStartTime=Date.now())}setErrorBreakdown(e){this.errorBreakdown=e}end(){hudRunningMode===o.HudRunningMode.enabled&&(-1===this.duration&&this.calculateDuration(),this.#e(),this._state="unusable")}calculateDuration(){this._startTime&&(this.duration=Number(s.default.hrtime.bigint()-this._startTime))}#e(){if(hudRunningMode===o.HudRunningMode.enabled){const e=this.toRaw();e&&(0,i.storeFlowMetric)(e)}}}},9896:e=>{"use strict";e.exports=require("fs")},9938:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wrapOutboundFunction=function(e,t,r,n,o){let i;return i=e instanceof u.AsyncFunction?async function(...i){const a={io:!0};let u,c,d;try{(0,s.wrapperInitial)(t,a);const e=l(i,a,r,o,t);u=e?.outboundInvocation,c=e?.outboundIndex}catch{}try{const r=e.apply(this,i);try{_hud_SI.value--,a.ff=!0}catch{}d=await r;try{_hud_S[++_hud_SI.value]=t,a.ff=!1}catch{}}catch(e){try{(0,s.wrapperCatch)(t,a,e,[]),g(e,c,u,a)}catch{}throw e}finally{try{(0,s.wrapperFinally)(t,a)}catch{}}return f(d,c,u,a.start,n),d}:function(...i){const a={io:!0};let u,c,d;try{(0,s.wrapperInitial)(t,a);const e=l(i,a,r,o,t);u=e?.outboundInvocation,c=e?.outboundIndex}catch{}try{d=e.apply(this,i)}catch(e){try{(0,s.wrapperCatch)(t,a,e,[]),g(e,c,u,a)}catch{}throw e}finally{try{(0,s.wrapperFinally)(t,a)}catch{}}return d instanceof Promise?d.catch(e=>{throw g(e,c,u,a),e}).then(e=>(f(e,c,u,a.start,n),e)):(f(d,c,u,a.start,n),d)},(0,u.copyPropertiesToTarget)(e,i),i},t.wrapOutboundBodyFunction=function(e,t,r,n){if(e instanceof u.AsyncFunction)return i.instrument_logger.warning("Wrap outbound body function doesn't support async functions"),e;const o=function(...o){const i={io:!0};let a,u,c;try{if((0,s.wrapperInitial)(t,i),a=r(this,o),void 0!==a){const e=(0,s.getInvestigationStorage)()?.getStore();u=e?.outbounds?.[a]}}catch{}try{c=e.apply(this,o)}catch(e){try{(0,s.wrapperCatch)(t,i,e,[]),h(e,u,a,i)}catch{}throw e}finally{try{(0,s.wrapperFinally)(t,i)}catch{}}return c instanceof Promise?c.catch(e=>{throw h(e,u,a,i),e}).then(e=>(p(this,e,a,u,i.start,n),e)):(p(this,c,a,u,i.start,n),c)};return(0,u.copyPropertiesToTarget)(e,o),o},t.getBodySize=function(e){if(e&&("string"==typeof e||e instanceof Buffer)&&e.length>0)return e.length},t.getReducedBody=_,t.reduceRequestArgsIfNeeded=function(e,t,r){try{const o=t.args;if(void 0===o)return;const i=r(e),s=isNaN(i)||0===i?void 0:i;o.bodySize=s,o.body=_(o.body,s,n.hudConfig.dynamicConfig.maxHTTPRequestBodySize)}catch(e){(0,a.limitedLogger)("Error reducing request args",{e})}};const n=r(5809),o=r(8528),i=r(523),s=r(7131),a=r(2822),u=r(8949),c={[o.OutboundType.HTTP]:e=>{void 0!==e&&(e.url=void 0,e.body=void 0)},[o.OutboundType.DB]:e=>{void 0!==e&&(e.query=void 0,e.params=void 0)}},d={[o.OutboundType.HTTP]:e=>{void 0!==e&&(e.body=void 0)},[o.OutboundType.DB]:e=>{}};function l(e,t,r,o,i){const u=(0,s.getInvestigationStorage)()?.getStore();if(void 0===u)return;if(u.outbounds.length>=n.hudConfig.dynamicConfig.maxTotalOutbounds)return void(0,a.limitedLogger)("max outbound calls reached");const d=u.outbounds.length;let l;try{void 0!==r&&d<n.hudConfig.dynamicConfig.maxOutboundCountWithData&&(l=r(e))}catch(e){(0,a.limitedLogger)("error parsing args",{e})}const f={function_id:i,caller_id:t.wrappedCaller,type:o,args:l,timestamp:Date.now()};return(d>=n.hudConfig.dynamicConfig.maxOutboundCountWithData||!n.hudConfig.dynamicConfig.enableOutboundData)&&c[f.type](f.args),u.outbounds.push(f),{outboundInvocation:f,outboundIndex:d}}function f(e,t,r,o,i){try{if(void 0===t||void 0===r)return;if(void 0!==i&&t<n.hudConfig.dynamicConfig.maxOutboundCountWithData){let o;try{o=i(e,t,r)}catch(e){(0,a.limitedLogger)("error parsing result",{e})}(t>=n.hudConfig.dynamicConfig.maxOutboundCountWithData||!n.hudConfig.dynamicConfig.enableOutboundData)&&d[r.type](o),r.result=o}const s=process.hrtime.bigint();r.duration=Number(s-o)}catch{}}function g(e,t,r,o){try{if(void 0===r||void 0===t)return;r.error=t<n.hudConfig.dynamicConfig.maxOutboundCountWithData&&n.hudConfig.dynamicConfig.enableOutboundData?e:(0,s.extractName)(e),r.duration=Number(process.hrtime.bigint()-o.start)}catch{}}function p(e,t,r,i,s,u){try{if(void 0===r||void 0===i||i.type!==o.OutboundType.HTTP||void 0===i.result)return;try{const r=u(e,t);i.result.body=r?.body,i.result.bodySize=r?.bodySize}catch(e){(0,a.limitedLogger)("error getting body",{e})}const c=process.hrtime.bigint();i.bodyDuration=Number(c-s),(r>=n.hudConfig.dynamicConfig.maxOutboundCountWithData||!n.hudConfig.dynamicConfig.enableOutboundData)&&d[o.OutboundType.HTTP](i.result)}catch{}}function h(e,t,r,o){try{if(void 0===t||void 0===r)return;t.bodyError=r<n.hudConfig.dynamicConfig.maxOutboundCountWithData&&n.hudConfig.dynamicConfig.enableOutboundData?e:(0,s.extractName)(e),t.bodyDuration=Number(process.hrtime.bigint()-o.start)}catch{}}const m="[HUD_BODY_TOO_LONG]",y="[HUD_NO_CONTENT_LENGTH_HEADER]";function _(e,t,r){return void 0!==t&&t>r?m:void 0===t&&null!=e&&""!==e?y:e}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.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 n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(global,()=>(()=>{var e={336:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(7131),i=r(2822),s=r(8949),a=r(4393),u=r(714);class c extends u.FrameworkPatcher{_patch(e){return this._patchSendRequest(e),n.instrument_logger.info("Patched @codegenie/serverless-express/src/frameworks/express.js successfully"),e}_patchSendRequest(e){const t=e.sendRequest;e.sendRequest=function(e){const r=e?.request,s=e?.response;if(!r||!s)return t.call(this,e);const u=a.HttpEndpointMetric.createUsableMetric(),c=(0,o.getFlowStateStorage)(),d=()=>{try{u.start(),u.setRequestAttributes(r)}catch(e){n.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 o=(0,i.runWithInvestigation)(()=>t.call(this,e));try{s.once("finish",function(){try{u.calculateDuration(),(0,i.finishHttpInvestigation)(r,s,u),u.setResponseAttributes(s),u.end()}catch(e){n.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){n.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 o};return c?c.run({httpMetric:u},d):d()},(0,s.copyPropertiesToTarget)(t,e.sendRequest)}}t.default=c},486:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8544);class o extends n.BaseKafkaJSPatcher{getExportsRoot(e){return e}getGroupId(e){return e[0].groupId}moduleName(){return"KafkaJS"}}t.default=o},523:e=>{"use strict";e.exports=require("./logger")},646:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(8949),i=r(5128),s=r(714);class a extends s.FrameworkPatcher{_patch(e){return this._patchCreate(e),n.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];"function"==typeof t.constructor&&"function"==typeof r?e[1]=(0,i.wrapLinkedFunction)(r):n.instrument_logger.error("Invalid args in NestJS RouterExecutionContext.create",{args:e})}catch(e){n.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,o.copyPropertiesToTarget)(t,e.RouterExecutionContext.prototype.create)}}t.default=a},714:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=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||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.FrameworkPatcher=void 0,t.isSupportedVersion=f,t.extractModuleVersion=g,t.getFrameworkPatcher=function(e){return new(r(2828)(`./${e}`).default)};const a=r(2546),u=r(523),c=r(9896),d=s(r(6928)),l=r(8064);function f(e,t){return""===e||l.satisfies(l.coerce(e),t)}function g(e){try{const t=(0,c.readFileSync)(d.join(e,"package.json"),{encoding:"utf8"}),r=JSON.parse(t).version;return"string"==typeof r?r:""}catch{u.instrument_logger.info("Failed extracting version",{baseDir:e})}return""}t.FrameworkPatcher=class{patch(e,t,r,n,o=this.constructor.name){try{if(this.isSupported(t,o,r,n))return this._patch(e)}catch(e){u.instrument_logger.error("Unhandeled error during patching framework",{framework:o,error:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return e}isSupported(e,t,r,n){const o=g(e);return!!f(o,r)||(u.instrument_logger.warning("Unsupported version",{framework:t,version:o,supportedVersion:r,basedir:e}),u.customer_logger.log(a.UserErrorLogs.UnsupportedFrameworkVersion(t)),!1)}}},828:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.KafkaJSMetric=void 0;const n=r(523),o=r(7131),i=r(9873);class s extends i.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,o.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,error_breakdown:this.errorBreakdown};n.instrument_logger.warning("No partition found for message",{flowId:this.flowId})}}t.KafkaJSMetric=s},857:e=>{"use strict";e.exports=require("os")},932:e=>{"use strict";e.exports=require("process")},1326:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(2546),i=r(523),s=r(8949),a=r(714),u=n(r(9589));class c extends a.FrameworkPatcher{static nextJSHudMarked=Symbol.for("hudNextJSMarked");_patch(e){return(0,o.setIsNextJsApp)(!0),this._pathLoad(e),i.instrument_logger.info("Patched Next.js successfully"),e}_pathLoad(e){try{const t=e.RouteModuleLoader;if(t[c.nextJSHudMarked])return e;const r=t.load;t.load=async function(...e){const t=await r.apply(this,e);try{if(t){const e=t.definition?.pathname;e&&!t[c.nextJSHudMarked]&&(u.default._detectAndPatchSupportedMethods(t,e),t[c.nextJSHudMarked]=!0)}}catch(e){i.instrument_logger.error("Failed to patch Next.js route module",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return t},t[c.nextJSHudMarked]=!0,(0,s.copyPropertiesToTarget)(r,t.load)}catch(e){i.instrument_logger.error("Failed to patch Next.js base server",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return e}}t.default=c},1427:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getSystemInfo=function(){return{pod_name:c(),node_name:d()}};const o=n(r(9896)),i=n(r(857)),s=Symbol("not found");let a,u;function c(){if(a!==s){if(a)return a;try{return a=i.default.hostname(),a}catch{return void(a=s)}}}function d(){if(u!==s){if(u)return u;try{const e=o.default.readFileSync("/etc/machine-id","utf8").trim();return u=e,u}catch{return void(u=s)}}}},1502:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(5809),o=r(8528),i=r(8269),s=r(2546),a=r(523),u=r(8949),c=r(714);class d extends c.FrameworkPatcher{static koaModuleName="koa";static koaPatchedSymbol=Symbol.for(n.hudConfig.hudPatchedName);_patch(e){return this._patchAppUse(e),a.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++)d._wrapRoute(e[t])}catch(e){a.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,u.copyPropertiesToTarget)(t,e.prototype.use)}static _wrapRoute(e){if(e.methods&&0===e.methods.length)return;if(!e.stack[0][d.koaPatchedSymbol]){const t=(0,u.wrapFlow)(p,e.stack[0],!0);e.stack[0]=t,e.stack[0][d.koaPatchedSymbol]=!0}const t=(0,s.generateEndpointFlowId)(e.path,e.methods);(0,i.storeEndpointDeclaration)(new o.EndpointDeclaration(t,e.methods,"koa",void 0,e.path));for(const r of e.methods)g(t,e.path,r)}}function l(e,t){return e+"|"+t}t.default=d;const f=new Map;function g(e,t,r){f.set(l(t,r),e)}function p(e,t){if(0===t.length)return;const r=t[0]._matchedRoute,n=t[0].req?.method;return function(e,t){return f.get(l(e,t))}(r,n)}},2080:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqsMetric=void 0;const n=r(9873);class o extends n.FlowMetric{errors;msgCount;e2eEpocStartTimeMS;e2eDurationNS;_finishedMessageCount;constructor(e){super(e),this._finishedMessageCount=0,this.errors=new Map}addError(e,t=1){this.errors.set(e,(this.errors.get(e)??0)+t)}increaseAndShouldEnd(e=1){return this._finishedMessageCount+=e,!(this.msgCount&&this._finishedMessageCount<this.msgCount)}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,errors:this.errors,error_breakdown:this.errorBreakdown}}}t.SqsMetric=o},2197:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=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)},a=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.serializableInvestigation=t.koa=t.express=t.safeLog=t.registerHook=t.hudRITM=void 0;var u=r(5688);Object.defineProperty(t,"hudRITM",{enumerable:!0,get:function(){return u.hudRITM}}),Object.defineProperty(t,"registerHook",{enumerable:!0,get:function(){return u.registerHook}}),Object.defineProperty(t,"safeLog",{enumerable:!0,get:function(){return u.safeLog}}),s(r(3901),t),t.express=a(r(7127)),s(r(714),t),t.koa=a(r(1502)),s(r(7166),t);var c=r(2822);Object.defineProperty(t,"serializableInvestigation",{enumerable:!0,get:function(){return c.serializableInvestigation}})},2546:e=>{"use strict";e.exports=require("./lib")},2729:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(7131),i=r(2822),s=r(8949),a=r(4393),u=r(714);class c extends u.FrameworkPatcher{_patch(e){const t=this._patchGetFramework(e);return n.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 u(e,...t){const s=a.HttpEndpointMetric.createUsableMetric(),u=(0,o.getFlowStateStorage)(),c=async()=>{try{s.start(),s.setRequestAttributes(e)}catch(e){n.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 o=await(0,i.runWithInvestigation)(()=>r.apply(r.this,[e,...t]));return o.once("finish",function(){try{s.calculateDuration(),(0,i.finishHttpInvestigation)(e,o,s),s.setResponseAttributes(o),s.end()}catch(e){n.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})}}),o};return u?await u.run({httpMetric:s},c):await c()}return(0,s.copyPropertiesToTarget)(r,u),u},(0,s.copyPropertiesToTarget)(t,e),e}}t.default=c},2741:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(6730),i=r(4815),s=r(7225),a=r(714);class u extends a.FrameworkPatcher{_patch(e){return s.isVerboseLoggingEnabled?((0,o.patchMethods)(e,"application_export"),(0,i.patchUse)(e,"application",!1),(0,s.logLazyRouter)(e),n.instrument_logger.info("Patched express.Application successfully"),e):(n.instrument_logger.info("Skipping express.Application patching, verbose logging is not enabled"),e)}}t.default=u},2784:e=>{"use strict";e.exports=require("../native/_index")},2822:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getStackTraceWithoutMessage=f,t.limitedLogger=p,t.serializableInvestigation=h,t.getBaseInvestigationStorage=m,t.createNewInvestigation=function(){if(!globalThis.hudEnableInvestigation)return;const e=(0,a.getInvestigationStorage)();void 0!==e&&e.enterWith(m())},t.runWithInvestigation=function(e){if(!globalThis.hudEnableInvestigation)return e();const t=(0,a.getInvestigationStorage)();return void 0===t?e():t.run(m(),e)},t.closeInvestigation=y,t.storeInvestigation=_,t.getInvestigationDedupingKey=v,t.minimizeObject=k,t.finishHttpInvestigation=function(e,t,r){r.apiProtocol!==u.ApiProtocol.GraphQL?function(e,t,r){const n=function(e,t){return e.statusCode>=500?"Error":!!x(t,o.InvestigationType.HTTP)&&"Duration"}(t,r);if(!1===n)return;const i=S(r,n,o.InvestigationType.HTTP);if(void 0===i)return;try{p("http requests headers",{headers:Object.keys(e.headers)})}catch{p("failed to log http requests headers")}const s=r.getFlowId(),a=r.getMsStartTime(),u=r.apiProtocolAttributes;void 0!==s&&u&&void 0!==u.route&&void 0!==u.method&&void 0!==a?_(i,{type:o.InvestigationType.HTTP,endpoint_uuid:s,route:u.route,method:u.method,timestamp:a,params:e.params,query:e.query,request_body:k(e.body),status_code:t.statusCode,machine_metrics:(0,c.getMachineMetrics)(),observability_identifiers:(0,d.getObservabilityIdentifiersHttp)(e),extra_headers:(0,d.getExtraHeaders)(e),system_info:(0,l.getSystemInfo)()}):p("route, method, or reqTimestamp are undefined even though they shouldn't",{flowId:s,route:u.route,method:u.method,reqTimestamp:a})}(e,t,r):function(e,t,r){const n=function(e,t){const r=t.apiProtocolAttributes;return e.statusCode>=500||r&&r.errorOccurred?"Error":!!x(t,o.InvestigationType.GraphQL)&&"Duration"}(t,r);if(!1===n)return;const i=S(r,n,o.InvestigationType.GraphQL);if(void 0===i)return void p("finishHttpInvestigation: base investigation return undefined");const s=r.getFlowId(),a=r.getMsStartTime();void 0!==s&&void 0!==a?_(i,{type:o.InvestigationType.GraphQL,flow_id:s,timestamp:a,request_body:k(e.body),graphql_errors:k(r.apiProtocolAttributes?.errors),status_code:t.statusCode,machine_metrics:(0,c.getMachineMetrics)(),observability_identifiers:(0,d.getObservabilityIdentifiersHttp)(e),system_info:(0,l.getSystemInfo)()}):p("flowId or reqTimestamp are undefined even though they shouldn't",{flowId:s,reqTimestamp:a})}(e,t,r)},t.finishSqsInvestigation=function(e,t){const r=function(e){return e.errors.size>0?"Error":!!x(e,o.InvestigationType.SQS)&&"Duration"}(t);if(!1===r)return;const n=S(t,r,o.InvestigationType.SQS);if(void 0===n)return;const i=t.getFlowId(),s=t.getMsStartTime();void 0!==s&&void 0!==i?_(n,{type:o.InvestigationType.SQS,timestamp:s,flow_id:i,messages:k(e),machine_metrics:(0,c.getMachineMetrics)(),system_info:(0,l.getSystemInfo)()}):p("reqTimestamp is undefined even though it shouldn't",{flowId:i})},t.finishKafkaJSInvestigation=function(e,t,r,n){const i=function(e){return void 0!==e.error?"Error":!!x(e,o.InvestigationType.Kafka)&&"Duration"}(t);if(!1===i)return;const s=S(t,i,o.InvestigationType.Kafka);if(void 0===s)return;const a=t.getFlowId(),u=t.getMsStartTime();if(void 0===u||void 0===a)return void p("reqTimestamp is undefined even though it shouldn't",{flowId:a});const f=e.map(e=>{let t=e.value;t instanceof Buffer&&(t=t.toString());try{t=JSON.parse(t)}catch{}return{key:e.key,value:t,timestamp:e.timestamp,offset:e.offset,headers:e.headers,attributes:e.attributes}});_(s,{type:o.InvestigationType.Kafka,timestamp:u,topic:r,partition:n,flow_id:a,messages:k(f),machine_metrics:(0,c.getMachineMetrics)(),system_info:(0,l.getSystemInfo)(),observability_identifiers:(0,d.getObservabilityIdentifiers)()})},t.getErrorRecordsFromInvestigation=E;const n=r(5809),o=r(8528),i=r(8269),s=r(523),a=r(7131),u=r(4393),c=r(7808),d=r(7603),l=r(1427);function f(e,t){if(void 0===t)return;const r=function(e){let t=0;for(let r=0;r<e.length;r++)"\n"===e[r]&&t++;return t}(e)+1;let n=-1;for(let e=0;e<r;e++)if(n=t.indexOf("\n",n+1)??-1,-1===n)return;return-1!==n?t.slice(n+1):void 0}const g={};function p(e,...t){let r="debug";(void 0===g[e]||g[e]<n.hudConfig.dynamicConfig.investigationRateLimits.maxUniqLogs)&&(r="warning",g[e]=g[e]+1||1),s.app_logger.logLevel(r,e,...t)}function h(e){return{status:e.status,context:e.context,exceptions:Array.from(e.exceptions.values()).map(({exception:e,executionFlow:t,caught:r})=>({name:(0,a.extractName)(e),message:(0,a.extractMessage)(e),stackTrace:e instanceof Error?f(e.message,e.stack):void 0,executionFlow:t.map(e=>({function_id:e.function_id,caller_id:e.caller_id,args:void 0!==e.args?k(e.args,n.hudConfig.dynamicConfig.investigationRateLimits.maxObjectDepth+2):void 0})),caught:r})),userContext:e.userContext,caught:e.caught,triggerType:e.triggerType,duration:e.duration,durationThreshold:e.durationThreshold,outbounds:e.outbounds.map(e=>function(e){try{return{function_id:e.function_id,caller_id:e.caller_id,type:e.type,duration:e.duration?Number(e.duration):void 0,timestamp:e.timestamp,args:k(e.args),result:k(e.result),error:e.error?{type:"string"==typeof e.error?e.error:(0,a.extractName)(e.error),message:(0,a.extractMessage)(e.error)}:void 0,...e.type===o.OutboundType.HTTP?{bodyDuration:e.bodyDuration,bodyError:e.bodyError?{type:"string"==typeof e.bodyError?e.bodyError:(0,a.extractName)(e.bodyError),message:(0,a.extractMessage)(e.bodyError)}:void 0}:{}}}catch(e){return void p("error serializing outbound",e)}}(e)).filter(e=>void 0!==e)}}function m(){return{triggerType:void 0,duration:0,status:o.InvestigationStatus.Open,caught:!0,exceptions:new Map,outbounds:[]}}function y(){if(!globalThis.hudEnableInvestigation)return;const e=(0,a.getInvestigationStorage)();if(void 0===e)return;const t=e.getStore();return void 0!==t&&t.status===o.InvestigationStatus.Open?(t.status=o.InvestigationStatus.Closed,t):void 0}function _(e,t){e.context=t,(0,i.storeClosedInvestigation)(h(e))}function b(e){for(const t of e)if(!t.is_outbound_function)return t.function_id}function v(e,t){let r="";for(const t of e)r+=`${t.error_type}-${t.function_id}|`;return r+=`${t}`,r}let w=null;function k(e,t=n.hudConfig.dynamicConfig.investigationRateLimits.maxObjectDepth,o=new WeakSet){try{if(null===w&&(w=r(8611).IncomingMessage),null!==e&&"object"==typeof e){if(o.has(e))return"[Circular Reference]";if(w&&e instanceof w)return"[Http Request]";o.add(e)}if(null==e||["number","boolean"].includes(typeof e))return e;if("string"==typeof e)return e.length>n.hudConfig.dynamicConfig.investigationRateLimits.maxStringLength?e.slice(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxStringLength)+"...":e;if(e instanceof Buffer)return e.length>n.hudConfig.dynamicConfig.investigationRateLimits.maxStringLength?e.subarray(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxStringLength).toString()+"...":e.toString();if(e instanceof ArrayBuffer){const t=Buffer.from(e);return t.length>n.hudConfig.dynamicConfig.investigationRateLimits.maxStringLength?t.subarray(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxStringLength).toString()+"...":t.toString()}if(["bigint","symbol"].includes(typeof e))return k(e.toString(),t-1,o);if("function"==typeof e)return`[Function: ${e.name||"anonymous"}]`;if(void 0===e)return;if(Array.isArray(e))return t<=0?"[Array]":e.slice(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxArrayLength).map(e=>k(e,t-1,o));if(e instanceof Map)return t<=0?"[Map]":{"[Map]":Array.from(e.entries()).slice(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxArrayLength).map(([e,r])=>[k(e,t-1,o),k(r,t-1,o)])};if(e instanceof Set)return t<=0?"[Set]":{"[Set]":Array.from(e.values()).slice(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxArrayLength).map(e=>k(e,t-1,o))};if(e instanceof Date){let r;try{r=e.toISOString()}catch{}return k(r,t-1,o)}if(e instanceof RegExp)return k(e.toString(),t-1,o);if(e&&"Proxy"===e[Symbol.toStringTag])return k(e.target||e,t-1,o);if(e&&e[Symbol.toStringTag])return`[${e[Symbol.toStringTag]}]`;if("object"==typeof e){if(t<=0)return"[Object]";const r={},i=Object.getOwnPropertyNames(e),s=Object.getOwnPropertySymbols(e);for(const s of i.slice(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxArrayLength))try{r[s.slice(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxKeyLength)]=k(e[s],t-1,o)}catch{}for(const i of s.slice(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxArrayLength))try{r[i.toString()]=k(e[i],t-1,o)}catch{}return r}}catch{}}function S(e,t,r){let o;if(o="Error"===t?function(e){const t=y();if(void 0===t)return void p("finishErrorInvestigation: investigation is undefined");const r=e.getFlowId();if(void 0===r)return void p("finishErrorInvestigation: flowId is undefined");const o=E(t),s=v(o,t.caught);if(e.setErrorBreakdown({key:s,errors:o,caught:t.caught}),(0,i.getGlobalInvestigationTracking)()>=n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigations)return void p("finishErrorInvestigation: globalInvestigationTracking is greater than maxTotalInvestigations",{globalInvestigationTracking:(0,i.getGlobalInvestigationTracking)(),maxTotalInvestigations:n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigations});if((0,i.getTotalInvestigationsErrorBased)()>=n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigationsErrorBased)return void p("finishErrorInvestigation: currentTotalInvestigationsErrorBased is greater than maxTotalInvestigationsErrorBased");const a=(0,i.getInvestigationDedupingCache)(r).get(s)??0;if(!(a>=n.hudConfig.dynamicConfig.investigationRateLimits.maxSameInvestigations))return(0,i.increaseGlobalInvestigationTracking)(),(0,i.increaseTotalInvestigationsErrorBased)(),(0,i.increaseInvestigationDedupingCache)(r,s),t;p("finishErrorInvestigation: investigationCount is greater than maxSameInvestigations",{investigationCount:a,maxSameInvestigations:n.hudConfig.dynamicConfig.investigationRateLimits.maxSameInvestigations})}(e):function(e,t){const r=e.getFlowId();if(void 0===r)return void p("finishDurationInvestigation: flowId is undefined");if((0,i.getGlobalInvestigationTracking)()>=n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigations)return void p("finishDurationInvestigation: currentTotalInvestigationsGlobal is greater than maxTotalInvestigations");if((0,i.getTotalInvestigationsDurationBased)()>=n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigationsDurationBased)return void p("finishDurationInvestigation: currentTotalInvestigationsDurationBased is greater than maxTotalInvestigationsDurationBased");const o=C(r,t);if(void 0!==o)return(0,i.getInvestigationDurationCount)(r)>=o.number_of_dumps?(p("finishDurationInvestigation: currentInvestigationCount is greater than durationThresholdAndCount.count"),void s.app_logger.debug("finishDurationInvestigation: currentInvestigationCount is greater than durationThresholdAndCount.count")):((0,i.increaseInvestigationDurationCount)(r),(0,i.increaseGlobalInvestigationTracking)(),(0,i.increaseTotalInvestigationsDurationBased)(),y());p("finishDurationInvestigation: durationThresholdAndCount is undefined")}(e,r),void 0!==o)return o.triggerType=t,o.duration=e.duration,o.durationThreshold=C(e.getFlowId()??"",r)?.duration,o;p("finishInvestigation: error investigation return undefined")}function C(e,t){const r=(0,i.getFlowIdDurationThresholdAndCount)(e);return void 0===r?(0,i.getFlowIdDurationThresholdAndCount)(`default-${t}`):r}function x(e,t){const r=e.getFlowId();if(void 0===r)return!1;const n=C(r,t);return void 0!==n&&n.duration<e.duration}function E(e){const t=new Set,r=[];for(const n of e.exceptions.values()){const e=(0,a.extractName)(n.exception),o=b(n.executionFlow)??"",i=`${e}-${o}`;if(t.has(i))continue;t.add(i);const s={error_type:e,function_id:o};r.push(s)}return r}},2828:(e,t,r)=>{var n={"./baseKafkaJsPatcher":8544,"./baseKafkaJsPatcher.ts":8544,"./codeGenieServerlessExpress":336,"./codeGenieServerlessExpress.ts":336,"./confluentKafkaJs":7276,"./confluentKafkaJs.ts":7276,"./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/flow":9873,"./flows/flow.ts":9873,"./flows/http":4393,"./flows/http.ts":4393,"./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,"./nestjsRouterExecutionContext":646,"./nestjsRouterExecutionContext.ts":646,"./nestjsRpcContextCreator":4290,"./nestjsRpcContextCreator.ts":4290,"./nextJsConfig":9723,"./nextJsConfig.ts":9723,"./nextJsModuleLoader":1326,"./nextJsModuleLoader.ts":1326,"./nextJsRouteModule":8840,"./nextJsRouteModule.ts":8840,"./nextjs":9589,"./nextjs.ts":9589,"./outbound/axios":5354,"./outbound/axios.ts":5354,"./outbound/nodeFetch":8564,"./outbound/nodeFetch.ts":8564,"./outbound/pg":7427,"./outbound/pg.ts":7427,"./outbound/wrapOutbound":9938,"./outbound/wrapOutbound.ts":9938,"./router":5946,"./router.ts":5946,"./serverlessHttp":2729,"./serverlessHttp.ts":2729,"./sqsConsumer":5150,"./sqsConsumer.ts":5150};function o(e){var t=i(e);return r(t)}function i(e){if(!r.o(n,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return n[e]}o.keys=function(){return Object.keys(n)},o.resolve=i,e.exports=o,o.id=2828},2977:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=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||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.patchRoute=function(e){const t=(0,g.getMethods)();t.concat("all").forEach(function(r){const n=e.prototype[r];e.prototype[r]=function(){let e;try{e=p(Array.prototype.slice.call(arguments));let n=function(e){const t=e[0][a.hudConfig.express.layerStateSymbol];if(t)return t.flowId}(e);const o=function(e){const t=e[0][a.hudConfig.express.layerStateSymbol];if(t)return t.kind}(e),i=function(e){const t=e[0][a.hudConfig.express.layerStateSymbol];return!!t&&t.allMethod}(e);if(n||(n=[l.randomUUID()]),"application"===o)if(Array.isArray(this.path)){y(e,void 0);for(let e=0;e<this.path.length;e++)m(n[e],i?t:[r],this.path[e])}else y(e,n[0]),m(n[0],i?t:[r],this.path);else if("router"===o)if(Array.isArray(this.path)){y(e,void 0);for(let e=0;e<this.path.length;e++)h(this,n[e],r,this.path[e])}else y(e,n[0]),h(this,n[0],r,this.path);else y(e,n[0]),h(this,n[0],r,this.path)}catch(e){d.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 n.apply(this,e||arguments)}})};const a=r(5809),u=r(8528),c=r(8269),d=r(523),l=s(r(6982)),f=r(8949),g=r(6730),p=r(5673);function h(e,t,r,n){!function(e,t,r,n){e[a.hudConfig.express.layerStateSymbol]||(e[a.hudConfig.express.layerStateSymbol]={}),e[a.hudConfig.express.layerStateSymbol][t]?e[a.hudConfig.express.layerStateSymbol][t].methods.push(r):e[a.hudConfig.express.layerStateSymbol][t]={layerPath:n,methods:[r]}}(e,t,r,n),function(e,t,r){const n=new u.EndpointDeclaration(e,[t],"express",void 0,void 0,r);(0,c.storePartialEndpointDeclaration)(n),(0,c.storeExpressEndpointDeclaration)(n)}(t,r,n)}function m(e,t,r){const n=new u.EndpointDeclaration(e,t,"express",void 0,r,void 0);(0,c.storeExpressEndpointDeclaration)(n)}function y(e,t){if(e&&!(e.length<1)){if(a.hudConfig.express.wrapAllCallbacks)for(let r=0;r<e.length;r++){const n=(0,f.wrapFlow)(b(t),e[r],!0);e[r]=n}else{const r=(0,f.wrapFlow)(b(t),e[e.length-1],!0);e[e.length-1]=r}return t}}function _(e){return(0,c.getLinkedConsistentFlowId)(e,!1)||(d.instrument_logger.warning("No consistent flowId found, returning temporary flow id",{flowId:e}),e)}function b(e){return e?function(){return _(e)}:function(e,t){const r=t[0]?.route[a.hudConfig.express.layerStateSymbol],n=t[0]?.url;if(r)for(const[e,t]of Object.entries(r)){if(t.layerPath instanceof RegExp&&t.layerPath.test(n))return _(e);if(n.includes(t.layerPath))return _(e)}d.instrument_logger.warning("No flowId found for path",{states:r,url:n.split("?")[0]})}}},2987:e=>{"use strict";e.exports=require("perf_hooks")},3176:e=>{"use strict";e.exports=require("buffer-crc32")},3339:e=>{"use strict";e.exports=require("module")},3868:e=>{"use strict";e.exports=require("@jridgewell/sourcemap-codec")},3901:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=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||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);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.getFunctionWrapperTemplate=v,t.splitCode=x,t.editInSplits=M,t.editWithCliBuildId=function(e,t,r,n){let{transformedCode:o,metadatas:i}=T(e,t,r,[],!0);return o+=`\n//# sourceMappingURL=${_.default.basename(t)}.map`,o+=`\n//"${n}";${d.hudConfig.cliSdkVersionVarName}="${d.SDK_VERSION}";${d.hudConfig.cliBuildIdVarName}`,{transformedCode:o,metadatas:i}},t.edit=T,t.incrementInstrumentedFunctionsCount=N;const u=a(r(3176)),c=r(3903),d=r(5809),l=r(2546),f=r(523),g=r(8528),p=r(8269),h=r(2546),m=r(3868),y=s(r(2784)),_=a(r(6928)),b=/([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 v(e,t,r=!1,n=!1){const o=`${e}_hudTemp`,i="BODY_PLACEHOLDER",s="FUNCTION_ID_PLACEHOLDER",a="AWAITABLE_PLACEHOLDER",u="EXCEPTION_VARIABLE_PLACEHOLDER",c="ARGS_ARRAY_PLACEHOLDER",l=function(e,t,r=!1){const n=[];if(r)return n;let o;t===g.Format.cjs?o="require":t===g.Format.esm&&(n.push(`import { createRequire as ${e}_createRequire } from "module";`,`const ${e}_require = ${e}_createRequire(import.meta.url);`),o=`${e}_require`);const i=h.myRequire.resolve(d.SDK_MODULE_NAME+"/wrap");return n.push(`let ${e}_temp;`,`try { ${e}_temp = ${o}(String.raw\`${i}\`); } catch (e) { ${e}_temp = { wrapperInitial: () => {}, wrapperCatch: () => {}, wrapperFinally: () => {}, fixStack: () => {}, wrapperUserCatch: () => {} }; globalThis._hud_SI = globalThis._hud_SI || { value: 0 }; globalThis._hud_S = globalThis._hud_S || [];\n }`,`const { wrapperInitial: ${e}_wi, wrapperCatch: ${e}_wc, wrapperFinally: ${e}_wf, fixStack: ${e}_fs, asyncIteratorWrapper: ${e}_aiw, wrapperUserCatch: ${e}_wuc } = ${e}_temp;`),n}(e,t,r),f=`${e}_cc.io = true;`;return{functionWrapper:`{\n let ${o};\n const ${d.hudConfig.functionIdVarName} = ${s};\n const ${e}_cc = {}; ${n?f:""}\n try {\n ${e}_wi(${d.hudConfig.functionIdVarName}, ${e}_cc);\n } catch (e) {\n globalThis._hud_SI = { value: 0 };\n globalThis._hud_S = [];\n }\n try {\n ${i}\n } catch (e) {\n try {\n ${e}_wc(${d.hudConfig.functionIdVarName}, ${e}_cc, e, ${c});\n } catch (e) {}\n throw e;\n } finally {\n try {\n ${e}_wf(${d.hudConfig.functionIdVarName}, ${e}_cc);\n } catch (e) {}\n }\n }`,awaitWrapper:`(${o} = ${a}, _hud_SI.value--, ${e}_cc.ff = true, ${o} = await ${o}, _hud_S[++_hud_SI.value] = ${d.hudConfig.functionIdVarName}, ${e}_cc.ff= false, ${o})`,yieldWrapper:`\n function* ${e}_generatorWrapper() {\n return (${o} = ${a}, _hud_SI.value--, ${e}_cc.ff = true, ${o} = yield ${o}, _hud_S[++_hud_SI.value] = ${d.hudConfig.functionIdVarName}, ${e}_cc.ff= false, ${o})\n }`,yieldStarWrapper:`\n function* ${e}_generatorWrapper() {\n return (${o} = ${a}, _hud_SI.value--, ${e}_cc.ff = true, ${o} = yield* ${o}, _hud_S[++_hud_SI.value] = ${d.hudConfig.functionIdVarName}, ${e}_cc.ff= false, ${o})\n }`,initialStatements:l,bodyPlaceholder:i,functionIdPlaceholder:s,awaitablePlaceholder:a,argsArrayPlaceholder:c,fixStackFunction:`\n try{\n ${e}_fs(${d.hudConfig.functionIdVarName}, ${e}_cc)\n }catch(e){};`,exceptionVariablePlaceholder:u,wrapperUserCatch:`\n try {\n ${e}_wuc(${d.hudConfig.functionIdVarName}, ${e}_cc, ${u}, ${c});\n } catch(e){};`,asyncIteratorWrapper:`${e}_aiw`,awaitableVariable:o}}function w(e,t,r,n=!0,o=!1,i){const s=Error.prepareStackTrace;let a=!1,l=function(e){const t=e.match(`${d.hudConfig.bundlerBuildIdVarName}="${b.source}"`);if(t&&t.length>0)return t[1]}(e);l||(l=function(e){return(0,c.v5)(e,d.hudConfig.bundlerBuildUuidNamespace)}(e),a=!0);const g=(0,c.v5)(e,d.hudConfig.functionUuidNamespace),p=(0,u.default)(t.filename).readUInt32BE(),m=(0,u.default)(e).readUInt32BE(),_=(0,h.isNextJsApp)(),w={data:t,bundlerBuildId:l,prefix:d.hudConfig.wrapVarPrefix,...v(d.hudConfig.wrapVarPrefix,t.format,o,r.length>0),uuidNamespace:d.hudConfig.functionUuidNamespace,fileHash:g,functionsToInstrument:r,useInputSourcemap:n,isNextJsFile:_,markCode:d.hudConfig.nextJsMarkVarName,enableForAwaitInstrumentation:!i,disableParametersExtraction:d.hudConfig.userConfig.disableParametersExtraction?.value},k=y.transform(e,w);return N(k.functionsIds.length,i),_&&k.marksCount!==k.functionsIds.length&&f.instrument_logger.warning("Marks count mismatch while instrumenting functions",{marksCount:k.marksCount,functionsIdsLength:k.functionsIds.length,filename:t.filename}),globalThis.hudNextJsPluginIndicator&&_&&(k.marksCount>0||k.functionsIds.length>0)&&(clearTimeout(globalThis.hudNextJsPluginIndicator),globalThis.hudNextJsPluginIndicator=void 0),Error.prepareStackTrace=s,f.instrument_logger.debug(`Successfully transformed ${t.filename}`),{code:k.code,map:k.map,functionIds:k.functionsIds,totalFunctionsCountIncludeUninstrumented:k.totalFunctionsCountIncludeUninstrumented,filename:t.filename,hasInputMap:k.isInputSourcemap,bundlerBuildId:l,bundlerBuildIdGenerated:a,file_path_checksum:p,file_checksum:m,sourceCodeHash:g,moduleBase:k.moduleBase,isNextJsApp:_,marksCount:k.marksCount,detectedForAwaitLoops:k.detectedForAwaitLoops}}class k extends Error{}function S(e,t){if(e&&t)throw new k("Start mark found inside mark");if(!e&&!t)throw new k("End mark found outside mark")}function C(e,t,r,n){const o=e.split("\n");let i=r,s=n;return i+=o.length-1,i+=t.split("\n").length-1,i===r?s+=o.pop()?.length||0:s=o.pop()?.length||0,{lineOffset:i,columnOffset:s}}function*x(e){let t=!1,r=0,n=0,o=!1,i=0,s=0;const a=new RegExp(`globalThis\\s*?&&\\s*?\\(globalThis\\.${d.hudConfig.esbuildGlobalVar}\\s*?=\\s*?"(Start|End):(?<fileName>.*?)"\\);?`,"g");for(const u of e.matchAll(a)){if(o=!0,!u.groups)throw new k("No groups found in match");const{fileName:a}=u.groups,[c,d]=u,l="Start"===d;S(l,t);let f="";if(t){const t=u.index+c.length;f=e.slice(r,t);const o=n+Buffer.byteLength(f,"utf8");yield{edit:!0,code:f,fileName:a,lineOffset:i,columnOffset:s,indexOffset:n,indexOffsetEnd:o},r=t,n=o}else{const t=u.index;f=e.slice(r,t),n+=Buffer.byteLength(f,"utf8"),r=t,yield{edit:!1,code:f}}t=!!l,({lineOffset:i,columnOffset:s}=C(f,c,i,s))}if(t)throw new k("End mark found outside mark");o?r<e.length&&(yield{edit:!1,code:e.slice(r)}):yield{edit:!1,code:e}}function E(e,t,r){f.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 I(e,t,r){const n=w(e.code,{filename:t,format:r},[],!1,!0,!1),o=n.code;return n.mapRelativeToChunk=n.map,n.map=function(e,t,r){"string"==typeof e&&(e=JSON.parse(e));const n=(0,m.decode)(e.mappings);return n.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,m.encode)(n),sourcesContent:void 0})}(n.map,e.lineOffset,e.columnOffset),{codeToAppend:o,metadata:{...n,filename:t,lineOffset:e.lineOffset,columnOffset:e.columnOffset}}}function M(e,t,r,n=!1,o=!1,i=()=>!0){const s=e.slice(-1e3);if(!o&&null!==y.getSourceMap(t,s))return f.instrument_logger.critical("Source map found for esbuild split",{filename:t}),f.customer_logger.log(l.UserErrorLogs.EsbuildSourceMapFound()),(0,p.detachHud)(!1,!1),{transformedCode:e,metadatas:[],editedChunksSizes:void 0};let a="",u=0,c=0;const g=[];let h=0;const m=n?[]:void 0,_=v(d.hudConfig.wrapVarPrefix,r).initialStatements.join("\n"),b=function(e){return e.slice(d.hudConfig.esbuildMark.length,d.hudConfig.esbuildMark.length+36)}(e);for(const n of x(e)){h++;try{let e="",o=!1;if(n.edit&&(o=i(n.fileName),m&&E(n,o,m)),n.edit&&o){const o=I(n,t,r);e=o.codeToAppend,g.push({...o.metadata,bundlerBuildId:b,transformedLineOffset:u,transformedColumnOffset:c,indexOffset:n.indexOffset,indexOffsetEnd:n.indexOffsetEnd})}else e=0===a.length?P(n.code,_):n.code;({transformedCodeLineOffset:u,transformedCodeColumnOffset:c}=O(e,u,c)),a+=e}catch(r){return f.instrument_logger.error("Failed to patch index",{index:h,filename:t,msg:r instanceof Error?r.message:void 0,stack:r instanceof Error?r.stack:void 0}),{transformedCode:e,metadatas:[],editedChunksSizes:m}}}return{transformedCode:a,metadatas:g,editedChunksSizes:m}}function P(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 O(e,t,r){const n=e.split("\n");return n.length>1?(t+=n.length-1,r=n.pop()?.length||0):r+=e.length,{transformedCodeLineOffset:t,transformedCodeColumnOffset:r}}function T(e,t,r,n,o){if(e.startsWith(d.hudConfig.esbuildMark))return f.instrument_logger.info("Editing in splits"),M(e,t,r,!1);{const i=w(e,{filename:t,format:r},n,d.hudConfig.userConfig.disableSourceMapsResolution?.value??!0,!1,o);return{transformedCode:i.code,metadatas:[i]}}}let F=0;function N(e,t){F+=e;const r=d.hudConfig.userConfig?.maxMappedFunctions?.value??0;F>=r&&(t||f.customer_logger.log(l.UserErrorLogs.InstrumentedFunctionCountExceeded(r)),f.app_logger.error("Instrumented function count exceeded",{instrumentedFunctionsCount:F,maxMappedFunctions:r}),(0,p.detachHud)(!1,!1))}},3903:e=>{"use strict";e.exports=require("uuid")},4290:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(8949),i=r(5128),s=r(714);class a extends s.FrameworkPatcher{_patch(e){return this._patchCreate(e),n.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];"function"==typeof t.constructor&&"function"==typeof r?e[1]=(0,i.wrapLinkedFunction)(r):n.instrument_logger.error("Invalid args in NestJS RpcContextCreator.create",{args:e})}catch(e){n.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,o.copyPropertiesToTarget)(t,e.RpcContextCreator.prototype.create)}}t.default=a},4393:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HttpEndpointMetric=t.ApiProtocol=void 0;const n=r(9873);var o;!function(e){e.REST="rest",e.GraphQL="graphql"}(o||(t.ApiProtocol=o={}));class i extends n.FlowMetric{statusCode;apiProtocol;apiProtocolAttributes;constructor(e){super(e)}_createUsableMetric(e){return this}setRequestAttributes(e){const t=e.url||e.path;this.apiProtocol=o.REST,this.apiProtocolAttributes={route:t?.split("?")[0],method:e.method}}setGraphQLAttributes(e,t){this.apiProtocol=o.GraphQL,this.apiProtocolAttributes={errorOccurred:e,errors:t}}setResponseAttributes(e){this.statusCode=e.statusCode}toRaw(){if(!this.statusCode)return;if(this.apiProtocol===o.GraphQL){const e=this.apiProtocolAttributes;return{flow_id:this.flowId,type:"GraphQLMetric",duration:this.duration,status_code:this.statusCode,error_occurred:e.errorOccurred,error_breakdown:this.errorBreakdown}}if(this.apiProtocol!==o.REST)return;const e=this.apiProtocolAttributes;return e.route&&e.method?{flow_id:this.flowId,type:"EndpointMetric",duration:this.duration,status_code:this.statusCode,route:e.route,method:e.method,error_breakdown:this.errorBreakdown}:void 0}}t.HttpEndpointMetric=i},4815:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=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||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.patchUse=function(e,t,r=!0){const n=e.use;e.use=function(e){const o=n.apply(this,arguments);try{let n=this[f.uuidSymbol];!n&&f.isVerboseLoggingEnabled&&(n=d.randomUUID(),this[f.uuidSymbol]=n,c.instrument_logger.info("Express use setting uuid",{kind:t,uuid:n})),"application"===t?function(e,t,r,n){try{r&&(e._router?p(e._router):e.router?p(e.router):c.instrument_logger.warning("Express application doesn't have router or _router")),n&&f.isVerboseLoggingEnabled&&c.instrument_logger.info("Express use app",{parent:n,child:t[1]?.[f.uuidSymbol]||"no uuid",path:t[0]})}catch(e){c.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,n):"router"===t&&function(e,t,r,n,o){try{if(!e.stack)return void c.instrument_logger.error("Express router without stack");if(0===e.stack.length)return void c.instrument_logger.warning("Express router with an empty stack");"query"===e.stack[0].name?p(e):f.isVerboseLoggingEnabled&&!f.skipLayerNamesLogs.has(e.stack[0].name)&&(f.skipLayerNamesLogs.add(e.stack[0].name),c.instrument_logger.warning("Found unknown stack name",{stack:e.stack[0].name}));const{path:i,offset:s}=function(e){let t=0,r="/";if("function"!=typeof e){let n=e;for(;Array.isArray(n)&&0!==n.length;)n=n[0];"function"!=typeof n&&(t=1,r=e)}return{path:r,offset:t}}(o),u=g(Array.prototype.slice.call(t,s));for(let t=0;t<u.length&&t<e.stack.length;t++){const o=e.stack[e.stack.length-t-1],s=u[u.length-t-1];"router"===o.name?(s&&!s[f.uuidSymbol]&&f.isVerboseLoggingEnabled&&(s[f.uuidSymbol]=d.randomUUID(),c.instrument_logger.info("Express handle router setting uuid",{uuid:s[f.uuidSymbol]})),r&&(o[a.hudConfig.express.routeNamesSymbol]=i)):f.isVerboseLoggingEnabled&&!f.skipLayerNamesLogs.has(o.name)&&(f.skipLayerNamesLogs.add(o.name),c.instrument_logger.warning("Found unknown layer name",{layer:o.name,parent:n,child:s[f.uuidSymbol]||"no uuid",path:i}))}}catch(e){c.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,n,e)}catch(e){c.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 o},(0,l.copyPropertiesToTarget)(n,e.use)},t.extractEndpointsFromRouter=function e(t,r){let n=[];if(!r.stack)return c.instrument_logger.error("Router without stack - bad OTEL version",{router:r}),n;for(const o of r.stack)if("router"===o.name){if(!o[a.hudConfig.express.routeNamesSymbol]){c.instrument_logger.error("Router layer without routes",{layer:o});continue}const r=t+o[a.hudConfig.express.routeNamesSymbol];n=n.concat(e(r,o.handle))}else o.route&&o.route[a.hudConfig.express.layerStateSymbol]?n=n.concat(h(o,t)):f.isVerboseLoggingEnabled&&!f.skipLayerNamesLogs.has(o.name)&&(f.skipLayerNamesLogs.add(o.name),c.instrument_logger.warning("Found unknown layer name when extracting endpoints",{layer:o.name}));return n};const a=r(5809),u=r(8528),c=r(523),d=s(r(6982)),l=r(8949),f=r(7225),g=r(5673);function p(e){e[a.hudConfig.express.markedSymbol]||(globalThis.hudExpressState.push(e),e[a.hudConfig.express.markedSymbol]=!0)}function h(e,t){const r=[];for(const[n,o]of Object.entries(e.route[a.hudConfig.express.layerStateSymbol]))r.push(new u.EndpointDeclaration(n,o.methods,"express",t,o.layerPath));return Array.from(r.values())}},5128:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHudLfMarked=void 0,t.wrapLinkedFunction=function(e){if(e[t.isHudLfMarked])return e;let r;e[t.isHudLfMarked]=!0;const a=(0,i.getFlowStateStorage)();return a?(r=e instanceof s.AsyncFunction?async function(...t){if(hudRunningMode!==n.HudRunningMode.enabled)return await e.apply(this,t);let r;try{r=a.getStore()}catch(r){return o.instrument_logger.error("Failed to get flowState",{msg:r instanceof Error?r.message:void 0,stack:r instanceof Error?r.stack:void 0}),await e.apply(this,t)}return r?(r.shouldLinkFunction=!0,await e.apply(this,t)):await e.apply(this,t)}:function(...t){if(hudRunningMode!==n.HudRunningMode.enabled)return e.apply(this,t);let r;try{r=a.getStore()}catch(r){return o.instrument_logger.error("Failed to get flowState",{msg:r instanceof Error?r.message:void 0,stack:r instanceof Error?r.stack:void 0}),e.apply(this,t)}return r?(r.shouldLinkFunction=!0,e.apply(this,t)):e.apply(this,t)},(0,s.copyPropertiesToTarget)(e,r),r):e};const n=r(8528),o=r(523),i=r(7131),s=r(8949);t.isHudLfMarked=Symbol.for("isHudLfMarked")},5150:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(5809),o=r(8269),i=r(2546),s=r(523),a=r(7131),u=r(2822),c=r(8949),d=r(2080),l=r(714);class f extends l.FrameworkPatcher{isSupported(e,t,r,o){const a=n.hudConfig.userConfig.enableDapulse?.value?o.mondayVersion:o.bbcVersion,u=(0,l.extractModuleVersion)(e);return!!(0,l.isSupportedVersion)(u,a)||(s.instrument_logger.warning("Unsupported sqs-consumer version",{framework:"SqsConsumer",version:u,supportedVersion:a,basedir:e,isDapulse:n.hudConfig.userConfig.enableDapulse?.value}),s.customer_logger.log(i.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 i.HudNoQueueUrlInSqsConsumer;const r=h(t);if(e.handleMessageBatch&&"function"==typeof e.handleMessageBatch){const t="handleMessageBatch",n=(0,i.generateSqsFlowId)(r,t);(0,o.storeSqsQueueDeclaration)({flow_id:n,queue_name:r,handle_type:t,batch_size:e.batchSize});const s=e.handleMessageBatch,a=(0,c.wrapFlow)(()=>n,s,!0,m);return void(e.handleMessageBatch=a)}if(e.handleMessage&&"function"==typeof e.handleMessage){const t="handleMessage",n=(0,i.generateSqsFlowId)(r,t);(0,o.storeSqsQueueDeclaration)({flow_id:n,queue_name:r,handle_type:t});const s=e.handleMessage,a=(0,c.wrapFlow)(()=>n,s,!0,m);return void(e.handleMessage=a)}s.instrument_logger.warning("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 i.HudNoEventTypeInSqsConsumerOn;const n=r[1];if(!n||"function"!=typeof n)throw new i.HudNoCallbackInSqsConsumerOn;const s=h(e.queueUrl),a="event",u=(0,i.generateSqsFlowId)(s,a,t);(0,o.storeSqsQueueDeclaration)({flow_id:u,queue_name:s,handle_type:a,event_type:t}),r[1]=(0,c.wrapFlow)(()=>u,n,!0,y,_,b)}catch(e){s.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)},(0,c.copyPropertiesToTarget)(t,e.on)}(r),function(e){const t=e.emit;e.emit=function(...e){return function(e){try{const t=e[0];if(!t||"string"!=typeof t)throw new i.HudNoEventTypeInSqsConsumerEmit;let r,o;if("message_processed"===t&&(r=1),["error","timeout_error","processing_error"].includes(t)&&(o=1,r=2),void 0===r)return;const c=e[r];if(!c)throw new i.HudNoMessageInSqsConsumerEmit;let d;if(void 0!==o){const t=e[o];if(!(t&&t instanceof Error))throw new i.HudNoErrorInSqsConsumerEmit;d=(0,a.extractName)(t),"StandardError"===d&&t.cause&&t.cause instanceof Error&&(d=(0,a.extractName)(t.cause))}const l=(e,t)=>{const r=e[n.hudConfig.metricSymbol];r?(d&&r.addError(d,t),r.increaseAndShouldEnd(t)&&(r.calculateDuration(),(0,u.finishSqsInvestigation)(Array.isArray(c)?c:[c],r),r.end())):p||(p=!0,s.instrument_logger.warning("No metric found for message"))};Array.isArray(c)&&c.length>=1?l(c[0],c.length):l(c,1)}catch(e){g||(g=!0,s.instrument_logger.error("Error in SqsConsumer.Consumer.emit patched logic",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0}))}}(e),t.apply(this,e)},(0,c.copyPropertiesToTarget)(t,e.emit)}(r)}catch(e){s.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,c.copyPropertiesToTarget)(t,e.Consumer.create)}(e),s.instrument_logger.info("Patched sqs-consumer successfully",{isDapulse:n.hudConfig.userConfig.enableDapulse?.value}),e}}t.default=f;let g=!1,p=!1;function h(e){const t=e.split("/").pop();if(!t)throw new i.HudFailExtractSqsQueueName(`Url: ${e}`);return t}function m(e,t,r){const o=d.SqsMetric.createUsableMetric(e);o.start();const i=r[0];if(!i)return s.instrument_logger.warning("No messages pass to sqs handler",{flowId:e}),void(t.flowMetric=o);if(Array.isArray(i)){if(o.msgCount=i.length,i.forEach(e=>{e[n.hudConfig.metricSymbol]=o}),i[0]?.Attributes?.SentTimestamp){const t=i.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:s.instrument_logger.warning("No valid SentTimestamp found eventhough the first element had SentTimestamp",{flowId:e})}}else o.msgCount=1,i[n.hudConfig.metricSymbol]=o,i?.Attributes?.SentTimestamp&&(o.e2eEpocStartTimeMS=i.Attributes.SentTimestamp);t.flowMetric=o,(0,u.createNewInvestigation)()}function y(e,t,r){const n=d.SqsMetric.createUsableMetric(e);n.start(),t.flowMetric=n}function _(e,t){const r=t.flowMetric;r?r.end():s.instrument_logger.warning("No flowMetric found for message during catch",{flowId:e})}function b(e,t,r){const n=t.flowMetric;n?(n.addError((0,a.extractName)(r)),n.end()):s.instrument_logger.warning("No flowMetric found for message during catch",{flowId:e})}},5354:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(714),i=r(5809),s=r(8528),a=r(8269),u=r(9938);class c extends o.FrameworkPatcher{_patch(e){return n.instrument_logger.info("Patching axios"),this._patchRequest(e),this._createAxiosDeclaration(),n.instrument_logger.info("Patched axios successfully"),e}_patchRequest(e){const t=e.Axios.prototype.request;e.Axios.prototype.request=(0,u.wrapOutboundFunction)(t,i.hudConfig.axiosFunctionId,e=>{const t=e[0];return{url:"string"==typeof t.url?t.url:void 0,method:t.method,body:t.data}},(e,t,r)=>{(0,u.reduceRequestArgsIfNeeded)(e,r,e=>Number.parseInt(e?.request?._contentLength));const n=Number.parseInt(e.headers.get("content-length")),o=isNaN(n)||0===n?void 0:n;return{status_code:e.status,body:(0,u.getReducedBody)(e.data,o,i.hudConfig.dynamicConfig.maxHTTPResponseBodySize),bodySize:o}},s.OutboundType.HTTP)}_createAxiosDeclaration(){(0,a.storeLoadedOutbound)("axios")}}t.default=c},5459:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(7131),i=r(2822),s=r(8949),a=r(4393),u=r(714);class c extends u.FrameworkPatcher{_patch(e){return this._patchEmit(e),n.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]);const s=(0,o.getFlowStateStorage)(),u=r?.[0],c=r?.[1],d=a.HttpEndpointMetric.createUsableMetric(),l=()=>{try{d.start(),(0,i.createNewInvestigation)(),d.setRequestAttributes(u),c.once("finish",function(){try{d.calculateDuration(),(0,i.finishHttpInvestigation)(u,c,d),d.setResponseAttributes(c),d.end()}catch(e){n.instrument_logger.error("Failed to set response attributes",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}})}catch(e){n.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])};return s?s.run({httpMetric:d},l):l()},(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.hudRITM=void 0,t.safeLog=function(e){try{s.app_logger.debug(e)}catch{return}},t.registerHook=function(){if(s.app_logger.info("HUD is required"),process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE){if(s.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 s.app_logger.warning("Lambda function memory size is less than required, Hud will not run",{memorySize:e,requiredMemory:n.hudConfig.lambdaMinimunMemory}),s.customer_logger.log(i.UserErrorLogs.UnsupportedLambdaMemory(n.hudConfig.lambdaMinimunMemory)),!1}globalThis.hudRuningInsideLambda=!0}return(0,o.initGlobals)(),s.app_logger.debug("InitGlobals done"),!(globalThis.hudStartFromAutoInit&&!(0,o.validateAndGetUserInput)())&&(s.instrument_logger.isValid()?globalThis.hudRanOnRequire?(s.instrument_logger.warning("Already ran onRequire!"),!1):(globalThis.hudRanOnRequire=!0,s.instrument_logger.info("Using module",{name:n.SDK_MODULE_NAME}),n.hudConfig.userConfig.enableFrameworks&&s.instrument_logger.info("User enabled frameworks",{frameworks:(0,a.getEnabledFrameworks)()}),(0,a.onRequire)(),(0,i.detectNextJsApp)(),s.instrument_logger.debug("onRequire done"),globalThis.hudInitGuard=setTimeout(u,n.hudConfig.userConfig.maxTimeUntilInitSessionMs?.value??0),globalThis.hudInitGuard.unref(),!0):((0,o.detachHud)(!1),!1))};const n=r(5809),o=r(8269),i=r(2546),s=r(523),a=r(7166);function u(){s.instrument_logger.critical("Init timeout reached - disabling hud"),s.customer_logger.log(i.UserErrorLogs.InitTimeout(globalThis.hudIsRunningFromSetup)),(0,o.detachHud)(!1)}t.hudRITM=a.onRequireFn},5809:e=>{"use strict";e.exports=require("./config")},5946:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(6730),i=r(4815),s=r(714);class a extends s.FrameworkPatcher{_patch(e){return(0,i.patchUse)(e.prototype,"router"),(0,o.patchMethods)(e.prototype,"router"),n.instrument_logger.info("Patched router successfully"),e}}t.default=a},6093:e=>{"use strict";e.exports=require("@cspotcode/source-map-support")},6730:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=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||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.getMethods=f,t.patchMethods=function(e,t){f().concat("all").forEach(function(r){const n=e[r];if(!n)return void(l.isVerboseLoggingEnabled&&u.instrument_logger.warning("Method not found",{method:r}));const o="all"===r;e[r]=function(){try{if(arguments.length<2)return n.apply(this,arguments);let e=this[l.uuidSymbol];l.isVerboseLoggingEnabled&&(e||(e=c.randomUUID(),this[l.uuidSymbol]=e,u.instrument_logger.info("Express method setting uuid",{uuid:e,kind:t})),u.instrument_logger.info("Express added new method",{method:r,uuid:e,path:arguments[0]}));const i=Array.prototype.slice.call(arguments);if(i[1][a.hudConfig.express.layerStateSymbol]={flowId:[],kind:t,allMethod:o},Array.isArray(i[0]))for(const e of i[0]){const e=c.randomUUID();i[1][a.hudConfig.express.layerStateSymbol].flowId.push(e)}else i[1][a.hudConfig.express.layerStateSymbol].flowId.push(c.randomUUID());const s=n.apply(this,i);try{delete i[1][a.hudConfig.express.layerStateSymbol]}catch{}return s}catch(e){u.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 n.apply(this,arguments)},(0,d.copyPropertiesToTarget)(n,e[r])})};const a=r(5809),u=r(523),c=s(r(6982)),d=r(8949),l=r(7225);function f(){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"]}},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 n=r(523),o=r(6730),i=r(2977),s=r(4815),a=r(7225),u=r(714);class c extends u.FrameworkPatcher{_patch(e){return(0,i.patchRoute)(e.Route),(0,s.patchUse)(e.application,"application"),(0,o.patchMethods)(e.application,"application"),a.isVerboseLoggingEnabled&&(0,a.logLazyRouter)(e.application),e.Router.use?((0,s.patchUse)(e.Router,"router"),(0,o.patchMethods)(e.Router,"router")):n.instrument_logger.warning("Skipping express.Router patching"),n.instrument_logger.info("Patched express successfully"),e}}t.default=c},7131:e=>{"use strict";e.exports=require("./wrap")},7166:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=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||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.parseCliInstrumentationPattern=k,t.supportSourceMapInstall=S,t.patch=C,t.patchCompile=M,t.onRequireFn=P,t.patchRequire=O,t.isFrameworkEnabled=T,t.getEnabledFrameworks=function(){const e=new Map;for(const[t,r]of g.hudConfig.frameworksToPatch)e.set(r.framework,T(r,g.hudConfig.userConfig.enableFrameworks));return Object.fromEntries(e)},t.getFunctionsToInstrument=R,t.createCheckers=D,t.updateModuleChecker=A,t.skip=q,t.onRequire=function(){try{(0,d.setInstrumentedFilesCountInterval)(),A();try{M()}catch(e){l.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,d.shouldSupportSourceMap)()&&S()}catch(e){l.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{O()}catch(e){l.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){l.instrument_logger.error("Something went wrong in onRequire",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}try{(0,h.saveMachineMetric)()}catch(e){l.instrument_logger.error("Failed to add metric",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}};const a=s(r(9896)),u=s(r(6928)),c=r(8528),d=r(2546),l=r(523),f=r(3901),g=r(5809),p=r(8528),h=r(8269),m=r(2546),y=r(9063),_=r(714),b=function(){const e=g.SDK_MODULE_NAME;try{return u.dirname(u.dirname(m.myRequire.resolve(e)))}catch(t){return l.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 v(e){const t=globalThis.HudSourceMapCache.get(e);return t?{map:JSON.parse(t)}:null}const w=new RegExp(`//"([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})";${g.hudConfig.cliSdkVersionVarName}="([^"]+)";${g.hudConfig.cliBuildIdVarName}`);function k(e){if(e.slice(-g.hudConfig.cliBuildIdVarName.length)!==g.hudConfig.cliBuildIdVarName)return null;const t=Math.min(100,e.length),r=e.slice(-t).match(w);return r?{buildId:r[1],sdkVersion:r[2],fullPattern:r[0]}:null}function S(){r(6093).install({handleUncaughtExceptions:!1,hookRequire:!1,environment:"node",retrieveSourceMap:v})}function C(e,t,r,n){const o={code:e,map:void 0};try{if(globalThis.hudRunningMode===p.HudRunningMode.detached)return o;if(r===c.Format.esm&&!n)throw new m.HudError("MessagePort is required for patching ESM modules");const i=k(e);if(i)return i.sdkVersion!==g.SDK_VERSION?(l.instrument_logger.critical("SDK version mismatch detected, disabling SDK",{filename:t,cliSdkVersion:i.sdkVersion,currentSdkVersion:g.SDK_VERSION}),(0,h.detachHud)(!1,!1),o):((0,h.addReingestValue)(i.buildId),globalThis.hudInstrumentationIndicator&&(0,h.clearInstrumentationIndicator)(),o);if(g.hudConfig.userConfig.disableRuntimeInstrumentation?.value)return o;const s=R(t);if(q(t,void 0,s))return o;if(e.length>(g.hudConfig.userConfig.maxFileSizeBytes?.value??0)&&!e.startsWith(g.hudConfig.esbuildMark))return l.instrument_logger.info("Skipping large file",{filename:t,size:e.length}),o;const y=(0,f.edit)(e,t,r,s,!1),_=y.metadatas;if(o.code=y.transformedCode,o.map=_,n)for(const e of _)n.postMessage({key:"HudModulePatch",hudPatched:t,hudProcessedFiles:(0,d.sourceFileMetadataToTransferSourceFileMetadata)(e)});else globalThis.hudPatched.add(t),globalThis.hudProcessedFiles.push(..._.map(e=>(0,d.sourceFileMetadataToTransferSourceFileMetadata)(e)));for(const e of _)e.functionIds.length>0&&(globalThis.hudInstrumentationOccured=!0,globalThis.hudInstrumentationIndicator&&(0,h.clearInstrumentationIndicator)());g.hudConfig.writePatched&&function(e,t){const r=u.parse(e);let n=`${r.dir}/patched.${r.base}`;r.dir.includes("dist")&&(n=u.join(`${r.dir.replace("dist","patched")}`,r.base)),a.existsSync(u.dirname(n))||a.mkdirSync(u.dirname(n),{recursive:!0}),a.writeFileSync(n,t,"utf8"),l.instrument_logger.debug("Dumped patched file",{filename:e,patchedPath:n})}(t,y.transformedCode)}catch(e){l.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 o}let x="",E=!0,I=!1;function M(){if(!(0,m.isSupportedNative)())return;const e=r(3339),t=(0,d.shouldSupportSourceMap)();I&&l.instrument_logger.warning("PatchCompile ran twice"),0===Object.keys(globalThis.hudLoadedModules).length&&(globalThis.hudLoadedModules=Object.keys(m.myRequire.cache));const n=e.prototype._compile;e.prototype._compile=function(e,r){const o=process.hrtime.bigint();let i=0,s=0,a=0,u=!1;try{if(r===x){try{const e=E?l.instrument_logger.warning.bind(l.instrument_logger):l.instrument_logger.debug.bind(l.instrument_logger);E=!1,e("Skipping compile since already ran",{filename:r})}catch{}const t=process.hrtime.bigint(),o=n.call(this,e,r);return i=Number(process.hrtime.bigint()-t),o}x=r,l.instrument_logger.debug("Compiling requirement",{filename:r});const o=C(e,r,c.Format.cjs);o.map&&(u=!0),s=o.map?.reduce((e,t)=>e+t.functionIds.length,0)??0,a=o.map?.reduce((e,t)=>e+t.totalFunctionsCountIncludeUninstrumented,0)??0;try{if(t&&o.map){const e=(0,d.combineSourceMaps)(o.map,r);e&&globalThis.HudSourceMapCache.set(r,e)}}catch(e){l.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 f=process.hrtime.bigint(),g=n.call(this,o.code,r);return i=Number(process.hrtime.bigint()-f),x="",g}finally{const t=Number(process.hrtime.bigint()-o)-i;u&&l.instrument_logger.debug("Patched",{filename:r,time:t}),(0,d.incrementInstrumentedStats)(u,t,i,e.length,s,a)}},I=!0,l.instrument_logger.debug("Patched _compile")}function P(e,t,r){try{const n=g.hudConfig.frameworksToPatch.get(t);return T(n,g.hudConfig.userConfig.enableFrameworks)&&n?.patcher&&n.version?(0,_.getFrameworkPatcher)(n.patcher).patch(e,r,n.version,n.extraInfo,t):e}catch(e){l.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 O(){const e=Array.from(g.hudConfig.frameworksToPatch.entries()).filter(([e,t])=>T(t,g.hudConfig.userConfig.enableFrameworks)).map(([e])=>e);new y.Hook(Array.from(e),{internals:!0},P)}function T(e,t){return!!e&&(t&&t.value?.has(e.framework)?t.value.get(e.framework)||!1:e.enable)}function F(e){const t=u.sep.replace(/\\/g,"\\\\"),r=u.join(e).split(".").join("\\.").split("*").join(".*?"),n=t+"node_modules"+t;return{isAllowdModule:new RegExp(n+r+`(?:${t}|$)`),isAllowdModuleSubModule:new RegExp(n+r+n)}}function N(e,t){return!!t.isAllowdModule.test(e)&&!t.isAllowdModuleSubModule.test(e)}function j(e,t){const r=t.replace(/\//g,u.sep);return e.includes(`node_modules${u.sep}${r}${u.sep}`)&&!e.includes(`node_modules${u.sep}${r}${u.sep}node_modules`)}function R(e){return(0,m.getInstrumentedThirdPartyModuleInfo)(e)?.functions||[]}function D(e){const t=[];for(const r of e){let e;if(r.includes("*")){const t=F(r);e=e=>N(e,t)}else e=e=>j(e,r);t.push(e)}return t}let L=[];function A(){L=D(g.hudConfig.userConfig.includeModules?.value??[])}function q(e,t,r=[]){if(!g.hudConfig.allowedEditExtensions.includes(u.extname(e))&&!e.endsWith(u.sep))return l.instrument_logger.warning("Skipping non-allowed extension",{filename:e}),!0;const n=t??L;return"/var/runtime/index.mjs"===e?(l.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,n)&&0===r.length||e.includes(".yarn")?(l.instrument_logger.debug("Skipping non-monitored imported module",{filename:e}),!0):!(b&&!e.includes(b)||(l.instrument_logger.debug("Skipping hud internal module",{filename:e}),0))}},7214:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(5809),o=r(8269),i=r(2546),s=r(523),a=r(7131),u=r(8949),c=r(714);class d extends c.FrameworkPatcher{static graphQLPatchedSymbol=Symbol.for(n.hudConfig.hudPatchedName);_patch(e){return this.patchExecute(e),s.instrument_logger.info("Patched GraphQL successfully"),e}patchExecute(e){const t=e.execute,r=(0,u.wrapFlow)(function(e,t){let r;if(e.operation)return e.operation.flow_id;try{if(t.length<1)return;const n=t[0];if(n.document.definitions.length>1){if(n.operationName)for(const t of n.document.definitions)if(r=l(e,t,n.operationName),r)break}else r=l(e,n.document.definitions[0])}catch(e){s.instrument_logger.error("Failed to store graphql operations",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return r?.flow_id},t,!1,void 0,function(e,t,r){return function(e,t){return"function"==typeof e.then?e.then(e=>(f(e,t),e)):(f(e,t),e)}(r,t.operation)});e.execute=r}}function l(e,t,r){const n=function(e){return e&&e.name?e.name.value:"anonymous"}(t),s=function(e){return e&&e.operation?e.operation:"query"}(t);if(!r||r===n){const t={flow_id:(0,i.generateGraphqlFlowId)(n,s),operation_name:n,operation_type:s};return(0,o.storeGraphQLOperation)(t),e.operation=t,t}}function f(e,t){try{if(!t)return;const r=(0,a.getHttpMetricFromFlowState)();if(!r)return void s.instrument_logger.warning("No http metric found for graphql operation",{operation_name:t.operation_name,operation_type:t.operation_type});r.setFlowId(t.flow_id),r.setGraphQLAttributes(!!e.errors&&e.errors.length>0,e.errors)}catch(e){s.instrument_logger.error("Failed to set flowId and graphql attributes in http metric",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}t.default=d},7225:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=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||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.skipStackNamesLogs=t.skipLayerNamesLogs=t.isVerboseLoggingEnabled=t.uuidSymbol=void 0,t.logLazyRouter=function(e){const r=e.lazyrouter;e.lazyrouter=function(){let e=!1;try{this._router||(e=!0)}catch(e){a.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 n=r.apply(this,arguments);try{if(e){let e=this[t.uuidSymbol];e||(e=u.randomUUID(),this[t.uuidSymbol]=e,a.instrument_logger.info("Express lazy router setting uuid",{uuid:e})),a.instrument_logger.info("Express lazy router",{parent:e,child:this._router?.[t.uuidSymbol]})}}catch(e){a.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 n},(0,d.copyPropertiesToTarget)(r,e.lazyrouter)};const a=r(523),u=s(r(6982)),c=r(932),d=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"])},7276:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8544);class o extends n.BaseKafkaJSPatcher{getExportsRoot(e){return e.KafkaJS}getGroupId(e){return e[0].kafkaJS.groupId}moduleName(){return"@confluentinc/kafka-javascript.KafkaJS"}}t.default=o},7427:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(714),i=r(5809),s=r(8528),a=r(8269),u=r(9938);class c extends o.FrameworkPatcher{_patch(e){return n.instrument_logger.info("Patching pg"),this._patchConnect(e),this._patchQuery(e),this._patchEnd(e),this._createPgDeclaration(),n.instrument_logger.info("Patched pg successfully"),e}_patchConnect(e){const t=e.Client.prototype.connect;e.Client.prototype.connect=(0,u.wrapOutboundFunction)(t,i.hudConfig.pgConnectFunctionId,void 0,void 0,s.OutboundType.DB)}_patchEnd(e){const t=e.Client.prototype.end;e.Client.prototype.end=(0,u.wrapOutboundFunction)(t,i.hudConfig.pgEndFunctionId,void 0,void 0,s.OutboundType.DB)}_patchQuery(e){const t=e.Client.prototype.query;e.Client.prototype.query=(0,u.wrapOutboundFunction)(t,i.hudConfig.pgQueryFunctionId,e=>({query:e[0],params:e[1]}),e=>({rowsCount:e.rowCount}),s.OutboundType.DB)}_createPgDeclaration(){(0,a.storeLoadedOutbound)("pg")}}t.default=c},7603:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getObservabilityIdentifiers=s,t.getObservabilityIdentifiersHttp=function(e){return{...s(),w3c_trace_context:a(e),w3c_baggage:c(e,"baggage"),amazon_trace_id:c(e,"x-amzn-trace-id"),b3_propagation:u(e),jaeger_trace_id:c(e,"uber-trace-id")}},t.getExtraHeaders=function(e){const t={};for(const r of n.hudConfig.dynamicConfig.extraHeaders){const n=c(e,r);void 0!==n&&(t[r]=n)}return t},t.getDatadogIds=f,t.getOtelTraceId=p;const n=r(5809),o=r(2546),i=r(523);function s(){const e=f();return{datadog_trace_id:e?.trace_id,datadog_span_id:e?.span_id,otel_trace_id:p()}}function a(e){try{return{traceparent:c(e,"traceparent"),tracestate:c(e,"tracestate")}}catch{return}}function u(e){try{return{full:c(e,"b3"),trace_id:c(e,"x-b3-traceid"),span_id:c(e,"x-b3-spanid"),parent_span_id:c(e,"x-b3-parentspanid")}}catch{return}}function c(e,t){try{return e.headers[t]}catch{return}}function d(e){let t;return()=>(void 0===t&&(t=function(e){try{const t=o.myRequire.resolve(e),r=o.myRequire.cache[t];return void 0===r?(i.instrument_logger.info("requireFromCache: codeModule is undefined",{path:e,fullPath:t}),null):"object"!=typeof r.exports?(i.instrument_logger.warning("requireFromCache: codeModule.exports is not an object",{path:e}),null):r.exports}catch(t){return i.instrument_logger.warning("requireFromCache: error",{path:e,error:t}),null}}(e)),t)}const l=d("dd-trace/packages/datadog-core");function f(){try{const e=l();if(null===e)return;const{storage:t}=e,r=t("legacy").getStore();return{trace_id:r.span._spanContext.toTraceId(),span_id:r.span._spanContext.toSpanId()}}catch{return}}const g=d("@opentelemetry/api");function p(){try{const e=g();if(null===e)return;const{trace:t}=e;return t.getActiveSpan()?.spanContext().traceId}catch{return}}},7808:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getMachineMetrics=function(){try{const e=(0,o.getLastMetrics)();return{cpu_usage:e.cpuUsage?l(e.cpuUsage,e.timestamp):void 0,memory_usage:d(),event_loop_utilization:e.elu?c(e.elu):void 0}}catch(e){return void s.app_logger.error("Error getting machine metrics",e)}},t.getCpuUsage=l;const o=r(8269),i=r(2546),s=r(523),a=n(r(857)),u=r(2987);function c(e){try{return u.performance.eventLoopUtilization(e).utilization}catch(e){return void s.app_logger.error("Error getting event loop utilization",e)}}function d(){try{const e=process.memoryUsage(),t=a.default.totalmem();return{rss:e.rss,heap_total:e.heapTotal,heap_used:e.heapUsed,external:e.external,system_memory:t,rss_percentage:e.rss/t*100}}catch(e){return void s.app_logger.error("Error getting memory usage",e)}}function l(e,t){try{const r=process.cpuUsage(),n=1e3*(Date.now()-t),o=(0,i.getCpuLimit)(s.app_logger),a=(r.user-e.user)/n,u=(r.system-e.system)/n;return{user_time:a,system_time:u,limit:o,user_percent_of_limit:"number"==typeof o?a/o*100:void 0,system_percent_of_limit:"number"==typeof o?u/o*100:void 0}}catch(e){return void s.app_logger.error("Error getting cpu usage",e)}}},8064:e=>{"use strict";e.exports=require("semver")},8269:e=>{"use strict";e.exports=require("./globalstate")},8528:e=>{"use strict";e.exports=require("./dto")},8544:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BaseKafkaJSPatcher=void 0;const n=r(8269),o=r(2546),i=r(523),s=r(2822),a=r(8949),u=r(828),c=r(714);class d extends c.FrameworkPatcher{_patch(e){const t=this.getExportsRoot(e);return this._patchConsumer(t),i.instrument_logger.info(`Patched ${this.moduleName()} successfully`),e}_patchConsumer(e){const t=e.Kafka.prototype.consumer;if(!t)return void i.instrument_logger.error("DD presumably ran before HUD - exports.Kafka.prototype.consumer is undefined");const r=this.getGroupId.bind(this);e.Kafka.prototype.consumer=function(...e){const n=t.apply(this,e);try{const t=new Map,o=[],c=[];!function(e,t){const r=e.subscribe;e.subscribe=async function(...e){const n=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):i.instrument_logger.warning("No topic found in KafkaJS.Consumer.subscribe",{args:e[0]})}catch(e){i.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 n},(0,a.copyPropertiesToTarget)(r,e.subscribe)}(n,c),function(e,t,r,n,o){const c=e.run;function d(e,c){const d="eachBatch"===c;for(const e of o)p(e,n,t,r,c);const h=function(e,t,r){return(n,o)=>{const s=o[0],a=r?s.batch.topic:s.topic;return function(e,t,r,n){const o=e.get(g(r,n));if(o)return o;for(const e of t)if(e.isBatch===n&&e.pattern.test(r))return e.flowId;i.instrument_logger.warning("No flowId found for topic",{topicName:r,isBatch:n})}(e,t,a,r)}}(t,r,d),m=function(e){return(t,r,n)=>{const o=u.KafkaJSMetric.createUsableMetric();o.start(),o.setFlowId(t),(0,s.createNewInvestigation)();const i=n[0],a=e?i.batch.partition:i.partition,c=e?i.batch.messages[0]?.timestamp:i.message?.timestamp;o.addPartition(a),o.addProducedTimestamp(c),r.topic=e?i.batch.topic:i.topic,r.partition=e?i.batch.partition:i.partition,r.messages=e?i.batch.messages:[i.message],r.flowMetric=o}}(d),y=(0,a.wrapFlow)(h,e[c],!0,m,l,f);e[c]=y}e.run=async function(...e){try{const t=e[0];t.eachMessage&&d(t,"eachMessage"),t.eachBatch&&d(t,"eachBatch")}catch(e){i.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,a.copyPropertiesToTarget)(c,e.run)}(n,t,o,r(e),c)}catch(e){i.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 n},(0,a.copyPropertiesToTarget)(t,e.Kafka.prototype.consumer)}}function l(e,t){const r=t.flowMetric;r?(r.calculateDuration(),(0,s.finishKafkaJSInvestigation)(t.messages,r,t.topic,t.partition),r.end()):i.instrument_logger.warning("No flowMetric found for message",{flowId:e})}function f(e,t,r){const n=t.flowMetric;n?(n.setError(r),n.calculateDuration(),(0,s.finishKafkaJSInvestigation)(t.messages,n,t.topic,t.partition),n.end()):i.instrument_logger.warning("No flowMetric found for message",{flowId:e})}function g(e,t){return e+"|"+t}function p(e,t,r,i,s){const a=(0,o.generateKafkaFlowId)(e,t,s),u={flow_id:a,topic_name:e.toString(),group_id:t,pulling_type:s};(0,n.storeKafkaJSTopicDeclaration)(u),function(e,t,r,n,o){"string"==typeof r?e.set(g(r,n),o):t.push({pattern:r,isBatch:n,flowId:o})}(r,i,e,"eachBatch"===s,a)}t.BaseKafkaJSPatcher=d},8564:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(714),i=r(5809),s=r(8528),a=r(8269),u=r(9938),c=Symbol.for("_HUD_outboundIndex");class d extends o.FrameworkPatcher{_patch(e){return n.instrument_logger.info("Patching node-fetch"),e=this._patchFetch(e),this._patchBody(e),this._createNodeFetchDeclaration(),n.instrument_logger.info("Patched node-fetch successfully"),e}_patchFetch(e){return(0,u.wrapOutboundFunction)(e,i.hudConfig.nodeFetchFunctionId,e=>{const t=e[1]?.body,r=(0,u.getBodySize)(t);return{url:e[0],method:e[1]?.method?.toLowerCase()??"get",body:(0,u.getReducedBody)(t,r,i.hudConfig.dynamicConfig.maxHTTPRequestBodySize),bodySize:r}},(e,t)=>(e[c]=t,{status_code:e.status}),s.OutboundType.HTTP)}_patchBody(e){for(const[t,r]of Object.entries(i.hudConfig.nodeFetchBodiesFunctionIds)){const n=e.Response.prototype[t];e.Response.prototype[t]=(0,u.wrapOutboundBodyFunction)(n,r,(e,t)=>e[c],(e,t)=>{const r=Number.parseInt(e.headers.get("content-length")),n=isNaN(r)||0===r?void 0:r;return{body:(0,u.getReducedBody)(t,n,i.hudConfig.dynamicConfig.maxHTTPResponseBodySize),bodySize:n}})}}_createNodeFetchDeclaration(){(0,a.storeLoadedOutbound)("node-fetch")}}t.default=d},8611:e=>{"use strict";e.exports=require("http")},8840:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(523),i=r(8949),s=r(714),a=n(r(9589));class u extends s.FrameworkPatcher{static nextJSHudMarked=Symbol.for("hudNextJSMarked");_patch(e){const t=e.PagesAPIRouteModule||e.default;if(!t||t[u.nextJSHudMarked])return e;const r=this._wrapConstructor(t);t[u.nextJSHudMarked]=!0,o.instrument_logger.info("Patched Next.js route module constructor successfully");const n=Object.create(Object.getPrototypeOf(e));return Object.defineProperty(n,"PagesAPIRouteModule",{enumerable:!0,get:function(){return r}}),e.default===t&&Object.defineProperty(n,"default",{enumerable:!0,get:function(){return r}}),(0,i.copyPropertiesToTarget)(e,n),n}_wrapConstructor(e){const t=function(...t){const r=new e(...t);try{const e=r.definition?.pathname;e&&!r[u.nextJSHudMarked]&&(a.default._detectAndPatchSupportedMethods(r,e),r[u.nextJSHudMarked]=!0)}catch(e){o.instrument_logger.error("Failed to patch Next.js Pages API route module instance",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return r};return(0,i.copyPropertiesToTarget)(e,t),t}}t.default=u},8949:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncFunction=void 0,t.wrapFlow=function(e,r,u=!0,c,d,l){let f;const g=(0,i.getFlowStateStorage)();if(!g)return r;try{if(r[s])return r}catch{return r}return f=r instanceof t.AsyncFunction?async function(...t){let s;const a={};try{s=e(a,t)}catch(e){o.instrument_logger.error("Failed to get flowId",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}if(!s||hudRunningMode!==n.HudRunningMode.enabled)return await r.apply(this,t);if(c)try{c(s,a,t)}catch(e){o.instrument_logger.error("Failed to execute beforeCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}const f=(0,i.getHttpMetricFromFlowState)();f?.setFlowId(s);try{const e=g.run({flowId:s,shouldLinkFunction:u,httpMetric:f},Reflect.apply,r,this,t),n=await e;if(d)try{d(s,a,n)}catch(e){o.instrument_logger.error("Failed to execute afterCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return n}catch(e){if(l)try{l(s,a,e)}catch(e){o.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}}:function(...t){let s;const a={};try{s=e(a,t)}catch(e){o.instrument_logger.error("Failed to get flowId",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}if(!s||hudRunningMode!==n.HudRunningMode.enabled)return r.apply(this,t);if(c)try{c(s,a,t)}catch(e){o.instrument_logger.error("Failed to execute beforeCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}const f=(0,i.getHttpMetricFromFlowState)();f?.setFlowId(s);try{const e=g.run({flowId:s,shouldLinkFunction:u,httpMetric:f},Reflect.apply,r,this,t);if(d||l)if(e instanceof Promise)e.catch(e=>{try{l&&l(s,a,e)}catch(e){o.instrument_logger.error("Failed to execute catchCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}).then(()=>{try{d&&d(s,a,e)}catch(e){o.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{d&&d(s,a,e)}catch(e){o.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(l)try{l(s,a,e)}catch(e){o.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}},a(r,f),f[s]=!0,f},t.copyPropertiesToTarget=a;const n=r(8528),o=r(523),i=r(7131);t.AsyncFunction=(async()=>{}).constructor;const s=Symbol.for("hudMarked");function a(e,t){const r=Object.getOwnPropertyDescriptors(e),n=Reflect.ownKeys(r);Object.setPrototypeOf(t,e),n.forEach(e=>{try{Object.defineProperty(t,e,r[e])}catch{}})}},9063:e=>{"use strict";e.exports=require("require-in-the-middle")},9589:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8528),o=r(8269),i=r(2546),s=r(523),a=r(8949),u=r(714);class c extends u.FrameworkPatcher{static nextJSHudMarked=Symbol.for("hudNextJSMarked");static routeInfoSymbol=Symbol.for("hudNextJSRouteInfo");static standardMethods=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"];_patch(e){return(0,i.setIsNextJsApp)(!0),this._patchBaseServer(e),s.instrument_logger.info("Patched Next.js successfully"),e}_patchBaseServer(e){try{const t=e.default;if(t[c.nextJSHudMarked])return e;const r=t.prototype.renderToResponseWithComponentsImpl;if(!r)return s.instrument_logger.error("Could not find renderToResponseWithComponentsImpl on BaseServer.prototype"),e;t.prototype.renderToResponseWithComponentsImpl=async function(e,t,...n){try{const r=t.components;if(r&&r.routeModule&&!r.routeModule[c.nextJSHudMarked]){const t=r.routeModule,n=t.definition?.pathname||e.pathname;c._detectAndPatchSupportedMethods(t,n),t[c.nextJSHudMarked]=!0}}catch(e){s.instrument_logger.error("Failed to patch Next.js route module",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return await r.apply(this,[e,t,...n])},t[c.nextJSHudMarked]=!0,(0,a.copyPropertiesToTarget)(r,t.prototype.renderToResponseWithComponentsImpl)}catch(e){s.instrument_logger.error("Failed to patch Next.js base server",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return e}static _detectAndPatchSupportedMethods(e,t){try{switch(s.instrument_logger.debug("Patching Next.js route module",{pathname:t,kind:e.definition?.kind||"unknown"}),e.definition.kind){case"APP_ROUTE":case"PAGES_API":c._patchApiModule(e,t);break;case"PAGES":case"APP_PAGE":c._patchPageModule(e,t);break;default:s.instrument_logger.warning("Unknown Next.js route module kind",{pathname:t,kind:e.definition?.kind||"unknown"})}}catch(e){s.instrument_logger.error("Error detecting and patching supported methods",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}static _patchApiModule(e,t){if(e.methods)for(const r of c.standardMethods)if("function"==typeof e.methods[r]&&"function"==typeof e.userland?.[r]){const u=(0,i.generateEndpointFlowId)(t,[r]);(0,o.storeEndpointDeclaration)(new n.EndpointDeclaration(u,[r],"nextjs","",t));try{const t=e.methods[r];e.methods[r]=(0,a.wrapFlow)(()=>u,t,!0)}catch(e){s.instrument_logger.error("Failed to patch Next.js App Route method",{method:r,pathname:t,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}if(e.userland?.default){const r=c.standardMethods.filter(t=>!e.methods?.[t]),s=(0,i.generateEndpointFlowId)(t,r);(0,o.storeEndpointDeclaration)(new n.EndpointDeclaration(s,r,"nextjs","",t));const u=e.userland.default;e.userland={...e.userland,default:(0,a.wrapFlow)(()=>s,u,!0)}}}static _patchPageModule(e,t){const r=(0,i.generateEndpointFlowId)(t,["GET"]);if((0,o.storeEndpointDeclaration)(new n.EndpointDeclaration(r,["GET"],"nextjs","",t)),e.render&&"function"==typeof e.render&&!e.render[this.nextJSHudMarked])try{const n=e.render;e.render=function(...e){try{const n=e[2]?.renderOpts?.Component;if(n&&"function"==typeof n){const t=(0,a.wrapFlow)(()=>r,n,!0);e[2].renderOpts.Component=t}const o=e[2]?.renderOpts?.ComponentMod;if(o){for(const t of Object.keys(o))if(o[t]&&"function"==typeof o[t]){const n=(0,a.wrapFlow)(()=>r,o[t],!0);e[2].renderOpts.ComponentMod[t]=n}}else s.instrument_logger.error("No Component found on Next.js page component",{pathname:t})}catch{}return n.apply(this,e)},(0,a.copyPropertiesToTarget)(n,e.render),e.render[this.nextJSHudMarked]=!0}catch(e){s.instrument_logger.error("Failed to patch Next.js Page render method",{pathname:t,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}if(e.userland?.loaderTree)try{l(e.userland.loaderTree,r)}catch(e){s.instrument_logger.error("Failed to patch App Router page component",{pathname:t,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}else s.instrument_logger.info("No loader tree found on Next.js page component, functions will be patched by the render function",{pathname:t})}}function d(e,t,r){return(...n)=>{const o=e(...n),i=e=>{if(e&&"function"==typeof e.default){try{e.default.a}catch{return e}const n=(0,a.wrapFlow)(()=>r,e.default,t);e={...e,default:n}}return e};return o&&"function"==typeof o.then?o.then(i):i(o)}}function l(e,t){const[,r,n]=e;for(const e of Object.keys(n))try{const r=n[e];if(Array.isArray(r)&&"function"==typeof r[0]){const n="page"===e,o=r[0];r[0]=d(o,n,t),(0,a.copyPropertiesToTarget)(o,r[0])}}catch(e){s.instrument_logger.error("Failed to iterate on Next.js components",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}for(const e of Object.values(r))try{l(e,t)}catch(e){s.instrument_logger.error("Failed to walk on Next.js parallel routes",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}t.default=c},9723:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=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||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0});const a=r(8269),u=r(2546),c=r(523),d=r(9896),l=s(r(6928)),f=r(8949),g=r(714);class p extends g.FrameworkPatcher{_patch(e){(0,u.setIsNextJsApp)(!0);const t=this._patchLoadConfig(e);return c.instrument_logger.info("Patched next.js config successfully"),t}_patchLoadConfig(e){const t=e.default,r=async function(...e){const r=await t.call(this,...e);if(!r)return r;try{const t=e[1],n=l.join(t,r.distDir||".next"),o=l.join(n,a.apiManifest),i=l.join(n,a.pageManifest),s=await d.promises.access(o).then(()=>!0).catch(()=>!1),u=await d.promises.access(i).then(()=>!0).catch(()=>!1);(0,a.isNextConfigExtracted)()||!s&&!u||(c.instrument_logger.info("Extracted next.js config successfully"),(0,a.setNextConfig)(r))}catch(e){c.instrument_logger.error("Failed to patch next.js loadConfig",{msg:e instanceof Error?e.message:String(e),stack:e instanceof Error?e.stack:void 0})}return r};(0,f.copyPropertiesToTarget)(t,r);const n=Object.create(Object.getPrototypeOf(e));return Object.defineProperty(n,"default",{enumerable:!0,get:function(){return r}}),(0,f.copyPropertiesToTarget)(e,n),n}}t.default=p},9873:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FlowMetric=void 0;const o=r(8528),i=r(8269),s=n(r(932));t.FlowMetric=class{_state;flowId;duration;_startTime;_msStartTime;errorBreakdown;constructor(e){this.flowId=e,this.duration=-1,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(){hudRunningMode===o.HudRunningMode.enabled&&(this._startTime=s.default.hrtime.bigint(),this._msStartTime=Date.now())}setErrorBreakdown(e){this.errorBreakdown=e}end(){hudRunningMode===o.HudRunningMode.enabled&&(-1===this.duration&&this.calculateDuration(),this.#e(),this._state="unusable")}calculateDuration(){this._startTime&&(this.duration=Number(s.default.hrtime.bigint()-this._startTime))}#e(){if(hudRunningMode===o.HudRunningMode.enabled){const e=this.toRaw();e&&(0,i.storeFlowMetric)(e)}}}},9896:e=>{"use strict";e.exports=require("fs")},9938:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wrapOutboundFunction=function(e,t,r,n,o){let i;return i=e instanceof u.AsyncFunction?async function(...i){const a={io:!0};let u,c,d;try{(0,s.wrapperInitial)(t,a);const e=l(i,a,r,o,t);u=e?.outboundInvocation,c=e?.outboundIndex}catch{}try{const r=e.apply(this,i);try{_hud_SI.value--,a.ff=!0}catch{}d=await r;try{_hud_S[++_hud_SI.value]=t,a.ff=!1}catch{}}catch(e){try{(0,s.wrapperCatch)(t,a,e,[]),g(e,c,u,a)}catch{}throw e}finally{try{(0,s.wrapperFinally)(t,a)}catch{}}return f(d,c,u,a.start,n),d}:function(...i){const a={io:!0};let u,c,d;try{(0,s.wrapperInitial)(t,a);const e=l(i,a,r,o,t);u=e?.outboundInvocation,c=e?.outboundIndex}catch{}try{d=e.apply(this,i)}catch(e){try{(0,s.wrapperCatch)(t,a,e,[]),g(e,c,u,a)}catch{}throw e}finally{try{(0,s.wrapperFinally)(t,a)}catch{}}return d instanceof Promise?d.catch(e=>{throw g(e,c,u,a),e}).then(e=>(f(e,c,u,a.start,n),e)):(f(d,c,u,a.start,n),d)},(0,u.copyPropertiesToTarget)(e,i),i},t.wrapOutboundBodyFunction=function(e,t,r,n){if(e instanceof u.AsyncFunction)return i.instrument_logger.warning("Wrap outbound body function doesn't support async functions"),e;const o=function(...o){const i={io:!0};let a,u,c;try{if((0,s.wrapperInitial)(t,i),a=r(this,o),void 0!==a){const e=(0,s.getInvestigationStorage)()?.getStore();u=e?.outbounds?.[a]}}catch{}try{c=e.apply(this,o)}catch(e){try{(0,s.wrapperCatch)(t,i,e,[]),h(e,u,a,i)}catch{}throw e}finally{try{(0,s.wrapperFinally)(t,i)}catch{}}return c instanceof Promise?c.catch(e=>{throw h(e,u,a,i),e}).then(e=>(p(this,e,a,u,i.start,n),e)):(p(this,c,a,u,i.start,n),c)};return(0,u.copyPropertiesToTarget)(e,o),o},t.getBodySize=function(e){if(e&&("string"==typeof e||e instanceof Buffer)&&e.length>0)return e.length},t.getReducedBody=_,t.reduceRequestArgsIfNeeded=function(e,t,r){try{const o=t.args;if(void 0===o)return;const i=r(e),s=isNaN(i)||0===i?void 0:i;o.bodySize=s,o.body=_(o.body,s,n.hudConfig.dynamicConfig.maxHTTPRequestBodySize)}catch(e){(0,a.limitedLogger)("Error reducing request args",{e})}};const n=r(5809),o=r(8528),i=r(523),s=r(7131),a=r(2822),u=r(8949),c={[o.OutboundType.HTTP]:e=>{void 0!==e&&(e.url=void 0,e.body=void 0)},[o.OutboundType.DB]:e=>{void 0!==e&&(e.query=void 0,e.params=void 0)}},d={[o.OutboundType.HTTP]:e=>{void 0!==e&&(e.body=void 0)},[o.OutboundType.DB]:e=>{}};function l(e,t,r,o,i){const u=(0,s.getInvestigationStorage)()?.getStore();if(void 0===u)return;if(u.outbounds.length>=n.hudConfig.dynamicConfig.maxTotalOutbounds)return void(0,a.limitedLogger)("max outbound calls reached");const d=u.outbounds.length;let l;try{void 0!==r&&d<n.hudConfig.dynamicConfig.maxOutboundCountWithData&&(l=r(e))}catch(e){(0,a.limitedLogger)("error parsing args",{e})}const f={function_id:i,caller_id:t.wrappedCaller,type:o,args:l,timestamp:Date.now()};return(d>=n.hudConfig.dynamicConfig.maxOutboundCountWithData||!n.hudConfig.dynamicConfig.enableOutboundData)&&c[f.type](f.args),u.outbounds.push(f),{outboundInvocation:f,outboundIndex:d}}function f(e,t,r,o,i){try{if(void 0===t||void 0===r)return;if(void 0!==i&&t<n.hudConfig.dynamicConfig.maxOutboundCountWithData){let o;try{o=i(e,t,r)}catch(e){(0,a.limitedLogger)("error parsing result",{e})}(t>=n.hudConfig.dynamicConfig.maxOutboundCountWithData||!n.hudConfig.dynamicConfig.enableOutboundData)&&d[r.type](o),r.result=o}const s=process.hrtime.bigint();r.duration=Number(s-o)}catch{}}function g(e,t,r,o){try{if(void 0===r||void 0===t)return;r.error=t<n.hudConfig.dynamicConfig.maxOutboundCountWithData&&n.hudConfig.dynamicConfig.enableOutboundData?e:(0,s.extractName)(e),r.duration=Number(process.hrtime.bigint()-o.start)}catch{}}function p(e,t,r,i,s,u){try{if(void 0===r||void 0===i||i.type!==o.OutboundType.HTTP||void 0===i.result)return;try{const r=u(e,t);i.result.body=r?.body,i.result.bodySize=r?.bodySize}catch(e){(0,a.limitedLogger)("error getting body",{e})}const c=process.hrtime.bigint();i.bodyDuration=Number(c-s),(r>=n.hudConfig.dynamicConfig.maxOutboundCountWithData||!n.hudConfig.dynamicConfig.enableOutboundData)&&d[o.OutboundType.HTTP](i.result)}catch{}}function h(e,t,r,o){try{if(void 0===t||void 0===r)return;t.bodyError=r<n.hudConfig.dynamicConfig.maxOutboundCountWithData&&n.hudConfig.dynamicConfig.enableOutboundData?e:(0,s.extractName)(e),t.bodyDuration=Number(process.hrtime.bigint()-o.start)}catch{}}const m="[HUD_BODY_TOO_LONG]",y="[HUD_NO_CONTENT_LENGTH_HEADER]";function _(e,t,r){return void 0!==t&&t>r?m:void 0===t&&null!=e&&""!==e?y:e}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}return r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r(2197)})());
2
2
  //# sourceMappingURL=instrument.js.map
package/dist/cjs/wrap.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var i in n)("object"==typeof exports?exports:t)[i]=n[i]}}(global,()=>(()=>{"use strict";var t={4403:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SketchManager=void 0;const i=n(4602);e.SketchManager=class{binWidth;logBinWidth;constructor(t){this.binWidth=t,this.logBinWidth=Math.log(t)}binIndex(t){return Math.floor(Math.log(t)/this.logBinWidth)}indexToBinStart(t){return this.binWidth**t}newSketchDataWithValue(t){const e=this.binIndex(t),n=new i.SketchData;return n.indexShift=e,n[0]=1,n}add(t,e){const n=this.binIndex(e);let i=n-t.indexShift;i<0?(t.unshift(...new Array(-i).fill(0)),t.indexShift=n,i=n-t.indexShift):i>=t.length&&t.push(...new Array(i-t.length+1).fill(0)),t[i]+=1}zero(t){t.fill(0)}copy(t){const e=new i.SketchData;return e.indexShift=t.indexShift,e.push(...t),e}mergeIntoNoChecks(t,e){const n=e.indexShift-t.indexShift;for(let i=0;i<e.length;i++)t[i+n]+=e[i]}mergeInto(t,e){e.indexShift<t.indexShift&&(t.unshift(...new Array(t.indexShift-e.indexShift).fill(0)),t.indexShift=e.indexShift),e.indexShift+e.length>t.indexShift+t.length&&t.push(...new Array(e.indexShift+e.length-(t.indexShift+t.length)).fill(0)),this.mergeIntoNoChecks(t,e)}mergeMany(t){if(0===t.length)throw new Error("Cannot merge empty list of SketchData.");if(1===t.length)return this.copy(t[0]);let e=1/0,n=-1/0;for(const i of t)e=Math.min(e,i.indexShift),n=Math.max(n,i.indexShift+i.length-1);const r=new i.SketchData;r.indexShift=e,r.push(...new Array(n-e+1).fill(0));for(const e of t)this.mergeIntoNoChecks(r,e);return r}getQuantile(t,e){const n=t.reduce((t,e)=>t+e,0);if(0===n)throw new Error("Cannot get quantile of empty SketchData.");const i=n*e;let r,o=0;for(r=0;r<t.length&&(o+=t[r],!(o>=i));r++);const a=this.indexToBinStart(r+t.indexShift),s=(o-i)/t[r];return a*this.binWidth**(1-s)}encode(t){return{binWidth:this.binWidth,indexShift:t.indexShift,data:Array.from(t)}}decode(t){if(t.binWidth!==this.binWidth)throw new Error(`Should not decode sketch data with bin width ${t.binWidth} using SketchManager with bin width ${this.binWidth}.`);const e=new i.SketchData;return e.indexShift=t.indexShift,e.push(...t.data),e}}},4602:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SketchData=void 0,e.SketchData=class extends Array{indexShift=0;constructor(){super()}}},6042:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.wrapperUserCatch=e.fixStack=e.wrapperFinally=e.wrapperCatch=e.wrapperInitial=e.InvestigationStatus=void 0,e.setFlowStateStorage=function(t){void 0===a&&(a=t)},e.getFlowStateStorage=s,e.getHttpMetricFromFlowState=function(){return a?.getStore()?.httpMetric},e.setInvestigationStorage=function(t){void 0===h&&(h=t)},e.getInvestigationStorage=function(){return h},e.investigateError=u,e.extractName=l,e.extractMessage=function(t){if(t instanceof Error)return t.message?t.message:void 0},e.extractStackTrace=function(t){if(t instanceof Error)return t.stack?t.stack:void 0},e.asyncIteratorWrapper=function(t){if(t&&t[Symbol.asyncIterator])return t[Symbol.asyncIterator]();if(t&&t[Symbol.iterator])return new f(t[Symbol.iterator]());if(t&&t["@@asyncIterator"])return t["@@asyncIterator"]();if(t&&t["@@iterator"])return t["@@iterator"]();throw new TypeError("Object is not async iterable")};const o=new(n(4403).SketchManager)(1.2);let a;function s(){return a}var c;let h;function u(t,e,n,i,r){if(!globalThis.hudEnableInvestigation)return;if(void 0===h)return;const o=h.getStore();if(void 0===o)return;const a=globalThis.hudExceptionMaxLength??100;let s=o.exceptions.get(i);if(void 0===s){if(o.exceptions.size>=a)return;s={exception:i,executionFlow:[],caught:n},o.exceptions.set(i,s)}s.caught=n,o.caught=n;const c=globalThis.hudExecutionFlowMaxLength??100;s.executionFlow.length>=c||s.executionFlow.push({function_id:t,caller_id:e.wrappedCaller,args:globalThis.hudEnableInvestigationArgsSending?r:void 0,is_outbound_function:e.io??!1})}function l(t){return t instanceof Error?t.constructor?t.constructor.name:t.name?t.name:"Non-Deducible-Name-Exception":"Non-Error-Exception"}function d(t,e){e.ff&&(_hud_S[++_hud_SI.value]=t,e.ff=!1)}!function(t){t[t.Open=1]="Open",t[t.Closed=2]="Closed"}(c||(e.InvestigationStatus=c={}));class f{iterator;n;constructor(t){this.iterator=t,this.n=t.next}static AsyncFromSyncIteratorContinuation(t){if(Object(t)!==t)return Promise.reject(new TypeError(t+" is not an object."));const e=t.done;return Promise.resolve(t.value).then(function(t){return{value:t,done:e}})}next(...t){return f.AsyncFromSyncIteratorContinuation(this.n.call(this.iterator,...t))}return(t){const e=this.iterator.return;return void 0===e?Promise.resolve({value:t,done:!0}):f.AsyncFromSyncIteratorContinuation(e.call(this.iterator,t))}throw(t){const e=this.iterator.throw;return void 0===e?Promise.reject(t):f.AsyncFromSyncIteratorContinuation(e.call(this.iterator,t))}[Symbol.asyncIterator](){return this}}e.wrapperInitial=function(t,e){const n=e.wrappedCaller=_hud_S[_hud_SI.value],i=hudCalls[t]??={},r=i[n]??={},o=s()?.getStore(),a=r[e.currentFlowId=o?.flowId||""]??={count:0,lastSentCounter:0,sampledCount:0,sum:0,exceptions:{},squareSum:0,sketch:null,isLinkedFunction:!1},c=a.count++;(e.sample_flag=2===hudRunningMode&&(!!e.io||(c>=5e3?c%103==0:hudSampleTable[c])))&&(e.start=process.hrtime.bigint()),o?.shouldLinkFunction&&(o.shouldLinkFunction=!1,a.isLinkedFunction=!0),_hud_S[++_hud_SI.value]=t},e.wrapperCatch=function(t,e,n,i){const r=l(n),o=hudCalls[t][e.wrappedCaller][e.currentFlowId];o.exceptions[r]??=0,o.exceptions[r]++,u(t,e,!1,n,i)},e.wrapperFinally=function(t,e){if(e.ff||_hud_SI.value--,e.sample_flag){const n=process.hrtime.bigint(),i=Number(n-e.start);if(i>0){const n=hudCalls[t][e.wrappedCaller][e.currentFlowId];n.sampledCount++,n.sum+=i,n.squareSum+=i*i,null===n.sketch?n.sketch=o.newSketchDataWithValue(i):o.add(n.sketch,i)}}},e.fixStack=d,e.wrapperUserCatch=function(t,e,n,i){d(t,e),u(t,e,!0,n,i)},r(n(4602),e),r(n(4403),e)}},e={};return function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,n),o.exports}(6042)})());
1
+ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var i in n)("object"==typeof exports?exports:t)[i]=n[i]}}(global,()=>(()=>{"use strict";var t={4403:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SketchManager=void 0;const i=n(4602);e.SketchManager=class{binWidth;logBinWidth;constructor(t){this.binWidth=t,this.logBinWidth=Math.log(t)}binIndex(t){return Math.floor(Math.log(t)/this.logBinWidth)}indexToBinStart(t){return this.binWidth**t}newSketchDataWithValue(t){const e=this.binIndex(t),n=new i.SketchData;return n.indexShift=e,n[0]=1,n}add(t,e){const n=this.binIndex(e);let i=n-t.indexShift;i<0?(t.unshift(...new Array(-i).fill(0)),t.indexShift=n,i=n-t.indexShift):i>=t.length&&t.push(...new Array(i-t.length+1).fill(0)),t[i]+=1}zero(t){t.fill(0)}copy(t){const e=new i.SketchData;return e.indexShift=t.indexShift,e.push(...t),e}mergeIntoNoChecks(t,e){const n=e.indexShift-t.indexShift;for(let i=0;i<e.length;i++)t[i+n]+=e[i]}mergeInto(t,e){e.indexShift<t.indexShift&&(t.unshift(...new Array(t.indexShift-e.indexShift).fill(0)),t.indexShift=e.indexShift),e.indexShift+e.length>t.indexShift+t.length&&t.push(...new Array(e.indexShift+e.length-(t.indexShift+t.length)).fill(0)),this.mergeIntoNoChecks(t,e)}mergeMany(t){if(0===t.length)throw new Error("Cannot merge empty list of SketchData.");if(1===t.length)return this.copy(t[0]);let e=1/0,n=-1/0;for(const i of t)e=Math.min(e,i.indexShift),n=Math.max(n,i.indexShift+i.length-1);const r=new i.SketchData;r.indexShift=e,r.push(...new Array(n-e+1).fill(0));for(const e of t)this.mergeIntoNoChecks(r,e);return r}getQuantile(t,e){const n=t.reduce((t,e)=>t+e,0);if(0===n)throw new Error("Cannot get quantile of empty SketchData.");const i=n*e;let r,o=0;for(r=0;r<t.length&&(o+=t[r],!(o>=i));r++);const a=this.indexToBinStart(r+t.indexShift),s=(o-i)/t[r];return a*this.binWidth**(1-s)}encode(t){return{binWidth:this.binWidth,indexShift:t.indexShift,data:Array.from(t)}}decode(t){if(t.binWidth!==this.binWidth)throw new Error(`Should not decode sketch data with bin width ${t.binWidth} using SketchManager with bin width ${this.binWidth}.`);const e=new i.SketchData;return e.indexShift=t.indexShift,e.push(...t.data),e}}},4602:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SketchData=void 0,e.SketchData=class extends Array{indexShift=0;constructor(){super()}}},6042:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.wrapperUserCatch=e.fixStack=e.wrapperFinally=e.wrapperCatch=e.wrapperInitial=e.InvestigationStatus=void 0,e.setFlowStateStorage=function(t){void 0===a&&(a=t)},e.getFlowStateStorage=s,e.getHttpMetricFromFlowState=function(){return a?.getStore()?.httpMetric},e.setInvestigationStorage=function(t){void 0===h&&(h=t)},e.getInvestigationStorage=function(){return h},e.investigateError=u,e.extractName=l,e.extractMessage=function(t){if(t instanceof Error)return t.message?t.message:void 0},e.extractStackTrace=function(t){if(t instanceof Error)return t.stack?t.stack:void 0},e.asyncIteratorWrapper=function(t){if(t&&t[Symbol.asyncIterator])return t[Symbol.asyncIterator]();if(t&&t[Symbol.iterator])return new f(t[Symbol.iterator]());if(t&&t["@@asyncIterator"])return t["@@asyncIterator"]();if(t&&t["@@iterator"])return t["@@iterator"]();throw new TypeError("Object is not async iterable")};const o=new(n(4403).SketchManager)(1.2);let a;function s(){return a}var c;let h;function u(t,e,n,i,r){if(!globalThis.hudEnableInvestigation)return;if(void 0===h)return;const o=h.getStore();if(void 0===o)return;const a=globalThis.hudExceptionMaxLength??20;let s=o.exceptions.get(i);if(void 0===s){if(o.exceptions.size>=a)return;s={exception:i,executionFlow:[],caught:n},o.exceptions.set(i,s)}s.caught=n,o.caught=n;const c=globalThis.hudExecutionFlowMaxLength??20;s.executionFlow.length>=c||s.executionFlow.push({function_id:t,caller_id:e.wrappedCaller,args:globalThis.hudEnableInvestigationArgsSending?r:void 0,is_outbound_function:e.io??!1})}function l(t){return t instanceof Error?t.constructor?t.constructor.name:t.name?t.name:"Non-Deducible-Name-Exception":"Non-Error-Exception"}function d(t,e){e.ff&&(_hud_S[++_hud_SI.value]=t,e.ff=!1)}!function(t){t[t.Open=1]="Open",t[t.Closed=2]="Closed"}(c||(e.InvestigationStatus=c={}));class f{iterator;n;constructor(t){this.iterator=t,this.n=t.next}static AsyncFromSyncIteratorContinuation(t){if(Object(t)!==t)return Promise.reject(new TypeError(t+" is not an object."));const e=t.done;return Promise.resolve(t.value).then(function(t){return{value:t,done:e}})}next(...t){return f.AsyncFromSyncIteratorContinuation(this.n.call(this.iterator,...t))}return(t){const e=this.iterator.return;return void 0===e?Promise.resolve({value:t,done:!0}):f.AsyncFromSyncIteratorContinuation(e.call(this.iterator,t))}throw(t){const e=this.iterator.throw;return void 0===e?Promise.reject(t):f.AsyncFromSyncIteratorContinuation(e.call(this.iterator,t))}[Symbol.asyncIterator](){return this}}e.wrapperInitial=function(t,e){const n=e.wrappedCaller=_hud_S[_hud_SI.value],i=hudCalls[t]??={},r=i[n]??={},o=s()?.getStore(),a=r[e.currentFlowId=o?.flowId||""]??={count:0,lastSentCounter:0,sampledCount:0,sum:0,exceptions:{},squareSum:0,sketch:null,isLinkedFunction:!1},c=a.count++;(e.sample_flag=2===hudRunningMode&&(!!e.io||(c>=5e3?c%103==0:hudSampleTable[c])))&&(e.start=process.hrtime.bigint()),o?.shouldLinkFunction&&(o.shouldLinkFunction=!1,a.isLinkedFunction=!0),_hud_S[++_hud_SI.value]=t},e.wrapperCatch=function(t,e,n,i){const r=l(n),o=hudCalls[t][e.wrappedCaller][e.currentFlowId];o.exceptions[r]??=0,o.exceptions[r]++,u(t,e,!1,n,i)},e.wrapperFinally=function(t,e){if(e.ff||_hud_SI.value--,e.sample_flag){const n=process.hrtime.bigint(),i=Number(n-e.start);if(i>0){const n=hudCalls[t][e.wrappedCaller][e.currentFlowId];n.sampledCount++,n.sum+=i,n.squareSum+=i*i,null===n.sketch?n.sketch=o.newSketchDataWithValue(i):o.add(n.sketch,i)}}},e.fixStack=d,e.wrapperUserCatch=function(t,e,n,i){d(t,e),u(t,e,!0,n,i)},r(n(4602),e),r(n(4403),e)}},e={};return function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,n),o.exports}(6042)})());
2
2
  //# sourceMappingURL=wrap.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hud-sdk",
3
- "version": "1.6.38",
3
+ "version": "1.6.39",
4
4
  "description": "Hud's Node SDK",
5
5
  "homepage": "https://www.hud.io/",
6
6
  "keywords": [