@grafana/faro-web-tracing 2.4.0 → 2.5.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.
@@ -1 +1 @@
1
- var GrafanaFaroWebTracing=function(t,e){"use strict";const n="1.9.1",r=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;const s=function(t){const e=new Set([t]),n=new Set,s=t.match(r);if(!s)return()=>!1;const i=+s[1],o=+s[2],a=+s[3];if(null!=s[4])return function(e){return e===t};function c(t){return n.add(t),!1}function u(t){return e.add(t),!0}return function(t){if(e.has(t))return!0;if(n.has(t))return!1;const s=t.match(r);if(!s)return c(t);const l=+s[1],d=+s[2],p=+s[3];return null!=s[4]||i!==l?c(t):0===i?o===d&&a<=p?u(t):c(t):o<=d?u(t):c(t)}}(n),i=n.split(".")[0],o=Symbol.for(`opentelemetry.js.api.${i}`),a="object"==typeof globalThis?globalThis:"object"==typeof self?self:"object"==typeof window?window:"object"==typeof global?global:{};function c(t,e,r,s=!1){var i;const c=a[o]=null!==(i=a[o])&&void 0!==i?i:{version:n};if(!s&&c[t]){const e=new Error(`@opentelemetry/api: Attempted duplicate registration of API: ${t}`);return r.error(e.stack||e.message),!1}if(c.version!==n){const e=new Error(`@opentelemetry/api: Registration of version v${c.version} for ${t} does not match previously registered API v${n}`);return r.error(e.stack||e.message),!1}return c[t]=e,r.debug(`@opentelemetry/api: Registered a global for ${t} v${n}.`),!0}function u(t){var e,n;const r=null===(e=a[o])||void 0===e?void 0:e.version;if(r&&s(r))return null===(n=a[o])||void 0===n?void 0:n[t]}function l(t,e){e.debug(`@opentelemetry/api: Unregistering a global for ${t} v${n}.`);const r=a[o];r&&delete r[t]}class d{constructor(t){this._namespace=t.namespace||"DiagComponentLogger"}debug(...t){return p("debug",this._namespace,t)}error(...t){return p("error",this._namespace,t)}info(...t){return p("info",this._namespace,t)}warn(...t){return p("warn",this._namespace,t)}verbose(...t){return p("verbose",this._namespace,t)}}function p(t,e,n){const r=u("diag");if(r)return r[t](e,...n)}var h;!function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"}(h||(h={}));class f{static instance(){return this._instance||(this._instance=new f),this._instance}constructor(){function t(t){return function(...e){const n=u("diag");if(n)return n[t](...e)}}const e=this;e.setLogger=(t,n={logLevel:h.INFO})=>{var r,s,i;if(t===e){const t=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return e.error(null!==(r=t.stack)&&void 0!==r?r:t.message),!1}"number"==typeof n&&(n={logLevel:n});const o=u("diag"),a=function(t,e){function n(n,r){const s=e[n];return"function"==typeof s&&t>=r?s.bind(e):function(){}}return t<h.NONE?t=h.NONE:t>h.ALL&&(t=h.ALL),e=e||{},{error:n("error",h.ERROR),warn:n("warn",h.WARN),info:n("info",h.INFO),debug:n("debug",h.DEBUG),verbose:n("verbose",h.VERBOSE)}}(null!==(s=n.logLevel)&&void 0!==s?s:h.INFO,t);if(o&&!n.suppressOverrideMessage){const t=null!==(i=(new Error).stack)&&void 0!==i?i:"<failed to generate stacktrace>";o.warn(`Current logger will be overwritten from ${t}`),a.warn(`Current logger will overwrite one already registered from ${t}`)}return c("diag",a,e,!0)},e.disable=()=>{l("diag",e)},e.createComponentLogger=t=>new d(t),e.verbose=t("verbose"),e.debug=t("debug"),e.info=t("info"),e.warn=t("warn"),e.error=t("error")}}class g{constructor(t){this._entries=t?new Map(t):new Map}getEntry(t){const e=this._entries.get(t);if(e)return Object.assign({},e)}getAllEntries(){return Array.from(this._entries.entries())}setEntry(t,e){const n=new g(this._entries);return n._entries.set(t,e),n}removeEntry(t){const e=new g(this._entries);return e._entries.delete(t),e}removeEntries(...t){const e=new g(this._entries);for(const n of t)e._entries.delete(n);return e}clear(){return new g}}const m=Symbol("BaggageEntryMetadata"),_=f.instance();function S(t={}){return new g(new Map(Object.entries(t)))}function b(t){return Symbol.for(t)}class v{constructor(t){const e=this;e._currentContext=t?new Map(t):new Map,e.getValue=t=>e._currentContext.get(t),e.setValue=(t,n)=>{const r=new v(e._currentContext);return r._currentContext.set(t,n),r},e.deleteValue=t=>{const n=new v(e._currentContext);return n._currentContext.delete(t),n}}}const E=new v;class T{}class y{addCallback(t){}removeCallback(t){}}const A=new class{constructor(){}createGauge(t,e){return C}createHistogram(t,e){return w}createCounter(t,e){return O}createUpDownCounter(t,e){return R}createObservableGauge(t,e){return N}createObservableCounter(t,e){return L}createObservableUpDownCounter(t,e){return P}addBatchObservableCallback(t,e){}removeBatchObservableCallback(t){}},O=new class extends T{add(t,e){}},C=new class extends T{record(t,e){}},w=new class extends T{record(t,e){}},R=new class extends T{add(t,e){}},L=new class extends y{},N=new class extends y{},P=new class extends y{};const x={get(t,e){if(null!=t)return t[e]},keys:t=>null==t?[]:Object.keys(t)},D={set(t,e,n){null!=t&&(t[e]=n)}};const I="context",k=new class{active(){return E}with(t,e,n,...r){return e.call(n,...r)}bind(t,e){return e}enable(){return this}disable(){return this}};class M{constructor(){}static getInstance(){return this._instance||(this._instance=new M),this._instance}setGlobalContextManager(t){return c(I,t,f.instance())}active(){return this._getContextManager().active()}with(t,e,n,...r){return this._getContextManager().with(t,e,n,...r)}bind(t,e){return this._getContextManager().bind(t,e)}_getContextManager(){return u(I)||k}disable(){this._getContextManager().disable(),l(I,f.instance())}}var U;!function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"}(U||(U={}));const B="0000000000000000",j="00000000000000000000000000000000",F={traceId:j,spanId:B,traceFlags:U.NONE};class H{constructor(t=F){this._spanContext=t}spanContext(){return this._spanContext}setAttribute(t,e){return this}setAttributes(t){return this}addEvent(t,e){return this}addLink(t){return this}addLinks(t){return this}setStatus(t){return this}updateName(t){return this}end(t){}isRecording(){return!1}recordException(t,e){}}const $=b("OpenTelemetry Context Key SPAN");function V(t){return t.getValue($)||void 0}function z(){return V(M.getInstance().active())}function q(t,e){return t.setValue($,e)}function G(t){return t.deleteValue($)}function K(t,e){return q(t,new H(e))}function W(t){var e;return null===(e=V(t))||void 0===e?void 0:e.spanContext()}const X=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1]);function Q(t,e){if("string"!=typeof t||t.length!==e)return!1;let n=0;for(let e=0;e<t.length;e+=4)n+=(0|X[t.charCodeAt(e)])+(0|X[t.charCodeAt(e+1)])+(0|X[t.charCodeAt(e+2)])+(0|X[t.charCodeAt(e+3)]);return n===e}function Y(t){return Q(t,32)&&t!==j}function Z(t){return Y(t.traceId)&&(Q(e=t.spanId,16)&&e!==B);var e}function J(t){return new H(t)}const tt=M.getInstance();class et{startSpan(t,e,n=tt.active()){if(Boolean(null==e?void 0:e.root))return new H;const r=n&&W(n);return null!==(s=r)&&"object"==typeof s&&"spanId"in s&&"string"==typeof s.spanId&&"traceId"in s&&"string"==typeof s.traceId&&"traceFlags"in s&&"number"==typeof s.traceFlags&&Z(r)?new H(r):new H;var s}startActiveSpan(t,e,n,r){let s,i,o;if(arguments.length<2)return;2===arguments.length?o=e:3===arguments.length?(s=e,o=n):(s=e,i=n,o=r);const a=null!=i?i:tt.active(),c=this.startSpan(t,s,a),u=q(a,c);return tt.with(u,o,void 0,c)}}const nt=new et;class rt{constructor(t,e,n,r){this._provider=t,this.name=e,this.version=n,this.options=r}startSpan(t,e,n){return this._getTracer().startSpan(t,e,n)}startActiveSpan(t,e,n,r){const s=this._getTracer();return Reflect.apply(s.startActiveSpan,s,arguments)}_getTracer(){if(this._delegate)return this._delegate;const t=this._provider.getDelegateTracer(this.name,this.version,this.options);return t?(this._delegate=t,this._delegate):nt}}const st=new class{getTracer(t,e,n){return new et}};class it{getTracer(t,e,n){var r;return null!==(r=this.getDelegateTracer(t,e,n))&&void 0!==r?r:new rt(this,t,e,n)}getDelegate(){var t;return null!==(t=this._delegate)&&void 0!==t?t:st}setDelegate(t){this._delegate=t}getDelegateTracer(t,e,n){var r;return null===(r=this._delegate)||void 0===r?void 0:r.getTracer(t,e,n)}}var ot,at,ct;!function(t){t[t.NOT_RECORD=0]="NOT_RECORD",t[t.RECORD=1]="RECORD",t[t.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"}(ot||(ot={})),function(t){t[t.INTERNAL=0]="INTERNAL",t[t.SERVER=1]="SERVER",t[t.CLIENT=2]="CLIENT",t[t.PRODUCER=3]="PRODUCER",t[t.CONSUMER=4]="CONSUMER"}(at||(at={})),function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"}(ct||(ct={}));const ut=M.getInstance(),lt=f.instance();const dt=new class{getMeter(t,e,n){return A}},pt="metrics";class ht{constructor(){}static getInstance(){return this._instance||(this._instance=new ht),this._instance}setGlobalMeterProvider(t){return c(pt,t,f.instance())}getMeterProvider(){return u(pt)||dt}getMeter(t,e,n){return this.getMeterProvider().getMeter(t,e,n)}disable(){l(pt,f.instance())}}const ft=ht.getInstance();const gt=b("OpenTelemetry Baggage Key");function mt(t){return t.getValue(gt)||void 0}function _t(){return mt(M.getInstance().active())}function St(t,e){return t.setValue(gt,e)}function bt(t){return t.deleteValue(gt)}const vt="propagation",Et=new class{inject(t,e){}extract(t,e){return t}fields(){return[]}};class Tt{constructor(){this.createBaggage=S,this.getBaggage=mt,this.getActiveBaggage=_t,this.setBaggage=St,this.deleteBaggage=bt}static getInstance(){return this._instance||(this._instance=new Tt),this._instance}setGlobalPropagator(t){return c(vt,t,f.instance())}inject(t,e,n=D){return this._getGlobalPropagator().inject(t,e,n)}extract(t,e,n=x){return this._getGlobalPropagator().extract(t,e,n)}fields(){return this._getGlobalPropagator().fields()}disable(){l(vt,f.instance())}_getGlobalPropagator(){return u(vt)||Et}}const yt=Tt.getInstance(),At="trace";class Ot{constructor(){this._proxyTracerProvider=new it,this.wrapSpanContext=J,this.isSpanContextValid=Z,this.deleteSpan=G,this.getSpan=V,this.getActiveSpan=z,this.getSpanContext=W,this.setSpan=q,this.setSpanContext=K}static getInstance(){return this._instance||(this._instance=new Ot),this._instance}setGlobalTracerProvider(t){const e=c(At,this._proxyTracerProvider,f.instance());return e&&this._proxyTracerProvider.setDelegate(t),e}getTracerProvider(){return u(At)||this._proxyTracerProvider}getTracer(t,e){return this.getTracerProvider().getTracer(t,e)}disable(){l(At,f.instance()),this._proxyTracerProvider=new it}}const Ct=Ot.getInstance(),wt=b("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function Rt(t){return t.setValue(wt,!0)}function Lt(t){return!0===t.getValue(wt)}const Nt=",",Pt="baggage";function xt(t){if(!t)return;const e=t.indexOf(";"),n=-1===e?t:t.substring(0,e),r=n.indexOf("=");if(r<=0)return;const s=n.substring(0,r).trim(),i=n.substring(r+1).trim();if(!s||!i)return;let o,a,c;try{o=decodeURIComponent(s),a=decodeURIComponent(i)}catch{return}if(-1!==e&&e<t.length-1){const n=t.substring(e+1);"string"!=typeof(u=n)&&(_.error("Cannot create baggage metadata from unknown type: "+typeof u),u=""),c={__TYPE__:m,toString:()=>u}}var u;return{key:o,value:a,metadata:c}}class Dt{inject(t,e,n){const r=yt.getBaggage(t);if(!r||Lt(t))return;const s=function(t){return t.getAllEntries().map(([t,e])=>{let n=`${encodeURIComponent(t)}=${encodeURIComponent(e.value)}`;return void 0!==e.metadata&&(n+=";"+e.metadata.toString()),n})}(r).filter(t=>t.length<=4096).slice(0,180),i=function(t){return t.reduce((t,e)=>{const n=`${t}${""!==t?Nt:""}${e}`;return n.length>8192?t:n},"")}(s);i.length>0&&n.set(e,Pt,i)}extract(t,e,n){const r=n.get(e,Pt),s=Array.isArray(r)?r.join(Nt):r;if(!s)return t;const i={};if(0===s.length)return t;return s.split(Nt).forEach(t=>{const e=xt(t);if(e){const t={value:e.value};e.metadata&&(t.metadata=e.metadata),i[e.key]=t}}),0===Object.entries(i).length?t:yt.setBaggage(t,yt.createBaggage(i))}fields(){return[Pt]}}function It(t){const e={};if("object"!=typeof t||null==t)return e;for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;if(!kt(n)){lt.warn(`Invalid attribute key: ${n}`);continue}const r=t[n];Mt(r)?Array.isArray(r)?e[n]=r.slice():e[n]=r:lt.warn(`Invalid attribute value set for key: ${n}`)}return e}function kt(t){return"string"==typeof t&&""!==t}function Mt(t){return null==t||(Array.isArray(t)?function(t){let e;for(const n of t){if(null==n)continue;const t=typeof n;if(t!==e){if(!e){if(Ut(t)){e=t;continue}return!1}return!1}}return!0}(t):Ut(typeof t))}function Ut(t){switch(t){case"number":case"boolean":case"string":return!0}return!1}function Bt(){return t=>{lt.error(function(t){return"string"==typeof t?t:JSON.stringify(function(t){const e={};let n=t;for(;null!==n;)Object.getOwnPropertyNames(n).forEach(t=>{if(e[t])return;const r=n[t];r&&(e[t]=String(r))}),n=Object.getPrototypeOf(n);return e}(t))}(t))}}let jt=Bt();function Ft(t){try{jt(t)}catch{}}function Ht(t){}const $t=globalThis,Vt="error.type",zt="exception.message",qt="exception.type",Gt="http.request.method",Kt="http.request.method_original",Wt="http.response.status_code",Xt="server.address",Qt="server.port",Yt="service.name",Zt="telemetry.sdk.language",Jt="telemetry.sdk.name",te="telemetry.sdk.version",ee="url.full",ne="process.runtime.name",re={[Jt]:"opentelemetry",[ne]:"browser",[Zt]:"webjs",[te]:"2.7.0"},se=performance,ie=Math.pow(10,6),oe=Math.pow(10,9);function ae(t){const e=t/1e3;return[Math.trunc(e),Math.round(t%1e3*ie)]}function ce(t){return fe(ae(se.timeOrigin),ae("number"==typeof t?t:se.now()))}function ue(t){if(pe(t))return t;if("number"==typeof t)return t<se.timeOrigin?ce(t):ae(t);if(t instanceof Date)return ae(t.getTime());throw TypeError("Invalid input type")}function le(t,e){let n=e[0]-t[0],r=e[1]-t[1];return r<0&&(n-=1,r+=oe),[n,r]}function de(t){return t[0]*oe+t[1]}function pe(t){return Array.isArray(t)&&2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]}function he(t){return pe(t)||"number"==typeof t||t instanceof Date}function fe(t,e){const n=[t[0]+e[0],t[1]+e[1]];return n[1]>=oe&&(n[1]-=oe,n[0]+=1),n}var ge;!function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"}(ge||(ge={}));class me{_propagators;_fields;constructor(t={}){this._propagators=t.propagators??[],this._fields=Array.from(new Set(this._propagators.map(t=>"function"==typeof t.fields?t.fields():[]).reduce((t,e)=>t.concat(e),[])))}inject(t,e,n){for(const r of this._propagators)try{r.inject(t,e,n)}catch(t){lt.warn(`Failed to inject with ${r.constructor.name}. Err: ${t.message}`)}}extract(t,e,n){return this._propagators.reduce((t,r)=>{try{return r.extract(t,e,n)}catch(t){lt.warn(`Failed to extract with ${r.constructor.name}. Err: ${t.message}`)}return t},t)}fields(){return this._fields.slice()}}const _e="[_0-9a-z-*/]",Se=new RegExp(`^(?:${`[a-z]${_e}{0,255}`}|${`[a-z0-9]${_e}{0,240}@[a-z]${_e}{0,13}`})$`),be=/^[ -~]{0,255}[!-~]$/,ve=/,|=/;class Ee{_internalState=new Map;constructor(t){t&&this._parse(t)}set(t,e){const n=this._clone();return n._internalState.has(t)&&n._internalState.delete(t),n._internalState.set(t,e),n}unset(t){const e=this._clone();return e._internalState.delete(t),e}get(t){return this._internalState.get(t)}serialize(){return this._keys().reduce((t,e)=>(t.push(e+"="+this.get(e)),t),[]).join(",")}_parse(t){t.length>512||(this._internalState=t.split(",").reverse().reduce((t,e)=>{const n=e.trim(),r=n.indexOf("=");if(-1!==r){const s=n.slice(0,r),i=n.slice(r+1,e.length);(function(t){return Se.test(t)})(s)&&function(t){return be.test(t)&&!ve.test(t)}(i)&&t.set(s,i)}return t},new Map),this._internalState.size>32&&(this._internalState=new Map(Array.from(this._internalState.entries()).reverse().slice(0,32))))}_keys(){return Array.from(this._internalState.keys()).reverse()}_clone(){const t=new Ee;return t._internalState=new Map(this._internalState),t}}const Te="traceparent",ye="tracestate",Ae=new RegExp("^\\s?((?!ff)[\\da-f]{2})-((?![0]{32})[\\da-f]{32})-((?![0]{16})[\\da-f]{16})-([\\da-f]{2})(-.*)?\\s?$");function Oe(t){const e=Ae.exec(t);return e?"00"===e[1]&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}:null}class Ce{inject(t,e,n){const r=Ct.getSpanContext(t);if(!r||Lt(t)||!Z(r))return;const s=`00-${r.traceId}-${r.spanId}-0${Number(r.traceFlags||U.NONE).toString(16)}`;n.set(e,Te,s),r.traceState&&n.set(e,ye,r.traceState.serialize())}extract(t,e,n){const r=n.get(e,Te);if(!r)return t;const s=Array.isArray(r)?r[0]:r;if("string"!=typeof s)return t;const i=Oe(s);if(!i)return t;i.isRemote=!0;const o=n.get(e,ye);if(o){const t=Array.isArray(o)?o.join(","):o;i.traceState=new Ee("string"==typeof t?t:void 0)}return Ct.setSpanContext(t,i)}fields(){return[Te,ye]}}const we=b("OpenTelemetry SDK Context Key RPC_METADATA");var Re;!function(t){t.HTTP="http"}(Re||(Re={}));const Le="[object Null]",Ne="[object Undefined]",Pe=Function.prototype.toString,xe=Pe.call(Object),De=Object.getPrototypeOf,Ie=Object.prototype,ke=Ie.hasOwnProperty,Me=Symbol?Symbol.toStringTag:void 0,Ue=Ie.toString;function Be(t){if(!function(t){return null!=t&&"object"==typeof t}(t)||"[object Object]"!==function(t){if(null==t)return void 0===t?Ne:Le;return Me&&Me in Object(t)?function(t){const e=ke.call(t,Me),n=t[Me];let r=!1;try{t[Me]=void 0,r=!0}catch{}const s=Ue.call(t);r&&(e?t[Me]=n:delete t[Me]);return s}(t):function(t){return Ue.call(t)}(t)}(t))return!1;const e=De(t);if(null===e)return!0;const n=ke.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Pe.call(n)===xe}function je(...t){let e=t.shift();const n=new WeakMap;for(;t.length>0;)e=He(e,t.shift(),0,n);return e}function Fe(t){return Ve(t)?t.slice():t}function He(t,e,n=0,r){let s;if(!(n>20)){if(n++,Ge(t)||Ge(e)||ze(e))s=Fe(e);else if(Ve(t)){if(s=t.slice(),Ve(e))for(let t=0,n=e.length;t<n;t++)s.push(Fe(e[t]));else if(qe(e)){const t=Object.keys(e);for(let n=0,r=t.length;n<r;n++){const r=t[n];"__proto__"!==r&&"constructor"!==r&&"prototype"!==r&&(s[r]=Fe(e[r]))}}}else if(qe(t))if(qe(e)){if(!function(t,e){if(!Be(t)||!Be(e))return!1;return!0}(t,e))return e;s=Object.assign({},t);const i=Object.keys(e);for(let o=0,a=i.length;o<a;o++){const a=i[o];if("__proto__"===a||"constructor"===a||"prototype"===a)continue;const c=e[a];if(Ge(c))void 0===c?delete s[a]:s[a]=c;else{const i=s[a],o=c;if($e(t,a,r)||$e(e,a,r))delete s[a];else{if(qe(i)&&qe(o)){const n=r.get(i)||[],s=r.get(o)||[];n.push({obj:t,key:a}),s.push({obj:e,key:a}),r.set(i,n),r.set(o,s)}s[a]=He(s[a],c,n,r)}}}}else s=e;return s}}function $e(t,e,n){const r=n.get(t[e])||[];for(let n=0,s=r.length;n<s;n++){const s=r[n];if(s.key===e&&s.obj===t)return!0}return!1}function Ve(t){return Array.isArray(t)}function ze(t){return"function"==typeof t}function qe(t){return!Ge(t)&&!Ve(t)&&!ze(t)&&"object"==typeof t}function Ge(t){return"string"==typeof t||"number"==typeof t||"boolean"==typeof t||void 0===t||t instanceof Date||t instanceof RegExp||null===t}class Ke extends Error{constructor(t){super(t),Object.setPrototypeOf(this,Ke.prototype)}}function We(t,e){return"string"==typeof e?t===e:!!t.match(e)}function Xe(t,e){if(!e)return!1;for(const n of e)if(We(t,n))return!0;return!1}class Qe{_promise;_resolve;_reject;constructor(){this._promise=new Promise((t,e)=>{this._resolve=t,this._reject=e})}get promise(){return this._promise}resolve(t){this._resolve(t)}reject(t){this._reject(t)}}class Ye{_isCalled=!1;_deferred=new Qe;_callback;_that;constructor(t,e){this._callback=t,this._that=e}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...t){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...t)).then(t=>this._deferred.resolve(t),t=>this._deferred.reject(t))}catch(t){this._deferred.reject(t)}}return this._deferred.promise}}const Ze={ALL:h.ALL,VERBOSE:h.VERBOSE,DEBUG:h.DEBUG,INFO:h.INFO,WARN:h.WARN,ERROR:h.ERROR,NONE:h.NONE};const Je={_export:function(t,e){return new Promise(n=>{ut.with(Rt(ut.active()),()=>{t.export(e,n)})})}};var tn=Object.freeze({__proto__:null,AnchoredClock:class{_monotonicClock;_epochMillis;_performanceMillis;constructor(t,e){this._monotonicClock=e,this._epochMillis=t.now(),this._performanceMillis=e.now()}now(){const t=this._monotonicClock.now()-this._performanceMillis;return this._epochMillis+t}},BindOnceFuture:Ye,CompositePropagator:me,get ExportResultCode(){return ge},get RPCType(){return Re},SDK_INFO:re,TRACE_PARENT_HEADER:Te,TRACE_STATE_HEADER:ye,TimeoutError:Ke,TraceState:Ee,W3CBaggagePropagator:Dt,W3CTraceContextPropagator:Ce,_globalThis:$t,addHrTimes:fe,callWithTimeout:function(t,e){let n;const r=new Promise(function(t,r){n=setTimeout(function(){r(new Ke("Operation timed out."))},e)});return Promise.race([t,r]).then(t=>(clearTimeout(n),t),t=>{throw clearTimeout(n),t})},deleteRPCMetadata:function(t){return t.deleteValue(we)},diagLogLevelFromString:function(t){if(null==t)return;const e=Ze[t.toUpperCase()];return null==e?(lt.warn(`Unknown log level "${t}", expected one of ${Object.keys(Ze)}, using default`),h.INFO):e},getBooleanFromEnv:function(t){},getNumberFromEnv:Ht,getRPCMetadata:function(t){return t.getValue(we)},getStringFromEnv:function(t){},getStringListFromEnv:function(t){},getTimeOrigin:function(){return se.timeOrigin},globalErrorHandler:Ft,hrTime:ce,hrTimeDuration:le,hrTimeToMicroseconds:function(t){return 1e6*t[0]+t[1]/1e3},hrTimeToMilliseconds:function(t){return 1e3*t[0]+t[1]/1e6},hrTimeToNanoseconds:de,hrTimeToTimeStamp:function(t){const e=`${"0".repeat(9)}${t[1]}Z`,n=e.substring(e.length-9-1);return new Date(1e3*t[0]).toISOString().replace("000Z",n)},internal:Je,isAttributeValue:Mt,isTimeInput:he,isTimeInputHrTime:pe,isTracingSuppressed:Lt,isUrlIgnored:Xe,loggingErrorHandler:Bt,merge:je,millisToHrTime:ae,otperformance:se,parseKeyPairsIntoRecord:function(t){const e={};return"string"==typeof t&&t.length>0&&t.split(Nt).forEach(t=>{const n=xt(t);void 0!==n&&n.value.length>0&&(e[n.key]=n.value)}),e},parseTraceParent:Oe,sanitizeAttributes:It,setGlobalErrorHandler:function(t){jt=t},setRPCMetadata:function(t,e){return t.setValue(we,e)},suppressTracing:Rt,timeInputToHrTime:ue,unrefTimer:function(t){"number"!=typeof t&&t.unref()},unsuppressTracing:function(t){return t.deleteValue(wt)},urlMatches:We});function en(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if("function"==typeof e){var n=function t(){var n=!1;try{n=this instanceof t}catch{}return n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})}),n}var nn,rn,sn={},on=en(tn),an={};function cn(){if(nn)return an;function t(t){return t>=48&&t<=57?t-48:t>=97&&t<=102?t-87:t-55}return nn=1,Object.defineProperty(an,"__esModule",{value:!0}),an.hexToBinary=void 0,an.hexToBinary=function(e){const n=new Uint8Array(e.length/2);let r=0;for(let s=0;s<e.length;s+=2){const i=t(e.charCodeAt(s)),o=t(e.charCodeAt(s+1));n[r++]=i<<4|o}return n},an}function un(){if(rn)return sn;rn=1,Object.defineProperty(sn,"__esModule",{value:!0}),sn.JSON_ENCODER=sn.PROTOBUF_ENCODER=sn.encodeAsString=sn.encodeAsLongBits=sn.toLongBits=sn.hrTimeToNanos=void 0;const t=on,e=cn();function n(t){const e=BigInt(1e9);return BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))}function r(t){return{low:Number(BigInt.asUintN(32,t)),high:Number(BigInt.asUintN(32,t>>BigInt(32)))}}function s(t){return r(n(t))}function i(t){return n(t).toString()}sn.hrTimeToNanos=n,sn.toLongBits=r,sn.encodeAsLongBits=s,sn.encodeAsString=i;const o="undefined"!=typeof BigInt?i:t.hrTimeToNanoseconds;function a(t){return t}return sn.PROTOBUF_ENCODER={encodeHrTime:s,encodeSpanContext:e.hexToBinary,encodeOptionalSpanContext:function(t){if(void 0!==t)return(0,e.hexToBinary)(t)},encodeUint8Array:a},sn.JSON_ENCODER={encodeHrTime:o,encodeSpanContext:a,encodeOptionalSpanContext:a,encodeUint8Array:t=>{if("undefined"!=typeof Buffer)return Buffer.from(t).toString("base64");const e=new Array(t.length);for(let n=0;n<t.length;n++)e[n]=String.fromCharCode(t[n]);return btoa(e.join(""))}},sn}var ln,dn,pn=un(),hn={},fn={};function gn(){if(ln)return fn;function t(t,n){return Object.keys(t).map(r=>e(r,t[r],n))}function e(t,e,r){return{key:t,value:n(e,r)}}function n(t,e){const r=typeof t;if("string"===r)return{stringValue:t};if("number"===r)return Number.isInteger(t)?{intValue:t}:{doubleValue:t};if("boolean"===r)return{boolValue:t};if(t instanceof Uint8Array)return{bytesValue:e.encodeUint8Array(t)};if(Array.isArray(t)){const r=new Array(t.length);for(let s=0;s<t.length;s++)r[s]=n(t[s],e);return{arrayValue:{values:r}}}if("object"===r&&null!=t){const r=Object.keys(t),s=new Array(r.length);for(let i=0;i<r.length;i++)s[i]={key:r[i],value:n(t[r[i]],e)};return{kvlistValue:{values:s}}}return{}}return ln=1,Object.defineProperty(fn,"__esModule",{value:!0}),fn.toAnyValue=fn.toKeyValue=fn.toAttributes=fn.createInstrumentationScope=fn.createResource=void 0,fn.createResource=function(e,n){const r={attributes:t(e.attributes,n),droppedAttributesCount:0},s=e.schemaUrl;return s&&""!==s&&(r.schemaUrl=s),r},fn.createInstrumentationScope=function(t){return{name:t.name,version:t.version}},fn.toAttributes=t,fn.toKeyValue=e,fn.toAnyValue=n,fn}function mn(){if(dn)return hn;dn=1,Object.defineProperty(hn,"__esModule",{value:!0}),hn.createExportTraceServiceRequest=hn.toOtlpSpanEvent=hn.toOtlpLink=hn.sdkSpanToOtlpSpan=void 0;const t=gn();function e(t,e){let n=255&t|256;return e&&(n|=512),n}function n(n,i){const o=n.spanContext(),a=n.status,c=n.parentSpanContext?.spanId?i.encodeSpanContext(n.parentSpanContext?.spanId):void 0;return{traceId:i.encodeSpanContext(o.traceId),spanId:i.encodeSpanContext(o.spanId),parentSpanId:c,traceState:o.traceState?.serialize(),name:n.name,kind:null==n.kind?0:n.kind+1,startTimeUnixNano:i.encodeHrTime(n.startTime),endTimeUnixNano:i.encodeHrTime(n.endTime),attributes:(0,t.toAttributes)(n.attributes,i),droppedAttributesCount:n.droppedAttributesCount,events:n.events.map(t=>s(t,i)),droppedEventsCount:n.droppedEventsCount,status:{code:a.code,message:a.message},links:n.links.map(t=>r(t,i)),droppedLinksCount:n.droppedLinksCount,flags:e(o.traceFlags,n.parentSpanContext?.isRemote)}}function r(n,r){return{attributes:n.attributes?(0,t.toAttributes)(n.attributes,r):[],spanId:r.encodeSpanContext(n.context.spanId),traceId:r.encodeSpanContext(n.context.traceId),traceState:n.context.traceState?.serialize(),droppedAttributesCount:n.droppedAttributesCount||0,flags:e(n.context.traceFlags,n.context.isRemote)}}function s(e,n){return{attributes:e.attributes?(0,t.toAttributes)(e.attributes,n):[],name:e.name,timeUnixNano:n.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}function i(e,r){const s=function(t){const e=new Map;for(const n of t){let t=e.get(n.resource);t||(t=new Map,e.set(n.resource,t));const r=`${n.instrumentationScope.name}@${n.instrumentationScope.version||""}:${n.instrumentationScope.schemaUrl||""}`;let s=t.get(r);s||(s=[],t.set(r,s)),s.push(n)}return e}(e),i=[],o=s.entries();let a=o.next();for(;!a.done;){const[e,s]=a.value,c=[],u=s.values();let l=u.next();for(;!l.done;){const e=l.value;if(e.length>0){const s=e.map(t=>n(t,r));c.push({scope:(0,t.createInstrumentationScope)(e[0].instrumentationScope),spans:s,schemaUrl:e[0].instrumentationScope.schemaUrl})}l=u.next()}const d=(0,t.createResource)(e,r),p={resource:d,scopeSpans:c,schemaUrl:d.schemaUrl};i.push(p),a=o.next()}return i}return hn.sdkSpanToOtlpSpan=n,hn.toOtlpLink=r,hn.toOtlpSpanEvent=s,hn.createExportTraceServiceRequest=function(t,e){return{resourceSpans:i(t,e)}},hn}var _n,Sn=mn(),bn={};function vn(){return _n||(_n=1,t=bn,Object.defineProperty(t,"__esModule",{value:!0}),t.EStatusCode=t.ESpanKind=void 0,(e=t.ESpanKind||(t.ESpanKind={}))[e.SPAN_KIND_UNSPECIFIED=0]="SPAN_KIND_UNSPECIFIED",e[e.SPAN_KIND_INTERNAL=1]="SPAN_KIND_INTERNAL",e[e.SPAN_KIND_SERVER=2]="SPAN_KIND_SERVER",e[e.SPAN_KIND_CLIENT=3]="SPAN_KIND_CLIENT",e[e.SPAN_KIND_PRODUCER=4]="SPAN_KIND_PRODUCER",e[e.SPAN_KIND_CONSUMER=5]="SPAN_KIND_CONSUMER",(n=t.EStatusCode||(t.EStatusCode={}))[n.STATUS_CODE_UNSET=0]="STATUS_CODE_UNSET",n[n.STATUS_CODE_OK=1]="STATUS_CODE_OK",n[n.STATUS_CODE_ERROR=2]="STATUS_CODE_ERROR"),bn;var t,e,n}var En=vn();class Tn{constructor(t){this.config=t}export(t,n){const r=Sn.createExportTraceServiceRequest(t,pn.JSON_ENCODER);this.config.api.pushTraces(r),function(t=[],n){var r,s;for(const i of t){const{scopeSpans:t}=i;for(const i of t){const{scope:t,spans:o=[]}=i;for(const i of o){if(i.kind!==En.ESpanKind.SPAN_KIND_CLIENT)continue;const o={traceId:i.traceId.toString(),spanId:i.spanId.toString()},a={};for(const t of i.attributes)a[t.key]=String(Object.values(t.value)[0]);Number.isNaN(i.endTimeUnixNano)||Number.isNaN(i.startTimeUnixNano)||(a.duration_ns=String(Number(i.endTimeUnixNano)-Number(i.startTimeUnixNano)));const c=(null!==(r=null==t?void 0:t.name)&&void 0!==r?r:"").indexOf("-");let u=e.unknownString;(null==t?void 0:t.name)&&(-1===c&&(u=null!==(s=t.name.split("/")[1])&&void 0!==s?s:t.name),c>-1&&(u=null==t?void 0:t.name.substring(c+1))),n.pushEvent(`faro.tracing.${u}`,a,void 0,{spanContext:o,timestampOverwriteMs:Number(i.endTimeUnixNano)/1e6,customPayloadTransformer:t=>{var e,n;return null!=a["faro.action.user.name"]&&null!=a["faro.action.user.parentId"]&&(t.action={name:a["faro.action.user.name"],parentId:a["faro.action.user.parentId"]},null===(e=t.attributes)||void 0===e||delete e["faro.action.user.name"],null===(n=t.attributes)||void 0===n||delete n["faro.action.user.parentId"]),t}})}}}}(r.resourceSpans,this.config.api),n({code:ge.SUCCESS})}shutdown(){return Promise.resolve(void 0)}}"function"==typeof SuppressedError&&SuppressedError;class yn{emit(t){}enabled(){return!1}}const An=new yn,On=Symbol.for("io.opentelemetry.js.api.logs"),Cn=globalThis;const wn=new class{getLogger(t,e,n){return new yn}};class Rn{constructor(t,e,n,r){this._provider=t,this.name=e,this.version=n,this.options=r}emit(t){this._getLogger().emit(t)}enabled(t){return this._getLogger().enabled(t)}_getLogger(){if(this._delegate)return this._delegate;const t=this._provider._getDelegateLogger(this.name,this.version,this.options);return t?(this._delegate=t,this._delegate):An}}class Ln{getLogger(t,e,n){var r;return null!==(r=this._getDelegateLogger(t,e,n))&&void 0!==r?r:new Rn(this,t,e,n)}_getDelegate(){var t;return null!==(t=this._delegate)&&void 0!==t?t:wn}_setDelegate(t){this._delegate=t}_getDelegateLogger(t,e,n){var r;return null===(r=this._delegate)||void 0===r?void 0:r.getLogger(t,e,n)}}class Nn{constructor(){this._proxyLoggerProvider=new Ln}static getInstance(){return this._instance||(this._instance=new Nn),this._instance}setGlobalLoggerProvider(t){return Cn[On]?this.getLoggerProvider():(Cn[On]=(e=1,n=t,r=wn,t=>t===e?n:r),this._proxyLoggerProvider._setDelegate(t),t);var e,n,r}getLoggerProvider(){var t,e;return null!==(e=null===(t=Cn[On])||void 0===t?void 0:t.call(Cn,1))&&void 0!==e?e:this._proxyLoggerProvider}getLogger(t,e,n){return this.getLoggerProvider().getLogger(t,e,n)}disable(){delete Cn[On],this._proxyLoggerProvider=new Ln}}const Pn=Nn.getInstance();let xn=console.error.bind(console);function Dn(t,e,n){const r=!!t[e]&&Object.prototype.propertyIsEnumerable.call(t,e);Object.defineProperty(t,e,{configurable:!0,enumerable:r,writable:!0,value:n})}const In=(t,e,n)=>{if(!t||!t[e])return void xn("no original function "+String(e)+" to wrap");if(!n)return xn("no wrapper function"),void xn((new Error).stack);const r=t[e];if("function"!=typeof r||"function"!=typeof n)return void xn("original object and wrapper must be functions");const s=n(r,e);return Dn(s,"__original",r),Dn(s,"__unwrap",()=>{t[e]===s&&Dn(t,e,r)}),Dn(s,"__wrapped",!0),Dn(t,e,s),s},kn=(t,e,n)=>{if(!t)return xn("must provide one or more modules to patch"),void xn((new Error).stack);Array.isArray(t)||(t=[t]),e&&Array.isArray(e)?t.forEach(t=>{e.forEach(e=>{In(t,e,n)})}):xn("must provide one or more functions to wrap on modules")},Mn=(t,e)=>{if(!t||!t[e])return xn("no function to unwrap."),void xn((new Error).stack);const n=t[e];n.__unwrap?n.__unwrap():xn("no original to unwrap to -- has "+String(e)+" already been unwrapped?")},Un=(t,e)=>{if(!t)return xn("must provide one or more modules to patch"),void xn((new Error).stack);Array.isArray(t)||(t=[t]),e&&Array.isArray(e)?t.forEach(t=>{e.forEach(e=>{Mn(t,e)})}):xn("must provide one or more functions to unwrap on modules")};class Bn{_config={};_tracer;_meter;_logger;_diag;instrumentationName;instrumentationVersion;constructor(t,e,n){this.instrumentationName=t,this.instrumentationVersion=e,this.setConfig(n),this._diag=lt.createComponentLogger({namespace:t}),this._tracer=Ct.getTracer(t,e),this._meter=ft.getMeter(t,e),this._logger=Pn.getLogger(t,e),this._updateMetricInstruments()}_wrap=In;_unwrap=Mn;_massWrap=kn;_massUnwrap=Un;get meter(){return this._meter}setMeterProvider(t){this._meter=t.getMeter(this.instrumentationName,this.instrumentationVersion),this._updateMetricInstruments()}get logger(){return this._logger}setLoggerProvider(t){this._logger=t.getLogger(this.instrumentationName,this.instrumentationVersion)}getModuleDefinitions(){const t=this.init()??[];return Array.isArray(t)?t:[t]}_updateMetricInstruments(){}getConfig(){return this._config}setConfig(t){this._config={enabled:!0,...t}}setTracerProvider(t){this._tracer=t.getTracer(this.instrumentationName,this.instrumentationVersion)}get tracer(){return this._tracer}_runSpanCustomizationHook(t,e,n,r){if(t)try{t(n,r)}catch(t){this._diag.error("Error running span customization hook due to exception in handler",{triggerName:e},t)}}}class jn extends Bn{constructor(t,e,n){super(t,e,n),this._config.enabled&&this.enable()}}function Fn(t,e,n){let r,s;try{s=t()}catch(t){r=t}finally{return e(r,s),s}}function Hn(t){return"function"==typeof t&&"function"==typeof t.__original&&"function"==typeof t.__unwrap&&!0===t.__wrapped}var $n;function Vn(t,e){let n=$n.OLD;const r=e?.split(",").map(t=>t.trim()).filter(t=>""!==t);for(const e of r??[]){if(e.toLowerCase()===t+"/dup"){n=$n.DUPLICATE;break}e.toLowerCase()===t&&(n=$n.STABLE)}return n}let zn;function qn(){if(void 0===zn)try{const t=globalThis.process.argv0;zn=t?`unknown_service:${t}`:"unknown_service"}catch{zn="unknown_service"}return zn}!function(t){t[t.STABLE=1]="STABLE",t[t.OLD=2]="OLD",t[t.DUPLICATE=3]="DUPLICATE"}($n||($n={}));const Gn=t=>null!==t&&"object"==typeof t&&"function"==typeof t.then;class Kn{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(t,e){const n=new Kn({},e);return n._rawAttributes=Qn(t),n._asyncAttributesPending=t.filter(([t,e])=>Gn(e)).length>0,n}constructor(t,e){const n=t.attributes??{};this._rawAttributes=Object.entries(n).map(([t,e])=>(Gn(e)&&(this._asyncAttributesPending=!0),[t,e])),this._rawAttributes=Qn(this._rawAttributes),this._schemaUrl=function(t){if("string"==typeof t||void 0===t)return t;return void lt.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}(e?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let t=0;t<this._rawAttributes.length;t++){const[e,n]=this._rawAttributes[t];this._rawAttributes[t]=[e,Gn(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&lt.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;const t={};for(const[e,n]of this._rawAttributes)Gn(n)?lt.debug(`Unsettled resource attribute ${e} skipped`):null!=n&&(t[e]??=n);return this._asyncAttributesPending||(this._memoizedAttributes=t),t}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(t){if(null==t)return this;const e=function(t,e){const n=t?.schemaUrl,r=e?.schemaUrl,s=void 0===n||""===n,i=void 0===r||""===r;if(s)return r;if(i)return n;if(n===r)return n;return void lt.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',n,r)}(this,t),n=e?{schemaUrl:e}:void 0;return Kn.FromAttributeList([...t.getRawAttributes(),...this.getRawAttributes()],n)}}function Wn(t,e){return Kn.FromAttributeList(Object.entries(t),e)}function Xn(){return Wn({[Yt]:qn(),[Zt]:re[Zt],[Jt]:re[Jt],[te]:re[te]})}function Qn(t){return t.map(([t,e])=>Gn(e)?[t,e.catch(e=>{lt.debug("promise rejection for resource attribute: %s - %s",t,e)})]:[t,e])}class Yn{_spanContext;kind;parentSpanContext;attributes={};links=[];events=[];startTime;resource;instrumentationScope;_droppedAttributesCount=0;_droppedEventsCount=0;_droppedLinksCount=0;_attributesCount=0;name;status={code:ct.UNSET};endTime=[0,0];_ended=!1;_duration=[-1,-1];_spanProcessor;_spanLimits;_attributeValueLengthLimit;_recordEndMetrics;_performanceStartTime;_performanceOffset;_startTimeProvided;constructor(t){const e=Date.now();if(this._spanContext=t.spanContext,this._performanceStartTime=se.now(),this._performanceOffset=e-(this._performanceStartTime+se.timeOrigin),this._startTimeProvided=null!=t.startTime,this._spanLimits=t.spanLimits,this._attributeValueLengthLimit=this._spanLimits.attributeValueLengthLimit??0,this._spanProcessor=t.spanProcessor,this.name=t.name,this.parentSpanContext=t.parentSpanContext,this.kind=t.kind,t.links)for(const e of t.links)this.addLink(e);this.startTime=this._getTime(t.startTime??e),this.resource=t.resource,this.instrumentationScope=t.scope,this._recordEndMetrics=t.recordEndMetrics,null!=t.attributes&&this.setAttributes(t.attributes),this._spanProcessor.onStart(this,t.context)}spanContext(){return this._spanContext}setAttribute(t,e){if(null==e||this._isSpanEnded())return this;if(0===t.length)return lt.warn(`Invalid attribute key: ${t}`),this;if(!Mt(e))return lt.warn(`Invalid attribute value set for key: ${t}`),this;const{attributeCountLimit:n}=this._spanLimits,r=!Object.prototype.hasOwnProperty.call(this.attributes,t);return void 0!==n&&this._attributesCount>=n&&r?(this._droppedAttributesCount++,this):(this.attributes[t]=this._truncateToSize(e),r&&this._attributesCount++,this)}setAttributes(t){for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&this.setAttribute(e,t[e]);return this}addEvent(t,e,n){if(this._isSpanEnded())return this;const{eventCountLimit:r}=this._spanLimits;if(0===r)return lt.warn("No events allowed."),this._droppedEventsCount++,this;void 0!==r&&this.events.length>=r&&(0===this._droppedEventsCount&&lt.debug("Dropping extra events."),this.events.shift(),this._droppedEventsCount++),he(e)&&(he(n)||(n=e),e=void 0);const s=It(e),{attributePerEventCountLimit:i}=this._spanLimits,o={};let a=0,c=0;for(const t in s){if(!Object.prototype.hasOwnProperty.call(s,t))continue;const e=s[t];void 0!==i&&c>=i?a++:(o[t]=this._truncateToSize(e),c++)}return this.events.push({name:t,attributes:o,time:this._getTime(n),droppedAttributesCount:a}),this}addLink(t){if(this._isSpanEnded())return this;const{linkCountLimit:e}=this._spanLimits;if(0===e)return this._droppedLinksCount++,this;void 0!==e&&this.links.length>=e&&(0===this._droppedLinksCount&&lt.debug("Dropping extra links."),this.links.shift(),this._droppedLinksCount++);const{attributePerLinkCountLimit:n}=this._spanLimits,r=It(t.attributes),s={};let i=0,o=0;for(const t in r){if(!Object.prototype.hasOwnProperty.call(r,t))continue;const e=r[t];void 0!==n&&o>=n?i++:(s[t]=this._truncateToSize(e),o++)}const a={context:t.context};return o>0&&(a.attributes=s),i>0&&(a.droppedAttributesCount=i),this.links.push(a),this}addLinks(t){for(const e of t)this.addLink(e);return this}setStatus(t){if(this._isSpanEnded())return this;if(t.code===ct.UNSET)return this;if(this.status.code===ct.OK)return this;const e={code:t.code};return t.code===ct.ERROR&&("string"==typeof t.message?e.message=t.message:null!=t.message&&lt.warn(`Dropping invalid status.message of type '${typeof t.message}', expected 'string'`)),this.status=e,this}updateName(t){return this._isSpanEnded()||(this.name=t),this}end(t){this._isSpanEnded()?lt.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`):(this.endTime=this._getTime(t),this._duration=le(this.startTime,this.endTime),this._duration[0]<0&&(lt.warn("Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.",this.startTime,this.endTime),this.endTime=this.startTime.slice(),this._duration=[0,0]),this._droppedEventsCount>0&&lt.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`),this._droppedLinksCount>0&&lt.warn(`Dropped ${this._droppedLinksCount} links because linkCountLimit reached`),this._spanProcessor.onEnding&&this._spanProcessor.onEnding(this),this._recordEndMetrics?.(),this._ended=!0,this._spanProcessor.onEnd(this))}_getTime(t){if("number"==typeof t&&t<=se.now())return ce(t+this._performanceOffset);if("number"==typeof t)return ae(t);if(t instanceof Date)return ae(t.getTime());if(pe(t))return t;if(this._startTimeProvided)return ae(Date.now());const e=se.now()-this._performanceStartTime;return fe(this.startTime,ae(e))}isRecording(){return!1===this._ended}recordException(t,e){const n={};"string"==typeof t?n[zt]=t:t&&(t.code?n[qt]=t.code.toString():t.name&&(n[qt]=t.name),t.message&&(n[zt]=t.message),t.stack&&(n["exception.stacktrace"]=t.stack)),n[qt]||n[zt]?this.addEvent("exception",n,e):lt.warn(`Failed to record an exception ${t}`)}get duration(){return this._duration}get ended(){return this._ended}get droppedAttributesCount(){return this._droppedAttributesCount}get droppedEventsCount(){return this._droppedEventsCount}get droppedLinksCount(){return this._droppedLinksCount}_isSpanEnded(){if(this._ended){const t=new Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);lt.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`,t)}return this._ended}_truncateToLimitUtil(t,e){return t.length<=e?t:t.substring(0,e)}_truncateToSize(t){const e=this._attributeValueLengthLimit;return e<=0?(lt.warn(`Attribute value limit must be positive, got ${e}`),t):"string"==typeof t?this._truncateToLimitUtil(t,e):Array.isArray(t)?t.map(t=>"string"==typeof t?this._truncateToLimitUtil(t,e):t):t}}var Zn,Jn;!function(t){t[t.NOT_RECORD=0]="NOT_RECORD",t[t.RECORD=1]="RECORD",t[t.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"}(Zn||(Zn={}));class tr{shouldSample(){return{decision:Zn.NOT_RECORD}}toString(){return"AlwaysOffSampler"}}class er{shouldSample(){return{decision:Zn.RECORD_AND_SAMPLED}}toString(){return"AlwaysOnSampler"}}class nr{_root;_remoteParentSampled;_remoteParentNotSampled;_localParentSampled;_localParentNotSampled;constructor(t){this._root=t.root,this._root||(Ft(new Error("ParentBasedSampler must have a root sampler configured")),this._root=new er),this._remoteParentSampled=t.remoteParentSampled??new er,this._remoteParentNotSampled=t.remoteParentNotSampled??new tr,this._localParentSampled=t.localParentSampled??new er,this._localParentNotSampled=t.localParentNotSampled??new tr}shouldSample(t,e,n,r,s,i){const o=Ct.getSpanContext(t);return o&&Z(o)?o.isRemote?o.traceFlags&U.SAMPLED?this._remoteParentSampled.shouldSample(t,e,n,r,s,i):this._remoteParentNotSampled.shouldSample(t,e,n,r,s,i):o.traceFlags&U.SAMPLED?this._localParentSampled.shouldSample(t,e,n,r,s,i):this._localParentNotSampled.shouldSample(t,e,n,r,s,i):this._root.shouldSample(t,e,n,r,s,i)}toString(){return`ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`}}class rr{_ratio;_upperBound;constructor(t=0){this._ratio=this._normalize(t),this._upperBound=Math.floor(4294967295*this._ratio)}shouldSample(t,e){return{decision:Y(e)&&this._accumulate(e)<this._upperBound?Zn.RECORD_AND_SAMPLED:Zn.NOT_RECORD}}toString(){return`TraceIdRatioBased{${this._ratio}}`}_normalize(t){return"number"!=typeof t||isNaN(t)?0:t>=1?1:t<=0?0:t}_accumulate(t){let e=0;for(let n=0;n<t.length/8;n++){const r=8*n;e=(e^parseInt(t.slice(r,r+8),16))>>>0}return e}}!function(t){t.AlwaysOff="always_off",t.AlwaysOn="always_on",t.ParentBasedAlwaysOff="parentbased_always_off",t.ParentBasedAlwaysOn="parentbased_always_on",t.ParentBasedTraceIdRatio="parentbased_traceidratio",t.TraceIdRatio="traceidratio"}(Jn||(Jn={}));function sr(){return{sampler:ir(),forceFlushTimeoutMillis:3e4,generalLimits:{attributeValueLengthLimit:1/0,attributeCountLimit:128},spanLimits:{attributeValueLengthLimit:1/0,attributeCountLimit:128,linkCountLimit:128,eventCountLimit:128,attributePerEventCountLimit:128,attributePerLinkCountLimit:128}}}function ir(){const t=Jn.ParentBasedAlwaysOn;switch(t){case Jn.AlwaysOn:return new er;case Jn.AlwaysOff:return new tr;case Jn.ParentBasedAlwaysOn:return new nr({root:new er});case Jn.ParentBasedAlwaysOff:return new nr({root:new tr});case Jn.TraceIdRatio:return new rr(or());case Jn.ParentBasedTraceIdRatio:return new nr({root:new rr(or())});default:return lt.error(`OTEL_TRACES_SAMPLER value "${t}" invalid, defaulting to "${Jn.ParentBasedAlwaysOn}".`),new nr({root:new er})}}function or(){return lt.error("OTEL_TRACES_SAMPLER_ARG is blank, defaulting to 1."),1}const ar=1/0;class cr{_maxExportBatchSize;_maxQueueSize;_scheduledDelayMillis;_exportTimeoutMillis;_exporter;_isExporting=!1;_finishedSpans=[];_timer;_shutdownOnce;_droppedSpansCount=0;constructor(t,e){this._exporter=t,this._maxExportBatchSize="number"==typeof e?.maxExportBatchSize?e.maxExportBatchSize:512,this._maxQueueSize="number"==typeof e?.maxQueueSize?e.maxQueueSize:2048,this._scheduledDelayMillis="number"==typeof e?.scheduledDelayMillis?e.scheduledDelayMillis:5e3,this._exportTimeoutMillis="number"==typeof e?.exportTimeoutMillis?e.exportTimeoutMillis:3e4,this._shutdownOnce=new Ye(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(lt.warn("BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize"),this._maxExportBatchSize=this._maxQueueSize)}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}onStart(t,e){}onEnd(t){this._shutdownOnce.isCalled||0!==(t.spanContext().traceFlags&U.SAMPLED)&&this._addToBuffer(t)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return Promise.resolve().then(()=>this.onShutdown()).then(()=>this._flushAll()).then(()=>this._exporter.shutdown())}_addToBuffer(t){if(this._finishedSpans.length>=this._maxQueueSize)return 0===this._droppedSpansCount&&lt.debug("maxQueueSize reached, dropping spans"),void this._droppedSpansCount++;this._droppedSpansCount>0&&(lt.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`),this._droppedSpansCount=0),this._finishedSpans.push(t),this._maybeStartTimer()}_flushAll(){return new Promise((t,e)=>{const n=[];for(let t=0,e=Math.ceil(this._finishedSpans.length/this._maxExportBatchSize);t<e;t++)n.push(this._flushOneBatch());Promise.all(n).then(()=>{t()}).catch(e)})}_flushOneBatch(){return this._clearTimer(),0===this._finishedSpans.length?Promise.resolve():new Promise((t,e)=>{const n=setTimeout(()=>{e(new Error("Timeout"))},this._exportTimeoutMillis);ut.with(Rt(ut.active()),()=>{let r;this._finishedSpans.length<=this._maxExportBatchSize?(r=this._finishedSpans,this._finishedSpans=[]):r=this._finishedSpans.splice(0,this._maxExportBatchSize);const s=()=>this._exporter.export(r,r=>{clearTimeout(n),r.code===ge.SUCCESS?t():e(r.error??new Error("BatchSpanProcessor: span export failed"))});let i=null;for(let t=0,e=r.length;t<e;t++){const e=r[t];e.resource.asyncAttributesPending&&e.resource.waitForAsyncAttributes&&(i??=[],i.push(e.resource.waitForAsyncAttributes()))}null===i?s():Promise.all(i).then(s,t=>{Ft(t),e(t)})})})}_maybeStartTimer(){if(this._isExporting)return;const t=()=>{this._isExporting=!0,this._flushOneBatch().finally(()=>{this._isExporting=!1,this._finishedSpans.length>0&&(this._clearTimer(),this._maybeStartTimer())}).catch(t=>{this._isExporting=!1,Ft(t)})};if(this._finishedSpans.length>=this._maxExportBatchSize)return t();void 0===this._timer&&(this._timer=setTimeout(()=>t(),this._scheduledDelayMillis),"number"!=typeof this._timer&&this._timer.unref())}_clearTimer(){void 0!==this._timer&&(clearTimeout(this._timer),this._timer=void 0)}}class ur extends cr{_visibilityChangeListener;_pageHideListener;constructor(t,e){super(t,e),this.onInit(e)}onInit(t){!0!==t?.disableAutoFlushOnDocumentHide&&"undefined"!=typeof document&&(this._visibilityChangeListener=()=>{"hidden"===document.visibilityState&&this.forceFlush().catch(t=>{Ft(t)})},this._pageHideListener=()=>{this.forceFlush().catch(t=>{Ft(t)})},document.addEventListener("visibilitychange",this._visibilityChangeListener),document.addEventListener("pagehide",this._pageHideListener))}onShutdown(){"undefined"!=typeof document&&(this._visibilityChangeListener&&document.removeEventListener("visibilitychange",this._visibilityChangeListener),this._pageHideListener&&document.removeEventListener("pagehide",this._pageHideListener))}}const lr=new Uint8Array(16),dr=new Uint8Array(8),pr=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function hr(t){for(let e=0;e<t.length;e++)t[e]=256*Math.random()>>>0;for(let e=0;e<t.length;e++)if(t[e]>0)return;t[t.length-1]=1}function fr(t){let e="";for(let n=0;n<t.length;n++)e+=pr[t[n]];return e}class gr{generateTraceId(){return hr(lr),fr(lr)}generateSpanId(){return hr(dr),fr(dr)}}const mr="otel.span.parent.origin",_r="otel.span.sampling_result";class Sr{startedSpans;liveSpans;constructor(t){this.startedSpans=t.createCounter("otel.sdk.span.started",{unit:"{span}",description:"The number of created spans."}),this.liveSpans=t.createUpDownCounter("otel.sdk.span.live",{unit:"{span}",description:"The number of currently live spans."})}startSpan(t,e){const n=function(t){switch(t){case Zn.RECORD_AND_SAMPLED:return"RECORD_AND_SAMPLE";case Zn.RECORD:return"RECORD_ONLY";case Zn.NOT_RECORD:return"DROP"}}(e);if(this.startedSpans.add(1,{[mr]:br(t),[_r]:n}),e===Zn.NOT_RECORD)return()=>{};const r={[_r]:n};return this.liveSpans.add(1,r),()=>{this.liveSpans.add(-1,r)}}}function br(t){return t?t.isRemote?"remote":"local":"none"}class vr{_sampler;_generalLimits;_spanLimits;_idGenerator;instrumentationScope;_resource;_spanProcessor;_tracerMetrics;constructor(t,e,n,r){const s=function(t){const e={sampler:ir()},n=sr(),r=Object.assign({},n,e,t);return r.generalLimits=Object.assign({},n.generalLimits,t.generalLimits||{}),r.spanLimits=Object.assign({},n.spanLimits,t.spanLimits||{}),r}(e);this._sampler=s.sampler,this._generalLimits=s.generalLimits,this._spanLimits=s.spanLimits,this._idGenerator=e.idGenerator||new gr,this._resource=n,this._spanProcessor=r,this.instrumentationScope=t;const i=s.meterProvider?s.meterProvider.getMeter("@opentelemetry/sdk-trace","2.7.0"):A;this._tracerMetrics=new Sr(i)}startSpan(t,e={},n=ut.active()){e.root&&(n=Ct.deleteSpan(n));const r=Ct.getSpan(n);if(Lt(n)){lt.debug("Instrumentation suppressed, returning Noop Span");return Ct.wrapSpanContext(F)}const s=r?.spanContext(),i=this._idGenerator.generateSpanId();let o,a,c;s&&Ct.isSpanContextValid(s)?(a=s.traceId,c=s.traceState,o=s):a=this._idGenerator.generateTraceId();const u=e.kind??at.INTERNAL,l=(e.links??[]).map(t=>({context:t.context,attributes:It(t.attributes)})),d=It(e.attributes),p=this._sampler.shouldSample(n,a,t,u,d,l),h=this._tracerMetrics.startSpan(s,p.decision);c=p.traceState??c;const f={traceId:a,spanId:i,traceFlags:p.decision===ot.RECORD_AND_SAMPLED?U.SAMPLED:U.NONE,traceState:c};if(p.decision===ot.NOT_RECORD){lt.debug("Recording is off, propagating context in a non-recording span");return Ct.wrapSpanContext(f)}const g=It(Object.assign(d,p.attributes));return new Yn({resource:this._resource,scope:this.instrumentationScope,context:n,spanContext:f,name:t,kind:u,links:l,parentSpanContext:o,attributes:g,startTime:e.startTime,spanProcessor:this._spanProcessor,spanLimits:this._spanLimits,recordEndMetrics:h})}startActiveSpan(t,e,n,r){let s,i,o;if(arguments.length<2)return;2===arguments.length?o=e:3===arguments.length?(s=e,o=n):(s=e,i=n,o=r);const a=i??ut.active(),c=this.startSpan(t,s,a),u=Ct.setSpan(a,c);return ut.with(u,o,void 0,c)}getGeneralLimits(){return this._generalLimits}getSpanLimits(){return this._spanLimits}}class Er{_spanProcessors;constructor(t){this._spanProcessors=t}forceFlush(){const t=[];for(const e of this._spanProcessors)t.push(e.forceFlush());return new Promise(e=>{Promise.all(t).then(()=>{e()}).catch(t=>{Ft(t||new Error("MultiSpanProcessor: forceFlush failed")),e()})})}onStart(t,e){for(const n of this._spanProcessors)n.onStart(t,e)}onEnding(t){for(const e of this._spanProcessors)e.onEnding&&e.onEnding(t)}onEnd(t){for(const e of this._spanProcessors)e.onEnd(t)}shutdown(){const t=[];for(const e of this._spanProcessors)t.push(e.shutdown());return new Promise((e,n)=>{Promise.all(t).then(()=>{e()},n)})}}var Tr,yr;!function(t){t[t.resolved=0]="resolved",t[t.timeout=1]="timeout",t[t.error=2]="error",t[t.unresolved=3]="unresolved"}(Tr||(Tr={}));class Ar{_config;_tracers=new Map;_resource;_activeSpanProcessor;constructor(t={}){const e=je({},sr(),function(t){const e=Object.assign({},t.spanLimits);return e.attributeCountLimit=t.spanLimits?.attributeCountLimit??t.generalLimits?.attributeCountLimit??void 0??void 0??128,e.attributeValueLengthLimit=t.spanLimits?.attributeValueLengthLimit??t.generalLimits?.attributeValueLengthLimit??void 0??void 0??ar,Object.assign({},t,{spanLimits:e})}(t));this._resource=e.resource??Xn(),this._config=Object.assign({},e,{resource:this._resource});const n=[];t.spanProcessors?.length&&n.push(...t.spanProcessors),this._activeSpanProcessor=new Er(n)}getTracer(t,e,n){const r=`${t}@${e||""}:${n?.schemaUrl||""}`;return this._tracers.has(r)||this._tracers.set(r,new vr({name:t,version:e,schemaUrl:n?.schemaUrl},this._config,this._resource,this._activeSpanProcessor)),this._tracers.get(r)}forceFlush(){const t=this._config.forceFlushTimeoutMillis,e=this._activeSpanProcessor._spanProcessors.map(e=>new Promise(n=>{let r;const s=setTimeout(()=>{n(new Error(`Span processor did not completed within timeout period of ${t} ms`)),r=Tr.timeout},t);e.forceFlush().then(()=>{clearTimeout(s),r!==Tr.timeout&&(r=Tr.resolved,n(r))}).catch(t=>{clearTimeout(s),r=Tr.error,n(t)})}));return new Promise((t,n)=>{Promise.all(e).then(e=>{const r=e.filter(t=>t!==Tr.resolved);r.length>0?n(r):t()}).catch(t=>n([t]))})}shutdown(){return this._activeSpanProcessor.shutdown()}}class Or{_enabled=!1;_currentContext=E;_bindFunction(t=E,e){const n=this,r=function(...r){return n.with(t,()=>e.apply(this,r))};return Object.defineProperty(r,"length",{enumerable:!1,configurable:!0,writable:!1,value:e.length}),r}active(){return this._currentContext}bind(t,e){return void 0===t&&(t=this.active()),"function"==typeof e?this._bindFunction(t,e):e}disable(){return this._currentContext=E,this._enabled=!1,this}enable(){return this._enabled||(this._enabled=!0,this._currentContext=E),this}with(t,e,n,...r){const s=this._currentContext;this._currentContext=t||E;try{return e.call(n,...r)}finally{this._currentContext=s}}}class Cr extends Ar{constructor(t={}){super(t)}register(t={}){var e;Ct.setGlobalTracerProvider(this),null!==(e=t.propagator)&&(void 0!==e?yt.setGlobalPropagator(e):yt.setGlobalPropagator(new me({propagators:[new Ce,new Dt]}))),function(t){if(null!==t){if(void 0===t){const t=new Or;return t.enable(),void ut.setGlobalContextManager(t)}t.enable(),ut.setGlobalContextManager(t)}}(t.contextManager)}}!function(t){t.CONNECT_END="connectEnd",t.CONNECT_START="connectStart",t.DECODED_BODY_SIZE="decodedBodySize",t.DOM_COMPLETE="domComplete",t.DOM_CONTENT_LOADED_EVENT_END="domContentLoadedEventEnd",t.DOM_CONTENT_LOADED_EVENT_START="domContentLoadedEventStart",t.DOM_INTERACTIVE="domInteractive",t.DOMAIN_LOOKUP_END="domainLookupEnd",t.DOMAIN_LOOKUP_START="domainLookupStart",t.ENCODED_BODY_SIZE="encodedBodySize",t.FETCH_START="fetchStart",t.LOAD_EVENT_END="loadEventEnd",t.LOAD_EVENT_START="loadEventStart",t.NAVIGATION_START="navigationStart",t.REDIRECT_END="redirectEnd",t.REDIRECT_START="redirectStart",t.REQUEST_START="requestStart",t.RESPONSE_END="responseEnd",t.RESPONSE_START="responseStart",t.SECURE_CONNECTION_START="secureConnectionStart",t.START_TIME="startTime",t.UNLOAD_EVENT_END="unloadEventEnd",t.UNLOAD_EVENT_START="unloadEventStart"}(yr||(yr={}));let wr;function Rr(t,e,n,r=!0){if(!(s=n,i=e,!(i in s)||"number"!=typeof n[e]||r&&0===n[e]))return t.addEvent(e,n[e]);var s,i}function Lr(t,e,n=!1,r,s){if(void 0===r&&(r=0!==e[yr.START_TIME]),n||(Rr(t,yr.FETCH_START,e,r),Rr(t,yr.DOMAIN_LOOKUP_START,e,r),Rr(t,yr.DOMAIN_LOOKUP_END,e,r),Rr(t,yr.CONNECT_START,e,r),Rr(t,yr.SECURE_CONNECTION_START,e,r),Rr(t,yr.CONNECT_END,e,r),Rr(t,yr.REQUEST_START,e,r),Rr(t,yr.RESPONSE_START,e,r),Rr(t,yr.RESPONSE_END,e,r)),!s){const n=e[yr.ENCODED_BODY_SIZE];void 0!==n&&t.setAttribute("http.response_content_length",n);const r=e[yr.DECODED_BODY_SIZE];void 0!==r&&n!==r&&t.setAttribute("http.response_content_length_uncompressed",r)}}function Nr(){return"undefined"!=typeof location?location.origin:void 0}function Pr(t,e,n,r,s=new WeakSet,i){const o=xr(t),a=function(t,e,n,r,s,i){const o=de(e),a=de(n);let c=r.filter(e=>{const n=de(ue(e[yr.FETCH_START])),r=de(ue(e[yr.RESPONSE_END]));return e.initiatorType.toLowerCase()===(i||"xmlhttprequest")&&e.name===t&&n>=o&&r<=a});c.length>0&&(c=c.filter(t=>!s.has(t)));return c}(t=o.toString(),e,n,r,s,i);if(0===a.length)return{mainRequest:void 0};if(1===a.length)return{mainRequest:a[0]};const c=function(t){return t.slice().sort((t,e)=>{const n=t[yr.FETCH_START],r=e[yr.FETCH_START];return n>r?1:n<r?-1:0})}(a);if(o.origin!==Nr()&&c.length>1){let t=c[0],e=function(t,e,n){const r=de(n),s=de(ue(e));let i,o=t[1];const a=t.length;for(let e=1;e<a;e++){const n=t[e],a=de(ue(n[yr.FETCH_START])),c=r-de(ue(n[yr.RESPONSE_END]));a>=s&&(!i||c<i)&&(i=c,o=n)}return o}(c,t[yr.RESPONSE_END],n);const r=t[yr.RESPONSE_END];return e[yr.FETCH_START]<r&&(e=t,t=void 0),{corsPreFlightRequest:t,mainRequest:e}}return{mainRequest:a[0]}}function xr(t){if("function"==typeof URL)return new URL(t,"undefined"!=typeof document?document.baseURI:"undefined"!=typeof location?location.href:void 0);const e=(wr||(wr=document.createElement("a")),wr);return e.href=t,e}function Dr(t,e){let n=e||[];("string"==typeof n||n instanceof RegExp)&&(n=[n]);return xr(t).origin===Nr()||n.some(e=>We(t,e))}var Ir;!function(t){t.COMPONENT="component",t.HTTP_STATUS_TEXT="http.status_text"}(Ir||(Ir={}));const kr=lt.createComponentLogger({namespace:"@opentelemetry/opentelemetry-instrumentation-fetch/utils"});function Mr(...t){if(t[0]instanceof URL||"string"==typeof t[0]){const e=t[1];if(!e?.body)return Promise.resolve();if(e.body instanceof ReadableStream){const{body:t,length:n}=function(t){if(!t.pipeThrough)return kr.warn("Platform has ReadableStream but not pipeThrough!"),{body:t,length:Promise.resolve(void 0)};let e,n=0;const r=new Promise(t=>{e=t}),s=new TransformStream({start(){},async transform(t,e){const r=await t;n+=r.byteLength,e.enqueue(t)},flush(){e(n)}});return{body:t.pipeThrough(s),length:r}}(e.body);return e.body=t,n}return Promise.resolve(function(t){if(e=t,"undefined"!=typeof Document&&e instanceof Document)return(new XMLSerializer).serializeToString(document).length;var e;if("string"==typeof t)return Br(t);if(t instanceof Blob)return t.size;if(t instanceof FormData)return function(t){let e=0;for(const[n,r]of t.entries())e+=n.length,r instanceof Blob?e+=r.size:e+=r.length;return e}(t);if(t instanceof URLSearchParams)return Br(t.toString());if(void 0!==t.byteLength)return t.byteLength;return void kr.warn("unknown body type")}(e.body))}{const e=t[0];return e?.body?e.clone().text().then(t=>Br(t)):Promise.resolve()}}const Ur=new TextEncoder;function Br(t){return Ur.encode(t).byteLength}function jr(t){const e=function(){void 0===Hr&&(Hr=Fr);return Hr}(),n=t.toUpperCase();return n in e?n:"_OTHER"}const Fr={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0};let Hr;const $r={"https:":"443","http:":"80"};const Vr="0.215.0",zr="undefined"!=typeof PerformanceObserver;class qr extends jn{component="fetch";version=Vr;moduleName=this.component;_usedResources=new WeakSet;_tasksCount=0;_semconvStability;constructor(t={}){super("@opentelemetry/instrumentation-fetch",Vr,t),this._semconvStability=Vn("http",t?.semconvStabilityOptIn)}init(){}_addChildSpan(t,e){const n=this.tracer.startSpan("CORS Preflight",{startTime:e[yr.FETCH_START]},Ct.setSpan(ut.active(),t)),r=!(this._semconvStability&$n.OLD);Lr(n,e,this.getConfig().ignoreNetworkEvents,void 0,r),n.end(e[yr.RESPONSE_END])}_addFinalSpanAttributes(t,e){const n=xr(e.url);if(this._semconvStability&$n.OLD&&(t.setAttribute("http.status_code",e.status),null!=e.statusText&&t.setAttribute(Ir.HTTP_STATUS_TEXT,e.statusText),t.setAttribute("http.host",n.host),t.setAttribute("http.scheme",n.protocol.replace(":","")),"undefined"!=typeof navigator&&t.setAttribute("http.user_agent",navigator.userAgent)),this._semconvStability&$n.STABLE){t.setAttribute(Wt,e.status),t.setAttribute(Xt,n.hostname);const r=function(t){const e=Number(t.port||$r[t.protocol]);return e&&!isNaN(e)?e:void 0}(n);r&&t.setAttribute(Qt,r)}}_addHeaders(t,e){if(!Dr(e,this.getConfig().propagateTraceHeaderCorsUrls)){const t={};return yt.inject(ut.active(),t),void(Object.keys(t).length>0&&this._diag.debug("headers inject skipped due to CORS policy"))}if(t instanceof Request)yt.inject(ut.active(),t.headers,{set:(t,e,n)=>t.set(e,"string"==typeof n?n:String(n))});else{const e=new Headers(t.headers);yt.inject(ut.active(),e,{set:(t,e,n)=>t.set(e,"string"==typeof n?n:String(n))}),t.headers=e}}_clearResources(){0===this._tasksCount&&this.getConfig().clearTimingResources&&(performance.clearResourceTimings(),this._usedResources=new WeakSet)}_createSpan(t,e={}){if(Xe(t,this.getConfig().ignoreUrls))return void this._diag.debug("ignoring span as url matches ignored url");let n="";const r={};if(this._semconvStability&$n.OLD){const s=(e.method||"GET").toUpperCase();n=`HTTP ${s}`,r[Ir.COMPONENT]=this.moduleName,r["http.method"]=s,r["http.url"]=t}if(this._semconvStability&$n.STABLE){const s=e.method,i=jr(e.method||"GET");n||(n=i),r[Gt]=i,i!==s&&(r[Kt]=s),r[ee]=t}return this.tracer.startSpan(n,{kind:at.CLIENT,attributes:r})}_findResourceAndAddNetworkEvents(t,e,n){let r=e.entries;if(!r.length){if(!performance.getEntriesByType)return;r=performance.getEntriesByType("resource")}const s=Pr(e.spanUrl,e.startTime,n,r,this._usedResources,"fetch");if(s.mainRequest){const e=s.mainRequest;this._markResourceAsUsed(e);const n=s.corsPreFlightRequest;n&&(this._addChildSpan(t,n),this._markResourceAsUsed(n));const r=!(this._semconvStability&$n.OLD);Lr(t,e,this.getConfig().ignoreNetworkEvents,void 0,r)}}_markResourceAsUsed(t){this._usedResources.add(t)}_endSpan(t,e,n){const r=ae(Date.now()),s=ce();this._addFinalSpanAttributes(t,n),this._semconvStability&$n.STABLE&&n.status>=400&&(t.setStatus({code:ct.ERROR}),t.setAttribute(Vt,String(n.status))),setTimeout(()=>{e.observer?.disconnect(),this._findResourceAndAddNetworkEvents(t,e,s),this._tasksCount--,this._clearResources(),t.end(r)},300)}_patchConstructor(){return t=>{const e=this;return function(...n){if(!e._isEnabled)return t.apply(this,n);const r=this,s=xr(n[0]instanceof Request?n[0].url:String(n[0])).href;let i;i=n[0]instanceof Request?null!=n[1]?new Request(n[0],n[1]):n[0]:n[1]||{};const o=e._createSpan(s,i);if(!o)return t.apply(this,n);const a=e._prepareSpanData(s);function c(t,n){e._applyAttributesAfterFetch(t,i,n),e._endSpan(t,a,{status:n.status||0,statusText:n.message,url:s})}function u(t,n){e._applyAttributesAfterFetch(t,i,n),n.status>=200&&n.status<400?e._endSpan(t,a,n):e._endSpan(t,a,{status:n.status,statusText:n.statusText,url:s})}function l(t,n){try{const e=n.clone().body;if(e){const r=e.getReader(),s=()=>{r.read().then(({done:e})=>{e?u(t,n):s()},e=>{c(t,e)})};s()}else u(t,n)}catch(n){e._diag.error("Failed to read fetch response body",n),e._endSpan(t,a,{status:0,url:s})}return n}function d(t,n){try{c(t,n)}catch(r){e._diag.error("Failed to end span on fetch error",r),e._endSpan(t,a,{status:n.status||0,url:s})}throw n}return e.getConfig().measureRequestSize&&Mr(...n).then(t=>{t&&(e._semconvStability&$n.OLD&&o.setAttribute("http.request_content_length_uncompressed",t),e._semconvStability&$n.STABLE&&o.setAttribute("http.request.body.size",t))}).catch(t=>{e._diag.warn("getFetchBodyLength",t)}),ut.with(Ct.setSpan(ut.active(),o),()=>(e._callRequestHook(o,i),e._addHeaders(i,s),e._tasksCount++,t.apply(r,i instanceof Request?[i]:[s,i]).then(l.bind(r,o),d.bind(r,o))))}}}_applyAttributesAfterFetch(t,e,n){const r=this.getConfig().applyCustomAttributesOnSpan;r&&Fn(()=>r(t,e,n),t=>{t&&this._diag.error("applyCustomAttributesOnSpan",t)})}_callRequestHook(t,e){const n=this.getConfig().requestHook;n&&Fn(()=>n(t,e),t=>{t&&this._diag.error("requestHook",t)})}_prepareSpanData(t){const e=ce(),n=[];if("function"!=typeof PerformanceObserver)return{entries:n,startTime:e,spanUrl:t};const r=new PerformanceObserver(e=>{e.getEntries().forEach(e=>{"fetch"===e.initiatorType&&e.name===t&&n.push(e)})});return r.observe({entryTypes:["resource"]}),{entries:n,observer:r,startTime:e,spanUrl:t}}enable(){zr?this._isEnabled||(this._isEnabled=!0,this._isFetchPatched?this._diag.debug("fetch constructor already patched"):(this._isFetchPatched=!0,this._wrap(globalThis,"fetch",this._patchConstructor()))):this._diag.warn("this instrumentation is intended for web usage only, it does not instrument server-side fetch()")}disable(){zr&&this._isEnabled&&(this._isEnabled=!1,this._usedResources=new WeakSet)}}var Gr;!function(t){t.METHOD_OPEN="open",t.METHOD_SEND="send",t.EVENT_ABORT="abort",t.EVENT_ERROR="error",t.EVENT_LOAD="loaded",t.EVENT_TIMEOUT="timeout"}(Gr||(Gr={}));const Kr=lt.createComponentLogger({namespace:"@opentelemetry/opentelemetry-instrumentation-xml-http-request/utils"});function Wr(t){return e=t,"undefined"!=typeof Document&&e instanceof Document?(new XMLSerializer).serializeToString(document).length:"string"==typeof t?Qr(t):t instanceof Blob?t.size:t instanceof FormData?function(t){let e=0;for(const[n,r]of t.entries())e+=n.length,r instanceof Blob?e+=r.size:e+=r.length;return e}(t):t instanceof URLSearchParams?Qr(t.toString()):void 0!==t.byteLength?t.byteLength:void Kr.warn("unknown body type");var e}const Xr=new TextEncoder;function Qr(t){return Xr.encode(t).byteLength}const Yr={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0};let Zr;function Jr(){return void 0===Zr&&(Zr=Yr),Zr}const ts={"https:":"443","http:":"80"};const es="0.215.0";var ns;!function(t){t.HTTP_STATUS_TEXT="http.status_text"}(ns||(ns={}));class rs extends jn{component="xml-http-request";version=es;moduleName=this.component;_tasksCount=0;_xhrMem=new WeakMap;_usedResources=new WeakSet;_semconvStability;constructor(t={}){super("@opentelemetry/instrumentation-xml-http-request",es,t),this._semconvStability=Vn("http",t?.semconvStabilityOptIn)}init(){}_addHeaders(t,e){if(!Dr(xr(e).href,this.getConfig().propagateTraceHeaderCorsUrls)){const t={};return yt.inject(ut.active(),t),void(Object.keys(t).length>0&&this._diag.debug("headers inject skipped due to CORS policy"))}const n={};yt.inject(ut.active(),n),Object.keys(n).forEach(e=>{t.setRequestHeader(e,String(n[e]))})}_addChildSpan(t,e){ut.with(Ct.setSpan(ut.active(),t),()=>{const t=this.tracer.startSpan("CORS Preflight",{startTime:e[yr.FETCH_START]}),n=!(this._semconvStability&$n.OLD);Lr(t,e,this.getConfig().ignoreNetworkEvents,void 0,n),t.end(e[yr.RESPONSE_END])})}_addFinalSpanAttributes(t,e,n){if(this._semconvStability&$n.OLD){if(void 0!==e.status&&t.setAttribute("http.status_code",e.status),void 0!==e.statusText&&t.setAttribute(ns.HTTP_STATUS_TEXT,e.statusText),"string"==typeof n){const e=xr(n);t.setAttribute("http.host",e.host),t.setAttribute("http.scheme",e.protocol.replace(":",""))}t.setAttribute("http.user_agent",navigator.userAgent)}this._semconvStability&$n.STABLE&&e.status&&t.setAttribute(Wt,e.status)}_applyAttributesAfterXHR(t,e){const n=this.getConfig().applyCustomAttributesOnSpan;"function"==typeof n&&Fn(()=>n(t,e),t=>{t&&this._diag.error("applyCustomAttributesOnSpan",t)})}_addResourceObserver(t,e){const n=this._xhrMem.get(t);n&&"function"==typeof PerformanceObserver&&"function"==typeof PerformanceResourceTiming&&(n.createdResources={observer:new PerformanceObserver(t=>{const r=t.getEntries(),s=xr(e);r.forEach(t=>{"xmlhttprequest"===t.initiatorType&&t.name===s.href&&n.createdResources&&n.createdResources.entries.push(t)})}),entries:[]},n.createdResources.observer.observe({entryTypes:["resource"]}))}_clearResources(){0===this._tasksCount&&this.getConfig().clearTimingResources&&(se.clearResourceTimings(),this._xhrMem=new WeakMap,this._usedResources=new WeakSet)}_findResourceAndAddNetworkEvents(t,e,n,r,s){if(!(n&&r&&s&&t.createdResources))return;let i=t.createdResources.entries;i&&i.length||(i=se.getEntriesByType("resource"));const o=Pr(xr(n).href,r,s,i,this._usedResources);if(o.mainRequest){const t=o.mainRequest;this._markResourceAsUsed(t);const n=o.corsPreFlightRequest;n&&(this._addChildSpan(e,n),this._markResourceAsUsed(n));const r=!(this._semconvStability&$n.OLD);Lr(e,t,this.getConfig().ignoreNetworkEvents,void 0,r)}}_cleanPreviousSpanInformation(t){const e=this._xhrMem.get(t);if(e){const n=e.callbackToRemoveEvents;n&&n(),this._xhrMem.delete(t)}}_createSpan(t,e,n){if(Xe(e,this.getConfig().ignoreUrls))return void this._diag.debug("ignoring span as url matches ignored url");let r="";const s=xr(e),i={};if(this._semconvStability&$n.OLD&&(r=n.toUpperCase(),i["http.method"]=n,i["http.url"]=s.toString()),this._semconvStability&$n.STABLE){const t=n,e=function(t){const e=Jr(),n=t.toUpperCase();return n in e?n:"_OTHER"}(n);r||(r=e),i[Gt]=e,e!==t&&(i[Kt]=t),i[ee]=s.toString(),i[Xt]=s.hostname;const o=function(t){const e=Number(t.port||ts[t.protocol]);return e&&!isNaN(e)?e:void 0}(s);o&&(i[Qt]=o)}const o=this.tracer.startSpan(r,{kind:at.CLIENT,attributes:i});return o.addEvent(Gr.METHOD_OPEN),this._cleanPreviousSpanInformation(t),this._xhrMem.set(t,{span:o,spanUrl:e}),o}_markResourceAsUsed(t){this._usedResources.add(t)}_patchOpen(){return t=>{const e=this;return function(...n){const r=n[0],s=n[1];return e._createSpan(this,s,r),t.apply(this,n)}}}_patchSend(){const t=this;function e(e,n,r,s){const i=t._xhrMem.get(n);if(!i)return;if(i.status=n.status,i.statusText=n.statusText,t._xhrMem.delete(n),i.span){const e=i.span;t._applyAttributesAfterXHR(e,n),t._semconvStability&$n.STABLE&&(r?s&&(e.setStatus({code:ct.ERROR,message:s}),e.setAttribute(Vt,s)):i.status&&i.status>=400&&(e.setStatus({code:ct.ERROR}),e.setAttribute(Vt,String(i.status))))}const o=ce(),a=Date.now();setTimeout(()=>{!function(e,n,r,s){const i=n.callbackToRemoveEvents;"function"==typeof i&&i();const{span:o,spanUrl:a,sendStartTime:c}=n;o&&(t._findResourceAndAddNetworkEvents(n,o,a,c,r),o.addEvent(e,s),t._addFinalSpanAttributes(o,n,a),o.end(s),t._tasksCount--),t._clearResources()}(e,i,o,a)},300)}function n(){e(Gr.EVENT_ERROR,this,!0,"error")}function r(){e(Gr.EVENT_ABORT,this,!1)}function s(){e(Gr.EVENT_TIMEOUT,this,!0,"timeout")}function i(){this.status<299?e(Gr.EVENT_LOAD,this,!1):e(Gr.EVENT_ERROR,this,!1)}return e=>function(...o){const a=t._xhrMem.get(this);if(!a)return e.apply(this,o);const c=a.span,u=a.spanUrl;if(c&&u){if(t.getConfig().measureRequestSize&&o?.[0]){const e=Wr(o[0]);void 0!==e&&(t._semconvStability&$n.OLD&&c.setAttribute("http.request_content_length_uncompressed",e),t._semconvStability&$n.STABLE&&c.setAttribute("http.request.body.size",e))}ut.with(Ct.setSpan(ut.active(),c),()=>{t._tasksCount++,a.sendStartTime=ce(),c.addEvent(Gr.METHOD_SEND),this.addEventListener("abort",r),this.addEventListener("error",n),this.addEventListener("load",i),this.addEventListener("timeout",s),a.callbackToRemoveEvents=()=>{!function(e){e.removeEventListener("abort",r),e.removeEventListener("error",n),e.removeEventListener("load",i),e.removeEventListener("timeout",s);const o=t._xhrMem.get(e);o&&(o.callbackToRemoveEvents=void 0)}(this),a.createdResources&&a.createdResources.observer.disconnect()},t._addHeaders(this,u),t._addResourceObserver(this,u)})}return e.apply(this,o)}}enable(){this._diag.debug("applying patch to",this.moduleName,this.version),Hn(XMLHttpRequest.prototype.open)&&(this._unwrap(XMLHttpRequest.prototype,"open"),this._diag.debug("removing previous patch from method open")),Hn(XMLHttpRequest.prototype.send)&&(this._unwrap(XMLHttpRequest.prototype,"send"),this._diag.debug("removing previous patch from method send")),this._wrap(XMLHttpRequest.prototype,"open",this._patchOpen()),this._wrap(XMLHttpRequest.prototype,"send",this._patchSend())}disable(){this._diag.debug("removing patch from",this.moduleName,this.version),this._unwrap(XMLHttpRequest.prototype,"open"),this._unwrap(XMLHttpRequest.prototype,"send"),this._tasksCount=0,this._xhrMem=new WeakMap,this._usedResources=new WeakSet}}class ss extends rs{constructor(t={}){super(t);this.parentCreateSpan=this._createSpan.bind(this)}_patchOpen(){return t=>{const n=this;return function(...r){let s;try{const t=r[0];let i=e.getUrlFromResource(r[1]);s=n.parentCreateSpan(this,i,t)}catch(t){e.faro.internalLogger.error(t)}const i=e.faro.api.getActiveUserAction();return s&&i&&(null==i?void 0:i.getState())===e.UserActionState.Started&&(s.setAttribute("faro.action.user.name",i.name),s.setAttribute("faro.action.user.parentId",i.parentId)),t.apply(this,r)}}}}function is(t,e,n){os(t,n instanceof Error?0:n.status)}function os(t,e){if(null==e)return;(0===e||e>=400&&e<600)&&t.setStatus({code:ct.ERROR})}function as(t){return(e,n,r)=>{is(e,0,r),null==t||t(e,n,r)}}function cs(t){return(e,n)=>{!function(t,e){os(t,e.status)}(e,n),null==t||t(e,n)}}function us(t={}){const{fetchInstrumentationOptions:n,xhrInstrumentationOptions:r}=t,s=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]])}return n}(t,["fetchInstrumentationOptions","xhrInstrumentationOptions"]),i=function(t,n){return Object.assign(Object.assign(Object.assign(Object.assign({},n),{ignoreNetworkEvents:!0}),t),{applyCustomAttributesOnSpan:as(null==t?void 0:t.applyCustomAttributesOnSpan),requestHook:(t,n)=>{const r=e.faro.api.getActiveUserAction();r&&(null==r?void 0:r.getState())===e.UserActionState.Started&&(t.setAttribute("faro.action.user.name",r.name),t.setAttribute("faro.action.user.parentId",r.parentId))}})}(n,s),o=function(t,e){return Object.assign(Object.assign(Object.assign(Object.assign({},e),{ignoreNetworkEvents:!0}),t),{applyCustomAttributesOnSpan:cs(null==t?void 0:t.applyCustomAttributesOnSpan)})}(r,s);return[new qr(i),new ss(o)]}class ls{constructor(t,e){this.processor=t,this.metas=e}forceFlush(){return this.processor.forceFlush()}onStart(t,e){var n;const r=this.metas.value.session;(null==r?void 0:r.id)&&(t.attributes["session.id"]=r.id);const s=null!==(n=this.metas.value.user)&&void 0!==n?n:{};s.email&&(t.attributes["user.email"]=s.email),s.id&&(t.attributes["user.id"]=s.id),s.username&&(t.attributes["user.name"]=s.username),s.fullName&&(t.attributes["user.full_name"]=s.fullName),s.roles&&(t.attributes["user.roles"]=s.roles.split(",").map(t=>t.trim())),s.hash&&(t.attributes["user.hash"]=s.hash),this.processor.onStart(t,e)}onEnd(t){this.processor.onEnd(t)}shutdown(){return this.processor.shutdown()}}function ds(t={}){var e;return"true"===(null===(e=t.attributes)||void 0===e?void 0:e.isSampled)?Zn.RECORD_AND_SAMPLED:Zn.NOT_RECORD}class ps extends e.BaseInstrumentation{constructor(t={}){super(),this.options=t,this.name="@grafana/faro-web-tracing",this.version=e.VERSION}initialize(){var t,n,r,s,i;const o=this.options,a={};this.config.app.name&&(a[Yt]=this.config.app.name),this.config.app.namespace&&(a["service.namespace"]=this.config.app.namespace),this.config.app.version&&(a["service.version"]=this.config.app.version),this.config.app.environment&&(a["deployment.environment.name"]=this.config.app.environment,a["deployment.environment"]=this.config.app.environment);const c=this.metas.value.browser;e.isArray(null==c?void 0:c.brands)&&(a["browser.brands"]=c.brands.map(t=>t.brand)),(null==c?void 0:c.language)&&(a["browser.language"]=c.language),"boolean"==typeof(null==c?void 0:c.mobile)&&(a["browser.mobile"]=Boolean(c.mobile)),(null==c?void 0:c.os)&&(a["browser.platform"]=c.os),(null==c?void 0:c.userAgent)&&(a["user_agent.original"]=c.userAgent),a["process.runtime.name"]="browser",a["process.runtime.version"]=null===(t=this.metas.value.browser)||void 0===t?void 0:t.userAgent,a["telemetry.distro.name"]="faro-web-sdk",a["telemetry.distro.version"]=e.VERSION,Object.assign(a,o.resourceAttributes);const u=Xn().merge(Wn(a));new Cr({resource:u,sampler:{shouldSample:()=>({decision:ds(this.api.getSession())})},spanProcessors:[null!==(n=o.spanProcessor)&&void 0!==n?n:new ls(new ur(new Tn({api:this.api}),{scheduledDelayMillis:ps.SCHEDULED_BATCH_DELAY_MS,maxExportBatchSize:30}),this.metas)]}).register({propagator:null!==(r=o.propagator)&&void 0!==r?r:new Ce,contextManager:o.contextManager});const{propagateTraceHeaderCorsUrls:l,fetchInstrumentationOptions:d,xhrInstrumentationOptions:p}=null!==(s=this.options.instrumentationOptions)&&void 0!==s?s:{};!function(t){const e=t.tracerProvider||Ct.getTracerProvider(),n=t.meterProvider||ft.getMeterProvider(),r=t.loggerProvider||Pn.getLoggerProvider(),s=t.instrumentations?.flat()??[];(function(t,e,n,r){for(let s=0,i=t.length;s<i;s++){const i=t[s];e&&i.setTracerProvider(e),n&&i.setMeterProvider(n),r&&i.setLoggerProvider&&i.setLoggerProvider(r),i.getConfig().enabled||i.enable()}})(s,e,n,r)}({instrumentations:null!==(i=o.instrumentations)&&void 0!==i?i:us({ignoreUrls:this.getIgnoreUrls(),propagateTraceHeaderCorsUrls:l,fetchInstrumentationOptions:d,xhrInstrumentationOptions:p})}),this.api.initOTEL(Ct,ut)}getIgnoreUrls(){return this.transports.transports.flatMap(t=>t.getIgnoreUrls())}}ps.SCHEDULED_BATCH_DELAY_MS=1e3;return t.FaroMetaAttributesSpanProcessor=ls,t.FaroTraceExporter=Tn,t.FaroUserActionSpanProcessor=class{constructor(t){this.processor=t}forceFlush(){return this.processor.forceFlush()}onStart(t,n){const r=e.faro.api.getActiveUserAction();r&&(null==r?void 0:r.getState())===e.UserActionState.Started&&t.kind===at.CLIENT&&(t.attributes["faro.action.user.name"]||(t.attributes["faro.action.user.name"]=null==r?void 0:r.name),t.attributes["faro.action.user.parentId"]||(t.attributes["faro.action.user.parentId"]=null==r?void 0:r.parentId)),this.processor.onStart(t,n)}onEnd(t){this.processor.onEnd(t)}shutdown(){return this.processor.shutdown()}},t.TracingInstrumentation=ps,t.fetchCustomAttributeFunctionWithDefaults=as,t.getDefaultOTELInstrumentations=us,t.getSamplingDecision=ds,t.setSpanStatusOnFetchError=is,t}({},GrafanaFaroWebSdk);
1
+ var GrafanaFaroWebTracing=function(t,e){"use strict";const n="1.9.1",r=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;const s=function(t){const e=new Set([t]),n=new Set,s=t.match(r);if(!s)return()=>!1;const i=+s[1],o=+s[2],a=+s[3];if(null!=s[4])return function(e){return e===t};function c(t){return n.add(t),!1}function u(t){return e.add(t),!0}return function(t){if(e.has(t))return!0;if(n.has(t))return!1;const s=t.match(r);if(!s)return c(t);const l=+s[1],d=+s[2],h=+s[3];return null!=s[4]||i!==l?c(t):0===i?o===d&&a<=h?u(t):c(t):o<=d?u(t):c(t)}}(n),i=n.split(".")[0],o=Symbol.for(`opentelemetry.js.api.${i}`),a="object"==typeof globalThis?globalThis:"object"==typeof self?self:"object"==typeof window?window:"object"==typeof global?global:{};function c(t,e,r,s=!1){var i;const c=a[o]=null!==(i=a[o])&&void 0!==i?i:{version:n};if(!s&&c[t]){const e=new Error(`@opentelemetry/api: Attempted duplicate registration of API: ${t}`);return r.error(e.stack||e.message),!1}if(c.version!==n){const e=new Error(`@opentelemetry/api: Registration of version v${c.version} for ${t} does not match previously registered API v${n}`);return r.error(e.stack||e.message),!1}return c[t]=e,r.debug(`@opentelemetry/api: Registered a global for ${t} v${n}.`),!0}function u(t){var e,n;const r=null===(e=a[o])||void 0===e?void 0:e.version;if(r&&s(r))return null===(n=a[o])||void 0===n?void 0:n[t]}function l(t,e){e.debug(`@opentelemetry/api: Unregistering a global for ${t} v${n}.`);const r=a[o];r&&delete r[t]}class d{constructor(t){this._namespace=t.namespace||"DiagComponentLogger"}debug(...t){return h("debug",this._namespace,t)}error(...t){return h("error",this._namespace,t)}info(...t){return h("info",this._namespace,t)}warn(...t){return h("warn",this._namespace,t)}verbose(...t){return h("verbose",this._namespace,t)}}function h(t,e,n){const r=u("diag");if(r)return r[t](e,...n)}var p;!function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"}(p||(p={}));class f{static instance(){return this._instance||(this._instance=new f),this._instance}constructor(){function t(t){return function(...e){const n=u("diag");if(n)return n[t](...e)}}const e=this;e.setLogger=(t,n={logLevel:p.INFO})=>{var r,s,i;if(t===e){const t=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return e.error(null!==(r=t.stack)&&void 0!==r?r:t.message),!1}"number"==typeof n&&(n={logLevel:n});const o=u("diag"),a=function(t,e){function n(n,r){const s=e[n];return"function"==typeof s&&t>=r?s.bind(e):function(){}}return t<p.NONE?t=p.NONE:t>p.ALL&&(t=p.ALL),e=e||{},{error:n("error",p.ERROR),warn:n("warn",p.WARN),info:n("info",p.INFO),debug:n("debug",p.DEBUG),verbose:n("verbose",p.VERBOSE)}}(null!==(s=n.logLevel)&&void 0!==s?s:p.INFO,t);if(o&&!n.suppressOverrideMessage){const t=null!==(i=(new Error).stack)&&void 0!==i?i:"<failed to generate stacktrace>";o.warn(`Current logger will be overwritten from ${t}`),a.warn(`Current logger will overwrite one already registered from ${t}`)}return c("diag",a,e,!0)},e.disable=()=>{l("diag",e)},e.createComponentLogger=t=>new d(t),e.verbose=t("verbose"),e.debug=t("debug"),e.info=t("info"),e.warn=t("warn"),e.error=t("error")}}class g{constructor(t){this._entries=t?new Map(t):new Map}getEntry(t){const e=this._entries.get(t);if(e)return Object.assign({},e)}getAllEntries(){return Array.from(this._entries.entries())}setEntry(t,e){const n=new g(this._entries);return n._entries.set(t,e),n}removeEntry(t){const e=new g(this._entries);return e._entries.delete(t),e}removeEntries(...t){const e=new g(this._entries);for(const n of t)e._entries.delete(n);return e}clear(){return new g}}const m=Symbol("BaggageEntryMetadata"),_=f.instance();function S(t={}){return new g(new Map(Object.entries(t)))}function b(t){return Symbol.for(t)}class v{constructor(t){const e=this;e._currentContext=t?new Map(t):new Map,e.getValue=t=>e._currentContext.get(t),e.setValue=(t,n)=>{const r=new v(e._currentContext);return r._currentContext.set(t,n),r},e.deleteValue=t=>{const n=new v(e._currentContext);return n._currentContext.delete(t),n}}}const E=new v;class T{}class y{addCallback(t){}removeCallback(t){}}const O=new class{constructor(){}createGauge(t,e){return C}createHistogram(t,e){return w}createCounter(t,e){return A}createUpDownCounter(t,e){return R}createObservableGauge(t,e){return L}createObservableCounter(t,e){return P}createObservableUpDownCounter(t,e){return N}addBatchObservableCallback(t,e){}removeBatchObservableCallback(t){}},A=new class extends T{add(t,e){}},C=new class extends T{record(t,e){}},w=new class extends T{record(t,e){}},R=new class extends T{add(t,e){}},P=new class extends y{},L=new class extends y{},N=new class extends y{};const x={get(t,e){if(null!=t)return t[e]},keys:t=>null==t?[]:Object.keys(t)},D={set(t,e,n){null!=t&&(t[e]=n)}};const I="context",k=new class{active(){return E}with(t,e,n,...r){return e.call(n,...r)}bind(t,e){return e}enable(){return this}disable(){return this}};class M{constructor(){}static getInstance(){return this._instance||(this._instance=new M),this._instance}setGlobalContextManager(t){return c(I,t,f.instance())}active(){return this._getContextManager().active()}with(t,e,n,...r){return this._getContextManager().with(t,e,n,...r)}bind(t,e){return this._getContextManager().bind(t,e)}_getContextManager(){return u(I)||k}disable(){this._getContextManager().disable(),l(I,f.instance())}}var U;!function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"}(U||(U={}));const j="0000000000000000",B="00000000000000000000000000000000",F={traceId:B,spanId:j,traceFlags:U.NONE};class H{constructor(t=F){this._spanContext=t}spanContext(){return this._spanContext}setAttribute(t,e){return this}setAttributes(t){return this}addEvent(t,e){return this}addLink(t){return this}addLinks(t){return this}setStatus(t){return this}updateName(t){return this}end(t){}isRecording(){return!1}recordException(t,e){}}const $=b("OpenTelemetry Context Key SPAN");function V(t){return t.getValue($)||void 0}function z(){return V(M.getInstance().active())}function q(t,e){return t.setValue($,e)}function G(t){return t.deleteValue($)}function K(t,e){return q(t,new H(e))}function W(t){var e;return null===(e=V(t))||void 0===e?void 0:e.spanContext()}const X=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1]);function Q(t,e){if("string"!=typeof t||t.length!==e)return!1;let n=0;for(let e=0;e<t.length;e+=4)n+=(0|X[t.charCodeAt(e)])+(0|X[t.charCodeAt(e+1)])+(0|X[t.charCodeAt(e+2)])+(0|X[t.charCodeAt(e+3)]);return n===e}function Y(t){return Q(t,32)&&t!==B}function Z(t){return Y(t.traceId)&&(Q(e=t.spanId,16)&&e!==j);var e}function J(t){return new H(t)}const tt=M.getInstance();class et{startSpan(t,e,n=tt.active()){if(Boolean(null==e?void 0:e.root))return new H;const r=n&&W(n);return null!==(s=r)&&"object"==typeof s&&"spanId"in s&&"string"==typeof s.spanId&&"traceId"in s&&"string"==typeof s.traceId&&"traceFlags"in s&&"number"==typeof s.traceFlags&&Z(r)?new H(r):new H;var s}startActiveSpan(t,e,n,r){let s,i,o;if(arguments.length<2)return;2===arguments.length?o=e:3===arguments.length?(s=e,o=n):(s=e,i=n,o=r);const a=null!=i?i:tt.active(),c=this.startSpan(t,s,a),u=q(a,c);return tt.with(u,o,void 0,c)}}const nt=new et;class rt{constructor(t,e,n,r){this._provider=t,this.name=e,this.version=n,this.options=r}startSpan(t,e,n){return this._getTracer().startSpan(t,e,n)}startActiveSpan(t,e,n,r){const s=this._getTracer();return Reflect.apply(s.startActiveSpan,s,arguments)}_getTracer(){if(this._delegate)return this._delegate;const t=this._provider.getDelegateTracer(this.name,this.version,this.options);return t?(this._delegate=t,this._delegate):nt}}const st=new class{getTracer(t,e,n){return new et}};class it{getTracer(t,e,n){var r;return null!==(r=this.getDelegateTracer(t,e,n))&&void 0!==r?r:new rt(this,t,e,n)}getDelegate(){var t;return null!==(t=this._delegate)&&void 0!==t?t:st}setDelegate(t){this._delegate=t}getDelegateTracer(t,e,n){var r;return null===(r=this._delegate)||void 0===r?void 0:r.getTracer(t,e,n)}}var ot,at,ct;!function(t){t[t.NOT_RECORD=0]="NOT_RECORD",t[t.RECORD=1]="RECORD",t[t.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"}(ot||(ot={})),function(t){t[t.INTERNAL=0]="INTERNAL",t[t.SERVER=1]="SERVER",t[t.CLIENT=2]="CLIENT",t[t.PRODUCER=3]="PRODUCER",t[t.CONSUMER=4]="CONSUMER"}(at||(at={})),function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"}(ct||(ct={}));const ut=M.getInstance(),lt=f.instance();const dt=new class{getMeter(t,e,n){return O}},ht="metrics";class pt{constructor(){}static getInstance(){return this._instance||(this._instance=new pt),this._instance}setGlobalMeterProvider(t){return c(ht,t,f.instance())}getMeterProvider(){return u(ht)||dt}getMeter(t,e,n){return this.getMeterProvider().getMeter(t,e,n)}disable(){l(ht,f.instance())}}const ft=pt.getInstance();const gt=b("OpenTelemetry Baggage Key");function mt(t){return t.getValue(gt)||void 0}function _t(){return mt(M.getInstance().active())}function St(t,e){return t.setValue(gt,e)}function bt(t){return t.deleteValue(gt)}const vt="propagation",Et=new class{inject(t,e){}extract(t,e){return t}fields(){return[]}};class Tt{constructor(){this.createBaggage=S,this.getBaggage=mt,this.getActiveBaggage=_t,this.setBaggage=St,this.deleteBaggage=bt}static getInstance(){return this._instance||(this._instance=new Tt),this._instance}setGlobalPropagator(t){return c(vt,t,f.instance())}inject(t,e,n=D){return this._getGlobalPropagator().inject(t,e,n)}extract(t,e,n=x){return this._getGlobalPropagator().extract(t,e,n)}fields(){return this._getGlobalPropagator().fields()}disable(){l(vt,f.instance())}_getGlobalPropagator(){return u(vt)||Et}}const yt=Tt.getInstance(),Ot="trace";class At{constructor(){this._proxyTracerProvider=new it,this.wrapSpanContext=J,this.isSpanContextValid=Z,this.deleteSpan=G,this.getSpan=V,this.getActiveSpan=z,this.getSpanContext=W,this.setSpan=q,this.setSpanContext=K}static getInstance(){return this._instance||(this._instance=new At),this._instance}setGlobalTracerProvider(t){const e=c(Ot,this._proxyTracerProvider,f.instance());return e&&this._proxyTracerProvider.setDelegate(t),e}getTracerProvider(){return u(Ot)||this._proxyTracerProvider}getTracer(t,e){return this.getTracerProvider().getTracer(t,e)}disable(){l(Ot,f.instance()),this._proxyTracerProvider=new it}}const Ct=At.getInstance(),wt=b("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function Rt(t){return t.setValue(wt,!0)}function Pt(t){return!0===t.getValue(wt)}const Lt=",",Nt="baggage";function xt(t){if(!t)return;const e=t.indexOf(";"),n=-1===e?t:t.substring(0,e),r=n.indexOf("=");if(r<=0)return;const s=n.substring(0,r).trim(),i=n.substring(r+1).trim();if(!s||!i)return;let o,a,c;try{o=decodeURIComponent(s),a=decodeURIComponent(i)}catch{return}if(-1!==e&&e<t.length-1){const n=t.substring(e+1);"string"!=typeof(u=n)&&(_.error("Cannot create baggage metadata from unknown type: "+typeof u),u=""),c={__TYPE__:m,toString:()=>u}}var u;return{key:o,value:a,metadata:c}}class Dt{inject(t,e,n){const r=yt.getBaggage(t);if(!r||Pt(t))return;const s=function(t){return t.getAllEntries().map(([t,e])=>{let n=`${encodeURIComponent(t)}=${encodeURIComponent(e.value)}`;return void 0!==e.metadata&&(n+=";"+e.metadata.toString()),n})}(r).filter(t=>t.length<=4096).slice(0,180),i=function(t){return t.reduce((t,e)=>{const n=`${t}${""!==t?Lt:""}${e}`;return n.length>8192?t:n},"")}(s);i.length>0&&n.set(e,Nt,i)}extract(t,e,n){const r=n.get(e,Nt),s=Array.isArray(r)?r.join(Lt):r;if(!s)return t;const i={};if(0===s.length)return t;return s.split(Lt).forEach(t=>{const e=xt(t);if(e){const t={value:e.value};e.metadata&&(t.metadata=e.metadata),i[e.key]=t}}),0===Object.entries(i).length?t:yt.setBaggage(t,yt.createBaggage(i))}fields(){return[Nt]}}function It(t){const e={};if("object"!=typeof t||null==t)return e;for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;if(!kt(n)){lt.warn(`Invalid attribute key: ${n}`);continue}const r=t[n];Mt(r)?Array.isArray(r)?e[n]=r.slice():e[n]=r:lt.warn(`Invalid attribute value set for key: ${n}`)}return e}function kt(t){return"string"==typeof t&&""!==t}function Mt(t){return null==t||(Array.isArray(t)?function(t){let e;for(const n of t){if(null==n)continue;const t=typeof n;if(t!==e){if(!e){if(Ut(t)){e=t;continue}return!1}return!1}}return!0}(t):Ut(typeof t))}function Ut(t){switch(t){case"number":case"boolean":case"string":return!0}return!1}function jt(){return t=>{lt.error(function(t){return"string"==typeof t?t:JSON.stringify(function(t){const e={};let n=t;for(;null!==n;)Object.getOwnPropertyNames(n).forEach(t=>{if(e[t])return;const r=n[t];r&&(e[t]=String(r))}),n=Object.getPrototypeOf(n);return e}(t))}(t))}}let Bt=jt();function Ft(t){try{Bt(t)}catch{}}function Ht(t){}const $t=globalThis,Vt="error.type",zt="exception.message",qt="exception.type",Gt="http.request.method",Kt="http.request.method_original",Wt="http.response.status_code",Xt="server.address",Qt="server.port",Yt="service.name",Zt="telemetry.sdk.language",Jt="telemetry.sdk.name",te="telemetry.sdk.version",ee="url.full",ne="process.runtime.name",re={[Jt]:"opentelemetry",[ne]:"browser",[Zt]:"webjs",[te]:"2.7.1"},se=performance,ie=Math.pow(10,6),oe=Math.pow(10,9);function ae(t){const e=t/1e3;return[Math.trunc(e),Math.round(t%1e3*ie)]}function ce(t){return fe(ae(se.timeOrigin),ae("number"==typeof t?t:se.now()))}function ue(t){if(he(t))return t;if("number"==typeof t)return t<se.timeOrigin?ce(t):ae(t);if(t instanceof Date)return ae(t.getTime());throw TypeError("Invalid input type")}function le(t,e){let n=e[0]-t[0],r=e[1]-t[1];return r<0&&(n-=1,r+=oe),[n,r]}function de(t){return t[0]*oe+t[1]}function he(t){return Array.isArray(t)&&2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]}function pe(t){return he(t)||"number"==typeof t||t instanceof Date}function fe(t,e){const n=[t[0]+e[0],t[1]+e[1]];return n[1]>=oe&&(n[1]-=oe,n[0]+=1),n}var ge;!function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"}(ge||(ge={}));class me{_propagators;_fields;constructor(t={}){this._propagators=t.propagators??[];const e=new Set;for(const t of this._propagators){const n="function"==typeof t.fields?t.fields():[];for(const t of n)e.add(t)}this._fields=Array.from(e)}inject(t,e,n){for(const r of this._propagators)try{r.inject(t,e,n)}catch(t){lt.warn(`Failed to inject with ${r.constructor.name}. Err: ${t.message}`)}}extract(t,e,n){return this._propagators.reduce((t,r)=>{try{return r.extract(t,e,n)}catch(t){lt.warn(`Failed to extract with ${r.constructor.name}. Err: ${t.message}`)}return t},t)}fields(){return this._fields.slice()}}const _e="[_0-9a-z-*/]",Se=new RegExp(`^(?:${`[a-z]${_e}{0,255}`}|${`[a-z0-9]${_e}{0,240}@[a-z]${_e}{0,13}`})$`),be=/^[ -~]{0,255}[!-~]$/,ve=/,|=/;function Ee(t){return Se.test(t)}function Te(t){return be.test(t)&&!ve.test(t)}class ye{_length;_rawTraceState;_internalState;constructor(t){this._rawTraceState="string"==typeof t?t:"",this._length=this._rawTraceState.length}set(t,e){if(!Ee(t)||!Te(e))return this;const n=this._getState(),r=n.get(t);let s=this._length;if(s+="string"==typeof r?e.length-r.length:t.length+e.length+(n.size>0?2:1),s>512)return this;const i=new Map(n);return i.delete(t),i.set(t,e),this._fromState(i,s)}unset(t){const e=this._getState(),n=e.get(t);if("string"!=typeof n)return this;let r=this._length-(t.length+n.length+1);e.size>1&&(r-=1);const s=new Map(e);return s.delete(t),this._fromState(s,r)}get(t){return this._getState().get(t)}serialize(){let t="",e=0;for(const n of this._getState())e>0&&(t=","+t),t=`${n[0]}=${n[1]}`+t,e++;return t}_getState(){if(this._internalState)return this._internalState;const t=this._rawTraceState.split(","),e=new Map;let n=0;for(const r of t){const t=r.trim(),s=t.indexOf("=");if(-1===s)continue;const i=t.slice(0,s),o=t.slice(s+1);if(!Ee(i)||!Te(o))continue;const a=n+t.length+(e.size>0?1:0);if(!(a>512)&&(e.set(i,o),n=a,e.size>=32))break}return this._length=n,this._internalState=new Map(Array.from(e.entries()).reverse()),this._internalState}_fromState(t,e){const n=Object.create(ye.prototype);return n._internalState=t,n._length=e,n}}const Oe="traceparent",Ae="tracestate",Ce=new RegExp("^\\s?((?!ff)[\\da-f]{2})-((?![0]{32})[\\da-f]{32})-((?![0]{16})[\\da-f]{16})-([\\da-f]{2})(-.*)?\\s?$");function we(t){const e=Ce.exec(t);return e?"00"===e[1]&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}:null}class Re{inject(t,e,n){const r=Ct.getSpanContext(t);if(!r||Pt(t)||!Z(r))return;const s=`00-${r.traceId}-${r.spanId}-0${Number(r.traceFlags||U.NONE).toString(16)}`;n.set(e,Oe,s),r.traceState&&n.set(e,Ae,r.traceState.serialize())}extract(t,e,n){const r=n.get(e,Oe);if(!r)return t;const s=Array.isArray(r)?r[0]:r;if("string"!=typeof s)return t;const i=we(s);if(!i)return t;i.isRemote=!0;const o=n.get(e,Ae);if(o){const t=Array.isArray(o)?o.join(","):o;i.traceState=new ye("string"==typeof t?t:void 0)}return Ct.setSpanContext(t,i)}fields(){return[Oe,Ae]}}const Pe=b("OpenTelemetry SDK Context Key RPC_METADATA");var Le;!function(t){t.HTTP="http"}(Le||(Le={}));const Ne="[object Null]",xe="[object Undefined]",De=Function.prototype.toString,Ie=De.call(Object),ke=Object.getPrototypeOf,Me=Object.prototype,Ue=Me.hasOwnProperty,je=Symbol?Symbol.toStringTag:void 0,Be=Me.toString;function Fe(t){if(!function(t){return null!=t&&"object"==typeof t}(t)||"[object Object]"!==function(t){if(null==t)return void 0===t?xe:Ne;return je&&je in Object(t)?function(t){const e=Ue.call(t,je),n=t[je];let r=!1;try{t[je]=void 0,r=!0}catch{}const s=Be.call(t);r&&(e?t[je]=n:delete t[je]);return s}(t):function(t){return Be.call(t)}(t)}(t))return!1;const e=ke(t);if(null===e)return!0;const n=Ue.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&De.call(n)===Ie}function He(...t){let e=t.shift();const n=new WeakMap;for(;t.length>0;)e=Ve(e,t.shift(),0,n);return e}function $e(t){return qe(t)?t.slice():t}function Ve(t,e,n=0,r){let s;if(!(n>20)){if(n++,We(t)||We(e)||Ge(e))s=$e(e);else if(qe(t)){if(s=t.slice(),qe(e))for(let t=0,n=e.length;t<n;t++)s.push($e(e[t]));else if(Ke(e)){const t=Object.keys(e);for(let n=0,r=t.length;n<r;n++){const r=t[n];"__proto__"!==r&&"constructor"!==r&&"prototype"!==r&&(s[r]=$e(e[r]))}}}else if(Ke(t))if(Ke(e)){if(!function(t,e){if(!Fe(t)||!Fe(e))return!1;return!0}(t,e))return e;s=Object.assign({},t);const i=Object.keys(e);for(let o=0,a=i.length;o<a;o++){const a=i[o];if("__proto__"===a||"constructor"===a||"prototype"===a)continue;const c=e[a];if(We(c))void 0===c?delete s[a]:s[a]=c;else{const i=s[a],o=c;if(ze(t,a,r)||ze(e,a,r))delete s[a];else{if(Ke(i)&&Ke(o)){const n=r.get(i)||[],s=r.get(o)||[];n.push({obj:t,key:a}),s.push({obj:e,key:a}),r.set(i,n),r.set(o,s)}s[a]=Ve(s[a],c,n,r)}}}}else s=e;return s}}function ze(t,e,n){const r=n.get(t[e])||[];for(let n=0,s=r.length;n<s;n++){const s=r[n];if(s.key===e&&s.obj===t)return!0}return!1}function qe(t){return Array.isArray(t)}function Ge(t){return"function"==typeof t}function Ke(t){return!We(t)&&!qe(t)&&!Ge(t)&&"object"==typeof t}function We(t){return"string"==typeof t||"number"==typeof t||"boolean"==typeof t||void 0===t||t instanceof Date||t instanceof RegExp||null===t}class Xe extends Error{constructor(t){super(t),Object.setPrototypeOf(this,Xe.prototype)}}function Qe(t,e){return"string"==typeof e?t===e:!!t.match(e)}function Ye(t,e){if(!e)return!1;for(const n of e)if(Qe(t,n))return!0;return!1}class Ze{_promise;_resolve;_reject;constructor(){this._promise=new Promise((t,e)=>{this._resolve=t,this._reject=e})}get promise(){return this._promise}resolve(t){this._resolve(t)}reject(t){this._reject(t)}}class Je{_isCalled=!1;_deferred=new Ze;_callback;_that;constructor(t,e){this._callback=t,this._that=e}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...t){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...t)).then(t=>this._deferred.resolve(t),t=>this._deferred.reject(t))}catch(t){this._deferred.reject(t)}}return this._deferred.promise}}const tn={ALL:p.ALL,VERBOSE:p.VERBOSE,DEBUG:p.DEBUG,INFO:p.INFO,WARN:p.WARN,ERROR:p.ERROR,NONE:p.NONE};const en={_export:function(t,e){return new Promise(n=>{ut.with(Rt(ut.active()),()=>{t.export(e,n)})})}};var nn=Object.freeze({__proto__:null,AnchoredClock:class{_monotonicClock;_epochMillis;_performanceMillis;constructor(t,e){this._monotonicClock=e,this._epochMillis=t.now(),this._performanceMillis=e.now()}now(){const t=this._monotonicClock.now()-this._performanceMillis;return this._epochMillis+t}},BindOnceFuture:Je,CompositePropagator:me,get ExportResultCode(){return ge},get RPCType(){return Le},SDK_INFO:re,TRACE_PARENT_HEADER:Oe,TRACE_STATE_HEADER:Ae,TimeoutError:Xe,TraceState:ye,W3CBaggagePropagator:Dt,W3CTraceContextPropagator:Re,_globalThis:$t,addHrTimes:fe,callWithTimeout:function(t,e){let n;const r=new Promise(function(t,r){n=setTimeout(function(){r(new Xe("Operation timed out."))},e)});return Promise.race([t,r]).then(t=>(clearTimeout(n),t),t=>{throw clearTimeout(n),t})},deleteRPCMetadata:function(t){return t.deleteValue(Pe)},diagLogLevelFromString:function(t){if(null==t)return;const e=tn[t.toUpperCase()];return null==e?(lt.warn(`Unknown log level "${t}", expected one of ${Object.keys(tn)}, using default`),p.INFO):e},getBooleanFromEnv:function(t){},getNumberFromEnv:Ht,getRPCMetadata:function(t){return t.getValue(Pe)},getStringFromEnv:function(t){},getStringListFromEnv:function(t){},getTimeOrigin:function(){return se.timeOrigin},globalErrorHandler:Ft,hrTime:ce,hrTimeDuration:le,hrTimeToMicroseconds:function(t){return 1e6*t[0]+t[1]/1e3},hrTimeToMilliseconds:function(t){return 1e3*t[0]+t[1]/1e6},hrTimeToNanoseconds:de,hrTimeToTimeStamp:function(t){const e=`${"0".repeat(9)}${t[1]}Z`,n=e.substring(e.length-9-1);return new Date(1e3*t[0]).toISOString().replace("000Z",n)},internal:en,isAttributeValue:Mt,isTimeInput:pe,isTimeInputHrTime:he,isTracingSuppressed:Pt,isUrlIgnored:Ye,loggingErrorHandler:jt,merge:He,millisToHrTime:ae,otperformance:se,parseKeyPairsIntoRecord:function(t){const e={};return"string"==typeof t&&t.length>0&&t.split(Lt).forEach(t=>{const n=xt(t);void 0!==n&&n.value.length>0&&(e[n.key]=n.value)}),e},parseTraceParent:we,sanitizeAttributes:It,setGlobalErrorHandler:function(t){Bt=t},setRPCMetadata:function(t,e){return t.setValue(Pe,e)},suppressTracing:Rt,timeInputToHrTime:ue,unrefTimer:function(t){"number"!=typeof t&&t.unref()},unsuppressTracing:function(t){return t.deleteValue(wt)},urlMatches:Qe});function rn(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if("function"==typeof e){var n=function t(){var n=!1;try{n=this instanceof t}catch{}return n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})}),n}var sn,on,an={},cn=rn(nn),un={};function ln(){if(sn)return un;function t(t){return t>=48&&t<=57?t-48:t>=97&&t<=102?t-87:t-55}return sn=1,Object.defineProperty(un,"__esModule",{value:!0}),un.hexToBinary=void 0,un.hexToBinary=function(e){const n=new Uint8Array(e.length/2);let r=0;for(let s=0;s<e.length;s+=2){const i=t(e.charCodeAt(s)),o=t(e.charCodeAt(s+1));n[r++]=i<<4|o}return n},un}function dn(){if(on)return an;on=1,Object.defineProperty(an,"__esModule",{value:!0}),an.JSON_ENCODER=an.PROTOBUF_ENCODER=an.encodeAsString=an.encodeAsLongBits=an.toLongBits=an.hrTimeToNanos=void 0;const t=cn,e=ln();function n(t){const e=BigInt(1e9);return BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))}function r(t){return{low:Number(BigInt.asUintN(32,t)),high:Number(BigInt.asUintN(32,t>>BigInt(32)))}}function s(t){return r(n(t))}function i(t){return n(t).toString()}an.hrTimeToNanos=n,an.toLongBits=r,an.encodeAsLongBits=s,an.encodeAsString=i;const o="undefined"!=typeof BigInt?i:t.hrTimeToNanoseconds;function a(t){return t}return an.PROTOBUF_ENCODER={encodeHrTime:s,encodeSpanContext:e.hexToBinary,encodeOptionalSpanContext:function(t){if(void 0!==t)return(0,e.hexToBinary)(t)},encodeUint8Array:a},an.JSON_ENCODER={encodeHrTime:o,encodeSpanContext:a,encodeOptionalSpanContext:a,encodeUint8Array:t=>{if("undefined"!=typeof Buffer)return Buffer.from(t).toString("base64");const e=new Array(t.length);for(let n=0;n<t.length;n++)e[n]=String.fromCharCode(t[n]);return btoa(e.join(""))}},an}var hn,pn,fn=dn(),gn={},mn={};function _n(){if(hn)return mn;function t(t,n){return Object.keys(t).map(r=>e(r,t[r],n))}function e(t,e,r){return{key:t,value:n(e,r)}}function n(t,e){const r=typeof t;if("string"===r)return{stringValue:t};if("number"===r)return Number.isInteger(t)?{intValue:t}:{doubleValue:t};if("boolean"===r)return{boolValue:t};if(t instanceof Uint8Array)return{bytesValue:e.encodeUint8Array(t)};if(Array.isArray(t)){const r=new Array(t.length);for(let s=0;s<t.length;s++)r[s]=n(t[s],e);return{arrayValue:{values:r}}}if("object"===r&&null!=t){const r=Object.keys(t),s=new Array(r.length);for(let i=0;i<r.length;i++)s[i]={key:r[i],value:n(t[r[i]],e)};return{kvlistValue:{values:s}}}return{}}return hn=1,Object.defineProperty(mn,"__esModule",{value:!0}),mn.toAnyValue=mn.toKeyValue=mn.toAttributes=mn.createInstrumentationScope=mn.createResource=void 0,mn.createResource=function(e,n){const r={attributes:t(e.attributes,n),droppedAttributesCount:0},s=e.schemaUrl;return s&&""!==s&&(r.schemaUrl=s),r},mn.createInstrumentationScope=function(t){return{name:t.name,version:t.version}},mn.toAttributes=t,mn.toKeyValue=e,mn.toAnyValue=n,mn}function Sn(){if(pn)return gn;pn=1,Object.defineProperty(gn,"__esModule",{value:!0}),gn.createExportTraceServiceRequest=gn.toOtlpSpanEvent=gn.toOtlpLink=gn.sdkSpanToOtlpSpan=void 0;const t=_n();function e(t,e){let n=255&t|256;return e&&(n|=512),n}function n(n,i){const o=n.spanContext(),a=n.status,c=n.parentSpanContext?.spanId?i.encodeSpanContext(n.parentSpanContext?.spanId):void 0;return{traceId:i.encodeSpanContext(o.traceId),spanId:i.encodeSpanContext(o.spanId),parentSpanId:c,traceState:o.traceState?.serialize(),name:n.name,kind:null==n.kind?0:n.kind+1,startTimeUnixNano:i.encodeHrTime(n.startTime),endTimeUnixNano:i.encodeHrTime(n.endTime),attributes:(0,t.toAttributes)(n.attributes,i),droppedAttributesCount:n.droppedAttributesCount,events:n.events.map(t=>s(t,i)),droppedEventsCount:n.droppedEventsCount,status:{code:a.code,message:a.message},links:n.links.map(t=>r(t,i)),droppedLinksCount:n.droppedLinksCount,flags:e(o.traceFlags,n.parentSpanContext?.isRemote)}}function r(n,r){return{attributes:n.attributes?(0,t.toAttributes)(n.attributes,r):[],spanId:r.encodeSpanContext(n.context.spanId),traceId:r.encodeSpanContext(n.context.traceId),traceState:n.context.traceState?.serialize(),droppedAttributesCount:n.droppedAttributesCount||0,flags:e(n.context.traceFlags,n.context.isRemote)}}function s(e,n){return{attributes:e.attributes?(0,t.toAttributes)(e.attributes,n):[],name:e.name,timeUnixNano:n.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}function i(e,r){const s=function(t){const e=new Map;for(const n of t){let t=e.get(n.resource);t||(t=new Map,e.set(n.resource,t));const r=`${n.instrumentationScope.name}@${n.instrumentationScope.version||""}:${n.instrumentationScope.schemaUrl||""}`;let s=t.get(r);s||(s=[],t.set(r,s)),s.push(n)}return e}(e),i=[],o=s.entries();let a=o.next();for(;!a.done;){const[e,s]=a.value,c=[],u=s.values();let l=u.next();for(;!l.done;){const e=l.value;if(e.length>0){const s=e.map(t=>n(t,r));c.push({scope:(0,t.createInstrumentationScope)(e[0].instrumentationScope),spans:s,schemaUrl:e[0].instrumentationScope.schemaUrl})}l=u.next()}const d=(0,t.createResource)(e,r),h={resource:d,scopeSpans:c,schemaUrl:d.schemaUrl};i.push(h),a=o.next()}return i}return gn.sdkSpanToOtlpSpan=n,gn.toOtlpLink=r,gn.toOtlpSpanEvent=s,gn.createExportTraceServiceRequest=function(t,e){return{resourceSpans:i(t,e)}},gn}var bn,vn=Sn(),En={};function Tn(){return bn||(bn=1,t=En,Object.defineProperty(t,"__esModule",{value:!0}),t.EStatusCode=t.ESpanKind=void 0,(e=t.ESpanKind||(t.ESpanKind={}))[e.SPAN_KIND_UNSPECIFIED=0]="SPAN_KIND_UNSPECIFIED",e[e.SPAN_KIND_INTERNAL=1]="SPAN_KIND_INTERNAL",e[e.SPAN_KIND_SERVER=2]="SPAN_KIND_SERVER",e[e.SPAN_KIND_CLIENT=3]="SPAN_KIND_CLIENT",e[e.SPAN_KIND_PRODUCER=4]="SPAN_KIND_PRODUCER",e[e.SPAN_KIND_CONSUMER=5]="SPAN_KIND_CONSUMER",(n=t.EStatusCode||(t.EStatusCode={}))[n.STATUS_CODE_UNSET=0]="STATUS_CODE_UNSET",n[n.STATUS_CODE_OK=1]="STATUS_CODE_OK",n[n.STATUS_CODE_ERROR=2]="STATUS_CODE_ERROR"),En;var t,e,n}var yn=Tn();class On{constructor(t){this.config=t}export(t,n){const r=vn.createExportTraceServiceRequest(t,fn.JSON_ENCODER);this.config.api.pushTraces(r),function(t=[],n){var r,s;for(const i of t){const{scopeSpans:t}=i;for(const i of t){const{scope:t,spans:o=[]}=i;for(const i of o){if(i.kind!==yn.ESpanKind.SPAN_KIND_CLIENT)continue;const o={traceId:i.traceId.toString(),spanId:i.spanId.toString()},a={};for(const t of i.attributes)a[t.key]=String(Object.values(t.value)[0]);Number.isNaN(i.endTimeUnixNano)||Number.isNaN(i.startTimeUnixNano)||(a.duration_ns=String(Number(i.endTimeUnixNano)-Number(i.startTimeUnixNano)));const c=(null!==(r=null==t?void 0:t.name)&&void 0!==r?r:"").indexOf("-");let u=e.unknownString;(null==t?void 0:t.name)&&(-1===c&&(u=null!==(s=t.name.split("/")[1])&&void 0!==s?s:t.name),c>-1&&(u=null==t?void 0:t.name.substring(c+1))),n.pushEvent(`faro.tracing.${u}`,a,void 0,{spanContext:o,timestampOverwriteMs:Number(i.endTimeUnixNano)/1e6,customPayloadTransformer:t=>{var e,n;return null!=a["faro.action.user.name"]&&null!=a["faro.action.user.parentId"]&&(t.action={name:a["faro.action.user.name"],parentId:a["faro.action.user.parentId"]},null===(e=t.attributes)||void 0===e||delete e["faro.action.user.name"],null===(n=t.attributes)||void 0===n||delete n["faro.action.user.parentId"]),t}})}}}}(r.resourceSpans,this.config.api),n({code:ge.SUCCESS})}shutdown(){return Promise.resolve(void 0)}}"function"==typeof SuppressedError&&SuppressedError;class An{emit(t){}enabled(){return!1}}const Cn=new An,wn=Symbol.for("io.opentelemetry.js.api.logs"),Rn=globalThis;const Pn=new class{getLogger(t,e,n){return new An}};class Ln{constructor(t,e,n,r){this._provider=t,this.name=e,this.version=n,this.options=r}emit(t){this._getLogger().emit(t)}enabled(t){return this._getLogger().enabled(t)}_getLogger(){if(this._delegate)return this._delegate;const t=this._provider._getDelegateLogger(this.name,this.version,this.options);return t?(this._delegate=t,this._delegate):Cn}}class Nn{getLogger(t,e,n){var r;return null!==(r=this._getDelegateLogger(t,e,n))&&void 0!==r?r:new Ln(this,t,e,n)}_getDelegate(){var t;return null!==(t=this._delegate)&&void 0!==t?t:Pn}_setDelegate(t){this._delegate=t}_getDelegateLogger(t,e,n){var r;return null===(r=this._delegate)||void 0===r?void 0:r.getLogger(t,e,n)}}class xn{constructor(){this._proxyLoggerProvider=new Nn}static getInstance(){return this._instance||(this._instance=new xn),this._instance}setGlobalLoggerProvider(t){return Rn[wn]?this.getLoggerProvider():(Rn[wn]=(e=1,n=t,r=Pn,t=>t===e?n:r),this._proxyLoggerProvider._setDelegate(t),t);var e,n,r}getLoggerProvider(){var t,e;return null!==(e=null===(t=Rn[wn])||void 0===t?void 0:t.call(Rn,1))&&void 0!==e?e:this._proxyLoggerProvider}getLogger(t,e,n){return this.getLoggerProvider().getLogger(t,e,n)}disable(){delete Rn[wn],this._proxyLoggerProvider=new Nn}}const Dn=xn.getInstance();let In=console.error.bind(console);function kn(t,e,n){const r=!!t[e]&&Object.prototype.propertyIsEnumerable.call(t,e);Object.defineProperty(t,e,{configurable:!0,enumerable:r,writable:!0,value:n})}const Mn=(t,e,n)=>{if(!t||!t[e])return void In("no original function "+String(e)+" to wrap");if(!n)return In("no wrapper function"),void In((new Error).stack);const r=t[e];if("function"!=typeof r||"function"!=typeof n)return void In("original object and wrapper must be functions");const s=n(r,e);return kn(s,"__original",r),kn(s,"__unwrap",()=>{t[e]===s&&kn(t,e,r)}),kn(s,"__wrapped",!0),kn(t,e,s),s},Un=(t,e,n)=>{if(!t)return In("must provide one or more modules to patch"),void In((new Error).stack);Array.isArray(t)||(t=[t]),e&&Array.isArray(e)?t.forEach(t=>{e.forEach(e=>{Mn(t,e,n)})}):In("must provide one or more functions to wrap on modules")},jn=(t,e)=>{if(!t||!t[e])return In("no function to unwrap."),void In((new Error).stack);const n=t[e];n.__unwrap?n.__unwrap():In("no original to unwrap to -- has "+String(e)+" already been unwrapped?")},Bn=(t,e)=>{if(!t)return In("must provide one or more modules to patch"),void In((new Error).stack);Array.isArray(t)||(t=[t]),e&&Array.isArray(e)?t.forEach(t=>{e.forEach(e=>{jn(t,e)})}):In("must provide one or more functions to unwrap on modules")};class Fn{_config={};_tracer;_meter;_logger;_diag;instrumentationName;instrumentationVersion;constructor(t,e,n){this.instrumentationName=t,this.instrumentationVersion=e,this.setConfig(n),this._diag=lt.createComponentLogger({namespace:t}),this._tracer=Ct.getTracer(t,e),this._meter=ft.getMeter(t,e),this._logger=Dn.getLogger(t,e),this._updateMetricInstruments()}_wrap=Mn;_unwrap=jn;_massWrap=Un;_massUnwrap=Bn;get meter(){return this._meter}setMeterProvider(t){this._meter=t.getMeter(this.instrumentationName,this.instrumentationVersion),this._updateMetricInstruments()}get logger(){return this._logger}setLoggerProvider(t){this._logger=t.getLogger(this.instrumentationName,this.instrumentationVersion)}getModuleDefinitions(){const t=this.init()??[];return Array.isArray(t)?t:[t]}_updateMetricInstruments(){}getConfig(){return this._config}setConfig(t){this._config={enabled:!0,...t}}setTracerProvider(t){this._tracer=t.getTracer(this.instrumentationName,this.instrumentationVersion)}get tracer(){return this._tracer}_runSpanCustomizationHook(t,e,n,r){if(t)try{t(n,r)}catch(t){this._diag.error("Error running span customization hook due to exception in handler",{triggerName:e},t)}}}class Hn extends Fn{constructor(t,e,n){super(t,e,n),this._config.enabled&&this.enable()}}function $n(t,e,n){let r,s;try{s=t()}catch(t){r=t}finally{return e(r,s),s}}var Vn;function zn(t,e){let n=Vn.OLD;const r=e?.split(",").map(t=>t.trim()).filter(t=>""!==t);for(const e of r??[]){if(e.toLowerCase()===t+"/dup"){n=Vn.DUPLICATE;break}e.toLowerCase()===t&&(n=Vn.STABLE)}return n}let qn;function Gn(){if(void 0===qn)try{const t=globalThis.process.argv0;qn=t?`unknown_service:${t}`:"unknown_service"}catch{qn="unknown_service"}return qn}!function(t){t[t.STABLE=1]="STABLE",t[t.OLD=2]="OLD",t[t.DUPLICATE=3]="DUPLICATE"}(Vn||(Vn={}));const Kn=t=>null!==t&&"object"==typeof t&&"function"==typeof t.then;class Wn{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(t,e){const n=new Wn({},e);return n._rawAttributes=Yn(t),n._asyncAttributesPending=t.filter(([t,e])=>Kn(e)).length>0,n}constructor(t,e){const n=t.attributes??{};this._rawAttributes=Object.entries(n).map(([t,e])=>(Kn(e)&&(this._asyncAttributesPending=!0),[t,e])),this._rawAttributes=Yn(this._rawAttributes),this._schemaUrl=function(t){if("string"==typeof t||void 0===t)return t;return void lt.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}(e?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let t=0;t<this._rawAttributes.length;t++){const[e,n]=this._rawAttributes[t];this._rawAttributes[t]=[e,Kn(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&lt.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;const t={};for(const[e,n]of this._rawAttributes)Kn(n)?lt.debug(`Unsettled resource attribute ${e} skipped`):null!=n&&(t[e]??=n);return this._asyncAttributesPending||(this._memoizedAttributes=t),t}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(t){if(null==t)return this;const e=function(t,e){const n=t?.schemaUrl,r=e?.schemaUrl,s=void 0===n||""===n,i=void 0===r||""===r;if(s)return r;if(i)return n;if(n===r)return n;return void lt.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',n,r)}(this,t),n=e?{schemaUrl:e}:void 0;return Wn.FromAttributeList([...t.getRawAttributes(),...this.getRawAttributes()],n)}}function Xn(t,e){return Wn.FromAttributeList(Object.entries(t),e)}function Qn(){return Xn({[Yt]:Gn(),[Zt]:re[Zt],[Jt]:re[Jt],[te]:re[te]})}function Yn(t){return t.map(([t,e])=>Kn(e)?[t,e.catch(e=>{lt.debug("promise rejection for resource attribute: %s - %s",t,e)})]:[t,e])}class Zn{_spanContext;kind;parentSpanContext;attributes={};links=[];events=[];startTime;resource;instrumentationScope;_droppedAttributesCount=0;_droppedEventsCount=0;_droppedLinksCount=0;_attributesCount=0;name;status={code:ct.UNSET};endTime=[0,0];_ended=!1;_duration=[-1,-1];_spanProcessor;_spanLimits;_attributeValueLengthLimit;_recordEndMetrics;_performanceStartTime;_performanceOffset;_startTimeProvided;constructor(t){const e=Date.now();if(this._spanContext=t.spanContext,this._performanceStartTime=se.now(),this._performanceOffset=e-(this._performanceStartTime+se.timeOrigin),this._startTimeProvided=null!=t.startTime,this._spanLimits=t.spanLimits,this._attributeValueLengthLimit=this._spanLimits.attributeValueLengthLimit??0,this._spanProcessor=t.spanProcessor,this.name=t.name,this.parentSpanContext=t.parentSpanContext,this.kind=t.kind,t.links)for(const e of t.links)this.addLink(e);this.startTime=this._getTime(t.startTime??e),this.resource=t.resource,this.instrumentationScope=t.scope,this._recordEndMetrics=t.recordEndMetrics,null!=t.attributes&&this.setAttributes(t.attributes),this._spanProcessor.onStart(this,t.context)}spanContext(){return this._spanContext}setAttribute(t,e){if(null==e||this._isSpanEnded())return this;if(0===t.length)return lt.warn(`Invalid attribute key: ${t}`),this;if(!Mt(e))return lt.warn(`Invalid attribute value set for key: ${t}`),this;const{attributeCountLimit:n}=this._spanLimits,r=!Object.prototype.hasOwnProperty.call(this.attributes,t);return void 0!==n&&this._attributesCount>=n&&r?(this._droppedAttributesCount++,this):(this.attributes[t]=this._truncateToSize(e),r&&this._attributesCount++,this)}setAttributes(t){for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&this.setAttribute(e,t[e]);return this}addEvent(t,e,n){if(this._isSpanEnded())return this;const{eventCountLimit:r}=this._spanLimits;if(0===r)return lt.warn("No events allowed."),this._droppedEventsCount++,this;void 0!==r&&this.events.length>=r&&(0===this._droppedEventsCount&&lt.debug("Dropping extra events."),this.events.shift(),this._droppedEventsCount++),pe(e)&&(pe(n)||(n=e),e=void 0);const s=It(e),{attributePerEventCountLimit:i}=this._spanLimits,o={};let a=0,c=0;for(const t in s){if(!Object.prototype.hasOwnProperty.call(s,t))continue;const e=s[t];void 0!==i&&c>=i?a++:(o[t]=this._truncateToSize(e),c++)}return this.events.push({name:t,attributes:o,time:this._getTime(n),droppedAttributesCount:a}),this}addLink(t){if(this._isSpanEnded())return this;const{linkCountLimit:e}=this._spanLimits;if(0===e)return this._droppedLinksCount++,this;void 0!==e&&this.links.length>=e&&(0===this._droppedLinksCount&&lt.debug("Dropping extra links."),this.links.shift(),this._droppedLinksCount++);const{attributePerLinkCountLimit:n}=this._spanLimits,r=It(t.attributes),s={};let i=0,o=0;for(const t in r){if(!Object.prototype.hasOwnProperty.call(r,t))continue;const e=r[t];void 0!==n&&o>=n?i++:(s[t]=this._truncateToSize(e),o++)}const a={context:t.context};return o>0&&(a.attributes=s),i>0&&(a.droppedAttributesCount=i),this.links.push(a),this}addLinks(t){for(const e of t)this.addLink(e);return this}setStatus(t){if(this._isSpanEnded())return this;if(t.code===ct.UNSET)return this;if(this.status.code===ct.OK)return this;const e={code:t.code};return t.code===ct.ERROR&&("string"==typeof t.message?e.message=t.message:null!=t.message&&lt.warn(`Dropping invalid status.message of type '${typeof t.message}', expected 'string'`)),this.status=e,this}updateName(t){return this._isSpanEnded()||(this.name=t),this}end(t){this._isSpanEnded()?lt.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`):(this.endTime=this._getTime(t),this._duration=le(this.startTime,this.endTime),this._duration[0]<0&&(lt.warn("Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.",this.startTime,this.endTime),this.endTime=this.startTime.slice(),this._duration=[0,0]),this._droppedEventsCount>0&&lt.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`),this._droppedLinksCount>0&&lt.warn(`Dropped ${this._droppedLinksCount} links because linkCountLimit reached`),this._spanProcessor.onEnding&&this._spanProcessor.onEnding(this),this._recordEndMetrics?.(),this._ended=!0,this._spanProcessor.onEnd(this))}_getTime(t){if("number"==typeof t&&t<=se.now())return ce(t+this._performanceOffset);if("number"==typeof t)return ae(t);if(t instanceof Date)return ae(t.getTime());if(he(t))return t;if(this._startTimeProvided)return ae(Date.now());const e=se.now()-this._performanceStartTime;return fe(this.startTime,ae(e))}isRecording(){return!1===this._ended}recordException(t,e){const n={};"string"==typeof t?n[zt]=t:t&&(t.code?n[qt]=t.code.toString():t.name&&(n[qt]=t.name),t.message&&(n[zt]=t.message),t.stack&&(n["exception.stacktrace"]=t.stack)),n[qt]||n[zt]?this.addEvent("exception",n,e):lt.warn(`Failed to record an exception ${t}`)}get duration(){return this._duration}get ended(){return this._ended}get droppedAttributesCount(){return this._droppedAttributesCount}get droppedEventsCount(){return this._droppedEventsCount}get droppedLinksCount(){return this._droppedLinksCount}_isSpanEnded(){if(this._ended){const t=new Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);lt.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`,t)}return this._ended}_truncateToLimitUtil(t,e){return t.length<=e?t:t.substring(0,e)}_truncateToSize(t){const e=this._attributeValueLengthLimit;return e<=0?(lt.warn(`Attribute value limit must be positive, got ${e}`),t):"string"==typeof t?this._truncateToLimitUtil(t,e):Array.isArray(t)?t.map(t=>"string"==typeof t?this._truncateToLimitUtil(t,e):t):t}}var Jn,tr;!function(t){t[t.NOT_RECORD=0]="NOT_RECORD",t[t.RECORD=1]="RECORD",t[t.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"}(Jn||(Jn={}));class er{shouldSample(){return{decision:Jn.NOT_RECORD}}toString(){return"AlwaysOffSampler"}}class nr{shouldSample(){return{decision:Jn.RECORD_AND_SAMPLED}}toString(){return"AlwaysOnSampler"}}class rr{_root;_remoteParentSampled;_remoteParentNotSampled;_localParentSampled;_localParentNotSampled;constructor(t){this._root=t.root,this._root||(Ft(new Error("ParentBasedSampler must have a root sampler configured")),this._root=new nr),this._remoteParentSampled=t.remoteParentSampled??new nr,this._remoteParentNotSampled=t.remoteParentNotSampled??new er,this._localParentSampled=t.localParentSampled??new nr,this._localParentNotSampled=t.localParentNotSampled??new er}shouldSample(t,e,n,r,s,i){const o=Ct.getSpanContext(t);return o&&Z(o)?o.isRemote?o.traceFlags&U.SAMPLED?this._remoteParentSampled.shouldSample(t,e,n,r,s,i):this._remoteParentNotSampled.shouldSample(t,e,n,r,s,i):o.traceFlags&U.SAMPLED?this._localParentSampled.shouldSample(t,e,n,r,s,i):this._localParentNotSampled.shouldSample(t,e,n,r,s,i):this._root.shouldSample(t,e,n,r,s,i)}toString(){return`ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`}}class sr{_ratio;_upperBound;constructor(t=0){this._ratio=this._normalize(t),this._upperBound=Math.floor(4294967295*this._ratio)}shouldSample(t,e){return{decision:Y(e)&&this._accumulate(e)<this._upperBound?Jn.RECORD_AND_SAMPLED:Jn.NOT_RECORD}}toString(){return`TraceIdRatioBased{${this._ratio}}`}_normalize(t){return"number"!=typeof t||isNaN(t)?0:t>=1?1:t<=0?0:t}_accumulate(t){let e=0;for(let n=0;n<32;n+=8){let r=0;for(let e=0;e<8;e++){const s=t.charCodeAt(n+e);r=r<<4|(s<58?s-48:s<71?s-55:s-87)}e=(e^r)>>>0}return e}}!function(t){t.AlwaysOff="always_off",t.AlwaysOn="always_on",t.ParentBasedAlwaysOff="parentbased_always_off",t.ParentBasedAlwaysOn="parentbased_always_on",t.ParentBasedTraceIdRatio="parentbased_traceidratio",t.TraceIdRatio="traceidratio"}(tr||(tr={}));function ir(){return{sampler:or(),forceFlushTimeoutMillis:3e4,generalLimits:{attributeValueLengthLimit:1/0,attributeCountLimit:128},spanLimits:{attributeValueLengthLimit:1/0,attributeCountLimit:128,linkCountLimit:128,eventCountLimit:128,attributePerEventCountLimit:128,attributePerLinkCountLimit:128}}}function or(){const t=tr.ParentBasedAlwaysOn;switch(t){case tr.AlwaysOn:return new nr;case tr.AlwaysOff:return new er;case tr.ParentBasedAlwaysOn:return new rr({root:new nr});case tr.ParentBasedAlwaysOff:return new rr({root:new er});case tr.TraceIdRatio:return new sr(ar());case tr.ParentBasedTraceIdRatio:return new rr({root:new sr(ar())});default:return lt.error(`OTEL_TRACES_SAMPLER value "${t}" invalid, defaulting to "${tr.ParentBasedAlwaysOn}".`),new rr({root:new nr})}}function ar(){return lt.error("OTEL_TRACES_SAMPLER_ARG is blank, defaulting to 1."),1}const cr=1/0;class ur{_maxExportBatchSize;_maxQueueSize;_scheduledDelayMillis;_exportTimeoutMillis;_exporter;_isExporting=!1;_finishedSpans=[];_timer;_shutdownOnce;_droppedSpansCount=0;constructor(t,e){this._exporter=t,this._maxExportBatchSize="number"==typeof e?.maxExportBatchSize?e.maxExportBatchSize:512,this._maxQueueSize="number"==typeof e?.maxQueueSize?e.maxQueueSize:2048,this._scheduledDelayMillis="number"==typeof e?.scheduledDelayMillis?e.scheduledDelayMillis:5e3,this._exportTimeoutMillis="number"==typeof e?.exportTimeoutMillis?e.exportTimeoutMillis:3e4,this._shutdownOnce=new Je(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(lt.warn("BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize"),this._maxExportBatchSize=this._maxQueueSize)}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}onStart(t,e){}onEnd(t){this._shutdownOnce.isCalled||0!==(t.spanContext().traceFlags&U.SAMPLED)&&this._addToBuffer(t)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return Promise.resolve().then(()=>this.onShutdown()).then(()=>this._flushAll()).then(()=>this._exporter.shutdown())}_addToBuffer(t){if(this._finishedSpans.length>=this._maxQueueSize)return 0===this._droppedSpansCount&&lt.debug("maxQueueSize reached, dropping spans"),void this._droppedSpansCount++;this._droppedSpansCount>0&&(lt.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`),this._droppedSpansCount=0),this._finishedSpans.push(t),this._maybeStartTimer()}_flushAll(){return new Promise((t,e)=>{const n=[];for(let t=0,e=Math.ceil(this._finishedSpans.length/this._maxExportBatchSize);t<e;t++)n.push(this._flushOneBatch());Promise.all(n).then(()=>{t()}).catch(e)})}_flushOneBatch(){return this._clearTimer(),0===this._finishedSpans.length?Promise.resolve():new Promise((t,e)=>{const n=setTimeout(()=>{e(new Error("Timeout"))},this._exportTimeoutMillis);ut.with(Rt(ut.active()),()=>{let r;this._finishedSpans.length<=this._maxExportBatchSize?(r=this._finishedSpans,this._finishedSpans=[]):r=this._finishedSpans.splice(0,this._maxExportBatchSize);const s=()=>this._exporter.export(r,r=>{clearTimeout(n),r.code===ge.SUCCESS?t():e(r.error??new Error("BatchSpanProcessor: span export failed"))});let i=null;for(let t=0,e=r.length;t<e;t++){const e=r[t];e.resource.asyncAttributesPending&&e.resource.waitForAsyncAttributes&&(i??=[],i.push(e.resource.waitForAsyncAttributes()))}null===i?s():Promise.all(i).then(s,t=>{Ft(t),e(t)})})})}_maybeStartTimer(){if(this._isExporting)return;const t=()=>{this._isExporting=!0,this._flushOneBatch().finally(()=>{this._isExporting=!1,this._finishedSpans.length>0&&(this._clearTimer(),this._maybeStartTimer())}).catch(t=>{this._isExporting=!1,Ft(t)})};if(this._finishedSpans.length>=this._maxExportBatchSize)return t();void 0===this._timer&&(this._timer=setTimeout(()=>t(),this._scheduledDelayMillis),"number"!=typeof this._timer&&this._timer.unref())}_clearTimer(){void 0!==this._timer&&(clearTimeout(this._timer),this._timer=void 0)}}class lr extends ur{_visibilityChangeListener;_pageHideListener;constructor(t,e){super(t,e),this.onInit(e)}onInit(t){!0!==t?.disableAutoFlushOnDocumentHide&&"undefined"!=typeof document&&(this._visibilityChangeListener=()=>{"hidden"===document.visibilityState&&this.forceFlush().catch(t=>{Ft(t)})},this._pageHideListener=()=>{this.forceFlush().catch(t=>{Ft(t)})},document.addEventListener("visibilitychange",this._visibilityChangeListener),document.addEventListener("pagehide",this._pageHideListener))}onShutdown(){"undefined"!=typeof document&&(this._visibilityChangeListener&&document.removeEventListener("visibilitychange",this._visibilityChangeListener),this._pageHideListener&&document.removeEventListener("pagehide",this._pageHideListener))}}const dr=new Uint8Array(16),hr=new Uint8Array(8),pr=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function fr(t){for(let e=0;e<t.length;e++)t[e]=256*Math.random()>>>0;for(let e=0;e<t.length;e++)if(t[e]>0)return;t[t.length-1]=1}function gr(t){let e="";for(let n=0;n<t.length;n++)e+=pr[t[n]];return e}class mr{generateTraceId(){return fr(dr),gr(dr)}generateSpanId(){return fr(hr),gr(hr)}}const _r="otel.span.parent.origin",Sr="otel.span.sampling_result";class br{startedSpans;liveSpans;constructor(t){this.startedSpans=t.createCounter("otel.sdk.span.started",{unit:"{span}",description:"The number of created spans."}),this.liveSpans=t.createUpDownCounter("otel.sdk.span.live",{unit:"{span}",description:"The number of currently live spans."})}startSpan(t,e){const n=function(t){switch(t){case Jn.RECORD_AND_SAMPLED:return"RECORD_AND_SAMPLE";case Jn.RECORD:return"RECORD_ONLY";case Jn.NOT_RECORD:return"DROP"}}(e);if(this.startedSpans.add(1,{[_r]:vr(t),[Sr]:n}),e===Jn.NOT_RECORD)return()=>{};const r={[Sr]:n};return this.liveSpans.add(1,r),()=>{this.liveSpans.add(-1,r)}}}function vr(t){return t?t.isRemote?"remote":"local":"none"}class Er{_sampler;_generalLimits;_spanLimits;_idGenerator;instrumentationScope;_resource;_spanProcessor;_tracerMetrics;constructor(t,e,n,r){const s=function(t){const e={sampler:or()},n=ir(),r=Object.assign({},n,e,t);return r.generalLimits=Object.assign({},n.generalLimits,t.generalLimits||{}),r.spanLimits=Object.assign({},n.spanLimits,t.spanLimits||{}),r}(e);this._sampler=s.sampler,this._generalLimits=s.generalLimits,this._spanLimits=s.spanLimits,this._idGenerator=e.idGenerator||new mr,this._resource=n,this._spanProcessor=r,this.instrumentationScope=t;const i=s.meterProvider?s.meterProvider.getMeter("@opentelemetry/sdk-trace","2.7.1"):O;this._tracerMetrics=new br(i)}startSpan(t,e={},n=ut.active()){e.root&&(n=Ct.deleteSpan(n));const r=Ct.getSpan(n);if(Pt(n)){lt.debug("Instrumentation suppressed, returning Noop Span");return Ct.wrapSpanContext(F)}const s=r?.spanContext(),i=this._idGenerator.generateSpanId();let o,a,c;s&&Ct.isSpanContextValid(s)?(a=s.traceId,c=s.traceState,o=s):a=this._idGenerator.generateTraceId();const u=e.kind??at.INTERNAL,l=(e.links??[]).map(t=>({context:t.context,attributes:It(t.attributes)})),d=It(e.attributes),h=this._sampler.shouldSample(n,a,t,u,d,l),p=this._tracerMetrics.startSpan(s,h.decision);c=h.traceState??c;const f={traceId:a,spanId:i,traceFlags:h.decision===ot.RECORD_AND_SAMPLED?U.SAMPLED:U.NONE,traceState:c};if(h.decision===ot.NOT_RECORD){lt.debug("Recording is off, propagating context in a non-recording span");return Ct.wrapSpanContext(f)}const g=It(Object.assign(d,h.attributes));return new Zn({resource:this._resource,scope:this.instrumentationScope,context:n,spanContext:f,name:t,kind:u,links:l,parentSpanContext:o,attributes:g,startTime:e.startTime,spanProcessor:this._spanProcessor,spanLimits:this._spanLimits,recordEndMetrics:p})}startActiveSpan(t,e,n,r){let s,i,o;if(arguments.length<2)return;2===arguments.length?o=e:3===arguments.length?(s=e,o=n):(s=e,i=n,o=r);const a=i??ut.active(),c=this.startSpan(t,s,a),u=Ct.setSpan(a,c);return ut.with(u,o,void 0,c)}getGeneralLimits(){return this._generalLimits}getSpanLimits(){return this._spanLimits}}class Tr{_spanProcessors;constructor(t){this._spanProcessors=t}forceFlush(){const t=[];for(const e of this._spanProcessors)t.push(e.forceFlush());return new Promise(e=>{Promise.all(t).then(()=>{e()}).catch(t=>{Ft(t||new Error("MultiSpanProcessor: forceFlush failed")),e()})})}onStart(t,e){for(const n of this._spanProcessors)n.onStart(t,e)}onEnding(t){for(const e of this._spanProcessors)e.onEnding&&e.onEnding(t)}onEnd(t){for(const e of this._spanProcessors)e.onEnd(t)}shutdown(){const t=[];for(const e of this._spanProcessors)t.push(e.shutdown());return new Promise((e,n)=>{Promise.all(t).then(()=>{e()},n)})}}var yr,Or;!function(t){t[t.resolved=0]="resolved",t[t.timeout=1]="timeout",t[t.error=2]="error",t[t.unresolved=3]="unresolved"}(yr||(yr={}));class Ar{_config;_tracers=new Map;_resource;_activeSpanProcessor;constructor(t={}){const e=He({},ir(),function(t){const e=Object.assign({},t.spanLimits);return e.attributeCountLimit=t.spanLimits?.attributeCountLimit??t.generalLimits?.attributeCountLimit??void 0??void 0??128,e.attributeValueLengthLimit=t.spanLimits?.attributeValueLengthLimit??t.generalLimits?.attributeValueLengthLimit??void 0??void 0??cr,Object.assign({},t,{spanLimits:e})}(t));this._resource=e.resource??Qn(),this._config=Object.assign({},e,{resource:this._resource});const n=[];t.spanProcessors?.length&&n.push(...t.spanProcessors),this._activeSpanProcessor=new Tr(n)}getTracer(t,e,n){const r=`${t}@${e||""}:${n?.schemaUrl||""}`;return this._tracers.has(r)||this._tracers.set(r,new Er({name:t,version:e,schemaUrl:n?.schemaUrl},this._config,this._resource,this._activeSpanProcessor)),this._tracers.get(r)}forceFlush(){const t=this._config.forceFlushTimeoutMillis,e=this._activeSpanProcessor._spanProcessors.map(e=>new Promise(n=>{let r;const s=setTimeout(()=>{n(new Error(`Span processor did not completed within timeout period of ${t} ms`)),r=yr.timeout},t);e.forceFlush().then(()=>{clearTimeout(s),r!==yr.timeout&&(r=yr.resolved,n(r))}).catch(t=>{clearTimeout(s),r=yr.error,n(t)})}));return new Promise((t,n)=>{Promise.all(e).then(e=>{const r=e.filter(t=>t!==yr.resolved);r.length>0?n(r):t()}).catch(t=>n([t]))})}shutdown(){return this._activeSpanProcessor.shutdown()}}class Cr{_enabled=!1;_currentContext=E;_bindFunction(t=E,e){const n=this,r=function(...r){return n.with(t,()=>e.apply(this,r))};return Object.defineProperty(r,"length",{enumerable:!1,configurable:!0,writable:!1,value:e.length}),r}active(){return this._currentContext}bind(t,e){return void 0===t&&(t=this.active()),"function"==typeof e?this._bindFunction(t,e):e}disable(){return this._currentContext=E,this._enabled=!1,this}enable(){return this._enabled||(this._enabled=!0,this._currentContext=E),this}with(t,e,n,...r){const s=this._currentContext;this._currentContext=t||E;try{return e.call(n,...r)}finally{this._currentContext=s}}}class wr extends Ar{constructor(t={}){super(t)}register(t={}){var e;Ct.setGlobalTracerProvider(this),null!==(e=t.propagator)&&(void 0!==e?yt.setGlobalPropagator(e):yt.setGlobalPropagator(new me({propagators:[new Re,new Dt]}))),function(t){if(null!==t){if(void 0===t){const t=new Cr;return t.enable(),void ut.setGlobalContextManager(t)}t.enable(),ut.setGlobalContextManager(t)}}(t.contextManager)}}!function(t){t.CONNECT_END="connectEnd",t.CONNECT_START="connectStart",t.DECODED_BODY_SIZE="decodedBodySize",t.DOM_COMPLETE="domComplete",t.DOM_CONTENT_LOADED_EVENT_END="domContentLoadedEventEnd",t.DOM_CONTENT_LOADED_EVENT_START="domContentLoadedEventStart",t.DOM_INTERACTIVE="domInteractive",t.DOMAIN_LOOKUP_END="domainLookupEnd",t.DOMAIN_LOOKUP_START="domainLookupStart",t.ENCODED_BODY_SIZE="encodedBodySize",t.FETCH_START="fetchStart",t.LOAD_EVENT_END="loadEventEnd",t.LOAD_EVENT_START="loadEventStart",t.NAVIGATION_START="navigationStart",t.REDIRECT_END="redirectEnd",t.REDIRECT_START="redirectStart",t.REQUEST_START="requestStart",t.RESPONSE_END="responseEnd",t.RESPONSE_START="responseStart",t.SECURE_CONNECTION_START="secureConnectionStart",t.START_TIME="startTime",t.UNLOAD_EVENT_END="unloadEventEnd",t.UNLOAD_EVENT_START="unloadEventStart"}(Or||(Or={}));let Rr;function Pr(t,e,n,r=!0){if(!(s=n,i=e,!(i in s)||"number"!=typeof n[e]||r&&0===n[e]))return t.addEvent(e,n[e]);var s,i}function Lr(t,e,n=!1,r,s){if(void 0===r&&(r=0!==e[Or.START_TIME]),n||(Pr(t,Or.FETCH_START,e,r),Pr(t,Or.DOMAIN_LOOKUP_START,e,r),Pr(t,Or.DOMAIN_LOOKUP_END,e,r),Pr(t,Or.CONNECT_START,e,r),Pr(t,Or.SECURE_CONNECTION_START,e,r),Pr(t,Or.CONNECT_END,e,r),Pr(t,Or.REQUEST_START,e,r),Pr(t,Or.RESPONSE_START,e,r),Pr(t,Or.RESPONSE_END,e,r)),!s){const n=e[Or.ENCODED_BODY_SIZE];void 0!==n&&t.setAttribute("http.response_content_length",n);const r=e[Or.DECODED_BODY_SIZE];void 0!==r&&n!==r&&t.setAttribute("http.response_content_length_uncompressed",r)}}function Nr(){return"undefined"!=typeof location?location.origin:void 0}function xr(t,e,n,r,s=new WeakSet,i){const o=Dr(t),a=function(t,e,n,r,s,i){const o=de(e),a=de(n);let c=r.filter(e=>{const n=de(ue(e[Or.FETCH_START])),r=de(ue(e[Or.RESPONSE_END]));return e.initiatorType.toLowerCase()===(i||"xmlhttprequest")&&e.name===t&&n>=o&&r<=a});c.length>0&&(c=c.filter(t=>!s.has(t)));return c}(t=o.toString(),e,n,r,s,i);if(0===a.length)return{mainRequest:void 0};if(1===a.length)return{mainRequest:a[0]};const c=function(t){return t.slice().sort((t,e)=>{const n=t[Or.FETCH_START],r=e[Or.FETCH_START];return n>r?1:n<r?-1:0})}(a);if(o.origin!==Nr()&&c.length>1){let t=c[0],e=function(t,e,n){const r=de(n),s=de(ue(e));let i,o=t[1];const a=t.length;for(let e=1;e<a;e++){const n=t[e],a=de(ue(n[Or.FETCH_START])),c=r-de(ue(n[Or.RESPONSE_END]));a>=s&&(!i||c<i)&&(i=c,o=n)}return o}(c,t[Or.RESPONSE_END],n);const r=t[Or.RESPONSE_END];return e[Or.FETCH_START]<r&&(e=t,t=void 0),{corsPreFlightRequest:t,mainRequest:e}}return{mainRequest:a[0]}}function Dr(t){if("function"==typeof URL)return new URL(t,"undefined"!=typeof document?document.baseURI:"undefined"!=typeof location?location.href:void 0);const e=(Rr||(Rr=document.createElement("a")),Rr);return e.href=t,e}function Ir(t,e){let n=e||[];("string"==typeof n||n instanceof RegExp)&&(n=[n]);return Dr(t).origin===Nr()||n.some(e=>Qe(t,e))}var kr;!function(t){t.COMPONENT="component",t.HTTP_STATUS_TEXT="http.status_text"}(kr||(kr={}));const Mr=lt.createComponentLogger({namespace:"@opentelemetry/opentelemetry-instrumentation-fetch/utils"});function Ur(...t){if(t[0]instanceof URL||"string"==typeof t[0]){const e=t[1];if(!e?.body)return Promise.resolve();if(e.body instanceof ReadableStream){const{body:t,length:n}=function(t){if(!t.pipeThrough)return Mr.warn("Platform has ReadableStream but not pipeThrough!"),{body:t,length:Promise.resolve(void 0)};let e,n=0;const r=new Promise(t=>{e=t}),s=new TransformStream({start(){},async transform(t,e){const r=await t;n+=r.byteLength,e.enqueue(t)},flush(){e(n)}});return{body:t.pipeThrough(s),length:r}}(e.body);return e.body=t,n}return Promise.resolve(function(t){if(e=t,"undefined"!=typeof Document&&e instanceof Document)return(new XMLSerializer).serializeToString(document).length;var e;if("string"==typeof t)return Br(t);if(t instanceof Blob)return t.size;if(t instanceof FormData)return function(t){let e=0;for(const[n,r]of t.entries())e+=n.length,r instanceof Blob?e+=r.size:e+=r.length;return e}(t);if(t instanceof URLSearchParams)return Br(t.toString());if(void 0!==t.byteLength)return t.byteLength;return void Mr.warn("unknown body type")}(e.body))}{const e=t[0];return e?.body?e.clone().text().then(t=>Br(t)):Promise.resolve()}}const jr=new TextEncoder;function Br(t){return jr.encode(t).byteLength}function Fr(t){const e=function(){void 0===$r&&($r=Hr);return $r}(),n=t.toUpperCase();return n in e?n:"_OTHER"}const Hr={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0};let $r;const Vr={"https:":"443","http:":"80"};const zr="0.216.0",qr="undefined"!=typeof PerformanceObserver;class Gr extends Hn{component="fetch";version=zr;moduleName=this.component;_usedResources=new WeakSet;_tasksCount=0;_semconvStability;constructor(t={}){super("@opentelemetry/instrumentation-fetch",zr,t),this._semconvStability=zn("http",t?.semconvStabilityOptIn)}init(){}_addChildSpan(t,e){const n=this.tracer.startSpan("CORS Preflight",{startTime:e[Or.FETCH_START]},Ct.setSpan(ut.active(),t)),r=!(this._semconvStability&Vn.OLD);Lr(n,e,this.getConfig().ignoreNetworkEvents,void 0,r),n.end(e[Or.RESPONSE_END])}_addFinalSpanAttributes(t,e){const n=Dr(e.url);if(this._semconvStability&Vn.OLD&&(t.setAttribute("http.status_code",e.status),null!=e.statusText&&t.setAttribute(kr.HTTP_STATUS_TEXT,e.statusText),t.setAttribute("http.host",n.host),t.setAttribute("http.scheme",n.protocol.replace(":","")),"undefined"!=typeof navigator&&t.setAttribute("http.user_agent",navigator.userAgent)),this._semconvStability&Vn.STABLE){t.setAttribute(Wt,e.status),t.setAttribute(Xt,n.hostname);const r=function(t){const e=Number(t.port||Vr[t.protocol]);return e&&!isNaN(e)?e:void 0}(n);r&&t.setAttribute(Qt,r)}}_addHeaders(t,e){if(!Ir(e,this.getConfig().propagateTraceHeaderCorsUrls)){const t={};return yt.inject(ut.active(),t),void(Object.keys(t).length>0&&this._diag.debug("headers inject skipped due to CORS policy"))}if(t instanceof Request)yt.inject(ut.active(),t.headers,{set:(t,e,n)=>t.set(e,"string"==typeof n?n:String(n))});else{const e=new Headers(t.headers);yt.inject(ut.active(),e,{set:(t,e,n)=>t.set(e,"string"==typeof n?n:String(n))}),t.headers=e}}_clearResources(){0===this._tasksCount&&this.getConfig().clearTimingResources&&(performance.clearResourceTimings(),this._usedResources=new WeakSet)}_createSpan(t,e={}){if(Ye(t,this.getConfig().ignoreUrls))return void this._diag.debug("ignoring span as url matches ignored url");let n="";const r={};if(this._semconvStability&Vn.OLD){const s=(e.method||"GET").toUpperCase();n=`HTTP ${s}`,r[kr.COMPONENT]=this.moduleName,r["http.method"]=s,r["http.url"]=t}if(this._semconvStability&Vn.STABLE){const s=e.method,i=Fr(e.method||"GET");n||(n=i),r[Gt]=i,i!==s&&(r[Kt]=s),r[ee]=t}return this.tracer.startSpan(n,{kind:at.CLIENT,attributes:r})}_findResourceAndAddNetworkEvents(t,e,n){let r=e.entries;if(!r.length){if(!performance.getEntriesByType)return;r=performance.getEntriesByType("resource")}const s=xr(e.spanUrl,e.startTime,n,r,this._usedResources,"fetch");if(s.mainRequest){const e=s.mainRequest;this._markResourceAsUsed(e);const n=s.corsPreFlightRequest;n&&(this._addChildSpan(t,n),this._markResourceAsUsed(n));const r=!(this._semconvStability&Vn.OLD);Lr(t,e,this.getConfig().ignoreNetworkEvents,void 0,r)}}_markResourceAsUsed(t){this._usedResources.add(t)}_endSpan(t,e,n){const r=ae(Date.now()),s=ce();this._addFinalSpanAttributes(t,n),this._semconvStability&Vn.STABLE&&n.status>=400&&(t.setStatus({code:ct.ERROR}),t.setAttribute(Vt,String(n.status))),setTimeout(()=>{e.observer?.disconnect(),this._findResourceAndAddNetworkEvents(t,e,s),this._tasksCount--,this._clearResources(),t.end(r)},300)}_patchConstructor(){return t=>{const e=this;return function(...n){if(!e._isEnabled)return t.apply(this,n);const r=this,s=Dr(n[0]instanceof Request?n[0].url:String(n[0])).href;let i;i=n[0]instanceof Request?null!=n[1]?new Request(n[0],n[1]):n[0]:n[1]||{};const o=e._createSpan(s,i);if(!o)return t.apply(this,n);const a=e._prepareSpanData(s);function c(t,n){e._applyAttributesAfterFetch(t,i,n),e._endSpan(t,a,{status:n.status||0,statusText:n.message,url:s})}function u(t,n){e._applyAttributesAfterFetch(t,i,n),n.status>=200&&n.status<400?e._endSpan(t,a,n):e._endSpan(t,a,{status:n.status,statusText:n.statusText,url:s})}function l(t,n){try{const e=n.clone().body;if(e){const r=e.getReader(),s=()=>{r.read().then(({done:e})=>{e?u(t,n):s()},e=>{c(t,e)})};s()}else u(t,n)}catch(n){e._diag.error("Failed to read fetch response body",n),e._endSpan(t,a,{status:0,url:s})}return n}function d(t,n){try{c(t,n)}catch(r){e._diag.error("Failed to end span on fetch error",r),e._endSpan(t,a,{status:n.status||0,url:s})}throw n}return e.getConfig().measureRequestSize&&Ur(...n).then(t=>{t&&(e._semconvStability&Vn.OLD&&o.setAttribute("http.request_content_length_uncompressed",t),e._semconvStability&Vn.STABLE&&o.setAttribute("http.request.body.size",t))}).catch(t=>{e._diag.warn("getFetchBodyLength",t)}),ut.with(Ct.setSpan(ut.active(),o),()=>(e._callRequestHook(o,i),e._addHeaders(i,s),e._tasksCount++,t.apply(r,i instanceof Request?[i]:[s,i]).then(l.bind(r,o),d.bind(r,o))))}}}_applyAttributesAfterFetch(t,e,n){const r=this.getConfig().applyCustomAttributesOnSpan;r&&$n(()=>r(t,e,n),t=>{t&&this._diag.error("applyCustomAttributesOnSpan",t)})}_callRequestHook(t,e){const n=this.getConfig().requestHook;n&&$n(()=>n(t,e),t=>{t&&this._diag.error("requestHook",t)})}_prepareSpanData(t){const e=ce(),n=[];if("function"!=typeof PerformanceObserver)return{entries:n,startTime:e,spanUrl:t};const r=new PerformanceObserver(e=>{e.getEntries().forEach(e=>{"fetch"===e.initiatorType&&e.name===t&&n.push(e)})});return r.observe({entryTypes:["resource"]}),{entries:n,observer:r,startTime:e,spanUrl:t}}enable(){if(qr){if(!this._isEnabled){if(this._isFetchPatched)return this._diag.debug("fetch constructor already patched"),void(this._isEnabled=!0);try{this._wrap(globalThis,"fetch",this._patchConstructor()),this._isFetchPatched=!0,this._isEnabled=!0}catch(t){this._diag.warn("Failed to patch globalThis.fetch; instrumentation will not be enabled. Another script may have locked globalThis.fetch via Object.defineProperty.",t)}}}else this._diag.warn("this instrumentation is intended for web usage only, it does not instrument server-side fetch()")}disable(){qr&&this._isEnabled&&(this._isEnabled=!1,this._usedResources=new WeakSet)}}var Kr;!function(t){t.METHOD_OPEN="open",t.METHOD_SEND="send",t.EVENT_ABORT="abort",t.EVENT_ERROR="error",t.EVENT_LOAD="loaded",t.EVENT_TIMEOUT="timeout"}(Kr||(Kr={}));const Wr=lt.createComponentLogger({namespace:"@opentelemetry/opentelemetry-instrumentation-xml-http-request/utils"});function Xr(t){return e=t,"undefined"!=typeof Document&&e instanceof Document?(new XMLSerializer).serializeToString(document).length:"string"==typeof t?Yr(t):t instanceof Blob?t.size:t instanceof FormData?function(t){let e=0;for(const[n,r]of t.entries())e+=n.length,r instanceof Blob?e+=r.size:e+=r.length;return e}(t):t instanceof URLSearchParams?Yr(t.toString()):void 0!==t.byteLength?t.byteLength:void Wr.warn("unknown body type");var e}const Qr=new TextEncoder;function Yr(t){return Qr.encode(t).byteLength}const Zr={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0};let Jr;function ts(){return void 0===Jr&&(Jr=Zr),Jr}const es={"https:":"443","http:":"80"};const ns="0.216.0";var rs;!function(t){t.HTTP_STATUS_TEXT="http.status_text"}(rs||(rs={}));class ss extends Hn{component="xml-http-request";version=ns;moduleName=this.component;_tasksCount=0;_xhrMem=new WeakMap;_usedResources=new WeakSet;_semconvStability;constructor(t={}){super("@opentelemetry/instrumentation-xml-http-request",ns,t),this._semconvStability=zn("http",t?.semconvStabilityOptIn)}init(){}_addHeaders(t,e){if(!Ir(Dr(e).href,this.getConfig().propagateTraceHeaderCorsUrls)){const t={};return yt.inject(ut.active(),t),void(Object.keys(t).length>0&&this._diag.debug("headers inject skipped due to CORS policy"))}const n={};yt.inject(ut.active(),n),Object.keys(n).forEach(e=>{t.setRequestHeader(e,String(n[e]))})}_addChildSpan(t,e){ut.with(Ct.setSpan(ut.active(),t),()=>{const t=this.tracer.startSpan("CORS Preflight",{startTime:e[Or.FETCH_START]}),n=!(this._semconvStability&Vn.OLD);Lr(t,e,this.getConfig().ignoreNetworkEvents,void 0,n),t.end(e[Or.RESPONSE_END])})}_addFinalSpanAttributes(t,e,n){if(this._semconvStability&Vn.OLD){if(void 0!==e.status&&t.setAttribute("http.status_code",e.status),void 0!==e.statusText&&t.setAttribute(rs.HTTP_STATUS_TEXT,e.statusText),"string"==typeof n){const e=Dr(n);t.setAttribute("http.host",e.host),t.setAttribute("http.scheme",e.protocol.replace(":",""))}t.setAttribute("http.user_agent",navigator.userAgent)}this._semconvStability&Vn.STABLE&&e.status&&t.setAttribute(Wt,e.status)}_applyAttributesAfterXHR(t,e){const n=this.getConfig().applyCustomAttributesOnSpan;"function"==typeof n&&$n(()=>n(t,e),t=>{t&&this._diag.error("applyCustomAttributesOnSpan",t)})}_addResourceObserver(t,e){const n=this._xhrMem.get(t);n&&"function"==typeof PerformanceObserver&&"function"==typeof PerformanceResourceTiming&&(n.createdResources={observer:new PerformanceObserver(t=>{const r=t.getEntries(),s=Dr(e);r.forEach(t=>{"xmlhttprequest"===t.initiatorType&&t.name===s.href&&n.createdResources&&n.createdResources.entries.push(t)})}),entries:[]},n.createdResources.observer.observe({entryTypes:["resource"]}))}_clearResources(){0===this._tasksCount&&this.getConfig().clearTimingResources&&(se.clearResourceTimings(),this._xhrMem=new WeakMap,this._usedResources=new WeakSet)}_findResourceAndAddNetworkEvents(t,e,n,r,s){if(!(n&&r&&s&&t.createdResources))return;let i=t.createdResources.entries;i&&i.length||(i=se.getEntriesByType("resource"));const o=xr(Dr(n).href,r,s,i,this._usedResources);if(o.mainRequest){const t=o.mainRequest;this._markResourceAsUsed(t);const n=o.corsPreFlightRequest;n&&(this._addChildSpan(e,n),this._markResourceAsUsed(n));const r=!(this._semconvStability&Vn.OLD);Lr(e,t,this.getConfig().ignoreNetworkEvents,void 0,r)}}_cleanPreviousSpanInformation(t){const e=this._xhrMem.get(t);if(e){const n=e.callbackToRemoveEvents;n&&n(),this._xhrMem.delete(t)}}_createSpan(t,e,n){const r=Dr(e);if(Ye(r.href,this.getConfig().ignoreUrls))return void this._diag.debug("ignoring span as url matches ignored url");let s="";const i={};if(this._semconvStability&Vn.OLD&&(s=n.toUpperCase(),i["http.method"]=n,i["http.url"]=r.toString()),this._semconvStability&Vn.STABLE){const t=n,e=function(t){const e=ts(),n=t.toUpperCase();return n in e?n:"_OTHER"}(n);s||(s=e),i[Gt]=e,e!==t&&(i[Kt]=t),i[ee]=r.toString(),i[Xt]=r.hostname;const o=function(t){const e=Number(t.port||es[t.protocol]);return e&&!isNaN(e)?e:void 0}(r);o&&(i[Qt]=o)}const o=this.tracer.startSpan(s,{kind:at.CLIENT,attributes:i});return o.addEvent(Kr.METHOD_OPEN),this._cleanPreviousSpanInformation(t),this._xhrMem.set(t,{span:o,spanUrl:e}),o}_markResourceAsUsed(t){this._usedResources.add(t)}_patchOpen(){return t=>{const e=this;return function(...n){if(!e._isEnabled)return t.apply(this,n);const r=n[0],s=n[1];return e._createSpan(this,s,r),t.apply(this,n)}}}_patchSend(){const t=this;function e(e,n,r,s){const i=t._xhrMem.get(n);if(!i)return;if(i.status=n.status,i.statusText=n.statusText,t._xhrMem.delete(n),i.span){const e=i.span;t._applyAttributesAfterXHR(e,n),t._semconvStability&Vn.STABLE&&(r?s&&(e.setStatus({code:ct.ERROR,message:s}),e.setAttribute(Vt,s)):i.status&&i.status>=400&&(e.setStatus({code:ct.ERROR}),e.setAttribute(Vt,String(i.status))))}const o=ce(),a=Date.now();setTimeout(()=>{!function(e,n,r,s){const i=n.callbackToRemoveEvents;"function"==typeof i&&i();const{span:o,spanUrl:a,sendStartTime:c}=n;o&&(t._findResourceAndAddNetworkEvents(n,o,a,c,r),o.addEvent(e,s),t._addFinalSpanAttributes(o,n,a),o.end(s),t._tasksCount--),t._clearResources()}(e,i,o,a)},300)}function n(){e(Kr.EVENT_ERROR,this,!0,"error")}function r(){e(Kr.EVENT_ABORT,this,!1)}function s(){e(Kr.EVENT_TIMEOUT,this,!0,"timeout")}function i(){this.status<299?e(Kr.EVENT_LOAD,this,!1):e(Kr.EVENT_ERROR,this,!1)}return e=>function(...o){if(!t._isEnabled)return e.apply(this,o);const a=t._xhrMem.get(this);if(!a)return e.apply(this,o);const c=a.span,u=a.spanUrl;if(c&&u){if(t.getConfig().measureRequestSize&&o?.[0]){const e=Xr(o[0]);void 0!==e&&(t._semconvStability&Vn.OLD&&c.setAttribute("http.request_content_length_uncompressed",e),t._semconvStability&Vn.STABLE&&c.setAttribute("http.request.body.size",e))}ut.with(Ct.setSpan(ut.active(),c),()=>{t._tasksCount++,a.sendStartTime=ce(),c.addEvent(Kr.METHOD_SEND),this.addEventListener("abort",r),this.addEventListener("error",n),this.addEventListener("load",i),this.addEventListener("timeout",s),a.callbackToRemoveEvents=()=>{!function(e){e.removeEventListener("abort",r),e.removeEventListener("error",n),e.removeEventListener("load",i),e.removeEventListener("timeout",s);const o=t._xhrMem.get(e);o&&(o.callbackToRemoveEvents=void 0)}(this),a.createdResources&&a.createdResources.observer.disconnect()},t._addHeaders(this,u),t._addResourceObserver(this,u)})}return e.apply(this,o)}}enable(){if(!this._isEnabled){if(this._isXhrPatched)return this._diag.debug("reactivating existing patch on",this.moduleName,this.version),void(this._isEnabled=!0);try{this._diag.debug("applying patch to",this.moduleName,this.version),this._wrap(XMLHttpRequest.prototype,"open",this._patchOpen()),this._wrap(XMLHttpRequest.prototype,"send",this._patchSend()),this._isXhrPatched=!0,this._isEnabled=!0}catch(t){this._unwrap(XMLHttpRequest.prototype,"open"),this._unwrap(XMLHttpRequest.prototype,"send"),this._diag.warn("Failed to patch globalThis.XMLHttpRequest; instrumentation will not be enabled. Another script may have locked globalThis.XMLHttpRequest via Object.defineProperty.",t)}}}disable(){this._isEnabled&&(this._isEnabled=!1,this._tasksCount=0,this._xhrMem=new WeakMap,this._usedResources=new WeakSet)}}class is extends ss{constructor(t={}){super(t);this.parentCreateSpan=this._createSpan.bind(this)}_patchOpen(){return t=>{const n=this;return function(...r){let s;try{const t=r[0];let i=e.getUrlFromResource(r[1]);s=n.parentCreateSpan(this,i,t)}catch(t){e.faro.internalLogger.error(t)}const i=e.faro.api.getActiveUserAction();return s&&i&&(null==i?void 0:i.getState())===e.UserActionState.Started&&(s.setAttribute("faro.action.user.name",i.name),s.setAttribute("faro.action.user.parentId",i.parentId)),t.apply(this,r)}}}}function os(t,e,n){as(t,n instanceof Error?0:n.status)}function as(t,e){if(null==e)return;(0===e||e>=400&&e<600)&&t.setStatus({code:ct.ERROR})}function cs(t){return(e,n,r)=>{os(e,0,r),null==t||t(e,n,r)}}function us(t){return(e,n)=>{!function(t,e){as(t,e.status)}(e,n),null==t||t(e,n)}}function ls(t={}){const{fetchInstrumentationOptions:n,xhrInstrumentationOptions:r}=t,s=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]])}return n}(t,["fetchInstrumentationOptions","xhrInstrumentationOptions"]),i=function(t,n){return Object.assign(Object.assign(Object.assign(Object.assign({},n),{ignoreNetworkEvents:!0}),t),{applyCustomAttributesOnSpan:cs(null==t?void 0:t.applyCustomAttributesOnSpan),requestHook:(t,n)=>{const r=e.faro.api.getActiveUserAction();r&&(null==r?void 0:r.getState())===e.UserActionState.Started&&(t.setAttribute("faro.action.user.name",r.name),t.setAttribute("faro.action.user.parentId",r.parentId))}})}(n,s),o=function(t,e){return Object.assign(Object.assign(Object.assign(Object.assign({},e),{ignoreNetworkEvents:!0}),t),{applyCustomAttributesOnSpan:us(null==t?void 0:t.applyCustomAttributesOnSpan)})}(r,s);return[new Gr(i),new is(o)]}class ds{constructor(t,e){this.processor=t,this.metas=e}forceFlush(){return this.processor.forceFlush()}onStart(t,e){var n;const r=this.metas.value.session;(null==r?void 0:r.id)&&(t.attributes["session.id"]=r.id);const s=null!==(n=this.metas.value.user)&&void 0!==n?n:{};s.email&&(t.attributes["user.email"]=s.email),s.id&&(t.attributes["user.id"]=s.id),s.username&&(t.attributes["user.name"]=s.username),s.fullName&&(t.attributes["user.full_name"]=s.fullName),s.roles&&(t.attributes["user.roles"]=s.roles.split(",").map(t=>t.trim())),s.hash&&(t.attributes["user.hash"]=s.hash),this.processor.onStart(t,e)}onEnd(t){this.processor.onEnd(t)}shutdown(){return this.processor.shutdown()}}function hs(t={}){var e;return"true"===(null===(e=t.attributes)||void 0===e?void 0:e.isSampled)?Jn.RECORD_AND_SAMPLED:Jn.NOT_RECORD}class ps extends e.BaseInstrumentation{constructor(t={}){super(),this.options=t,this.name="@grafana/faro-web-tracing",this.version=e.VERSION}initialize(){var t,n,r,s,i;const o=this.options,a={};this.config.app.name&&(a[Yt]=this.config.app.name),this.config.app.namespace&&(a["service.namespace"]=this.config.app.namespace),this.config.app.version&&(a["service.version"]=this.config.app.version),this.config.app.environment&&(a["deployment.environment.name"]=this.config.app.environment,a["deployment.environment"]=this.config.app.environment);const c=this.metas.value.browser;e.isArray(null==c?void 0:c.brands)&&(a["browser.brands"]=c.brands.map(t=>t.brand)),(null==c?void 0:c.language)&&(a["browser.language"]=c.language),"boolean"==typeof(null==c?void 0:c.mobile)&&(a["browser.mobile"]=Boolean(c.mobile)),(null==c?void 0:c.os)&&(a["browser.platform"]=c.os),(null==c?void 0:c.userAgent)&&(a["user_agent.original"]=c.userAgent),a["process.runtime.name"]="browser",a["process.runtime.version"]=null===(t=this.metas.value.browser)||void 0===t?void 0:t.userAgent,a["telemetry.distro.name"]="faro-web-sdk",a["telemetry.distro.version"]=e.VERSION,Object.assign(a,o.resourceAttributes);const u=Qn().merge(Xn(a));new wr({resource:u,sampler:{shouldSample:()=>({decision:hs(this.api.getSession())})},spanProcessors:[null!==(n=o.spanProcessor)&&void 0!==n?n:new ds(new lr(new On({api:this.api}),{scheduledDelayMillis:ps.SCHEDULED_BATCH_DELAY_MS,maxExportBatchSize:30}),this.metas)]}).register({propagator:null!==(r=o.propagator)&&void 0!==r?r:new Re,contextManager:o.contextManager});const{propagateTraceHeaderCorsUrls:l,fetchInstrumentationOptions:d,xhrInstrumentationOptions:h}=null!==(s=this.options.instrumentationOptions)&&void 0!==s?s:{};!function(t){const e=t.tracerProvider||Ct.getTracerProvider(),n=t.meterProvider||ft.getMeterProvider(),r=t.loggerProvider||Dn.getLoggerProvider(),s=t.instrumentations?.flat()??[];(function(t,e,n,r){for(let s=0,i=t.length;s<i;s++){const i=t[s];e&&i.setTracerProvider(e),n&&i.setMeterProvider(n),r&&i.setLoggerProvider&&i.setLoggerProvider(r),i.getConfig().enabled||i.enable()}})(s,e,n,r)}({instrumentations:null!==(i=o.instrumentations)&&void 0!==i?i:ls({ignoreUrls:this.getIgnoreUrls(),propagateTraceHeaderCorsUrls:l,fetchInstrumentationOptions:d,xhrInstrumentationOptions:h})}),this.api.initOTEL(Ct,ut)}getIgnoreUrls(){return this.transports.transports.flatMap(t=>t.getIgnoreUrls())}}ps.SCHEDULED_BATCH_DELAY_MS=1e3;return t.FaroMetaAttributesSpanProcessor=ds,t.FaroTraceExporter=On,t.FaroUserActionSpanProcessor=class{constructor(t){this.processor=t}forceFlush(){return this.processor.forceFlush()}onStart(t,n){const r=e.faro.api.getActiveUserAction();r&&(null==r?void 0:r.getState())===e.UserActionState.Started&&t.kind===at.CLIENT&&(t.attributes["faro.action.user.name"]||(t.attributes["faro.action.user.name"]=null==r?void 0:r.name),t.attributes["faro.action.user.parentId"]||(t.attributes["faro.action.user.parentId"]=null==r?void 0:r.parentId)),this.processor.onStart(t,n)}onEnd(t){this.processor.onEnd(t)}shutdown(){return this.processor.shutdown()}},t.TracingInstrumentation=ps,t.fetchCustomAttributeFunctionWithDefaults=cs,t.getDefaultOTELInstrumentations=ls,t.getSamplingDecision=hs,t.setSpanStatusOnFetchError=os,t}({},GrafanaFaroWebSdk);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/faro-web-tracing",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "Faro web tracing implementation.",
5
5
  "keywords": [
6
6
  "observability",
@@ -55,14 +55,14 @@
55
55
  "quality:circular-deps": "madge --circular ."
56
56
  },
57
57
  "dependencies": {
58
- "@grafana/faro-web-sdk": "^2.4.0",
58
+ "@grafana/faro-web-sdk": "^2.5.0",
59
59
  "@opentelemetry/api": "^1.9.0",
60
60
  "@opentelemetry/core": "^2.0.0",
61
- "@opentelemetry/exporter-trace-otlp-http": "^0.215.0",
62
- "@opentelemetry/instrumentation": "^0.215.0",
63
- "@opentelemetry/instrumentation-fetch": "^0.215.0",
64
- "@opentelemetry/instrumentation-xml-http-request": "^0.215.0",
65
- "@opentelemetry/otlp-transformer": "^0.215.0",
61
+ "@opentelemetry/exporter-trace-otlp-http": "^0.216.0",
62
+ "@opentelemetry/instrumentation": "^0.216.0",
63
+ "@opentelemetry/instrumentation-fetch": "^0.216.0",
64
+ "@opentelemetry/instrumentation-xml-http-request": "^0.216.0",
65
+ "@opentelemetry/otlp-transformer": "^0.216.0",
66
66
  "@opentelemetry/resources": "^2.0.0",
67
67
  "@opentelemetry/sdk-trace-web": "^2.0.0",
68
68
  "@opentelemetry/semantic-conventions": "^1.32.0"
@@ -70,5 +70,5 @@
70
70
  "publishConfig": {
71
71
  "access": "public"
72
72
  },
73
- "gitHead": "0dcca81629cfc20cb18c6a7306209dceccdc75c8"
73
+ "gitHead": "be7742480b1b4d936f3476620aab338237ae16ca"
74
74
  }