@depup/sentry__node 11.0.0-depup.0 → 11.1.0-depup.0
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.
- package/README.md +3 -9
- package/build/cjs/index.js +3 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/integrations/anr/index.js +1 -1
- package/build/cjs/integrations/childProcess.js +2 -2
- package/build/cjs/integrations/childProcess.js.map +1 -1
- package/build/cjs/integrations/http/SentryHttpInstrumentation.js +2 -2
- package/build/cjs/integrations/http/SentryHttpInstrumentation.js.map +1 -1
- package/build/cjs/integrations/http/httpServerIntegration.js +2 -2
- package/build/cjs/integrations/http/httpServerIntegration.js.map +1 -1
- package/build/cjs/integrations/local-variables/local-variables-async.js +1 -1
- package/build/cjs/integrations/node-fetch/undici-instrumentation.js +2 -2
- package/build/cjs/integrations/node-fetch/undici-instrumentation.js.map +1 -1
- package/build/cjs/integrations/pino.js +2 -2
- package/build/cjs/integrations/pino.js.map +1 -1
- package/build/cjs/integrations/workerThreads.js +2 -2
- package/build/cjs/integrations/workerThreads.js.map +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/integrations/anr/index.js +1 -1
- package/build/esm/integrations/anr/worker-script.js +2 -2
- package/build/esm/integrations/childProcess.js +2 -2
- package/build/esm/integrations/childProcess.js.map +1 -1
- package/build/esm/integrations/http/SentryHttpInstrumentation.js +2 -2
- package/build/esm/integrations/http/SentryHttpInstrumentation.js.map +1 -1
- package/build/esm/integrations/http/httpServerIntegration.js +2 -2
- package/build/esm/integrations/http/httpServerIntegration.js.map +1 -1
- package/build/esm/integrations/local-variables/local-variables-async.js +1 -1
- package/build/esm/integrations/local-variables/worker-script.js +1 -1
- package/build/esm/integrations/node-fetch/undici-instrumentation.js +2 -2
- package/build/esm/integrations/node-fetch/undici-instrumentation.js.map +1 -1
- package/build/esm/integrations/pino.js +2 -2
- package/build/esm/integrations/pino.js.map +1 -1
- package/build/esm/integrations/workerThreads.js +2 -2
- package/build/esm/integrations/workerThreads.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/types/index.d.ts +2 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/integrations/http/SentryHttpInstrumentation.d.ts.map +1 -1
- package/build/types/integrations/http/httpServerIntegration.d.ts.map +1 -1
- package/build/types/integrations/pino.d.ts.map +1 -1
- package/changes.json +3 -8
- package/package.json +10 -15
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @sentry/node 11.
|
|
2
|
-
import{Session as t}from"node:inspector";import{workerData as e,parentPort as n}from"node:worker_threads";import{posix as r,sep as o}from"node:path";import*as s from"node:http";import*as i from"node:https";import{Readable as c}from"node:stream";import{createGzip as u}from"node:zlib";import*as a from"node:net";import*as f from"node:tls";const h="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,p=globalThis,l="11.0.0";function d(){return g(p),p}function g(t){const e=t.__SENTRY__=t.__SENTRY__||{};return e.version=e.version||l,e[l]=e[l]||{}}function m(t,e,n=p){const r=n.__SENTRY__=n.__SENTRY__||{},o=r[l]=r[l]||{};return o[t]||(o[t]=e())}const y={};function b(t){if(!("console"in p))return t();const e=p.console,n={},r=Object.keys(y);r.forEach(t=>{const r=y[t];n[t]=e[t],e[t]=r});try{return t()}finally{r.forEach(t=>{e[t]=n[t]})}}function v(){return S().enabled}function w(t,...e){h&&v()&&b(()=>{p.console[t](`Sentry Logger [${t}]:`,...e)})}function S(){return h?m("loggerSettings",()=>({enabled:!1})):{enabled:!1}}const _={enable:function(){S().enabled=!0},disable:function(){S().enabled=!1},isEnabled:v,log:function(...t){w("log",...t)},warn:function(...t){w("warn",...t)},error:function(...t){w("error",...t)}},$=/captureMessage|captureException/;function E(t){return t[t.length-1]||{}}const x="<anonymous>";const N=Object.prototype.toString;function C(t){return function(t,e){return N.call(t)===`[object ${e}]`}(t,"Object")}function j(t){return Boolean(t?.then&&"function"==typeof t.then)}function O(t,e){try{return t instanceof e}catch{return!1}}function P(t){if(function(t){switch(N.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return O(t,Error)}}(t))return{message:t.message,name:t.name,stack:t.stack,...k(t)};if(e=t,"undefined"!=typeof Event&&O(e,Event)){const{type:e,target:n,currentTarget:r,detail:o}=t;return{type:e,target:n,currentTarget:r,...o?{detail:o}:{},...k(t)}}var e;return t}function k(t){return"object"==typeof(e=t)&&null!==e?Object.fromEntries(Object.entries(t)):{};var e}let A;function T(t){if(void 0!==A)return A?A(t):t();const e=Symbol.for("__SENTRY_SAFE_RANDOM_ID_WRAPPER__"),n=p;return e in n&&"function"==typeof n[e]?(A=n[e],A(t)):(A=null,t())}function R(){return T(()=>Math.random())}function I(){return T(()=>Date.now())}const D=Symbol.for("sentry.skipNormalization"),U=Symbol.for("sentry.overrideNormalizationDepth");function B(t,e=100,n=1/0){try{return L("",t,e,n)}catch(t){return{ERROR:`**non-serializable** (${t})`}}}function L(t,e,n=1/0,r=1/0,o=function(){const t=new WeakSet;function e(e){return!!t.has(e)||(t.add(e),!1)}function n(e){t.delete(e)}return[e,n]}()){const[s,i]=o;if(null==e||["boolean","string"].includes(typeof e)||"number"==typeof e&&Number.isFinite(e))return e;const c=function(t,e){try{if("undefined"!=typeof global&&e===global)return"[Global]";if("number"==typeof e&&!Number.isFinite(e))return`[${e}]`;if("function"==typeof e)return`[Function: ${function(t){try{return t&&"function"==typeof t&&t.name||x}catch{return x}}(e)}]`;if("symbol"==typeof e)return`[${String(e)}]`;if("bigint"==typeof e)return`[BigInt: ${String(e)}]`;const t=function(t){const e=Object.getPrototypeOf(t);return e?.constructor?e.constructor.name:"null prototype"}(e);return`[object ${t}]`}catch(t){return`**non-serializable** (${t})`}}(0,e);if(!c.startsWith("[object "))return c;if(function(t){return Boolean(t[D])}(e))return e;const u=function(t){const e=t[U];return"number"==typeof e?e:void 0}(e),a=void 0!==u?u:n;if(0===a)return c.replace("object ","");if(s(e))return"[Circular ~]";const f=e;if(f&&"function"==typeof f.toJSON)try{return L("",f.toJSON(),a-1,r,o)}catch{}const h=Array.isArray(e)?[]:{};let p=0;const l=P(e);for(const t in l){if(!Object.prototype.hasOwnProperty.call(l,t))continue;if(p>=r){h[t]="[MaxProperties ~]";break}const e=l[t];h[t]=L(t,e,a-1,r,o),p++}return i(e),h}function M(t,e){const n=e.replace(/\\/g,"/").replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");let r=t;try{r=decodeURI(t)}catch{}return r.replace(/\\/g,"/").replace(/webpack:\/?/g,"").replace(new RegExp(`(file://)?/*${n}/*`,"ig"),"app:///")}function z(t,e=0){return"string"!=typeof t||0===e||t.length<=e?t:`${t.slice(0,e)}...`}let J;function W(t=function(){const t=p;return t.crypto||t.msCrypto}()){try{if(t?.randomUUID)return T(()=>t.randomUUID()).replace(/-/g,"")}catch{}return J||(J="10000000100040008000100000000000"),J.replace(/[018]/g,t=>(t^(16*R()&15)>>t/4).toString(16))}function F(){return I()/1e3}let G;function Y(){return(G??(G=function(){const{performance:t}=p;if(!t?.now||!t.timeOrigin)return F;const e=t.timeOrigin;return()=>(e+T(()=>t.now()))/1e3}()))()}function H(t){const e=Y(),n={sid:W(),init:!0,timestamp:e,started:e,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>function(t){return{sid:`${t.sid}`,init:t.init,started:new Date(1e3*t.started).toISOString(),timestamp:new Date(1e3*t.timestamp).toISOString(),status:t.status,errors:t.errors,did:"number"==typeof t.did||"string"==typeof t.did?`${t.did}`:void 0,duration:t.duration,abnormal_mechanism:t.abnormal_mechanism,attrs:{release:t.release,environment:t.environment,ip_address:t.ipAddress,user_agent:t.userAgent}}}(n)};return t&&Z(n,t),n}function Z(t,e={}){if(e.user&&(!t.ipAddress&&e.user.ip_address&&(t.ipAddress=e.user.ip_address),t.did||e.did||(t.did=e.user.id||e.user.email||e.user.username)),t.timestamp=e.timestamp||Y(),e.abnormal_mechanism&&(t.abnormal_mechanism=e.abnormal_mechanism),e.ignoreDuration&&(t.ignoreDuration=e.ignoreDuration),e.sid&&(t.sid=32===e.sid.length?e.sid:W()),void 0!==e.init&&(t.init=e.init),!t.did&&e.did&&(t.did=`${e.did}`),"number"==typeof e.started&&(t.started=e.started),t.ignoreDuration)t.duration=void 0;else if("number"==typeof e.duration)t.duration=e.duration;else{const e=t.timestamp-t.started;t.duration=e>=0?e:0}e.release&&(t.release=e.release),e.environment&&(t.environment=e.environment),!t.ipAddress&&e.ipAddress&&(t.ipAddress=e.ipAddress),!t.userAgent&&e.userAgent&&(t.userAgent=e.userAgent),"number"==typeof e.errors&&(t.errors=e.errors),e.status&&(t.status=e.status)}function q(t,e,n=2){if(!e||"object"!=typeof e||n<=0)return e;if(t&&0===Object.keys(e).length)return t;const r={...t};for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=q(r[t],e[t],n-1));return r}class K{constructor(){this.t=!1,this.o=[],this.i=[],this.u=[],this.h=[],this.p={},this.l={},this.m={},this.v={},this.S={},this._={},function(t,e,n){try{Object.defineProperty(t,e,{value:n,writable:!0,configurable:!0})}catch{h&&_.log(`Failed to add non-enumerable property "${String(e)}" to object`,t)}}(this,"refs",{}),this.N={traceId:W(),sampleRand:R()}}clone(){const t=new K;return t.u=[...this.u],t.l={...this.l},t.m={...this.m},t.v={...this.v},t.S={...this.S},this.S.flags&&(t.S.flags={values:[...this.S.flags.values]}),t.p=this.p,t.C=this.C,t.j=this.j,t.O=this.O,t.P=this.P,t.i=[...this.i],t.h=[...this.h],t._={...this._},t.N={...this.N},t.k=this.k,t.A=this.A,t.T=this.T,t.refs={...this.refs},t}setClient(t){this.k=t}setLastEventId(t){this.A=t}getClient(){return this.k}lastEventId(){return this.A}addScopeListener(t){this.o.push(t)}addEventProcessor(t){return this.i.push(t),this}setUser(t){return this.p=t||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this.j&&Z(this.j,{user:t}),this.R(),this}getUser(){return this.p}setConversationId(t){return this.T=t||void 0,this.R(),this}setTags(t){return this.l={...this.l,...t},this.R(),this}setTag(t,e){return this.setTags({[t]:e})}setAttributes(t){return this.m={...this.m,...t},this.R(),this}setAttribute(t,e){return this.setAttributes({[t]:e})}removeAttribute(t){return t in this.m&&(delete this.m[t],this.R()),this}setExtras(t){return this.v={...this.v,...t},this.R(),this}setExtra(t,e){return this.v={...this.v,[t]:e},this.R(),this}setFingerprint(t){return this.P=t,this.R(),this}setLevel(t){return this.C=t,this.R(),this}setTransactionName(t){return this.O=t,this.R(),this}setContext(t,e){return null===e?delete this.S[t]:this.S[t]=e,this.R(),this}setSession(t){return t?this.j=t:delete this.j,this.R(),this}getSession(){return this.j}update(t){if(!t)return this;const e="function"==typeof t?t(this):t,n=e instanceof K?e.getScopeData():C(e)?t:void 0,{tags:r,attributes:o,extra:s,user:i,contexts:c,level:u,fingerprint:a=[],propagationContext:f,conversationId:h}=n||{};return this.l={...this.l,...r},this.m={...this.m,...o},this.v={...this.v,...s},this.S={...this.S,...c},i&&Object.keys(i).length&&(this.p=i),u&&(this.C=u),a.length&&(this.P=a),f&&(this.N=f),h&&(this.T=h),this}addBreadcrumb(t,e){const n="number"==typeof e?e:100;if(n<=0)return this;const r={timestamp:F(),...t,message:t.message?z(t.message,2048):t.message};return this.u.push(r),this.u.length>n&&(this.u=this.u.slice(-n)),this.R(),this}getLastBreadcrumb(){return this.u[this.u.length-1]}clearBreadcrumbs(){return this.u=[],this.R(),this}addAttachment(t){return this.h.push(t),this}clearAttachments(){return this.h=[],this}getScopeData(){return{breadcrumbs:this.u,attachments:this.h,contexts:this.S,tags:this.l,attributes:this.m,extra:this.v,user:this.p,level:this.C,fingerprint:this.P||[],eventProcessors:this.i,propagationContext:this.N,sdkProcessingMetadata:this._,transactionName:this.O,conversationId:this.T}}setSDKProcessingMetadata(t){return this._=q(this._,t,2),this}setPropagationContext(t){return this.N=t,this}getPropagationContext(){return this.N}captureException(t,e){const n=e?.event_id||W();if(!this.k)return h&&_.warn("No client configured on scope - will not capture exception!"),n;const r=new Error("Sentry syntheticException");return this.k.captureException(t,{originalException:t,syntheticException:r,...e,event_id:n},this),n}captureMessage(t,e,n){const r=n?.event_id||W();if(!this.k)return h&&_.warn("No client configured on scope - will not capture message!"),r;const o=n?.syntheticException??new Error(t);return this.k.captureMessage(t,e,{originalException:t,syntheticException:o,...n,event_id:r},this),r}captureEvent(t,e){const n=t.event_id||e?.event_id||W();return this.k?(this.k.captureEvent(t,{...e,event_id:n},this),n):(h&&_.warn("No client configured on scope - will not capture event!"),n)}R(){this.t||(this.t=!0,this.o.forEach(t=>{t(this)}),this.t=!1)}}const V="__SENTRY_SUPPRESS_TRACING__",Q=t=>t instanceof Promise&&!t[X],X=Symbol("chained PromiseLike"),tt=(t,e)=>{if(!e)return t;let n=!1;for(const r in t){if(r in e)continue;n=!0;const o=t[r];"function"==typeof o?Object.defineProperty(e,r,{value:(...e)=>o.apply(t,e),enumerable:!0,configurable:!0,writable:!0}):e[r]=o}return n&&Object.assign(e,{[X]:!0}),e};class et{constructor(t,e){let n,r;n=t||new K,r=e||new K,this.I=[{scope:n}],this.D=r}withScope(t){const e=this.U();let n;try{n=t(e)}catch(t){throw this.B(),t}return j(n)?((t,e,n)=>{const r=t.then(t=>(e(t),t),t=>{throw n(t),t});return Q(r)&&Q(t)?r:tt(t,r)})(n,()=>this.B(),()=>this.B()):(this.B(),n)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this.D}getStackTop(){return this.I[this.I.length-1]}U(){const t=this.getScope().clone();return this.I.push({client:this.getClient(),scope:t}),t}B(){return!(this.I.length<=1)&&!!this.I.pop()}}function nt(){const t=g(d());return t.stack=t.stack||new et(m("defaultCurrentScope",()=>new K),m("defaultIsolationScope",()=>new K))}function rt(t){return nt().withScope(t)}function ot(t,e){const n=nt();return n.withScope(()=>(n.getStackTop().scope=t,e(t)))}function st(t){return nt().withScope(()=>t(nt().getIsolationScope()))}function it(t){return rt(e=>{e.setSDKProcessingMetadata({[V]:!0});const n=t();return e.setSDKProcessingMetadata({[V]:void 0}),n})}function ct(t){const e=g(t);return e.acs?e.acs:{suppressTracing:it,withIsolationScope:st,withScope:rt,withSetScope:ot,withSetIsolationScope:(t,e)=>st(e),getCurrentScope:()=>nt().getScope(),getIsolationScope:()=>nt().getIsolationScope()}}function ut(t,e=!1){const{host:n,path:r,pass:o,port:s,projectId:i,protocol:c,publicKey:u}=t;return`${c}://${u}${e&&o?`:${o}`:""}@${n}${s?`:${s}`:""}/${r?`${r}/`:r}${i}`}function at(t,e){const{fingerprint:n,breadcrumbs:r,sdkProcessingMetadata:o}=e;!function(t,e){const{extra:n,tags:r,user:o,contexts:s,level:i,transactionName:c}=e;Object.keys(n).length&&(t.extra={...n,...t.extra});Object.keys(r).length&&(t.tags={...r,...t.tags});Object.keys(o).length&&(t.user={...o,...t.user});Object.keys(s).length&&(t.contexts={...s,...t.contexts});i&&(t.level=i);c&&"transaction"!==t.type&&(t.transaction=c)}(t,e),function(t,e){t.fingerprint=t.fingerprint?Array.isArray(t.fingerprint)?t.fingerprint:[t.fingerprint]:[],e&&(t.fingerprint=t.fingerprint.concat(e));t.fingerprint.length||delete t.fingerprint}(t,n),function(t,e){const n=[...t.breadcrumbs||[],...e];t.breadcrumbs=n.length?n:void 0}(t,r),function(t,e){t.sdkProcessingMetadata={...t.sdkProcessingMetadata,...e}}(t,o)}function ft(t,e=[]){return[t,e]}function ht(t,e){const n=t[1];for(const t of n){if(e(t,t[0].type))return!0}return!1}function pt(t){const e=g(p);return e.encodePolyfill?e.encodePolyfill(t):(new TextEncoder).encode(t)}function lt(t){const[e,n]=t;let r=JSON.stringify(e);function o(t){"string"==typeof r?r="string"==typeof t?r+t:[pt(r),t]:r.push("string"==typeof t?pt(t):t)}for(const t of n){const[e,n]=t;if(o(`\n${JSON.stringify(e)}\n`),"string"==typeof n||n instanceof Uint8Array)o(n);else{let t;try{t=JSON.stringify(n)}catch{t=JSON.stringify(B(n))}o(t)}}return"string"==typeof r?r:function(t){const e=t.reduce((t,e)=>t+e.length,0),n=new Uint8Array(e);let r=0;for(const e of t)n.set(e,r),r+=e.length;return n}(r)}const dt={sessions:"session",event:"error",client_report:"internal",user_report:"default",profile_chunk:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor",raw_security:"security",log:"log_item",trace_metric:"metric"};function gt(t){return function(t){return t in dt}(t)?dt[t]:t}function mt(t){if(!t?.sdk)return;const{name:e,version:n}=t.sdk;return{name:e,version:n}}function yt(t){const e=ct(d());return e.suppressTracing?e.suppressTracing(t):function(...t){const e=ct(d());if(2===t.length){const[n,r]=t;return n?e.withSetScope(n,r):e.withScope(r)}return e.withScope(t[0])}(e=>(e.setSDKProcessingMetadata({[V]:!0}),t()))}function bt(t,e,n,r){const o=mt(n),s=t.type&&"replay_event"!==t.type?t.type:"event";!function(t,e){if(!e)return t;const n=t.sdk||{};t.sdk={...n,name:n.name||e.name,version:n.version||e.version,integrations:[...t.sdk?.integrations||[],...e.integrations||[]],packages:[...t.sdk?.packages||[],...e.packages||[]],settings:t.sdk?.settings||e.settings?{...t.sdk?.settings,...e.settings}:void 0}}(t,n?.sdk);const i=function(t,e,n,r){const o=t.sdkProcessingMetadata?.dynamicSamplingContext;return{event_id:t.event_id,sent_at:new Date(I()).toISOString(),...e&&{sdk:e},...!!n&&r&&{dsn:ut(r)},...o&&{trace:o}}}(t,o,r,e);delete t.sdkProcessingMetadata;return ft(i,[[{type:s},t]])}class vt{constructor(t){this.L=0,this.M=[],this.J(t)}then(t,e){return new vt((n,r)=>{this.M.push([!1,e=>{if(t)try{n(t(e))}catch(t){r(t)}else n(e)},t=>{if(e)try{n(e(t))}catch(t){r(t)}else r(t)}]),this.W()})}catch(t){return this.then(t=>t,t)}finally(t){return new vt((e,n)=>{let r,o;return this.then(e=>{o=!1,r=e,t&&t()},e=>{o=!0,r=e,t&&t()}).then(()=>{o?n(r):e(r)})})}W(){if(0===this.L)return;const t=this.M.slice();this.M=[],t.forEach(t=>{t[0]||(1===this.L&&t[1](this.F),2===this.L&&t[2](this.F),t[0]=!0)})}J(t){const e=(t,e)=>{0===this.L&&(j(e)?e.then(n,r):(this.L=t,this.F=e,this.W()))},n=t=>{e(1,t)},r=t=>{e(2,t)};try{t(n,r)}catch(t){r(t)}}}const wt=Symbol.for("SentryBufferFullError");function St(t=100){const e=new Set;function n(t){e.delete(t)}return{get $(){return Array.from(e)},add:function(r){if(!(e.size<t))return o=wt,new vt((t,e)=>{e(o)});var o;const s=r();return e.add(s),s.then(()=>n(s),()=>n(s)),s},drain:function(t){if(!e.size)return n=!0,new vt(t=>{t(n)});var n;const r=Promise.allSettled(Array.from(e)).then(()=>!0);if(!t)return r;const o=[r,new Promise(e=>{return"object"==typeof(n=setTimeout(()=>e(!1),t))&&"function"==typeof n.unref&&n.unref(),n;var n})];return Promise.race(o)}}}function _t(t,{statusCode:e,headers:n},r=I()){const o={...t},s=n?.["x-sentry-rate-limits"],i=n?.["retry-after"];if(s)for(const t of s.trim().split(",")){const[e,n,,,s]=t.split(":",5),i=parseInt(e,10),c=1e3*(isNaN(i)?60:i);if(n)for(const t of n.split(";"))"metric_bucket"===t&&s&&!s.split(";").includes("custom")||(o[t]=r+c);else o.all=r+c}else i?o.all=r+function(t,e=I()){const n=parseInt(`${t}`,10);if(!isNaN(n))return 1e3*n;const r=Date.parse(`${t}`);return isNaN(r)?6e4:r-e}(i,r):429===e&&(o.all=r+6e4);return o}function $t(t,e,n=St(t.bufferSize||64)){let r={};return{send:function(t){const o=[];if(ht(t,(t,e)=>{const n=gt(e);(function(t,e,n=I()){return function(t,e){return t[e]||t.all||0}(t,e)>n})(r,n)||o.push(t)}),0===o.length)return Promise.resolve({});const s=ft(t[0],o),i=t=>{!function(t,e){return ht(t,(t,n)=>e.includes(n))}(s,["client_report"])?ht(s,(t,e)=>{}):h&&_.warn(`Dropping client report. Will not send outcomes (reason: ${t}).`)};return n.add(()=>e({body:lt(s)}).then(t=>413===t.statusCode?(h&&_.error("Sentry responded with status code 413. Envelope was discarded due to exceeding size limits."),i("send_error"),t):(h&&void 0!==t.statusCode&&(t.statusCode<200||t.statusCode>=300)&&_.warn(`Sentry responded with status code ${t.statusCode} to sent event.`),r=_t(r,t),t),t=>{throw i("network_error"),h&&_.error("Encountered error running transport request:",t),t})).then(t=>t,t=>{if(t===wt)return h&&_.error("Skipped sending event because buffer is full."),i("queue_overflow"),Promise.resolve({});throw t})},flush:t=>n.drain(t)}}const Et=/^(\S+:\\|\/?)([\s\S]*?)((?:\.{1,2}|[^/\\]+?|)(\.[^./\\]*|))(?:[/\\]*)$/;function xt(t){const e=function(t){const e=t.length>1024?`<truncated>${t.slice(-1024)}`:t,n=Et.exec(e);return n?n.slice(1):[]}(t),n=e[0]||"";let r=e[1];return n||r?(r&&(r=r.slice(0,r.length-1)),n+r):"."}function Nt(t,e=!1){return!(e||t&&!t.startsWith("/")&&!t.match(/^[A-Z]:/)&&!t.startsWith(".")&&!t.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//))&&void 0!==t&&!t.includes("node_modules/")}var Ct;const jt=Symbol("AgentBaseInternalState");class Ot extends(Ct=s.Agent,Ct){constructor(t){super(t),this[jt]={}}isSecureEndpoint(t){if(t){if("boolean"==typeof t.secureEndpoint)return t.secureEndpoint;if("string"==typeof t.protocol)return"https:"===t.protocol}const{stack:e}=new Error;return"string"==typeof e&&e.split("\n").some(t=>-1!==t.indexOf("(https.js:")||-1!==t.indexOf("node:https:"))}createSocket(t,e,n){const r={...e,secureEndpoint:this.isSecureEndpoint(e)};Promise.resolve().then(()=>this.connect(t,r)).then(o=>{if(o instanceof s.Agent)return o.addRequest(t,r);this[jt].currentSocket=o,super.createSocket(t,e,n)},n)}createConnection(){const t=this[jt].currentSocket;if(this[jt].currentSocket=void 0,!t)throw new Error("No socket was returned in the `connect()` function");return t}get defaultPort(){return this[jt].defaultPort??("https:"===this.protocol?443:80)}set defaultPort(t){this[jt]&&(this[jt].defaultPort=t)}get protocol(){return this[jt].protocol??(this.isSecureEndpoint()?"https:":"http:")}set protocol(t){this[jt]&&(this[jt].protocol=t)}}function Pt(...t){_.log("[https-proxy-agent:parse-proxy-response]",...t)}function kt(t){return new Promise((e,n)=>{let r=0;const o=[];function s(){const c=t.read();c?function(c){o.push(c),r+=c.length;const u=Buffer.concat(o,r),a=u.indexOf("\r\n\r\n");if(-1===a)return Pt("have not received end of HTTP headers yet..."),void s();const f=u.subarray(0,a).toString("ascii").split("\r\n"),h=f.shift();if(!h)return t.destroy(),n(new Error("No header received from proxy CONNECT response"));const p=h.split(" "),l=+(p[1]||0),d=p.slice(2).join(" "),g={};for(const e of f){if(!e)continue;const r=e.indexOf(":");if(-1===r)return t.destroy(),n(new Error(`Invalid header from proxy CONNECT response: "${e}"`));const o=e.slice(0,r).toLowerCase(),s=e.slice(r+1).trimStart(),i=g[o];"string"==typeof i?g[o]=[i,s]:Array.isArray(i)?i.push(s):g[o]=s}Pt("got proxy server response: %o %o",h,g),i(),e({connect:{statusCode:l,statusText:d,headers:g},buffered:u})}(c):t.once("readable",s)}function i(){t.removeListener("end",c),t.removeListener("error",u),t.removeListener("readable",s)}function c(){i(),Pt("onend"),n(new Error("Proxy connection ended before receiving CONNECT response"))}function u(t){i(),Pt("onerror %o",t),n(t)}t.on("error",u),t.on("end",c),s()})}function At(...t){_.log("[https-proxy-agent]",...t)}class Tt extends Ot{constructor(t,e){super(e),this.options={},this.proxy="string"==typeof t?new URL(t):t,this.proxyHeaders=e?.headers??{},At("Creating new HttpsProxyAgent instance: %o",this.proxy.href);const n=(this.proxy.hostname||this.proxy.host).replace(/^\[|\]$/g,""),r=this.proxy.port?parseInt(this.proxy.port,10):"https:"===this.proxy.protocol?443:80;this.connectOpts={ALPNProtocols:["http/1.1"],...e?It(e,"headers"):null,host:n,port:r}}async connect(t,e){const{proxy:n}=this;if(!e.host)throw new TypeError('No "host" provided');let r;if("https:"===n.protocol){At("Creating `tls.Socket`: %o",this.connectOpts);const t=this.connectOpts.servername||this.connectOpts.host;r=f.connect({...this.connectOpts,servername:t&&a.isIP(t)?void 0:t})}else At("Creating `net.Socket`: %o",this.connectOpts),r=a.connect(this.connectOpts);const o="function"==typeof this.proxyHeaders?this.proxyHeaders():{...this.proxyHeaders},s=a.isIPv6(e.host)?`[${e.host}]`:e.host;let i=`CONNECT ${s}:${e.port} HTTP/1.1\r\n`;if(n.username||n.password){const t=`${decodeURIComponent(n.username)}:${decodeURIComponent(n.password)}`;o["Proxy-Authorization"]=`Basic ${Buffer.from(t).toString("base64")}`}o.Host=`${s}:${e.port}`,o["Proxy-Connection"]||(o["Proxy-Connection"]=this.keepAlive?"Keep-Alive":"close");for(const t of Object.keys(o))i+=`${t}: ${o[t]}\r\n`;const c=kt(r);r.write(`${i}\r\n`);const{connect:u,buffered:h}=await c;if(t.emit("proxyConnect",u),this.emit("proxyConnect",u,t),200===u.statusCode){if(t.once("socket",Rt),e.secureEndpoint){At("Upgrading socket connection to TLS");const t=e.servername||e.host;return f.connect({...It(e,"host","path","port"),socket:r,servername:a.isIP(t)?void 0:t})}return r}r.destroy();const p=new a.Socket({writable:!1});return p.readable=!0,t.once("socket",t=>{At("Replaying proxy buffer for failed request"),t.push(h),t.push(null)}),p}}function Rt(t){t.resume()}function It(t,...e){const n={};let r;for(r in t)e.includes(r)||(n[r]=t[r]);return n}Tt.protocols=["http","https"];function Dt(t){return t.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}const Ut=e;let Bt,Lt=0,Mt={};function zt(t){Ut.debug&&console.log(`[ANR Worker] ${t}`)}var Jt,Wt,Ft;const Gt=function(t){let e;try{e=new URL(t.url)}catch{return b(()=>{console.warn("[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.")}),$t(t,()=>Promise.resolve({}))}const n="https:"===e.protocol,r=function(t,e){const{no_proxy:n}=process.env,r=n?.split(",").some(e=>t.host.endsWith(e)||t.hostname.endsWith(e));return r?void 0:e}(e,t.proxy||(n?process.env.https_proxy:void 0)||process.env.http_proxy),o=n?i:s,a=t.keepAlive??!0,f=r?new Tt(r):new o.Agent({keepAlive:a,maxSockets:30,timeout:2e3}),h=function(t,e,n){const{hostname:r,pathname:o,port:s,protocol:i,search:a}=new URL(t.url);return function(f){const h=p=>new Promise((l,d)=>{yt(()=>{let g=function(t){return new c({read(){this.push(t),this.push(null)}})}(f.body);const m={...t.headers};f.body.length>32768&&(m["content-encoding"]="gzip",g=g.pipe(u()));const y=r.startsWith("["),b=e.request({method:"POST",agent:n,headers:m,hostname:y?r.slice(1,-1):r,path:`${o}${a}`,port:s,protocol:i,ca:t.caCerts},t=>{t.on("data",()=>{}),t.on("end",()=>{}),t.setEncoding("utf8");const e=t.headers["retry-after"]??null,n=t.headers["x-sentry-rate-limits"]??null;l({statusCode:t.statusCode,headers:{"retry-after":e,"x-sentry-rate-limits":Array.isArray(n)?n[0]||null:n}})});b.on("error",t=>{p&&b.reusedSocket&&"ECONNRESET"===t.code?l(h(!1)):d(t)}),g.pipe(b)})});return h(!0)}}(t,t.httpModule??o,f);return $t(t,h)}({url:(Jt=Ut.dsn,Wt=Ut.tunnel,Ft=Ut.sdkMetadata.sdk,Wt||`${function(t){return`${function(t){const e=t.protocol?`${t.protocol}:`:"",n=t.port?`:${t.port}`:"";return`${e}//${t.host}${n}${t.path?`/${t.path}`:""}/api/`}(t)}${t.projectId}/envelope/`}(Jt)}?${function(t,e){const n={sentry_version:"7"};return t.publicKey&&(n.sentry_key=t.publicKey),e&&(n.sentry_client=`${e.name}/${e.version}`),new URLSearchParams(n).toString()}(Jt,Ft)}`)});async function Yt(){if(Bt){zt("Sending abnormal session"),Z(Bt,{status:"abnormal",abnormal_mechanism:"anr_foreground",release:Ut.release,environment:Ut.environment});const t=function(t,e,n,r){const o=mt(n);return ft({sent_at:new Date(I()).toISOString(),...o&&{sdk:o},...!!r&&e&&{dsn:ut(e)}},["aggregates"in t?[{type:"sessions"},t]:[{type:"session"},t.toJSON()]])}(Bt,Ut.dsn,Ut.sdkMetadata,Ut.tunnel);zt(JSON.stringify(t)),await Gt.send(t);try{n?.postMessage("session-ended")}catch{}}}function Ht(t){if(!t)return;const e=function(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(E(e).function||"")&&e.pop(),e.reverse(),$.test(E(e).function||"")&&(e.pop(),$.test(E(e).function||"")&&e.pop()),e.slice(0,50).map(t=>({...t,filename:t.filename||E(e).filename,function:t.function||"?"}))}(t);if(Ut.appRootPath)for(const t of e)t.filename&&(t.filename=M(t.filename,Ut.appRootPath));return e}async function Zt(t,e){if(Lt>=Ut.maxAnrEvents)return;Lt+=1,await Yt(),zt("Sending event");const n={event_id:W(),contexts:Ut.contexts,release:Ut.release,environment:Ut.environment,dist:Ut.dist,platform:"node",level:"error",exception:{values:[{type:"ApplicationNotResponding",value:`Application Not Responding for at least ${Ut.anrThreshold} ms`,stacktrace:{frames:Ht(t)},mechanism:{type:"ANR"}}]},tags:Ut.staticTags};e&&function(t,e){if(at(t,e),!t.contexts?.trace){const{traceId:n,parentSpanId:r,propagationSpanId:o}=e.propagationContext;t.contexts={trace:{trace_id:n,span_id:o||W().substring(16),parent_span_id:r},...t.contexts}}}(n,e),function(t){if(0===Object.keys(Mt).length)return;const e=Ut.appRootPath?{}:Mt;if(Ut.appRootPath)for(const[t,n]of Object.entries(Mt))e[M(t,Ut.appRootPath)]=n;const n=new Map;for(const r of t.exception?.values||[])for(const t of r.stacktrace?.frames||[]){const r=t.abs_path||t.filename;r&&e[r]&&n.set(r,e[r])}if(n.size>0){const e=[];for(const[t,r]of n.entries())e.push({type:"sourcemap",code_file:t,debug_id:r});t.debug_meta={images:e}}}(n);const r=bt(n,Ut.dsn,Ut.sdkMetadata,Ut.tunnel);zt(JSON.stringify(r)),await Gt.send(r),await Gt.flush(2e3),Lt>=Ut.maxAnrEvents&&setTimeout(()=>{process.exit(0)},5e3)}let qt;if(zt("Started"),Ut.captureStackTrace){zt("Connecting to debugger");const e=new t;e.connectToMainThread(),zt("Connected to debugger");const n=new Map;e.on("Debugger.scriptParsed",t=>{n.set(t.params.scriptId,t.params.url)}),e.on("Debugger.paused",t=>{if("other"===t.params.reason)try{zt("Debugger paused");const s=[...t.params.callFrames],i=Ut.appRootPath?function(t=(process.argv[1]?xt(process.argv[1]):process.cwd()),e="\\"===o){const n=e?Dt(t):t;return t=>{if(!t)return;const o=e?Dt(t):t;let{dir:s,base:i,ext:c}=r.parse(o);".js"!==c&&".mjs"!==c&&".cjs"!==c||(i=i.slice(0,-1*c.length));const u=decodeURIComponent(i);s||(s=".");const a=s.lastIndexOf("/node_modules");if(a>-1)return`${s.slice(a+14).replace(/\//g,".")}:${u}`;if(s.startsWith(n)){const t=s.slice(n.length+1).replace(/\//g,".");return t?`${t}:${u}`:u}return u}}(Ut.appRootPath):()=>{},c=s.map(t=>function(t,e,n){const r=e?e.replace(/^file:\/\//,""):void 0,o=t.location.columnNumber?t.location.columnNumber+1:void 0,s=t.location.lineNumber?t.location.lineNumber+1:void 0;return{filename:r,module:n(r),function:t.functionName||"?",colno:o,lineno:s,in_app:r?Nt(r):void 0}}(t,n.get(t.location.scriptId),i)),u=setTimeout(()=>{Zt(c).then(null,()=>{zt("Sending ANR event failed.")})},5e3);e.post("Runtime.evaluate",{expression:"global.__SENTRY_GET_SCOPES__();",silent:!0,returnByValue:!0},(t,n)=>{t&&zt(`Error executing script: '${t.message}'`),clearTimeout(u);const r=n?.result?n.result.value:void 0;e.post("Debugger.resume"),e.post("Debugger.disable"),Zt(c,r).then(null,()=>{zt("Sending ANR event failed.")})})}catch(t){throw e.post("Debugger.resume"),e.post("Debugger.disable"),t}}),qt=()=>{try{e.post("Debugger.enable",()=>{e.post("Debugger.pause")})}catch{}}}const{poll:Kt}=function(t,e,n,r){const o=t();let s=!1,i=!0;return setInterval(()=>{const t=o.getTimeMs();!1===s&&t>e+n&&(s=!0,i&&r()),t<e+n&&(s=!1)},20),{poll:()=>{o.reset()},enabled:t=>{i=t}}}(function(){let t=process.hrtime.bigint();return{getTimeMs:()=>Number((process.hrtime.bigint()-t)/1000000n),reset:()=>{t=process.hrtime.bigint()}}},Ut.pollInterval,Ut.anrThreshold,function(){zt("Watchdog timeout"),qt?(zt("Pausing debugger to capture stack trace"),qt()):(zt("Capturing event without a stack trace"),Zt().then(null,()=>{zt("Sending ANR event failed on watchdog timeout.")}))});n?.on("message",t=>{t.session&&(Bt=H(t.session)),t.debugImages&&(Mt=t.debugImages),Kt()}),n?.postMessage("worker-ready");
|
|
1
|
+
/*! @sentry/node 11.1.0 (1dcfd2f) | https://github.com/getsentry/sentry-javascript */
|
|
2
|
+
import{Session as t}from"node:inspector";import{workerData as e,parentPort as n}from"node:worker_threads";import{posix as r,sep as o}from"node:path";import*as s from"node:http";import*as i from"node:https";import{Readable as c}from"node:stream";import{createGzip as u}from"node:zlib";import*as a from"node:net";import*as f from"node:tls";const h="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,p=globalThis,l="11.1.0";function d(){return g(p),p}function g(t){const e=t.__SENTRY__=t.__SENTRY__||{};return e.version=e.version||l,e[l]=e[l]||{}}function m(t,e,n=p){const r=n.__SENTRY__=n.__SENTRY__||{},o=r[l]=r[l]||{};return o[t]||(o[t]=e())}const y={};function b(t){if(!("console"in p))return t();const e=p.console,n={},r=Object.keys(y);r.forEach(t=>{const r=y[t];n[t]=e[t],e[t]=r});try{return t()}finally{r.forEach(t=>{e[t]=n[t]})}}function v(){return S().enabled}function w(t,...e){h&&v()&&b(()=>{p.console[t](`Sentry Logger [${t}]:`,...e)})}function S(){return h?m("loggerSettings",()=>({enabled:!1})):{enabled:!1}}const _={enable:function(){S().enabled=!0},disable:function(){S().enabled=!1},isEnabled:v,log:function(...t){w("log",...t)},warn:function(...t){w("warn",...t)},error:function(...t){w("error",...t)}},$=/captureMessage|captureException/;function E(t){return t[t.length-1]||{}}const x="<anonymous>";const N=Object.prototype.toString;function C(t){return function(t,e){return N.call(t)===`[object ${e}]`}(t,"Object")}function j(t){return Boolean(t?.then&&"function"==typeof t.then)}function O(t,e){try{return t instanceof e}catch{return!1}}function P(t){if(function(t){switch(N.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return O(t,Error)}}(t))return{message:t.message,name:t.name,stack:t.stack,...k(t)};if(e=t,"undefined"!=typeof Event&&O(e,Event)){const{type:e,target:n,currentTarget:r,detail:o}=t;return{type:e,target:n,currentTarget:r,...o?{detail:o}:{},...k(t)}}var e;return t}function k(t){return"object"==typeof(e=t)&&null!==e?Object.fromEntries(Object.entries(t)):{};var e}let A;function T(t){if(void 0!==A)return A?A(t):t();const e=Symbol.for("__SENTRY_SAFE_RANDOM_ID_WRAPPER__"),n=p;return e in n&&"function"==typeof n[e]?(A=n[e],A(t)):(A=null,t())}function R(){return T(()=>Math.random())}function I(){return T(()=>Date.now())}const D=Symbol.for("sentry.skipNormalization"),U=Symbol.for("sentry.overrideNormalizationDepth");function B(t,e=100,n=1/0){try{return L("",t,e,n)}catch(t){return{ERROR:`**non-serializable** (${t})`}}}function L(t,e,n=1/0,r=1/0,o=function(){const t=new WeakSet;function e(e){return!!t.has(e)||(t.add(e),!1)}function n(e){t.delete(e)}return[e,n]}()){const[s,i]=o;if(null==e||["boolean","string"].includes(typeof e)||"number"==typeof e&&Number.isFinite(e))return e;const c=function(t,e){try{if("undefined"!=typeof global&&e===global)return"[Global]";if("number"==typeof e&&!Number.isFinite(e))return`[${e}]`;if("function"==typeof e)return`[Function: ${function(t){try{return t&&"function"==typeof t&&t.name||x}catch{return x}}(e)}]`;if("symbol"==typeof e)return`[${String(e)}]`;if("bigint"==typeof e)return`[BigInt: ${String(e)}]`;const t=function(t){const e=Object.getPrototypeOf(t);return e?.constructor?e.constructor.name:"null prototype"}(e);return`[object ${t}]`}catch(t){return`**non-serializable** (${t})`}}(0,e);if(!c.startsWith("[object "))return c;if(function(t){return Boolean(t[D])}(e))return e;const u=function(t){const e=t[U];return"number"==typeof e?e:void 0}(e),a=void 0!==u?u:n;if(0===a)return c.replace("object ","");if(s(e))return"[Circular ~]";const f=e;if(f&&"function"==typeof f.toJSON)try{return L("",f.toJSON(),a-1,r,o)}catch{}const h=Array.isArray(e)?[]:{};let p=0;const l=P(e);for(const t in l){if(!Object.prototype.hasOwnProperty.call(l,t))continue;if(p>=r){h[t]="[MaxProperties ~]";break}const e=l[t];h[t]=L(t,e,a-1,r,o),p++}return i(e),h}function M(t,e){const n=e.replace(/\\/g,"/").replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");let r=t;try{r=decodeURI(t)}catch{}return r.replace(/\\/g,"/").replace(/webpack:\/?/g,"").replace(new RegExp(`(file://)?/*${n}/*`,"ig"),"app:///")}function z(t,e=0){return"string"!=typeof t||0===e||t.length<=e?t:`${t.slice(0,e)}...`}let J;function W(t=function(){const t=p;return t.crypto||t.msCrypto}()){try{if(t?.randomUUID)return T(()=>t.randomUUID()).replace(/-/g,"")}catch{}return J||(J="10000000100040008000100000000000"),J.replace(/[018]/g,t=>(t^(16*R()&15)>>t/4).toString(16))}function F(){return I()/1e3}let G;function Y(){return(G??(G=function(){const{performance:t}=p;if(!t?.now||!t.timeOrigin)return F;const e=t.timeOrigin;return()=>(e+T(()=>t.now()))/1e3}()))()}function H(t){const e=Y(),n={sid:W(),init:!0,timestamp:e,started:e,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>function(t){return{sid:`${t.sid}`,init:t.init,started:new Date(1e3*t.started).toISOString(),timestamp:new Date(1e3*t.timestamp).toISOString(),status:t.status,errors:t.errors,did:"number"==typeof t.did||"string"==typeof t.did?`${t.did}`:void 0,duration:t.duration,abnormal_mechanism:t.abnormal_mechanism,attrs:{release:t.release,environment:t.environment,ip_address:t.ipAddress,user_agent:t.userAgent}}}(n)};return t&&Z(n,t),n}function Z(t,e={}){if(e.user&&(!t.ipAddress&&e.user.ip_address&&(t.ipAddress=e.user.ip_address),t.did||e.did||(t.did=e.user.id||e.user.email||e.user.username)),t.timestamp=e.timestamp||Y(),e.abnormal_mechanism&&(t.abnormal_mechanism=e.abnormal_mechanism),e.ignoreDuration&&(t.ignoreDuration=e.ignoreDuration),e.sid&&(t.sid=32===e.sid.length?e.sid:W()),void 0!==e.init&&(t.init=e.init),!t.did&&e.did&&(t.did=`${e.did}`),"number"==typeof e.started&&(t.started=e.started),t.ignoreDuration)t.duration=void 0;else if("number"==typeof e.duration)t.duration=e.duration;else{const e=t.timestamp-t.started;t.duration=e>=0?e:0}e.release&&(t.release=e.release),e.environment&&(t.environment=e.environment),!t.ipAddress&&e.ipAddress&&(t.ipAddress=e.ipAddress),!t.userAgent&&e.userAgent&&(t.userAgent=e.userAgent),"number"==typeof e.errors&&(t.errors=e.errors),e.status&&(t.status=e.status)}function q(t,e,n=2){if(!e||"object"!=typeof e||n<=0)return e;if(t&&0===Object.keys(e).length)return t;const r={...t};for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=q(r[t],e[t],n-1));return r}class K{constructor(){this.t=!1,this.o=[],this.i=[],this.u=[],this.h=[],this.p={},this.l={},this.m={},this.v={},this.S={},this._={},function(t,e,n){try{Object.defineProperty(t,e,{value:n,writable:!0,configurable:!0})}catch{h&&_.log(`Failed to add non-enumerable property "${String(e)}" to object`,t)}}(this,"refs",{}),this.N={traceId:W(),sampleRand:R()}}clone(){const t=new K;return t.u=[...this.u],t.l={...this.l},t.m={...this.m},t.v={...this.v},t.S={...this.S},this.S.flags&&(t.S.flags={values:[...this.S.flags.values]}),t.p=this.p,t.C=this.C,t.j=this.j,t.O=this.O,t.P=this.P,t.i=[...this.i],t.h=[...this.h],t._={...this._},t.N={...this.N},t.k=this.k,t.A=this.A,t.T=this.T,t.refs={...this.refs},t}setClient(t){this.k=t}setLastEventId(t){this.A=t}getClient(){return this.k}lastEventId(){return this.A}addScopeListener(t){this.o.push(t)}addEventProcessor(t){return this.i.push(t),this}setUser(t){return this.p=t||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this.j&&Z(this.j,{user:t}),this.R(),this}getUser(){return this.p}setConversationId(t){return this.T=t||void 0,this.R(),this}setTags(t){return this.l={...this.l,...t},this.R(),this}setTag(t,e){return this.setTags({[t]:e})}setAttributes(t){return this.m={...this.m,...t},this.R(),this}setAttribute(t,e){return this.setAttributes({[t]:e})}removeAttribute(t){return t in this.m&&(delete this.m[t],this.R()),this}setExtras(t){return this.v={...this.v,...t},this.R(),this}setExtra(t,e){return this.v={...this.v,[t]:e},this.R(),this}setFingerprint(t){return this.P=t,this.R(),this}setLevel(t){return this.C=t,this.R(),this}setTransactionName(t){return this.O=t,this.R(),this}setContext(t,e){return null===e?delete this.S[t]:this.S[t]=e,this.R(),this}setSession(t){return t?this.j=t:delete this.j,this.R(),this}getSession(){return this.j}update(t){if(!t)return this;const e="function"==typeof t?t(this):t,n=e instanceof K?e.getScopeData():C(e)?t:void 0,{tags:r,attributes:o,extra:s,user:i,contexts:c,level:u,fingerprint:a=[],propagationContext:f,conversationId:h}=n||{};return this.l={...this.l,...r},this.m={...this.m,...o},this.v={...this.v,...s},this.S={...this.S,...c},i&&Object.keys(i).length&&(this.p=i),u&&(this.C=u),a.length&&(this.P=a),f&&(this.N=f),h&&(this.T=h),this}addBreadcrumb(t,e){const n="number"==typeof e?e:100;if(n<=0)return this;const r={timestamp:F(),...t,message:t.message?z(t.message,2048):t.message};return this.u.push(r),this.u.length>n&&(this.u=this.u.slice(-n)),this.R(),this}getLastBreadcrumb(){return this.u[this.u.length-1]}clearBreadcrumbs(){return this.u=[],this.R(),this}addAttachment(t){return this.h.push(t),this}clearAttachments(){return this.h=[],this}getScopeData(){return{breadcrumbs:this.u,attachments:this.h,contexts:this.S,tags:this.l,attributes:this.m,extra:this.v,user:this.p,level:this.C,fingerprint:this.P||[],eventProcessors:this.i,propagationContext:this.N,sdkProcessingMetadata:this._,transactionName:this.O,conversationId:this.T}}setSDKProcessingMetadata(t){return this._=q(this._,t,2),this}setPropagationContext(t){return this.N=t,this}getPropagationContext(){return this.N}captureException(t,e){const n=e?.event_id||W();if(!this.k)return h&&_.warn("No client configured on scope - will not capture exception!"),n;const r=new Error("Sentry syntheticException");return this.k.captureException(t,{originalException:t,syntheticException:r,...e,event_id:n},this),n}captureMessage(t,e,n){const r=n?.event_id||W();if(!this.k)return h&&_.warn("No client configured on scope - will not capture message!"),r;const o=n?.syntheticException??new Error(t);return this.k.captureMessage(t,e,{originalException:t,syntheticException:o,...n,event_id:r},this),r}captureEvent(t,e){const n=t.event_id||e?.event_id||W();return this.k?(this.k.captureEvent(t,{...e,event_id:n},this),n):(h&&_.warn("No client configured on scope - will not capture event!"),n)}R(){this.t||(this.t=!0,this.o.forEach(t=>{t(this)}),this.t=!1)}}const V="__SENTRY_SUPPRESS_TRACING__",Q=t=>t instanceof Promise&&!t[X],X=Symbol("chained PromiseLike"),tt=(t,e)=>{if(!e)return t;let n=!1;for(const r in t){if(r in e)continue;n=!0;const o=t[r];"function"==typeof o?Object.defineProperty(e,r,{value:(...e)=>o.apply(t,e),enumerable:!0,configurable:!0,writable:!0}):e[r]=o}return n&&Object.assign(e,{[X]:!0}),e};class et{constructor(t,e){let n,r;n=t||new K,r=e||new K,this.I=[{scope:n}],this.D=r}withScope(t){const e=this.U();let n;try{n=t(e)}catch(t){throw this.B(),t}return j(n)?((t,e,n)=>{const r=t.then(t=>(e(t),t),t=>{throw n(t),t});return Q(r)&&Q(t)?r:tt(t,r)})(n,()=>this.B(),()=>this.B()):(this.B(),n)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this.D}getStackTop(){return this.I[this.I.length-1]}U(){const t=this.getScope().clone();return this.I.push({client:this.getClient(),scope:t}),t}B(){return!(this.I.length<=1)&&!!this.I.pop()}}function nt(){const t=g(d());return t.stack=t.stack||new et(m("defaultCurrentScope",()=>new K),m("defaultIsolationScope",()=>new K))}function rt(t){return nt().withScope(t)}function ot(t,e){const n=nt();return n.withScope(()=>(n.getStackTop().scope=t,e(t)))}function st(t){return nt().withScope(()=>t(nt().getIsolationScope()))}function it(t){return rt(e=>{e.setSDKProcessingMetadata({[V]:!0});const n=t();return e.setSDKProcessingMetadata({[V]:void 0}),n})}function ct(t){const e=g(t);return e.acs?e.acs:{suppressTracing:it,withIsolationScope:st,withScope:rt,withSetScope:ot,withSetIsolationScope:(t,e)=>st(e),getCurrentScope:()=>nt().getScope(),getIsolationScope:()=>nt().getIsolationScope()}}function ut(t,e=!1){const{host:n,path:r,pass:o,port:s,projectId:i,protocol:c,publicKey:u}=t;return`${c}://${u}${e&&o?`:${o}`:""}@${n}${s?`:${s}`:""}/${r?`${r}/`:r}${i}`}function at(t,e){const{fingerprint:n,breadcrumbs:r,sdkProcessingMetadata:o}=e;!function(t,e){const{extra:n,tags:r,user:o,contexts:s,level:i,transactionName:c}=e;Object.keys(n).length&&(t.extra={...n,...t.extra});Object.keys(r).length&&(t.tags={...r,...t.tags});Object.keys(o).length&&(t.user={...o,...t.user});Object.keys(s).length&&(t.contexts={...s,...t.contexts});i&&(t.level=i);c&&"transaction"!==t.type&&(t.transaction=c)}(t,e),function(t,e){t.fingerprint=t.fingerprint?Array.isArray(t.fingerprint)?t.fingerprint:[t.fingerprint]:[],e&&(t.fingerprint=t.fingerprint.concat(e));t.fingerprint.length||delete t.fingerprint}(t,n),function(t,e){const n=[...t.breadcrumbs||[],...e];t.breadcrumbs=n.length?n:void 0}(t,r),function(t,e){t.sdkProcessingMetadata={...t.sdkProcessingMetadata,...e}}(t,o)}function ft(t,e=[]){return[t,e]}function ht(t,e){const n=t[1];for(const t of n){if(e(t,t[0].type))return!0}return!1}function pt(t){const e=g(p);return e.encodePolyfill?e.encodePolyfill(t):(new TextEncoder).encode(t)}function lt(t){const[e,n]=t;let r=JSON.stringify(e);function o(t){"string"==typeof r?r="string"==typeof t?r+t:[pt(r),t]:r.push("string"==typeof t?pt(t):t)}for(const t of n){const[e,n]=t;if(o(`\n${JSON.stringify(e)}\n`),"string"==typeof n||n instanceof Uint8Array)o(n);else{let t;try{t=JSON.stringify(n)}catch{t=JSON.stringify(B(n))}o(t)}}return"string"==typeof r?r:function(t){const e=t.reduce((t,e)=>t+e.length,0),n=new Uint8Array(e);let r=0;for(const e of t)n.set(e,r),r+=e.length;return n}(r)}const dt={sessions:"session",event:"error",client_report:"internal",user_report:"default",profile_chunk:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor",raw_security:"security",log:"log_item",trace_metric:"metric"};function gt(t){return function(t){return t in dt}(t)?dt[t]:t}function mt(t){if(!t?.sdk)return;const{name:e,version:n}=t.sdk;return{name:e,version:n}}function yt(t){const e=ct(d());return e.suppressTracing?e.suppressTracing(t):function(...t){const e=ct(d());if(2===t.length){const[n,r]=t;return n?e.withSetScope(n,r):e.withScope(r)}return e.withScope(t[0])}(e=>(e.setSDKProcessingMetadata({[V]:!0}),t()))}function bt(t,e,n,r){const o=mt(n),s=t.type&&"replay_event"!==t.type?t.type:"event";!function(t,e){if(!e)return t;const n=t.sdk||{};t.sdk={...n,name:n.name||e.name,version:n.version||e.version,integrations:[...t.sdk?.integrations||[],...e.integrations||[]],packages:[...t.sdk?.packages||[],...e.packages||[]],settings:t.sdk?.settings||e.settings?{...t.sdk?.settings,...e.settings}:void 0}}(t,n?.sdk);const i=function(t,e,n,r){const o=t.sdkProcessingMetadata?.dynamicSamplingContext;return{event_id:t.event_id,sent_at:new Date(I()).toISOString(),...e&&{sdk:e},...!!n&&r&&{dsn:ut(r)},...o&&{trace:o}}}(t,o,r,e);delete t.sdkProcessingMetadata;return ft(i,[[{type:s},t]])}class vt{constructor(t){this.L=0,this.M=[],this.J(t)}then(t,e){return new vt((n,r)=>{this.M.push([!1,e=>{if(t)try{n(t(e))}catch(t){r(t)}else n(e)},t=>{if(e)try{n(e(t))}catch(t){r(t)}else r(t)}]),this.W()})}catch(t){return this.then(t=>t,t)}finally(t){return new vt((e,n)=>{let r,o;return this.then(e=>{o=!1,r=e,t&&t()},e=>{o=!0,r=e,t&&t()}).then(()=>{o?n(r):e(r)})})}W(){if(0===this.L)return;const t=this.M.slice();this.M=[],t.forEach(t=>{t[0]||(1===this.L&&t[1](this.F),2===this.L&&t[2](this.F),t[0]=!0)})}J(t){const e=(t,e)=>{0===this.L&&(j(e)?e.then(n,r):(this.L=t,this.F=e,this.W()))},n=t=>{e(1,t)},r=t=>{e(2,t)};try{t(n,r)}catch(t){r(t)}}}const wt=Symbol.for("SentryBufferFullError");function St(t=100){const e=new Set;function n(t){e.delete(t)}return{get $(){return Array.from(e)},add:function(r){if(!(e.size<t))return o=wt,new vt((t,e)=>{e(o)});var o;const s=r();return e.add(s),s.then(()=>n(s),()=>n(s)),s},drain:function(t){if(!e.size)return n=!0,new vt(t=>{t(n)});var n;const r=Promise.allSettled(Array.from(e)).then(()=>!0);if(!t)return r;const o=[r,new Promise(e=>{return"object"==typeof(n=setTimeout(()=>e(!1),t))&&"function"==typeof n.unref&&n.unref(),n;var n})];return Promise.race(o)}}}function _t(t,{statusCode:e,headers:n},r=I()){const o={...t},s=n?.["x-sentry-rate-limits"],i=n?.["retry-after"];if(s)for(const t of s.trim().split(",")){const[e,n,,,s]=t.split(":",5),i=parseInt(e,10),c=1e3*(isNaN(i)?60:i);if(n)for(const t of n.split(";"))"metric_bucket"===t&&s&&!s.split(";").includes("custom")||(o[t]=r+c);else o.all=r+c}else i?o.all=r+function(t,e=I()){const n=parseInt(`${t}`,10);if(!isNaN(n))return 1e3*n;const r=Date.parse(`${t}`);return isNaN(r)?6e4:r-e}(i,r):429===e&&(o.all=r+6e4);return o}function $t(t,e,n=St(t.bufferSize||64)){let r={};return{send:function(t){const o=[];if(ht(t,(t,e)=>{const n=gt(e);(function(t,e,n=I()){return function(t,e){return t[e]||t.all||0}(t,e)>n})(r,n)||o.push(t)}),0===o.length)return Promise.resolve({});const s=ft(t[0],o),i=t=>{!function(t,e){return ht(t,(t,n)=>e.includes(n))}(s,["client_report"])?ht(s,(t,e)=>{}):h&&_.warn(`Dropping client report. Will not send outcomes (reason: ${t}).`)};return n.add(()=>e({body:lt(s)}).then(t=>413===t.statusCode?(h&&_.error("Sentry responded with status code 413. Envelope was discarded due to exceeding size limits."),i("send_error"),t):(h&&void 0!==t.statusCode&&(t.statusCode<200||t.statusCode>=300)&&_.warn(`Sentry responded with status code ${t.statusCode} to sent event.`),r=_t(r,t),t),t=>{throw i("network_error"),h&&_.error("Encountered error running transport request:",t),t})).then(t=>t,t=>{if(t===wt)return h&&_.error("Skipped sending event because buffer is full."),i("queue_overflow"),Promise.resolve({});throw t})},flush:t=>n.drain(t)}}const Et=/^(\S+:\\|\/?)([\s\S]*?)((?:\.{1,2}|[^/\\]+?|)(\.[^./\\]*|))(?:[/\\]*)$/;function xt(t){const e=function(t){const e=t.length>1024?`<truncated>${t.slice(-1024)}`:t,n=Et.exec(e);return n?n.slice(1):[]}(t),n=e[0]||"";let r=e[1];return n||r?(r&&(r=r.slice(0,r.length-1)),n+r):"."}function Nt(t,e=!1){return!(e||t&&!t.startsWith("/")&&!t.match(/^[A-Z]:/)&&!t.startsWith(".")&&!t.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//))&&void 0!==t&&!t.includes("node_modules/")}var Ct;const jt=Symbol("AgentBaseInternalState");class Ot extends(Ct=s.Agent,Ct){constructor(t){super(t),this[jt]={}}isSecureEndpoint(t){if(t){if("boolean"==typeof t.secureEndpoint)return t.secureEndpoint;if("string"==typeof t.protocol)return"https:"===t.protocol}const{stack:e}=new Error;return"string"==typeof e&&e.split("\n").some(t=>-1!==t.indexOf("(https.js:")||-1!==t.indexOf("node:https:"))}createSocket(t,e,n){const r={...e,secureEndpoint:this.isSecureEndpoint(e)};Promise.resolve().then(()=>this.connect(t,r)).then(o=>{if(o instanceof s.Agent)return o.addRequest(t,r);this[jt].currentSocket=o,super.createSocket(t,e,n)},n)}createConnection(){const t=this[jt].currentSocket;if(this[jt].currentSocket=void 0,!t)throw new Error("No socket was returned in the `connect()` function");return t}get defaultPort(){return this[jt].defaultPort??("https:"===this.protocol?443:80)}set defaultPort(t){this[jt]&&(this[jt].defaultPort=t)}get protocol(){return this[jt].protocol??(this.isSecureEndpoint()?"https:":"http:")}set protocol(t){this[jt]&&(this[jt].protocol=t)}}function Pt(...t){_.log("[https-proxy-agent:parse-proxy-response]",...t)}function kt(t){return new Promise((e,n)=>{let r=0;const o=[];function s(){const c=t.read();c?function(c){o.push(c),r+=c.length;const u=Buffer.concat(o,r),a=u.indexOf("\r\n\r\n");if(-1===a)return Pt("have not received end of HTTP headers yet..."),void s();const f=u.subarray(0,a).toString("ascii").split("\r\n"),h=f.shift();if(!h)return t.destroy(),n(new Error("No header received from proxy CONNECT response"));const p=h.split(" "),l=+(p[1]||0),d=p.slice(2).join(" "),g={};for(const e of f){if(!e)continue;const r=e.indexOf(":");if(-1===r)return t.destroy(),n(new Error(`Invalid header from proxy CONNECT response: "${e}"`));const o=e.slice(0,r).toLowerCase(),s=e.slice(r+1).trimStart(),i=g[o];"string"==typeof i?g[o]=[i,s]:Array.isArray(i)?i.push(s):g[o]=s}Pt("got proxy server response: %o %o",h,g),i(),e({connect:{statusCode:l,statusText:d,headers:g},buffered:u})}(c):t.once("readable",s)}function i(){t.removeListener("end",c),t.removeListener("error",u),t.removeListener("readable",s)}function c(){i(),Pt("onend"),n(new Error("Proxy connection ended before receiving CONNECT response"))}function u(t){i(),Pt("onerror %o",t),n(t)}t.on("error",u),t.on("end",c),s()})}function At(...t){_.log("[https-proxy-agent]",...t)}class Tt extends Ot{constructor(t,e){super(e),this.options={},this.proxy="string"==typeof t?new URL(t):t,this.proxyHeaders=e?.headers??{},At("Creating new HttpsProxyAgent instance: %o",this.proxy.href);const n=(this.proxy.hostname||this.proxy.host).replace(/^\[|\]$/g,""),r=this.proxy.port?parseInt(this.proxy.port,10):"https:"===this.proxy.protocol?443:80;this.connectOpts={ALPNProtocols:["http/1.1"],...e?It(e,"headers"):null,host:n,port:r}}async connect(t,e){const{proxy:n}=this;if(!e.host)throw new TypeError('No "host" provided');let r;if("https:"===n.protocol){At("Creating `tls.Socket`: %o",this.connectOpts);const t=this.connectOpts.servername||this.connectOpts.host;r=f.connect({...this.connectOpts,servername:t&&a.isIP(t)?void 0:t})}else At("Creating `net.Socket`: %o",this.connectOpts),r=a.connect(this.connectOpts);const o="function"==typeof this.proxyHeaders?this.proxyHeaders():{...this.proxyHeaders},s=a.isIPv6(e.host)?`[${e.host}]`:e.host;let i=`CONNECT ${s}:${e.port} HTTP/1.1\r\n`;if(n.username||n.password){const t=`${decodeURIComponent(n.username)}:${decodeURIComponent(n.password)}`;o["Proxy-Authorization"]=`Basic ${Buffer.from(t).toString("base64")}`}o.Host=`${s}:${e.port}`,o["Proxy-Connection"]||(o["Proxy-Connection"]=this.keepAlive?"Keep-Alive":"close");for(const t of Object.keys(o))i+=`${t}: ${o[t]}\r\n`;const c=kt(r);r.write(`${i}\r\n`);const{connect:u,buffered:h}=await c;if(t.emit("proxyConnect",u),this.emit("proxyConnect",u,t),200===u.statusCode){if(t.once("socket",Rt),e.secureEndpoint){At("Upgrading socket connection to TLS");const t=e.servername||e.host;return f.connect({...It(e,"host","path","port"),socket:r,servername:a.isIP(t)?void 0:t})}return r}r.destroy();const p=new a.Socket({writable:!1});return p.readable=!0,t.once("socket",t=>{At("Replaying proxy buffer for failed request"),t.push(h),t.push(null)}),p}}function Rt(t){t.resume()}function It(t,...e){const n={};let r;for(r in t)e.includes(r)||(n[r]=t[r]);return n}Tt.protocols=["http","https"];function Dt(t){return t.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}const Ut=e;let Bt,Lt=0,Mt={};function zt(t){Ut.debug&&console.log(`[ANR Worker] ${t}`)}var Jt,Wt,Ft;const Gt=function(t){let e;try{e=new URL(t.url)}catch{return b(()=>{console.warn("[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.")}),$t(t,()=>Promise.resolve({}))}const n="https:"===e.protocol,r=function(t,e){const{no_proxy:n}=process.env,r=n?.split(",").some(e=>t.host.endsWith(e)||t.hostname.endsWith(e));return r?void 0:e}(e,t.proxy||(n?process.env.https_proxy:void 0)||process.env.http_proxy),o=n?i:s,a=t.keepAlive??!0,f=r?new Tt(r):new o.Agent({keepAlive:a,maxSockets:30,timeout:2e3}),h=function(t,e,n){const{hostname:r,pathname:o,port:s,protocol:i,search:a}=new URL(t.url);return function(f){const h=p=>new Promise((l,d)=>{yt(()=>{let g=function(t){return new c({read(){this.push(t),this.push(null)}})}(f.body);const m={...t.headers};f.body.length>32768&&(m["content-encoding"]="gzip",g=g.pipe(u()));const y=r.startsWith("["),b=e.request({method:"POST",agent:n,headers:m,hostname:y?r.slice(1,-1):r,path:`${o}${a}`,port:s,protocol:i,ca:t.caCerts},t=>{t.on("data",()=>{}),t.on("end",()=>{}),t.setEncoding("utf8");const e=t.headers["retry-after"]??null,n=t.headers["x-sentry-rate-limits"]??null;l({statusCode:t.statusCode,headers:{"retry-after":e,"x-sentry-rate-limits":Array.isArray(n)?n[0]||null:n}})});b.on("error",t=>{p&&b.reusedSocket&&"ECONNRESET"===t.code?l(h(!1)):d(t)}),g.pipe(b)})});return h(!0)}}(t,t.httpModule??o,f);return $t(t,h)}({url:(Jt=Ut.dsn,Wt=Ut.tunnel,Ft=Ut.sdkMetadata.sdk,Wt||`${function(t){return`${function(t){const e=t.protocol?`${t.protocol}:`:"",n=t.port?`:${t.port}`:"";return`${e}//${t.host}${n}${t.path?`/${t.path}`:""}/api/`}(t)}${t.projectId}/envelope/`}(Jt)}?${function(t,e){const n={sentry_version:"7"};return t.publicKey&&(n.sentry_key=t.publicKey),e&&(n.sentry_client=`${e.name}/${e.version}`),new URLSearchParams(n).toString()}(Jt,Ft)}`)});async function Yt(){if(Bt){zt("Sending abnormal session"),Z(Bt,{status:"abnormal",abnormal_mechanism:"anr_foreground",release:Ut.release,environment:Ut.environment});const t=function(t,e,n,r){const o=mt(n);return ft({sent_at:new Date(I()).toISOString(),...o&&{sdk:o},...!!r&&e&&{dsn:ut(e)}},["aggregates"in t?[{type:"sessions"},t]:[{type:"session"},t.toJSON()]])}(Bt,Ut.dsn,Ut.sdkMetadata,Ut.tunnel);zt(JSON.stringify(t)),await Gt.send(t);try{n?.postMessage("session-ended")}catch{}}}function Ht(t){if(!t)return;const e=function(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(E(e).function||"")&&e.pop(),e.reverse(),$.test(E(e).function||"")&&(e.pop(),$.test(E(e).function||"")&&e.pop()),e.slice(0,50).map(t=>({...t,filename:t.filename||E(e).filename,function:t.function||"?"}))}(t);if(Ut.appRootPath)for(const t of e)t.filename&&(t.filename=M(t.filename,Ut.appRootPath));return e}async function Zt(t,e){if(Lt>=Ut.maxAnrEvents)return;Lt+=1,await Yt(),zt("Sending event");const n={event_id:W(),contexts:Ut.contexts,release:Ut.release,environment:Ut.environment,dist:Ut.dist,platform:"node",level:"error",exception:{values:[{type:"ApplicationNotResponding",value:`Application Not Responding for at least ${Ut.anrThreshold} ms`,stacktrace:{frames:Ht(t)},mechanism:{type:"ANR"}}]},tags:Ut.staticTags};e&&function(t,e){if(at(t,e),!t.contexts?.trace){const{traceId:n,parentSpanId:r,propagationSpanId:o}=e.propagationContext;t.contexts={trace:{trace_id:n,span_id:o||W().substring(16),parent_span_id:r},...t.contexts}}}(n,e),function(t){if(0===Object.keys(Mt).length)return;const e=Ut.appRootPath?{}:Mt;if(Ut.appRootPath)for(const[t,n]of Object.entries(Mt))e[M(t,Ut.appRootPath)]=n;const n=new Map;for(const r of t.exception?.values||[])for(const t of r.stacktrace?.frames||[]){const r=t.abs_path||t.filename;r&&e[r]&&n.set(r,e[r])}if(n.size>0){const e=[];for(const[t,r]of n.entries())e.push({type:"sourcemap",code_file:t,debug_id:r});t.debug_meta={images:e}}}(n);const r=bt(n,Ut.dsn,Ut.sdkMetadata,Ut.tunnel);zt(JSON.stringify(r)),await Gt.send(r),await Gt.flush(2e3),Lt>=Ut.maxAnrEvents&&setTimeout(()=>{process.exit(0)},5e3)}let qt;if(zt("Started"),Ut.captureStackTrace){zt("Connecting to debugger");const e=new t;e.connectToMainThread(),zt("Connected to debugger");const n=new Map;e.on("Debugger.scriptParsed",t=>{n.set(t.params.scriptId,t.params.url)}),e.on("Debugger.paused",t=>{if("other"===t.params.reason)try{zt("Debugger paused");const s=[...t.params.callFrames],i=Ut.appRootPath?function(t=(process.argv[1]?xt(process.argv[1]):process.cwd()),e="\\"===o){const n=e?Dt(t):t;return t=>{if(!t)return;const o=e?Dt(t):t;let{dir:s,base:i,ext:c}=r.parse(o);".js"!==c&&".mjs"!==c&&".cjs"!==c||(i=i.slice(0,-1*c.length));const u=decodeURIComponent(i);s||(s=".");const a=s.lastIndexOf("/node_modules");if(a>-1)return`${s.slice(a+14).replace(/\//g,".")}:${u}`;if(s.startsWith(n)){const t=s.slice(n.length+1).replace(/\//g,".");return t?`${t}:${u}`:u}return u}}(Ut.appRootPath):()=>{},c=s.map(t=>function(t,e,n){const r=e?e.replace(/^file:\/\//,""):void 0,o=t.location.columnNumber?t.location.columnNumber+1:void 0,s=t.location.lineNumber?t.location.lineNumber+1:void 0;return{filename:r,module:n(r),function:t.functionName||"?",colno:o,lineno:s,in_app:r?Nt(r):void 0}}(t,n.get(t.location.scriptId),i)),u=setTimeout(()=>{Zt(c).then(null,()=>{zt("Sending ANR event failed.")})},5e3);e.post("Runtime.evaluate",{expression:"global.__SENTRY_GET_SCOPES__();",silent:!0,returnByValue:!0},(t,n)=>{t&&zt(`Error executing script: '${t.message}'`),clearTimeout(u);const r=n?.result?n.result.value:void 0;e.post("Debugger.resume"),e.post("Debugger.disable"),Zt(c,r).then(null,()=>{zt("Sending ANR event failed.")})})}catch(t){throw e.post("Debugger.resume"),e.post("Debugger.disable"),t}}),qt=()=>{try{e.post("Debugger.enable",()=>{e.post("Debugger.pause")})}catch{}}}const{poll:Kt}=function(t,e,n,r){const o=t();let s=!1,i=!0;return setInterval(()=>{const t=o.getTimeMs();!1===s&&t>e+n&&(s=!0,i&&r()),t<e+n&&(s=!1)},20),{poll:()=>{o.reset()},enabled:t=>{i=t}}}(function(){let t=process.hrtime.bigint();return{getTimeMs:()=>Number((process.hrtime.bigint()-t)/1000000n),reset:()=>{t=process.hrtime.bigint()}}},Ut.pollInterval,Ut.anrThreshold,function(){zt("Watchdog timeout"),qt?(zt("Pausing debugger to capture stack trace"),qt()):(zt("Capturing event without a stack trace"),Zt().then(null,()=>{zt("Sending ANR event failed on watchdog timeout.")}))});n?.on("message",t=>{t.session&&(Bt=H(t.session)),t.debugImages&&(Mt=t.debugImages),Kt()}),n?.postMessage("worker-ready");
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import * as diagnosticsChannel from 'node:diagnostics_channel';
|
|
2
1
|
import { defineIntegration, isObjectLike, addBreadcrumb } from '@sentry/core';
|
|
2
|
+
import { subscribeDiagnosticsChannel } from '@sentry/server-utils';
|
|
3
3
|
|
|
4
4
|
const INTEGRATION_NAME = "ChildProcess";
|
|
5
5
|
const childProcessIntegration = defineIntegration((options = {}) => {
|
|
6
6
|
return {
|
|
7
7
|
name: INTEGRATION_NAME,
|
|
8
8
|
setup() {
|
|
9
|
-
|
|
9
|
+
subscribeDiagnosticsChannel("child_process", (event) => {
|
|
10
10
|
if (isObjectLike(event) && "process" in event) {
|
|
11
11
|
captureChildProcessEvents(event.process, options);
|
|
12
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"childProcess.js","sources":["../../../src/integrations/childProcess.ts"],"sourcesContent":["import type { ChildProcess } from 'node:child_process';\nimport
|
|
1
|
+
{"version":3,"file":"childProcess.js","sources":["../../../src/integrations/childProcess.ts"],"sourcesContent":["import type { ChildProcess } from 'node:child_process';\nimport { addBreadcrumb, defineIntegration, isObjectLike } from '@sentry/core';\nimport { subscribeDiagnosticsChannel } from '@sentry/server-utils';\n\ninterface Options {\n /**\n * Whether to include child process arguments in breadcrumbs data.\n *\n * @default false\n */\n includeChildProcessArgs?: boolean;\n}\n\nconst INTEGRATION_NAME = 'ChildProcess' as const;\n\n/**\n * Capture breadcrumbs and events for child processes.\n * For worker thread events, use `workerThreadsIntegration()` instead.\n */\nexport const childProcessIntegration = defineIntegration((options: Options = {}) => {\n return {\n name: INTEGRATION_NAME,\n setup() {\n subscribeDiagnosticsChannel('child_process', (event: unknown) => {\n if (isObjectLike(event) && 'process' in event) {\n captureChildProcessEvents(event.process as ChildProcess, options);\n }\n });\n },\n };\n});\n\nfunction captureChildProcessEvents(child: ChildProcess, options: Options): void {\n let hasExited = false;\n let data: Record<string, unknown> | undefined;\n\n child\n .on('spawn', () => {\n // This is Sentry getting macOS OS context\n if (child.spawnfile === '/usr/bin/sw_vers') {\n hasExited = true;\n return;\n }\n\n data = { spawnfile: child.spawnfile };\n if (options.includeChildProcessArgs) {\n data.spawnargs = child.spawnargs;\n }\n })\n .on('exit', code => {\n if (!hasExited) {\n hasExited = true;\n\n // Only log for non-zero exit codes\n if (code !== null && code !== 0) {\n addBreadcrumb({\n category: 'child_process',\n message: `Child process exited with code '${code}'`,\n level: code === 0 ? 'info' : 'warning',\n data,\n });\n }\n }\n })\n .on('error', error => {\n if (!hasExited) {\n hasExited = true;\n\n addBreadcrumb({\n category: 'child_process',\n message: `Child process errored with '${error.message}'`,\n level: 'error',\n data,\n });\n }\n });\n}\n"],"names":[],"mappings":";;;AAaA,MAAM,gBAAA,GAAmB,cAAA;AAMlB,MAAM,uBAAA,GAA0B,iBAAA,CAAkB,CAAC,OAAA,GAAmB,EAAC,KAAM;AAClF,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,KAAA,GAAQ;AACN,MAAA,2BAAA,CAA4B,eAAA,EAAiB,CAAC,KAAA,KAAmB;AAC/D,QAAA,IAAI,YAAA,CAAa,KAAK,CAAA,IAAK,SAAA,IAAa,KAAA,EAAO;AAC7C,UAAA,yBAAA,CAA0B,KAAA,CAAM,SAAyB,OAAO,CAAA;AAAA,QAClE;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF,CAAC;AAED,SAAS,yBAAA,CAA0B,OAAqB,OAAA,EAAwB;AAC9E,EAAA,IAAI,SAAA,GAAY,KAAA;AAChB,EAAA,IAAI,IAAA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|
3
2
|
import { isTracingSuppressed } from '@sentry/core';
|
|
4
3
|
import { getHttpClientSubscriptions, HTTP_ON_CLIENT_REQUEST, patchHttpModuleClient, getRequestOptions } from '@sentry/core/server';
|
|
4
|
+
import { subscribeDiagnosticsChannel } from '@sentry/server-utils';
|
|
5
5
|
import { NODE_VERSION } from '../../nodeVersion.js';
|
|
6
6
|
import { errorMonitor } from 'node:events';
|
|
7
7
|
import * as http from 'node:http';
|
|
@@ -50,7 +50,7 @@ function instrumentHttpOutgoingRequests(instrumentationOptions = {}) {
|
|
|
50
50
|
}
|
|
51
51
|
function instrumentHttpOutgoingRequestsViaChannel(options) {
|
|
52
52
|
const { [HTTP_ON_CLIENT_REQUEST]: onHttpClientRequestCreated } = getHttpClientSubscriptions(options);
|
|
53
|
-
|
|
53
|
+
subscribeDiagnosticsChannel(HTTP_ON_CLIENT_REQUEST, onHttpClientRequestCreated);
|
|
54
54
|
}
|
|
55
55
|
function instrumentHttpOutgoingRequestsViaMonkeyPatching(options) {
|
|
56
56
|
patchHttpModuleClient(http, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SentryHttpInstrumentation.js","sources":["../../../../src/integrations/http/SentryHttpInstrumentation.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"SentryHttpInstrumentation.js","sources":["../../../../src/integrations/http/SentryHttpInstrumentation.ts"],"sourcesContent":["import { context, trace } from '@opentelemetry/api';\nimport type { ClientRequest, IncomingMessage } from 'node:http';\nimport type { Span } from '@sentry/core';\nimport { isTracingSuppressed } from '@sentry/core';\nimport type { HttpClientRequest, HttpIncomingMessage, HttpInstrumentationOptions } from '@sentry/core/server';\nimport {\n getHttpClientSubscriptions,\n getRequestOptions,\n HTTP_ON_CLIENT_REQUEST,\n patchHttpModuleClient,\n} from '@sentry/core/server';\nimport { subscribeDiagnosticsChannel } from '@sentry/server-utils';\nimport { NODE_VERSION } from '../../nodeVersion';\nimport { errorMonitor } from 'node:events';\nimport * as http from 'node:http';\n\nconst FULLY_SUPPORTS_HTTP_DIAGNOSTICS_CHANNEL =\n (NODE_VERSION.major === 22 && NODE_VERSION.minor >= 12) ||\n (NODE_VERSION.major === 23 && NODE_VERSION.minor >= 2) ||\n NODE_VERSION.major >= 24;\n\nexport interface OutgoingHttpRequestInstrumentationOptions {\n /**\n * Whether breadcrumbs should be recorded for outgoing requests.\n *\n * @default `true`\n */\n breadcrumbs?: boolean;\n\n /**\n * Whether to create spans for outgoing requests.\n *\n * @default `true`\n */\n spans?: boolean;\n\n /**\n * Whether to propagate Sentry trace headers in outgoing requests.\n *\n * @default `true`\n */\n tracePropagation?: boolean;\n\n /**\n * Do not instrument outgoing HTTP requests to URLs where the given callback returns `true`.\n * When it returns `true`, the request is skipped entirely: no breadcrumb and no span are created,\n * and no trace headers are propagated for that request.\n *\n * @param url Contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.\n * @param request Contains the {@type RequestOptions} object used to make the outgoing request.\n */\n ignoreOutgoingRequests?: (url: string, request: http.RequestOptions) => boolean;\n\n /**\n * Hooks for outgoing request spans, only called when spans are created for outgoing requests\n * (i.e. when `spans` is enabled).\n */\n outgoingRequestHook?: (span: Span, request: ClientRequest) => void;\n outgoingResponseHook?: (span: Span, response: IncomingMessage) => void;\n outgoingRequestApplyCustomAttributes?: (\n span: Span,\n request: HttpClientRequest,\n response: HttpIncomingMessage,\n ) => void;\n}\n\n/**\n * This instruments the http modules for outgoing requests.\n * It uses the diagnostics channel if available, otherwise it falls back to monkey-patching.\n *\n * The instrumentation will start spans, create breadcrumbs, and propagate trace headers in outgoing requests (depending on the settings).\n */\nexport function instrumentHttpOutgoingRequests(\n instrumentationOptions: OutgoingHttpRequestInstrumentationOptions = {},\n): void {\n const { outgoingRequestApplyCustomAttributes: applyCustomAttributesOnSpan, ...options } = instrumentationOptions;\n const patchOptions = {\n applyCustomAttributesOnSpan,\n ...options,\n tracePropagation: options.tracePropagation ?? true,\n spans: options.spans ?? true,\n ignoreOutgoingRequests(url, request) {\n return isTracingSuppressed() || !!options.ignoreOutgoingRequests?.(url, getRequestOptions(request));\n },\n outgoingRequestHook(span, request) {\n options.outgoingRequestHook?.(span, request as ClientRequest);\n // We monkey-patch `req.once('response'), which is used to trigger\n // the callback of the request, so that it runs in the active context\n // eslint-disable-next-line @typescript-eslint/unbound-method, typescript/no-deprecated\n const originalOnce = request.once;\n\n const newOnce = new Proxy(originalOnce, {\n apply(target, thisArg, args: Parameters<typeof originalOnce>) {\n const [event] = args;\n if (event !== 'response') {\n return target.apply(thisArg, args);\n }\n\n const parentContext = context.active();\n const requestContext = trace.setSpan(parentContext, span);\n\n return context.with(requestContext, () => {\n return target.apply(thisArg, args);\n });\n },\n });\n\n // eslint-disable-next-line typescript/no-deprecated\n request.once = newOnce;\n },\n outgoingResponseHook(span, response) {\n options.outgoingResponseHook?.(span, response as IncomingMessage);\n },\n errorMonitor,\n // Pass these in to detect OTel double-wrapping if we're enabling spans\n http,\n } satisfies HttpInstrumentationOptions;\n\n if (FULLY_SUPPORTS_HTTP_DIAGNOSTICS_CHANNEL) {\n instrumentHttpOutgoingRequestsViaChannel(patchOptions);\n } else {\n instrumentHttpOutgoingRequestsViaMonkeyPatching(patchOptions);\n }\n}\n\nfunction instrumentHttpOutgoingRequestsViaChannel(options: HttpInstrumentationOptions): void {\n const { [HTTP_ON_CLIENT_REQUEST]: onHttpClientRequestCreated } = getHttpClientSubscriptions(options);\n subscribeDiagnosticsChannel(HTTP_ON_CLIENT_REQUEST, onHttpClientRequestCreated);\n}\n\n/**\n * Instrument outgoing HTTP(S) requests by old-school monkey-patching the `http` module.\n * This is the fallback for runtimes that do not fully support the `node:http` client diagnostics channel\n * (Node < 22.12).\n */\nfunction instrumentHttpOutgoingRequestsViaMonkeyPatching(options: HttpInstrumentationOptions): void {\n // Patching http also patches https, as this uses the same underlying object\n patchHttpModuleClient(http, options);\n}\n"],"names":[],"mappings":";;;;;;;;AAgBA,MAAM,uCAAA,GACH,YAAA,CAAa,KAA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CAAK,cAAA,EAAgB,MAAM;AACxC,YAAA,OAAO,MAAA,CAAO,KAAA,CAAM,OAAA,EAAS,IAAI,CAAA;AAAA,UACnC,CAAC,CAAA;AAAA,QACH;AAAA,OACD,CAAA;AAGD,MAAA,OAAA,CAAQ,IAAA,GAAO,OAAA;AAAA,IACjB,CAAA;AAAA,IACA,oBAAA,CAAqB,MAAM,QAAA,EAAU;AACnC,MAAA,OAAA,CAAQ,oBAAA,GAAuB,MAAM,QAA2B,CAAA;AAAA,IAClE,CAAA;AAAA,IACA,YAAA;AAAA;AAAA,IAEA;AAAA,GACF;AAEA,EAAA,IAAI,uCAAA,EAAyC;AAC3C,IAAA,wCAAA,CAAyC,YAAY,CAAA;AAAA,EACvD,CAAA,MAAO;AACL,IAAA,+CAAA,CAAgD,YAAY,CAAA;AAAA,EAC9D;AACF;AAEA,SAAS,yCAAyC,OAAA,EAA2C;AAC3F,EAAA,MAAM,EAAE,CAAC,sBAAsB,GAAG,0BAAA,EAA2B,GAAI,2BAA2B,OAAO,CAAA;AACnG,EAAA,2BAAA,CAA4B,wBAAwB,0BAA0B,CAAA;AAChF;AAOA,SAAS,gDAAgD,OAAA,EAA2C;AAElG,EAAA,qBAAA,CAAsB,MAAM,OAAO,CAAA;AACrC;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { subscribe } from 'node:diagnostics_channel';
|
|
2
1
|
import { createContextKey, context, propagation } from '@opentelemetry/api';
|
|
3
2
|
import { debug, getClient, addNonEnumerableProperty } from '@sentry/core';
|
|
4
3
|
import { getHttpServerSubscriptions, HTTP_ON_SERVER_REQUEST } from '@sentry/core/server';
|
|
5
4
|
export { recordRequestSession } from '@sentry/core/server';
|
|
5
|
+
import { subscribeDiagnosticsChannel } from '@sentry/server-utils';
|
|
6
6
|
import { DEBUG_BUILD } from '../../debug-build.js';
|
|
7
7
|
|
|
8
8
|
const HTTP_SERVER_INSTRUMENTED_KEY = createContextKey("sentry_http_server_instrumented");
|
|
@@ -58,7 +58,7 @@ const _httpServerIntegration = ((options = {}) => {
|
|
|
58
58
|
name: INTEGRATION_NAME,
|
|
59
59
|
setupOnce() {
|
|
60
60
|
const { [HTTP_ON_SERVER_REQUEST]: onHttpServerRequestStart } = getHttpServerSubscriptions(_options);
|
|
61
|
-
|
|
61
|
+
subscribeDiagnosticsChannel(HTTP_ON_SERVER_REQUEST, onHttpServerRequestStart);
|
|
62
62
|
},
|
|
63
63
|
afterAllSetup(client) {
|
|
64
64
|
if (DEBUG_BUILD && client.getIntegrationByName("Http")) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpServerIntegration.js","sources":["../../../../src/integrations/http/httpServerIntegration.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"httpServerIntegration.js","sources":["../../../../src/integrations/http/httpServerIntegration.ts"],"sourcesContent":["import type { RequestOptions } from 'node:http';\nimport { context, createContextKey, propagation } from '@opentelemetry/api';\nimport type { Integration, IntegrationFn } from '@sentry/core';\nimport { addNonEnumerableProperty, debug, getClient } from '@sentry/core';\nimport type { HttpIncomingMessage, HttpServerResponse } from '@sentry/core/server';\nimport { getHttpServerSubscriptions, HTTP_ON_SERVER_REQUEST, recordRequestSession } from '@sentry/core/server';\nimport { subscribeDiagnosticsChannel } from '@sentry/server-utils';\nimport type { RequestEventData } from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\n\n// Re-export so existing test imports continue to work; the implementation now lives in core.\nexport { recordRequestSession };\n\nconst HTTP_SERVER_INSTRUMENTED_KEY = createContextKey('sentry_http_server_instrumented');\nconst INTEGRATION_NAME = 'Http.Server' as const;\n\n// Inlining this type to not depend on newer TS types\ninterface WeakRefImpl<T> {\n deref(): T | undefined;\n}\n\ntype StartSpanCallback = (next: () => boolean) => boolean;\ntype RequestWithOptionalStartSpanCallback = HttpIncomingMessage & {\n _startSpanCallback?: WeakRefImpl<StartSpanCallback>;\n};\n\nexport interface HttpServerIntegrationOptions {\n /**\n * Whether the integration should create [Sessions](https://docs.sentry.io/product/releases/health/#sessions) for incoming requests to track the health and crash-free rate of your releases in Sentry.\n * Read more about Release Health: https://docs.sentry.io/product/releases/health/\n *\n * Defaults to `true`.\n */\n sessions?: boolean;\n\n /**\n * Number of milliseconds until sessions tracked with `sessions` will be flushed as a session aggregate.\n *\n * Defaults to `60000` (60s).\n */\n sessionFlushingDelayMS?: number;\n\n /**\n * Do not capture the request body for incoming HTTP requests to URLs where the given callback returns `true`.\n * This can be useful for long running requests where the body is not needed and we want to avoid capturing it.\n *\n * @param url Contains the entire URL, including query string (if any), protocol, host, etc. of the incoming request.\n * @param request Contains the {@type RequestOptions} object used to make the incoming request.\n */\n ignoreRequestBody?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Controls the maximum size of incoming HTTP request bodies attached to events.\n *\n * Available options:\n * - 'none': No request bodies will be attached\n * - 'small': Request bodies up to 1,000 bytes will be attached\n * - 'medium': Request bodies up to 10,000 bytes will be attached (default)\n * - 'always': Request bodies will always be attached\n *\n * Note that even with 'always' setting, bodies exceeding 1MB will never be attached\n * for performance and security reasons.\n *\n * @default 'medium'\n */\n maxRequestBodySize?: 'none' | 'small' | 'medium' | 'always';\n}\n\n/**\n * Add a callback to the request object that will be called when the request is started.\n * The callback will receive the next function to continue processing the request.\n */\nexport function addStartSpanCallback(request: RequestWithOptionalStartSpanCallback, callback: StartSpanCallback): void {\n addNonEnumerableProperty(request, '_startSpanCallback', new WeakRef(callback));\n}\n\nconst _httpServerIntegration = ((options: HttpServerIntegrationOptions = {}) => {\n const _options = {\n sessions: options.sessions ?? true,\n sessionFlushingDelayMS: options.sessionFlushingDelayMS ?? 60_000,\n maxRequestBodySize: options.maxRequestBodySize,\n // Server spans are created by `httpServerSpansIntegration` via the\n // `httpServerRequest` client event + `_startSpanCallback`, not by the\n // core subscription helper. Explicitly opt out so the helper does not\n // double-create spans when the client has tracing enabled.\n spans: false as const,\n // Cast: core uses HttpIncomingMessage; node consumers pass\n // RequestOptions-typed callbacks.\n // The two are structurally compatible for the fields the callback reads\n // (url, method, headers).\n ignoreRequestBody: options.ignoreRequestBody as\n | ((url: string, request: HttpIncomingMessage) => boolean)\n | undefined,\n\n /**\n * Hook called by core's `instrumentServer` to wrap the upstream\n * `emit('request')` call.\n *\n * We use it to extract OTel context from request headers and re-enter\n * the OTel context before the framework sees the request, so subsequent\n * spans (eg from `httpServerSpansIntegration`) attach to the right trace.\n */\n wrapServerEmitRequest(\n request: HttpIncomingMessage,\n response: HttpServerResponse,\n normalizedRequest: RequestEventData,\n next: () => void,\n ): void {\n const client = getClient();\n if (!client) return next();\n\n // Guard against double-wrapping: if our wrapper somehow runs inside an\n // already-instrumented context, just continue without re-extracting\n // and re-emitting.\n if (context.active().getValue(HTTP_SERVER_INSTRUMENTED_KEY)) {\n return next();\n }\n\n const ctx = propagation\n .extract(context.active(), normalizedRequest.headers)\n .setValue(HTTP_SERVER_INSTRUMENTED_KEY, true);\n\n context.with(ctx, () => {\n // httpServerSpansIntegration listens for this and may attach\n // `_startSpanCallback` to the request to wrap span creation around\n // the emit.\n client.emit('httpServerRequest', request, response, normalizedRequest);\n\n const callback = (request as RequestWithOptionalStartSpanCallback)._startSpanCallback?.deref();\n if (callback) {\n callback(() => {\n next();\n return true;\n });\n } else {\n next();\n }\n });\n },\n };\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n const { [HTTP_ON_SERVER_REQUEST]: onHttpServerRequestStart } = getHttpServerSubscriptions(_options);\n subscribeDiagnosticsChannel(HTTP_ON_SERVER_REQUEST, onHttpServerRequestStart);\n },\n afterAllSetup(client) {\n if (DEBUG_BUILD && client.getIntegrationByName('Http')) {\n debug.warn(\n 'It seems that you have manually added `httpServerIntegration` while `httpIntegration` is also present. Make sure to remove `httpServerIntegration` when adding `httpIntegration`.',\n );\n }\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * This integration handles request isolation, trace continuation and other core Sentry functionality around incoming http requests\n * handled via the node `http` module.\n *\n * This version uses OpenTelemetry for context propagation and span management.\n *\n * @see {@link ../../light/integrations/httpServerIntegration.ts} for the lightweight version without OpenTelemetry\n */\nexport const httpServerIntegration = _httpServerIntegration as (\n options?: HttpServerIntegrationOptions,\n) => Integration & {\n name: 'Http.Server';\n setupOnce: () => void;\n};\n"],"names":[],"mappings":";;;;;;;AAaA,MAAM,4BAAA,GAA+B,iBAAiB,iCAAiC,CAAA;AACvF,MAAM,gBAAA,GAAmB,aAAA;AA0DlB,SAAS,oBAAA,CAAqB,SAA+C,QAAA,EAAmC;AACrH,EAAA,wBAAA,CAAyB,OAAA,EAAS,oBAAA,EAAsB,IAAI,OAAA,CAAQ,QAAQ,CAAC,CAAA;AAC/E;AAEA,MAAM,sBAAA,IAA0B,CAAC,OAAA,GAAwC,EAAC,KAAM;AAC9E,EAAA,MAAM,QAAA,GAAW;AAAA,IACf,QAAA,EAAU,QAAQ,QAAA,IAAY,IAAA;AAAA,IAC9B,sBAAA,EAAwB,QAAQ,sBAAA,IAA0B,GAAA;AAAA,IAC1D,oBAAoB,OAAA,CAAQ,kBAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAK5B,KAAA,EAAO,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKP,mBAAmB,OAAA,CAAQ,iBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAY3B,qBAAA,CACE,OAAA,EACA,QAAA,EACA,iBAAA,EACA,IAAA,EACM;AACN,MAAA,MAAM,SAAS,SAAA,EAAU;AACzB,MAAA,IAAI,CAAC,MAAA,EAAQ,OAAO,IAAA,EAAK;AAKzB,MAAA,IAAI,OAAA,CAAQ,MAAA,EAAO,CAAE,QAAA,CAAS,4BAA4B,CAAA,EAAG;AAC3D,QAAA,OAAO,IAAA,EAAK;AAAA,MACd;AAEA,MAAA,MAAM,GAAA,GAAM,WAAA,CACT,OAAA,CAAQ,OAAA,CAAQ,MAAA,EAAO,EAAG,iBAAA,CAAkB,OAAO,CAAA,CACnD,QAAA,CAAS,4BAAA,EAA8B,IAAI,CAAA;AAE9C,MAAA,OAAA,CAAQ,IAAA,CAAK,KAAK,MAAM;AAItB,QAAA,MAAA,CAAO,IAAA,CAAK,mBAAA,EAAqB,OAAA,EAAS,QAAA,EAAU,iBAAiB,CAAA;AAErE,QAAA,MAAM,QAAA,GAAY,OAAA,CAAiD,kBAAA,EAAoB,KAAA,EAAM;AAC7F,QAAA,IAAI,QAAA,EAAU;AACZ,UAAA,QAAA,CAAS,MAAM;AACb,YAAA,IAAA,EAAK;AACL,YAAA,OAAO,IAAA;AAAA,UACT,CAAC,CAAA;AAAA,QACH,CAAA,MAAO;AACL,UAAA,IAAA,EAAK;AAAA,QACP;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AAEA,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,MAAM,EAAE,CAAC,sBAAsB,GAAG,wBAAA,EAAyB,GAAI,2BAA2B,QAAQ,CAAA;AAClG,MAAA,2BAAA,CAA4B,wBAAwB,wBAAwB,CAAA;AAAA,IAC9E,CAAA;AAAA,IACA,cAAc,MAAA,EAAQ;AACpB,MAAA,IAAI,WAAA,IAAe,MAAA,CAAO,oBAAA,CAAqB,MAAM,CAAA,EAAG;AACtD,QAAA,KAAA,CAAM,IAAA;AAAA,UACJ;AAAA,SACF;AAAA,MACF;AAAA,IACF;AAAA,GACF;AACF,CAAA,CAAA;AAUO,MAAM,qBAAA,GAAwB;;;;"}
|
|
@@ -3,7 +3,7 @@ import { defineIntegration, debug, getClient } from '@sentry/core';
|
|
|
3
3
|
import { isDebuggerEnabled } from '../../utils/debug.js';
|
|
4
4
|
import { LOCAL_VARIABLES_KEY, functionNamesMatch, filterFrameVariables } from './common.js';
|
|
5
5
|
|
|
6
|
-
const base64WorkerScript = "
|
|
6
|
+
const base64WorkerScript = "LyohIEBzZW50cnkvbm9kZSAxMS4xLjAgKDFkY2ZkMmYpIHwgaHR0cH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*! @sentry/node 11.1.0 (1dcfd2f) | https://github.com/getsentry/sentry-javascript */
|
|
2
2
|
import{Session as e}from"node:inspector/promises";import{workerData as t}from"node:worker_threads";const n=globalThis,i={};const o="__SENTRY_ERROR_LOCAL_VARIABLES__";const a=t;function s(...e){a.debug&&function(e){if(!("console"in n))return e();const t=n.console,o={},a=Object.keys(i);a.forEach(e=>{const n=i[e];o[e]=t[e],t[e]=n});try{return e()}finally{a.forEach(e=>{t[e]=o[e]})}}(()=>console.log("[LocalVariables Worker]",...e))}async function c(e,t,n,i){const o=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0});i[n]=o.result.filter(e=>"length"!==e.name&&!isNaN(parseInt(e.name,10))).sort((e,t)=>parseInt(e.name,10)-parseInt(t.name,10)).map(e=>e.value?.value)}async function r(e,t,n,i){const o=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0});i[n]=o.result.map(e=>[e.name,e.value?.value]).reduce((e,[t,n])=>(e[t]=n,e),{})}function u(e,t){e.value&&("value"in e.value?void 0===e.value.value||null===e.value.value?t[e.name]=`<${e.value.value}>`:t[e.name]=e.value.value:"description"in e.value&&"function"!==e.value.type?t[e.name]=`<${e.value.description}>`:"undefined"===e.value.type&&(t[e.name]="<undefined>"))}async function l(e,t){const n=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0}),i={};for(const t of n.result)if(t.value?.objectId&&"Array"===t.value.className){const n=t.value.objectId;await c(e,n,t.name,i)}else if(t.value?.objectId&&"Object"===t.value.className){const n=t.value.objectId;await r(e,n,t.name,i)}else t.value&&u(t,i);return i}let f;(async function(){const t=new e;t.connectToMainThread(),s("Connected to main thread");let n=!1;t.on("Debugger.resumed",()=>{n=!1}),t.on("Debugger.paused",e=>{n=!0,async function(e,{reason:t,data:{objectId:n},callFrames:i}){if("exception"!==t&&"promiseRejection"!==t)return;if(f?.(),null==n)return;const a=[];for(let t=0;t<i.length;t++){const{scopeChain:n,functionName:o,this:s}=i[t],c=n.find(e=>"local"===e.type),r="global"!==s.className&&s.className?`${s.className}.${o}`:o;if(void 0===c?.object.objectId)a[t]={function:r};else{const n=await l(e,c.object.objectId);a[t]={function:r,vars:n}}}await e.post("Runtime.callFunctionOn",{functionDeclaration:`function() { this.${o} = this.${o} || ${JSON.stringify(a)}; }`,silent:!0,objectId:n}),await e.post("Runtime.releaseObject",{objectId:n})}(t,e.params).then(async()=>{n&&await t.post("Debugger.resume")},async e=>{n&&await t.post("Debugger.resume")})}),await t.post("Debugger.enable");const i=!1!==a.captureAllExceptions;if(await t.post("Debugger.setPauseOnExceptions",{state:i?"all":"uncaught"}),i){const e=a.maxExceptionsPerSecond||50;f=function(e,t,n){let i=0,o=5,a=0;return setInterval(()=>{0===a?i>e&&(o*=2,n(o),o>86400&&(o=86400),a=o):(a-=1,0===a&&t()),i=0},1e3).unref(),()=>{i+=1}}(e,async()=>{s("Rate-limit lifted."),await t.post("Debugger.setPauseOnExceptions",{state:"all"})},async e=>{s(`Rate-limit exceeded. Disabling capturing of caught exceptions for ${e} seconds.`),await t.post("Debugger.setPauseOnExceptions",{state:"uncaught"})})}})().catch(e=>{s("Failed to start debugger",e)}),setInterval(()=>{},1e4);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as diagch from 'diagnostics_channel';
|
|
2
1
|
import { URL } from 'url';
|
|
3
2
|
import { LRUMap, safeCallback, isTracingSuppressed, debug, getUrlFragment, filterCollectedUrlQuery, getUrlQuery, filterCollectedUrl, stripDataUrlContent, getClient, hasSpanStreamingEnabled, getSanitizedUrlString, parseUrl, startInactiveSpan, httpHeadersToSpanAttributes, getSpanStatusFromHttpCode, SPAN_STATUS_ERROR, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME, HTTP_SPAN_NAME_FALLBACK } from '@sentry/core';
|
|
3
|
+
import { subscribeDiagnosticsChannel } from '@sentry/server-utils';
|
|
4
4
|
import { addTracePropagationHeadersToFetchRequest, addFetchRequestBreadcrumb } from '../../utils/outgoingFetchRequest.js';
|
|
5
5
|
import { URL_FRAGMENT, URL_QUERY, URL_PATH, URL_DOMAIN, URL_FULL, HTTP_RESPONSE_STATUS_CODE, URL_SCHEME, HTTP_REQUEST_METHOD, SENTRY_OP, SENTRY_KIND, SERVER_ADDRESS, SERVER_PORT, USER_AGENT_ORIGINAL, NETWORK_PEER_PORT, NETWORK_PEER_ADDRESS } from '@sentry/conventions/attributes';
|
|
6
6
|
import { HTTP_CLIENT } from '@sentry/conventions/op';
|
|
@@ -26,7 +26,7 @@ function instrumentUndici(config = {}) {
|
|
|
26
26
|
subscribeToChannel("undici:request:error", (message) => onError(message));
|
|
27
27
|
}
|
|
28
28
|
function subscribeToChannel(diagnosticChannel, onMessage) {
|
|
29
|
-
|
|
29
|
+
subscribeDiagnosticsChannel(diagnosticChannel, onMessage);
|
|
30
30
|
}
|
|
31
31
|
function parseRequestHeaders(request) {
|
|
32
32
|
const result = /* @__PURE__ */ new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"undici-instrumentation.js","sources":["../../../../src/integrations/node-fetch/undici-instrumentation.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/ed97091c9890dd18e52759f2ea98e9d7593b3ae4/packages/instrumentation-undici\n * - Upstream version: @opentelemetry/instrumentation-undici@0.24.0\n * - Tracking issue: https://github.com/getsentry/sentry-javascript/issues/20165\n * - Refactored to use Sentry's span APIs instead of OpenTelemetry tracing APIs\n * - Dropped the OTel metrics (no MeterProvider is wired up) and the dead\n * `requireParentforSpans` code path (the SDK always passes `false`)\n * - Dropped the `@opentelemetry/instrumentation` base (undici reports via `diagnostics_channel`,\n * so no module patching was needed) — exposed as a plain `instrumentUndici()` function that the\n * integration wires up directly\n */\n\n/* eslint-disable max-lines */\n\nimport * as diagch from 'diagnostics_channel';\nimport { URL } from 'url';\n\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport {\n debug,\n getClient,\n getSanitizedUrlString,\n getSpanStatusFromHttpCode,\n hasSpanStreamingEnabled,\n HTTP_SPAN_NAME_FALLBACK,\n isTracingSuppressed,\n LRUMap,\n parseUrl,\n safeCallback,\n SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n stripDataUrlContent,\n getUrlFragment,\n getUrlQuery,\n filterCollectedUrl,\n filterCollectedUrlQuery,\n httpHeadersToSpanAttributes,\n} from '@sentry/core';\nimport { addFetchRequestBreadcrumb, addTracePropagationHeadersToFetchRequest } from '../../utils/outgoingFetchRequest';\nimport {\n HTTP_REQUEST_METHOD,\n HTTP_RESPONSE_STATUS_CODE,\n NETWORK_PEER_ADDRESS,\n NETWORK_PEER_PORT,\n SENTRY_KIND,\n SENTRY_OP,\n SERVER_ADDRESS,\n SERVER_PORT,\n URL_DOMAIN,\n URL_FRAGMENT,\n URL_FULL,\n URL_PATH,\n URL_QUERY,\n URL_SCHEME,\n USER_AGENT_ORIGINAL,\n} from '@sentry/conventions/attributes';\nimport { HTTP_CLIENT } from '@sentry/conventions/op';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport type {\n NodeFetchOptions,\n UndiciRequest,\n RequestErrorMessage,\n RequestHeadersMessage,\n RequestMessage,\n RequestTrailersMessage,\n ResponseHeadersMessage,\n} from './types';\n\n// `http.request.method_original` is not part of `@sentry/conventions`, so we keep it inline.\nconst ATTR_HTTP_REQUEST_METHOD_ORIGINAL = 'http.request.method_original';\n\nlet _isInstrumented = false;\nconst spanFromReq = new WeakMap<UndiciRequest, Span>();\n// Whether breadcrumbs (and span-less trace propagation) should be skipped for a given request.\n// We evaluate this at request-creation time because the active context is no longer correct by the\n// time the response-headers event fires.\nconst ignoreRequestMap = new WeakMap<UndiciRequest, boolean>();\n// Caches trace-propagation decisions per URL so we don't recompute the `tracePropagationTargets` regexes per request.\nconst propagationDecisionMap = new LRUMap<string, boolean>(100);\n\n/**\n * Instrument outgoing HTTP requests made through `undici` or the global `fetch` API: emit `http.client`\n * spans, record breadcrumbs, and propagate traces into the outgoing request headers.\n *\n * Span creation is gated by the `spans` option (defaults to `true`). When spans are disabled, breadcrumbs\n * are still recorded and trace propagation headers are still injected (gated by `tracePropagation`).\n *\n * undici reports its request lifecycle via `diagnostics_channel`, so rather than patching any module we\n * subscribe to those channels directly. This is idempotent — subsequent calls are no-ops once the\n * channels have been subscribed to, and the config of the first call wins.\n *\n * A combination of https://github.com/elastic/apm-agent-nodejs and\n * https://github.com/gadget-inc/opentelemetry-instrumentations/blob/main/packages/opentelemetry-instrumentation-undici/src/index.ts\n */\nexport function instrumentUndici(config: NodeFetchOptions = {}): void {\n // Avoid duplicate subscriptions\n if (_isInstrumented) {\n return;\n }\n _isInstrumented = true;\n\n subscribeToChannel('undici:request:create', message => onRequestCreated(config, message as RequestMessage));\n subscribeToChannel('undici:client:sendHeaders', message =>\n onRequestHeaders(config, message as RequestHeadersMessage),\n );\n subscribeToChannel('undici:request:headers', message => onResponseHeaders(config, message as ResponseHeadersMessage));\n subscribeToChannel('undici:request:trailers', message => onDone(message as RequestTrailersMessage));\n subscribeToChannel('undici:request:error', message => onError(message as RequestErrorMessage));\n}\n\nfunction subscribeToChannel(\n diagnosticChannel: string,\n onMessage: (message: unknown, name: string | symbol) => void,\n): void {\n diagch.subscribe?.(diagnosticChannel, onMessage);\n}\n\nfunction parseRequestHeaders(request: UndiciRequest): Map<string, string | string[]> {\n const result = new Map<string, string | string[]>();\n\n if (Array.isArray(request.headers)) {\n // headers are an array [k1, v2, k2, v2] (undici v6+)\n // values could be string or a string[] for multiple values\n for (let i = 0; i < request.headers.length; i += 2) {\n const key = request.headers[i];\n const value = request.headers[i + 1];\n\n // Key should always be a string, but the types don't know that, and let's be safe\n if (typeof key === 'string' && value !== undefined) {\n result.set(key.toLowerCase(), value);\n }\n }\n } else if (typeof request.headers === 'string') {\n // headers are a raw string (undici v5)\n // headers could be repeated in several lines for multiple values\n const headers = request.headers.split('\\r\\n');\n for (const line of headers) {\n if (!line) {\n continue;\n }\n const colonIndex = line.indexOf(':');\n if (colonIndex === -1) {\n // Invalid header? Probably this can't happen, but again let's be safe.\n continue;\n }\n const key = line.substring(0, colonIndex).toLowerCase();\n const value = line.substring(colonIndex + 1).trim();\n const allValues = result.get(key);\n\n if (allValues && Array.isArray(allValues)) {\n allValues.push(value);\n } else if (allValues) {\n result.set(key, [allValues, value]);\n } else {\n result.set(key, value);\n }\n }\n }\n return result;\n}\n\n// This is the 1st message we receive for each request (fired after request creation). Here we will\n// create the span and populate some atttributes, then link the span to the request for further\n// span processing\nfunction onRequestCreated(config: NodeFetchOptions, { request }: RequestMessage): void {\n const url = getAbsoluteUrl(request.origin, request.path);\n\n const ignoredByCallback = safeCallback(\n DEBUG_BUILD ? 'The `ignoreOutgoingRequests` callback threw an error, not ignoring the request:' : '',\n () => !!config.ignoreOutgoingRequests?.(url),\n () => false,\n );\n\n // Breadcrumbs & span-less trace propagation are additionally skipped when tracing is suppressed.\n // We store this here because the active context is no longer correct in later channel events.\n const ignoreForBreadcrumbs = isTracingSuppressed() || !!ignoredByCallback;\n ignoreRequestMap.set(request, ignoreForBreadcrumbs);\n\n // When spans are disabled we do not create a span, but we still inject trace propagation headers\n // directly (unless disabled via `tracePropagation`).\n if (!config.spans) {\n if (config.tracePropagation !== false && !ignoreForBreadcrumbs) {\n addTracePropagationHeadersToFetchRequest(request, propagationDecisionMap);\n }\n return;\n }\n\n // Ignore span creation if:\n // - the outgoing request is ignored via config\n // - method is 'CONNECT'\n if (request.method === 'CONNECT' || ignoredByCallback) {\n return;\n }\n\n let requestUrl;\n try {\n requestUrl = new URL(request.path, request.origin);\n } catch (err) {\n DEBUG_BUILD && debug.warn('could not determine url.full:', err);\n // Skip instrumenting this request.\n return;\n }\n\n const urlScheme = requestUrl.protocol.replace(':', '');\n const requestMethod = getRequestMethod(request.method);\n const attributes: SpanAttributes = {\n [SENTRY_KIND]: 'client',\n [SENTRY_OP]: HTTP_CLIENT,\n [HTTP_REQUEST_METHOD]: requestMethod,\n [ATTR_HTTP_REQUEST_METHOD_ORIGINAL]: request.method,\n [URL_FULL]: filterCollectedUrl(requestUrl.toString()),\n [URL_DOMAIN]: requestUrl.hostname || undefined,\n [URL_PATH]: requestUrl.pathname,\n [URL_QUERY]: filterCollectedUrlQuery(getUrlQuery(requestUrl.search)),\n [URL_FRAGMENT]: getUrlFragment(requestUrl.hash),\n [URL_SCHEME]: urlScheme,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.node_fetch',\n };\n\n // Sanitize data URLs to prevent long base64 strings in span attributes\n if (url.startsWith('data:')) {\n const sanitizedUrl = stripDataUrlContent(url);\n attributes[URL_FULL] = sanitizedUrl;\n attributes[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME] = `${request.method || 'GET'} ${sanitizedUrl}`;\n }\n\n const schemePorts: Record<string, string> = { https: '443', http: '80' };\n const serverAddress = requestUrl.hostname;\n const serverPort = requestUrl.port || schemePorts[urlScheme];\n\n attributes[SERVER_ADDRESS] = serverAddress;\n if (serverPort && !isNaN(Number(serverPort))) {\n attributes[SERVER_PORT] = Number(serverPort);\n }\n\n // Get user agent from headers\n const headersMap = parseRequestHeaders(request);\n const userAgentValues = headersMap.get('user-agent');\n\n if (userAgentValues) {\n // NOTE: having multiple user agents is not expected so\n // we're going to take last one like `curl` does\n // ref: https://curl.se/docs/manpage.html#-A\n const userAgent = Array.isArray(userAgentValues) ? userAgentValues[userAgentValues.length - 1] : userAgentValues;\n attributes[USER_AGENT_ORIGINAL] = userAgent;\n }\n\n // Outside of span streaming, only record an `http.client` span when it has a parent. An orphan\n // one (no local parent) is left to the server for the downstream sampling decision: `onlyIfParent`\n // still creates a non-recording span so trace propagation headers are injected, but it isn't\n // emitted as a standalone transaction. This rule also lives in `SentrySampler`, but that only runs\n // when an OpenTelemetry SDK tracer provider is set up, so we enforce it here too, which covers\n // SDKs that don't use an OpenTelemetry tracer provider at all.\n const isDataUrl = url.startsWith('data:');\n const client = getClient();\n\n let spanName: string;\n if (requestMethod === '_OTHER') {\n spanName = HTTP_SPAN_NAME_FALLBACK;\n } else if (!!client && hasSpanStreamingEnabled(client)) {\n // With span streaming, span names have to be low cardinality, so the URL path is dropped and only\n // the domain is kept. Outgoing requests have no route to parameterize, and data URLs have no domain.\n spanName = requestUrl.hostname ? `${requestMethod} ${requestUrl.hostname}` : requestMethod;\n } else if (isDataUrl) {\n spanName = `${request.method || 'GET'} ${stripDataUrlContent(url)}`;\n } else {\n spanName = `${requestMethod} ${getSanitizedUrlString(parseUrl(requestUrl.toString()))}`;\n }\n\n const span = startInactiveSpan({\n name: spanName,\n attributes,\n onlyIfParent: !client || !hasSpanStreamingEnabled(client),\n });\n\n // Execute the request hook if defined\n safeCallback(\n DEBUG_BUILD ? 'The `requestHook` callback threw an error:' : '',\n () => config.requestHook?.(span, request),\n () => undefined,\n );\n\n // Context propagation goes last so no hook can tamper the propagation headers.\n // We propagate the trace data of the freshly created client span (not the active parent span)\n // so downstream services are parented to the http.client span, matching the upstream behavior.\n // This also de-duplicates against any trace headers the user set manually (e.g. via `getTraceData()`).\n addTracePropagationHeadersToFetchRequest(request, propagationDecisionMap, span);\n\n spanFromReq.set(request, span);\n}\n\n// This is the 2nd message we receive for each request. It is fired when connection with\n// the remote is established and about to send the first byte. Here we do have info about the\n// remote address and port so we can populate some `network.*` attributes into the span\nfunction onRequestHeaders(config: NodeFetchOptions, { request, socket }: RequestHeadersMessage): void {\n const span = spanFromReq.get(request);\n\n if (!span) {\n return;\n }\n\n const { remoteAddress, remotePort } = socket;\n const spanAttributes: SpanAttributes = {\n [NETWORK_PEER_ADDRESS]: remoteAddress,\n [NETWORK_PEER_PORT]: remotePort,\n };\n\n // After hooks have been processed (which may modify request headers)\n // we can collect the headers based on the configuration\n const client = getClient();\n if (config.headersToSpanAttributes?.requestHeaders && client) {\n const headersToAttribs = new Set(config.headersToSpanAttributes.requestHeaders.map(n => n.toLowerCase()));\n const headersMap = parseRequestHeaders(request);\n\n const allowlisted: Record<string, string | string[]> = {};\n for (const [name, value] of headersMap.entries()) {\n if (headersToAttribs.has(name)) {\n allowlisted[name] = value;\n }\n }\n\n // An entry in `headersToSpanAttributes` does not exempt a header from the `dataCollection`\n // filtering, so the allowlisted subset goes through the same pipeline as any other header.\n Object.assign(spanAttributes, httpHeadersToSpanAttributes(allowlisted, client.getDataCollectionOptions()));\n }\n\n span.setAttributes(spanAttributes);\n}\n\n// This is the 3rd message we get for each request and it's fired when the server\n// headers are received, body may not be accessible yet.\n// From the response headers we can set the status and content length\nfunction onResponseHeaders(config: NodeFetchOptions, { request, response }: ResponseHeadersMessage): void {\n // Breadcrumbs are recorded independently of spans, so this runs even when span creation is disabled.\n const breadcrumbsEnabled = config.breadcrumbs !== false;\n if (breadcrumbsEnabled && !ignoreRequestMap.get(request)) {\n addFetchRequestBreadcrumb(request, response);\n }\n\n const span = spanFromReq.get(request);\n\n if (!span) {\n return;\n }\n\n const spanAttributes: SpanAttributes = {\n [HTTP_RESPONSE_STATUS_CODE]: response.statusCode,\n };\n\n // Execute the response hook if defined\n safeCallback(\n DEBUG_BUILD ? 'The `responseHook` callback threw an error:' : '',\n () => config.responseHook?.(span, { request, response }),\n () => undefined,\n );\n\n const client = getClient();\n if (config.headersToSpanAttributes?.responseHeaders && client) {\n const headersToAttribs = new Set<string>();\n config.headersToSpanAttributes?.responseHeaders.forEach(name => headersToAttribs.add(name.toLowerCase()));\n\n const allowlisted: Record<string, string[]> = {};\n for (let idx = 0; idx < response.headers.length; idx = idx + 2) {\n const nameBuf = response.headers[idx];\n const valueBuf = response.headers[idx + 1];\n if (nameBuf === undefined || valueBuf === undefined) {\n continue;\n }\n const name = nameBuf.toString().toLowerCase();\n\n if (headersToAttribs.has(name)) {\n (allowlisted[name] ??= []).push(valueBuf.toString());\n }\n }\n\n // An entry in `headersToSpanAttributes` does not exempt a header from the `dataCollection`\n // filtering, so the allowlisted subset goes through the same pipeline as any other header.\n Object.assign(\n spanAttributes,\n httpHeadersToSpanAttributes(allowlisted, client.getDataCollectionOptions(), 'response'),\n );\n }\n\n span.setAttributes(spanAttributes);\n\n // Resolve the HTTP status code to a Sentry span status here (like the raw http client/server\n // instrumentation does) instead of setting a bare error and deferring to downstream inference.\n // The SentryTracerProvider's status finalization reads the already-stringified span status, which\n // can no longer be inferred back to `not_found` etc. the way the OpenTelemetry SDK exporter's\n // `mapStatus` does from the raw `{ code, message }`.\n if (response.statusCode >= 400) {\n span.setStatus(getSpanStatusFromHttpCode(response.statusCode));\n }\n}\n\n// This is the last event we receive if the request went without any errors\nfunction onDone({ request }: RequestTrailersMessage): void {\n const span = spanFromReq.get(request);\n\n if (!span) {\n return;\n }\n\n span.end();\n spanFromReq.delete(request);\n}\n\n// This is the event we get when something is wrong in the request like\n// - invalid options when calling `fetch` global API or any undici method for request\n// - connectivity errors such as unreachable host\n// - requests aborted through an `AbortController.signal`\n// NOTE: server errors are considered valid responses and it's the lib consumer\n// who should deal with that.\nfunction onError({ request, error }: RequestErrorMessage): void {\n const span = spanFromReq.get(request);\n\n if (!span) {\n return;\n }\n\n // NOTE: in `undici@6.3.0` when request aborted the error type changes from\n // a custom error (`RequestAbortedError`) to a built-in `DOMException` carrying\n // some differences:\n // - `code` is from DOMEXception (ABORT_ERR: 20)\n // - `message` changes\n // - stacktrace is smaller and contains node internal frames\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n message: error.message,\n });\n span.end();\n spanFromReq.delete(request);\n}\n\nfunction getRequestMethod(original: string): string {\n const knownMethods = {\n CONNECT: true,\n OPTIONS: true,\n HEAD: true,\n GET: true,\n POST: true,\n PUT: true,\n PATCH: true,\n DELETE: true,\n TRACE: true,\n // QUERY from https://datatracker.ietf.org/doc/rfc10008/\n QUERY: true,\n };\n\n if (original.toUpperCase() in knownMethods) {\n return original.toUpperCase();\n }\n\n return '_OTHER';\n}\n\n// Matching the behavior of the base instrumentation\nfunction getAbsoluteUrl(origin: string, path: string = '/'): string {\n const url = `${origin}`;\n\n if (url.endsWith('/') && path.startsWith('/')) {\n return `${url}${path.slice(1)}`;\n }\n\n if (!url.endsWith('/') && !path.startsWith('/')) {\n return `${url}/${path}`;\n }\n\n return `${url}${path}`;\n}\n"],"names":[],"mappings":";;;;;;;;AA2EA,MAAM,iCAAA,GAAoC,8BAAA;AAE1C,IAAI,eAAA,GAAkB,KAAA;AACtB,MAAM,WAAA,uBAAkB,OAAA,EAA6B;AAIrD,MAAM,gBAAA,uBAAuB,OAAA,EAAgC;AAE7D,MAAM,sBAAA,GAAyB,IAAI,MAAA,CAAwB,GAAG,CAAA;AAgBvD,SAAS,gBAAA,CAAiB,MAAA,GAA2B,EAAC,EAAS;AAEpE,EAAA,IAAI,eAAA,EAAiB;AACnB,IAAA;AAAA,EACF;AACA,EAAA,eAAA,GAAkB,IAAA;AAElB,EAAA,kBAAA,CAAmB,uBAAA,EAAyB,CAAA,OAAA,KAAW,gBAAA,CAAiB,MAAA,EAAQ,OAAyB,CAAC,CAAA;AAC1G,EAAA,kBAAA;AAAA,IAAmB,2BAAA;AAAA,IAA6B,CAAA,OAAA,KAC9C,gBAAA,CAAiB,MAAA,EAAQ,OAAgC;AAAA,GAC3D;AACA,EAAA,kBAAA,CAAmB,wBAAA,EAA0B,CAAA,OAAA,KAAW,iBAAA,CAAkB,MAAA,EAAQ,OAAiC,CAAC,CAAA;AACpH,EAAA,kBAAA,CAAmB,yBAAA,EAA2B,CAAA,OAAA,KAAW,MAAA,CAAO,OAAiC,CAAC,CAAA;AAClG,EAAA,kBAAA,CAAmB,sBAAA,EAAwB,CAAA,OAAA,KAAW,OAAA,CAAQ,OAA8B,CAAC,CAAA;AAC/F;AAEA,SAAS,kBAAA,CACP,mBACA,SAAA,EACM;AACN,EAAA,MAAA,CAAO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AK,IAAA,CAAK,UAAA,CAAW,GAAG,CAAA,EAAG;AAC7C,IAAA,OAAO,GAAG,GAAG,CAAA,EAAG,IAAA,CAAK,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AAAA,EAC/B;AAEA,EAAA,IAAI,CAAC,IAAI,QAAA,CAAS,GAAG,KAAK,CAAC,IAAA,CAAK,UAAA,CAAW,GAAG,CAAA,EAAG;AAC/C,IAAA,OAAO,CAAA,EAAG,GAAG,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAAA,EACvB;AAEA,EAAA,OAAO,CAAA,EAAG,GAAG,CAAA,EAAG,IAAI,CAAA,CAAA;AACtB;;;;"}
|
|
1
|
+
{"version":3,"file":"undici-instrumentation.js","sources":["../../../../src/integrations/node-fetch/undici-instrumentation.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/ed97091c9890dd18e52759f2ea98e9d7593b3ae4/packages/instrumentation-undici\n * - Upstream version: @opentelemetry/instrumentation-undici@0.24.0\n * - Tracking issue: https://github.com/getsentry/sentry-javascript/issues/20165\n * - Refactored to use Sentry's span APIs instead of OpenTelemetry tracing APIs\n * - Dropped the OTel metrics (no MeterProvider is wired up) and the dead\n * `requireParentforSpans` code path (the SDK always passes `false`)\n * - Dropped the `@opentelemetry/instrumentation` base (undici reports via `diagnostics_channel`,\n * so no module patching was needed) — exposed as a plain `instrumentUndici()` function that the\n * integration wires up directly\n */\n\n/* eslint-disable max-lines */\n\nimport { URL } from 'url';\n\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport {\n debug,\n getClient,\n getSanitizedUrlString,\n getSpanStatusFromHttpCode,\n hasSpanStreamingEnabled,\n HTTP_SPAN_NAME_FALLBACK,\n isTracingSuppressed,\n LRUMap,\n parseUrl,\n safeCallback,\n SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n stripDataUrlContent,\n getUrlFragment,\n getUrlQuery,\n filterCollectedUrl,\n filterCollectedUrlQuery,\n httpHeadersToSpanAttributes,\n} from '@sentry/core';\nimport { subscribeDiagnosticsChannel } from '@sentry/server-utils';\nimport { addFetchRequestBreadcrumb, addTracePropagationHeadersToFetchRequest } from '../../utils/outgoingFetchRequest';\nimport {\n HTTP_REQUEST_METHOD,\n HTTP_RESPONSE_STATUS_CODE,\n NETWORK_PEER_ADDRESS,\n NETWORK_PEER_PORT,\n SENTRY_KIND,\n SENTRY_OP,\n SERVER_ADDRESS,\n SERVER_PORT,\n URL_DOMAIN,\n URL_FRAGMENT,\n URL_FULL,\n URL_PATH,\n URL_QUERY,\n URL_SCHEME,\n USER_AGENT_ORIGINAL,\n} from '@sentry/conventions/attributes';\nimport { HTTP_CLIENT } from '@sentry/conventions/op';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport type {\n NodeFetchOptions,\n UndiciRequest,\n RequestErrorMessage,\n RequestHeadersMessage,\n RequestMessage,\n RequestTrailersMessage,\n ResponseHeadersMessage,\n} from './types';\n\n// `http.request.method_original` is not part of `@sentry/conventions`, so we keep it inline.\nconst ATTR_HTTP_REQUEST_METHOD_ORIGINAL = 'http.request.method_original';\n\nlet _isInstrumented = false;\nconst spanFromReq = new WeakMap<UndiciRequest, Span>();\n// Whether breadcrumbs (and span-less trace propagation) should be skipped for a given request.\n// We evaluate this at request-creation time because the active context is no longer correct by the\n// time the response-headers event fires.\nconst ignoreRequestMap = new WeakMap<UndiciRequest, boolean>();\n// Caches trace-propagation decisions per URL so we don't recompute the `tracePropagationTargets` regexes per request.\nconst propagationDecisionMap = new LRUMap<string, boolean>(100);\n\n/**\n * Instrument outgoing HTTP requests made through `undici` or the global `fetch` API: emit `http.client`\n * spans, record breadcrumbs, and propagate traces into the outgoing request headers.\n *\n * Span creation is gated by the `spans` option (defaults to `true`). When spans are disabled, breadcrumbs\n * are still recorded and trace propagation headers are still injected (gated by `tracePropagation`).\n *\n * undici reports its request lifecycle via `diagnostics_channel`, so rather than patching any module we\n * subscribe to those channels directly. This is idempotent — subsequent calls are no-ops once the\n * channels have been subscribed to, and the config of the first call wins.\n *\n * A combination of https://github.com/elastic/apm-agent-nodejs and\n * https://github.com/gadget-inc/opentelemetry-instrumentations/blob/main/packages/opentelemetry-instrumentation-undici/src/index.ts\n */\nexport function instrumentUndici(config: NodeFetchOptions = {}): void {\n // Avoid duplicate subscriptions\n if (_isInstrumented) {\n return;\n }\n _isInstrumented = true;\n\n subscribeToChannel('undici:request:create', message => onRequestCreated(config, message as RequestMessage));\n subscribeToChannel('undici:client:sendHeaders', message =>\n onRequestHeaders(config, message as RequestHeadersMessage),\n );\n subscribeToChannel('undici:request:headers', message => onResponseHeaders(config, message as ResponseHeadersMessage));\n subscribeToChannel('undici:request:trailers', message => onDone(message as RequestTrailersMessage));\n subscribeToChannel('undici:request:error', message => onError(message as RequestErrorMessage));\n}\n\nfunction subscribeToChannel(\n diagnosticChannel: string,\n onMessage: (message: unknown, name: string | symbol) => void,\n): void {\n subscribeDiagnosticsChannel(diagnosticChannel, onMessage);\n}\n\nfunction parseRequestHeaders(request: UndiciRequest): Map<string, string | string[]> {\n const result = new Map<string, string | string[]>();\n\n if (Array.isArray(request.headers)) {\n // headers are an array [k1, v2, k2, v2] (undici v6+)\n // values could be string or a string[] for multiple values\n for (let i = 0; i < request.headers.length; i += 2) {\n const key = request.headers[i];\n const value = request.headers[i + 1];\n\n // Key should always be a string, but the types don't know that, and let's be safe\n if (typeof key === 'string' && value !== undefined) {\n result.set(key.toLowerCase(), value);\n }\n }\n } else if (typeof request.headers === 'string') {\n // headers are a raw string (undici v5)\n // headers could be repeated in several lines for multiple values\n const headers = request.headers.split('\\r\\n');\n for (const line of headers) {\n if (!line) {\n continue;\n }\n const colonIndex = line.indexOf(':');\n if (colonIndex === -1) {\n // Invalid header? Probably this can't happen, but again let's be safe.\n continue;\n }\n const key = line.substring(0, colonIndex).toLowerCase();\n const value = line.substring(colonIndex + 1).trim();\n const allValues = result.get(key);\n\n if (allValues && Array.isArray(allValues)) {\n allValues.push(value);\n } else if (allValues) {\n result.set(key, [allValues, value]);\n } else {\n result.set(key, value);\n }\n }\n }\n return result;\n}\n\n// This is the 1st message we receive for each request (fired after request creation). Here we will\n// create the span and populate some atttributes, then link the span to the request for further\n// span processing\nfunction onRequestCreated(config: NodeFetchOptions, { request }: RequestMessage): void {\n const url = getAbsoluteUrl(request.origin, request.path);\n\n const ignoredByCallback = safeCallback(\n DEBUG_BUILD ? 'The `ignoreOutgoingRequests` callback threw an error, not ignoring the request:' : '',\n () => !!config.ignoreOutgoingRequests?.(url),\n () => false,\n );\n\n // Breadcrumbs & span-less trace propagation are additionally skipped when tracing is suppressed.\n // We store this here because the active context is no longer correct in later channel events.\n const ignoreForBreadcrumbs = isTracingSuppressed() || !!ignoredByCallback;\n ignoreRequestMap.set(request, ignoreForBreadcrumbs);\n\n // When spans are disabled we do not create a span, but we still inject trace propagation headers\n // directly (unless disabled via `tracePropagation`).\n if (!config.spans) {\n if (config.tracePropagation !== false && !ignoreForBreadcrumbs) {\n addTracePropagationHeadersToFetchRequest(request, propagationDecisionMap);\n }\n return;\n }\n\n // Ignore span creation if:\n // - the outgoing request is ignored via config\n // - method is 'CONNECT'\n if (request.method === 'CONNECT' || ignoredByCallback) {\n return;\n }\n\n let requestUrl;\n try {\n requestUrl = new URL(request.path, request.origin);\n } catch (err) {\n DEBUG_BUILD && debug.warn('could not determine url.full:', err);\n // Skip instrumenting this request.\n return;\n }\n\n const urlScheme = requestUrl.protocol.replace(':', '');\n const requestMethod = getRequestMethod(request.method);\n const attributes: SpanAttributes = {\n [SENTRY_KIND]: 'client',\n [SENTRY_OP]: HTTP_CLIENT,\n [HTTP_REQUEST_METHOD]: requestMethod,\n [ATTR_HTTP_REQUEST_METHOD_ORIGINAL]: request.method,\n [URL_FULL]: filterCollectedUrl(requestUrl.toString()),\n [URL_DOMAIN]: requestUrl.hostname || undefined,\n [URL_PATH]: requestUrl.pathname,\n [URL_QUERY]: filterCollectedUrlQuery(getUrlQuery(requestUrl.search)),\n [URL_FRAGMENT]: getUrlFragment(requestUrl.hash),\n [URL_SCHEME]: urlScheme,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.node_fetch',\n };\n\n // Sanitize data URLs to prevent long base64 strings in span attributes\n if (url.startsWith('data:')) {\n const sanitizedUrl = stripDataUrlContent(url);\n attributes[URL_FULL] = sanitizedUrl;\n attributes[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME] = `${request.method || 'GET'} ${sanitizedUrl}`;\n }\n\n const schemePorts: Record<string, string> = { https: '443', http: '80' };\n const serverAddress = requestUrl.hostname;\n const serverPort = requestUrl.port || schemePorts[urlScheme];\n\n attributes[SERVER_ADDRESS] = serverAddress;\n if (serverPort && !isNaN(Number(serverPort))) {\n attributes[SERVER_PORT] = Number(serverPort);\n }\n\n // Get user agent from headers\n const headersMap = parseRequestHeaders(request);\n const userAgentValues = headersMap.get('user-agent');\n\n if (userAgentValues) {\n // NOTE: having multiple user agents is not expected so\n // we're going to take last one like `curl` does\n // ref: https://curl.se/docs/manpage.html#-A\n const userAgent = Array.isArray(userAgentValues) ? userAgentValues[userAgentValues.length - 1] : userAgentValues;\n attributes[USER_AGENT_ORIGINAL] = userAgent;\n }\n\n // Outside of span streaming, only record an `http.client` span when it has a parent. An orphan\n // one (no local parent) is left to the server for the downstream sampling decision: `onlyIfParent`\n // still creates a non-recording span so trace propagation headers are injected, but it isn't\n // emitted as a standalone transaction. This rule also lives in `SentrySampler`, but that only runs\n // when an OpenTelemetry SDK tracer provider is set up, so we enforce it here too, which covers\n // SDKs that don't use an OpenTelemetry tracer provider at all.\n const isDataUrl = url.startsWith('data:');\n const client = getClient();\n\n let spanName: string;\n if (requestMethod === '_OTHER') {\n spanName = HTTP_SPAN_NAME_FALLBACK;\n } else if (!!client && hasSpanStreamingEnabled(client)) {\n // With span streaming, span names have to be low cardinality, so the URL path is dropped and only\n // the domain is kept. Outgoing requests have no route to parameterize, and data URLs have no domain.\n spanName = requestUrl.hostname ? `${requestMethod} ${requestUrl.hostname}` : requestMethod;\n } else if (isDataUrl) {\n spanName = `${request.method || 'GET'} ${stripDataUrlContent(url)}`;\n } else {\n spanName = `${requestMethod} ${getSanitizedUrlString(parseUrl(requestUrl.toString()))}`;\n }\n\n const span = startInactiveSpan({\n name: spanName,\n attributes,\n onlyIfParent: !client || !hasSpanStreamingEnabled(client),\n });\n\n // Execute the request hook if defined\n safeCallback(\n DEBUG_BUILD ? 'The `requestHook` callback threw an error:' : '',\n () => config.requestHook?.(span, request),\n () => undefined,\n );\n\n // Context propagation goes last so no hook can tamper the propagation headers.\n // We propagate the trace data of the freshly created client span (not the active parent span)\n // so downstream services are parented to the http.client span, matching the upstream behavior.\n // This also de-duplicates against any trace headers the user set manually (e.g. via `getTraceData()`).\n addTracePropagationHeadersToFetchRequest(request, propagationDecisionMap, span);\n\n spanFromReq.set(request, span);\n}\n\n// This is the 2nd message we receive for each request. It is fired when connection with\n// the remote is established and about to send the first byte. Here we do have info about the\n// remote address and port so we can populate some `network.*` attributes into the span\nfunction onRequestHeaders(config: NodeFetchOptions, { request, socket }: RequestHeadersMessage): void {\n const span = spanFromReq.get(request);\n\n if (!span) {\n return;\n }\n\n const { remoteAddress, remotePort } = socket;\n const spanAttributes: SpanAttributes = {\n [NETWORK_PEER_ADDRESS]: remoteAddress,\n [NETWORK_PEER_PORT]: remotePort,\n };\n\n // After hooks have been processed (which may modify request headers)\n // we can collect the headers based on the configuration\n const client = getClient();\n if (config.headersToSpanAttributes?.requestHeaders && client) {\n const headersToAttribs = new Set(config.headersToSpanAttributes.requestHeaders.map(n => n.toLowerCase()));\n const headersMap = parseRequestHeaders(request);\n\n const allowlisted: Record<string, string | string[]> = {};\n for (const [name, value] of headersMap.entries()) {\n if (headersToAttribs.has(name)) {\n allowlisted[name] = value;\n }\n }\n\n // An entry in `headersToSpanAttributes` does not exempt a header from the `dataCollection`\n // filtering, so the allowlisted subset goes through the same pipeline as any other header.\n Object.assign(spanAttributes, httpHeadersToSpanAttributes(allowlisted, client.getDataCollectionOptions()));\n }\n\n span.setAttributes(spanAttributes);\n}\n\n// This is the 3rd message we get for each request and it's fired when the server\n// headers are received, body may not be accessible yet.\n// From the response headers we can set the status and content length\nfunction onResponseHeaders(config: NodeFetchOptions, { request, response }: ResponseHeadersMessage): void {\n // Breadcrumbs are recorded independently of spans, so this runs even when span creation is disabled.\n const breadcrumbsEnabled = config.breadcrumbs !== false;\n if (breadcrumbsEnabled && !ignoreRequestMap.get(request)) {\n addFetchRequestBreadcrumb(request, response);\n }\n\n const span = spanFromReq.get(request);\n\n if (!span) {\n return;\n }\n\n const spanAttributes: SpanAttributes = {\n [HTTP_RESPONSE_STATUS_CODE]: response.statusCode,\n };\n\n // Execute the response hook if defined\n safeCallback(\n DEBUG_BUILD ? 'The `responseHook` callback threw an error:' : '',\n () => config.responseHook?.(span, { request, response }),\n () => undefined,\n );\n\n const client = getClient();\n if (config.headersToSpanAttributes?.responseHeaders && client) {\n const headersToAttribs = new Set<string>();\n config.headersToSpanAttributes?.responseHeaders.forEach(name => headersToAttribs.add(name.toLowerCase()));\n\n const allowlisted: Record<string, string[]> = {};\n for (let idx = 0; idx < response.headers.length; idx = idx + 2) {\n const nameBuf = response.headers[idx];\n const valueBuf = response.headers[idx + 1];\n if (nameBuf === undefined || valueBuf === undefined) {\n continue;\n }\n const name = nameBuf.toString().toLowerCase();\n\n if (headersToAttribs.has(name)) {\n (allowlisted[name] ??= []).push(valueBuf.toString());\n }\n }\n\n // An entry in `headersToSpanAttributes` does not exempt a header from the `dataCollection`\n // filtering, so the allowlisted subset goes through the same pipeline as any other header.\n Object.assign(\n spanAttributes,\n httpHeadersToSpanAttributes(allowlisted, client.getDataCollectionOptions(), 'response'),\n );\n }\n\n span.setAttributes(spanAttributes);\n\n // Resolve the HTTP status code to a Sentry span status here (like the raw http client/server\n // instrumentation does) instead of setting a bare error and deferring to downstream inference.\n // The SentryTracerProvider's status finalization reads the already-stringified span status, which\n // can no longer be inferred back to `not_found` etc. the way the OpenTelemetry SDK exporter's\n // `mapStatus` does from the raw `{ code, message }`.\n if (response.statusCode >= 400) {\n span.setStatus(getSpanStatusFromHttpCode(response.statusCode));\n }\n}\n\n// This is the last event we receive if the request went without any errors\nfunction onDone({ request }: RequestTrailersMessage): void {\n const span = spanFromReq.get(request);\n\n if (!span) {\n return;\n }\n\n span.end();\n spanFromReq.delete(request);\n}\n\n// This is the event we get when something is wrong in the request like\n// - invalid options when calling `fetch` global API or any undici method for request\n// - connectivity errors such as unreachable host\n// - requests aborted through an `AbortController.signal`\n// NOTE: server errors are considered valid responses and it's the lib consumer\n// who should deal with that.\nfunction onError({ request, error }: RequestErrorMessage): void {\n const span = spanFromReq.get(request);\n\n if (!span) {\n return;\n }\n\n // NOTE: in `undici@6.3.0` when request aborted the error type changes from\n // a custom error (`RequestAbortedError`) to a built-in `DOMException` carrying\n // some differences:\n // - `code` is from DOMEXception (ABORT_ERR: 20)\n // - `message` changes\n // - stacktrace is smaller and contains node internal frames\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n message: error.message,\n });\n span.end();\n spanFromReq.delete(request);\n}\n\nfunction getRequestMethod(original: string): string {\n const knownMethods = {\n CONNECT: true,\n OPTIONS: true,\n HEAD: true,\n GET: true,\n POST: true,\n PUT: true,\n PATCH: true,\n DELETE: true,\n TRACE: true,\n // QUERY from https://datatracker.ietf.org/doc/rfc10008/\n QUERY: true,\n };\n\n if (original.toUpperCase() in knownMethods) {\n return original.toUpperCase();\n }\n\n return '_OTHER';\n}\n\n// Matching the behavior of the base instrumentation\nfunction getAbsoluteUrl(origin: string, path: string = '/'): string {\n const url = `${origin}`;\n\n if (url.endsWith('/') && path.startsWith('/')) {\n return `${url}${path.slice(1)}`;\n }\n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IAAA,CAAK,UAAA,CAAW,GAAG,CAAA,EAAG;AAC/C,IAAA,OAAO,CAAA,EAAG,GAAG,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAAA,EACvB;AAEA,EAAA,OAAO,CAAA,EAAG,GAAG,CAAA,EAAG,IAAI,CAAA,CAAA;AACtB;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as diagnosticsChannel from 'node:diagnostics_channel';
|
|
2
1
|
import { defineIntegration, isObjectLike, _INTERNAL_captureLog, severityLevelFromString, withScope, addExceptionMechanism, captureException, captureMessage } from '@sentry/core';
|
|
2
|
+
import { diagnosticsTracingChannel } from '@sentry/server-utils';
|
|
3
3
|
|
|
4
4
|
const SENTRY_TRACK_SYMBOL = /* @__PURE__ */ Symbol("sentry-track-pino-logger");
|
|
5
5
|
function getPinoKey(logger, symbolName, defaultKey) {
|
|
@@ -34,7 +34,7 @@ const _pinoIntegration = defineIntegration((userOptions = {}) => {
|
|
|
34
34
|
return {
|
|
35
35
|
name: "Pino",
|
|
36
36
|
setup: () => {
|
|
37
|
-
const integratedChannel =
|
|
37
|
+
const integratedChannel = diagnosticsTracingChannel("pino_asJson");
|
|
38
38
|
function onPinoStart(self, args, result) {
|
|
39
39
|
if (!shouldTrackLogger(self)) {
|
|
40
40
|
return;
|