@grafana/faro-web-tracing
Version:
Faro web tracing implementation.
1 lines • 82.3 kB
JavaScript
var GrafanaFaroWebTracing=function(t,e){"use strict";var n="object"==typeof globalThis?globalThis:"object"==typeof self?self:"object"==typeof window?window:"object"==typeof global?global:{},r="1.9.0",o=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;var i=function(t){var e=new Set([t]),n=new Set,r=t.match(o);if(!r)return function(){return!1};var i=+r[1],s=+r[2],a=+r[3];if(null!=r[4])return function(e){return e===t};function u(t){return n.add(t),!1}function c(t){return e.add(t),!0}return function(t){if(e.has(t))return!0;if(n.has(t))return!1;var r=t.match(o);if(!r)return u(t);var l=+r[1],p=+r[2],d=+r[3];return null!=r[4]||i!==l?u(t):0===i?s===p&&a<=d?c(t):u(t):s<=p?c(t):u(t)}}(r),s=r.split(".")[0],a=Symbol.for("opentelemetry.js.api."+s),u=n;function c(t,e,n,o){var i;void 0===o&&(o=!1);var s=u[a]=null!==(i=u[a])&&void 0!==i?i:{version:r};if(!o&&s[t]){var c=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return n.error(c.stack||c.message),!1}if(s.version!==r){c=new Error("@opentelemetry/api: Registration of version v"+s.version+" for "+t+" does not match previously registered API v"+r);return n.error(c.stack||c.message),!1}return s[t]=e,n.debug("@opentelemetry/api: Registered a global for "+t+" v"+r+"."),!0}function l(t){var e,n,r=null===(e=u[a])||void 0===e?void 0:e.version;if(r&&i(r))return null===(n=u[a])||void 0===n?void 0:n[t]}function p(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+r+".");var n=u[a];n&&delete n[t]}var d,h=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},f=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))},_=function(){function t(t){this._namespace=t.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return g("debug",this._namespace,t)},t.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return g("error",this._namespace,t)},t.prototype.info=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return g("info",this._namespace,t)},t.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return g("warn",this._namespace,t)},t.prototype.verbose=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return g("verbose",this._namespace,t)},t}();function g(t,e,n){var r=l("diag");if(r)return n.unshift(e),r[t].apply(r,f([],h(n),!1))}!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"}(d||(d={}));var m=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},S=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))},v=function(){function t(){function t(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=l("diag");if(r)return r[t].apply(r,S([],m(e),!1))}}var e=this;e.setLogger=function(t,n){var r,o,i;if(void 0===n&&(n={logLevel:d.INFO}),t===e){var s=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=s.stack)&&void 0!==r?r:s.message),!1}"number"==typeof n&&(n={logLevel:n});var a=l("diag"),u=function(t,e){function n(n,r){var o=e[n];return"function"==typeof o&&t>=r?o.bind(e):function(){}}return t<d.NONE?t=d.NONE:t>d.ALL&&(t=d.ALL),e=e||{},{error:n("error",d.ERROR),warn:n("warn",d.WARN),info:n("info",d.INFO),debug:n("debug",d.DEBUG),verbose:n("verbose",d.VERBOSE)}}(null!==(o=n.logLevel)&&void 0!==o?o:d.INFO,t);if(a&&!n.suppressOverrideMessage){var p=null!==(i=(new Error).stack)&&void 0!==i?i:"<failed to generate stacktrace>";a.warn("Current logger will be overwritten from "+p),u.warn("Current logger will overwrite one already registered from "+p)}return c("diag",u,e,!0)},e.disable=function(){p("diag",e)},e.createComponentLogger=function(t){return new _(t)},e.verbose=t("verbose"),e.debug=t("debug"),e.info=t("info"),e.warn=t("warn"),e.error=t("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t}(),T=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},y=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},b=function(){function t(t){this._entries=t?new Map(t):new Map}return t.prototype.getEntry=function(t){var e=this._entries.get(t);if(e)return Object.assign({},e)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map((function(t){var e=T(t,2);return[e[0],e[1]]}))},t.prototype.setEntry=function(e,n){var r=new t(this._entries);return r._entries.set(e,n),r},t.prototype.removeEntry=function(e){var n=new t(this._entries);return n._entries.delete(e),n},t.prototype.removeEntries=function(){for(var e,n,r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];var i=new t(this._entries);try{for(var s=y(r),a=s.next();!a.done;a=s.next()){var u=a.value;i._entries.delete(u)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(e)throw e.error}}return i},t.prototype.clear=function(){return new t},t}(),E=Symbol("BaggageEntryMetadata"),A=v.instance();function O(t){return void 0===t&&(t={}),new b(new Map(Object.entries(t)))}function C(t){return Symbol.for(t)}var w,R,N=function t(e){var n=this;n._currentContext=e?new Map(e):new Map,n.getValue=function(t){return n._currentContext.get(t)},n.setValue=function(e,r){var o=new t(n._currentContext);return o._currentContext.set(e,r),o},n.deleteValue=function(e){var r=new t(n._currentContext);return r._currentContext.delete(e),r}},P=new N,L=(w=function(t,e){return w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},w(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}w(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),x=function(){function t(){}return t.prototype.createGauge=function(t,e){return z},t.prototype.createHistogram=function(t,e){return q},t.prototype.createCounter=function(t,e){return $},t.prototype.createUpDownCounter=function(t,e){return G},t.prototype.createObservableGauge=function(t,e){return W},t.prototype.createObservableCounter=function(t,e){return K},t.prototype.createObservableUpDownCounter=function(t,e){return Q},t.prototype.addBatchObservableCallback=function(t,e){},t.prototype.removeBatchObservableCallback=function(t){},t}(),D=function(){},I=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return L(e,t),e.prototype.add=function(t,e){},e}(D),M=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return L(e,t),e.prototype.add=function(t,e){},e}(D),k=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return L(e,t),e.prototype.record=function(t,e){},e}(D),U=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return L(e,t),e.prototype.record=function(t,e){},e}(D),j=function(){function t(){}return t.prototype.addCallback=function(t){},t.prototype.removeCallback=function(t){},t}(),H=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return L(e,t),e}(j),B=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return L(e,t),e}(j),F=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return L(e,t),e}(j),V=new x,$=new I,z=new k,q=new U,G=new M,K=new H,W=new B,Q=new F,X={get:function(t,e){if(null!=t)return t[e]},keys:function(t){return null==t?[]:Object.keys(t)}},Y={set:function(t,e,n){null!=t&&(t[e]=n)}},Z=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},J=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))},tt=function(){function t(){}return t.prototype.active=function(){return P},t.prototype.with=function(t,e,n){for(var r=[],o=3;o<arguments.length;o++)r[o-3]=arguments[o];return e.call.apply(e,J([n],Z(r),!1))},t.prototype.bind=function(t,e){return e},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t}(),et=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},nt=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))},rt="context",ot=new tt,it=function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(t){return c(rt,t,v.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(t,e,n){for(var r,o=[],i=3;i<arguments.length;i++)o[i-3]=arguments[i];return(r=this._getContextManager()).with.apply(r,nt([t,e,n],et(o),!1))},t.prototype.bind=function(t,e){return this._getContextManager().bind(t,e)},t.prototype._getContextManager=function(){return l(rt)||ot},t.prototype.disable=function(){this._getContextManager().disable(),p(rt,v.instance())},t}();!function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"}(R||(R={}));var st="0000000000000000",at="00000000000000000000000000000000",ut={traceId:at,spanId:st,traceFlags:R.NONE},ct=function(){function t(t){void 0===t&&(t=ut),this._spanContext=t}return t.prototype.spanContext=function(){return this._spanContext},t.prototype.setAttribute=function(t,e){return this},t.prototype.setAttributes=function(t){return this},t.prototype.addEvent=function(t,e){return this},t.prototype.addLink=function(t){return this},t.prototype.addLinks=function(t){return this},t.prototype.setStatus=function(t){return this},t.prototype.updateName=function(t){return this},t.prototype.end=function(t){},t.prototype.isRecording=function(){return!1},t.prototype.recordException=function(t,e){},t}(),lt=C("OpenTelemetry Context Key SPAN");function pt(t){return t.getValue(lt)||void 0}function dt(){return pt(it.getInstance().active())}function ht(t,e){return t.setValue(lt,e)}function ft(t){return t.deleteValue(lt)}function _t(t,e){return ht(t,new ct(e))}function gt(t){var e;return null===(e=pt(t))||void 0===e?void 0:e.spanContext()}var mt=/^([0-9a-f]{32})$/i,St=/^[0-9a-f]{16}$/i;function vt(t){return mt.test(t)&&t!==at}function Tt(t){return vt(t.traceId)&&(e=t.spanId,St.test(e)&&e!==st);var e}function yt(t){return new ct(t)}var bt=it.getInstance(),Et=function(){function t(){}return t.prototype.startSpan=function(t,e,n){if(void 0===n&&(n=bt.active()),Boolean(null==e?void 0:e.root))return new ct;var r,o=n&>(n);return"object"==typeof(r=o)&&"string"==typeof r.spanId&&"string"==typeof r.traceId&&"number"==typeof r.traceFlags&&Tt(o)?new ct(o):new ct},t.prototype.startActiveSpan=function(t,e,n,r){var o,i,s;if(!(arguments.length<2)){2===arguments.length?s=e:3===arguments.length?(o=e,s=n):(o=e,i=n,s=r);var a=null!=i?i:bt.active(),u=this.startSpan(t,o,a),c=ht(a,u);return bt.with(c,s,void 0,u)}},t}();var At,Ot,Ct,wt=new Et,Rt=function(){function t(t,e,n,r){this._provider=t,this.name=e,this.version=n,this.options=r}return t.prototype.startSpan=function(t,e,n){return this._getTracer().startSpan(t,e,n)},t.prototype.startActiveSpan=function(t,e,n,r){var o=this._getTracer();return Reflect.apply(o.startActiveSpan,o,arguments)},t.prototype._getTracer=function(){if(this._delegate)return this._delegate;var t=this._provider.getDelegateTracer(this.name,this.version,this.options);return t?(this._delegate=t,this._delegate):wt},t}(),Nt=new(function(){function t(){}return t.prototype.getTracer=function(t,e,n){return new Et},t}()),Pt=function(){function t(){}return t.prototype.getTracer=function(t,e,n){var r;return null!==(r=this.getDelegateTracer(t,e,n))&&void 0!==r?r:new Rt(this,t,e,n)},t.prototype.getDelegate=function(){var t;return null!==(t=this._delegate)&&void 0!==t?t:Nt},t.prototype.setDelegate=function(t){this._delegate=t},t.prototype.getDelegateTracer=function(t,e,n){var r;return null===(r=this._delegate)||void 0===r?void 0:r.getTracer(t,e,n)},t}();!function(t){t[t.NOT_RECORD=0]="NOT_RECORD",t[t.RECORD=1]="RECORD",t[t.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"}(At||(At={})),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"}(Ot||(Ot={})),function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"}(Ct||(Ct={}));var Lt=it.getInstance(),xt=v.instance(),Dt=new(function(){function t(){}return t.prototype.getMeter=function(t,e,n){return V},t}()),It="metrics",Mt=function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalMeterProvider=function(t){return c(It,t,v.instance())},t.prototype.getMeterProvider=function(){return l(It)||Dt},t.prototype.getMeter=function(t,e,n){return this.getMeterProvider().getMeter(t,e,n)},t.prototype.disable=function(){p(It,v.instance())},t}().getInstance(),kt=function(){function t(){}return t.prototype.inject=function(t,e){},t.prototype.extract=function(t,e){return t},t.prototype.fields=function(){return[]},t}(),Ut=C("OpenTelemetry Baggage Key");function jt(t){return t.getValue(Ut)||void 0}function Ht(){return jt(it.getInstance().active())}function Bt(t,e){return t.setValue(Ut,e)}function Ft(t){return t.deleteValue(Ut)}var Vt="propagation",$t=new kt,zt=function(){function t(){this.createBaggage=O,this.getBaggage=jt,this.getActiveBaggage=Ht,this.setBaggage=Bt,this.deleteBaggage=Ft}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(t){return c(Vt,t,v.instance())},t.prototype.inject=function(t,e,n){return void 0===n&&(n=Y),this._getGlobalPropagator().inject(t,e,n)},t.prototype.extract=function(t,e,n){return void 0===n&&(n=X),this._getGlobalPropagator().extract(t,e,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){p(Vt,v.instance())},t.prototype._getGlobalPropagator=function(){return l(Vt)||$t},t}(),qt=zt.getInstance(),Gt="trace",Kt=function(){function t(){this._proxyTracerProvider=new Pt,this.wrapSpanContext=yt,this.isSpanContextValid=Tt,this.deleteSpan=ft,this.getSpan=pt,this.getActiveSpan=dt,this.getSpanContext=gt,this.setSpan=ht,this.setSpanContext=_t}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(t){var e=c(Gt,this._proxyTracerProvider,v.instance());return e&&this._proxyTracerProvider.setDelegate(t),e},t.prototype.getTracerProvider=function(){return l(Gt)||this._proxyTracerProvider},t.prototype.getTracer=function(t,e){return this.getTracerProvider().getTracer(t,e)},t.prototype.disable=function(){p(Gt,v.instance()),this._proxyTracerProvider=new Pt},t}().getInstance();const Wt=C("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function Qt(t){return t.setValue(Wt,!0)}function Xt(t){return!0===t.getValue(Wt)}const Yt="=",Zt=";",Jt=",",te="baggage";function ee(t){const e=t.split(Zt);if(e.length<=0)return;const n=e.shift();if(!n)return;const r=n.indexOf(Yt);if(r<=0)return;const o=decodeURIComponent(n.substring(0,r).trim()),i=decodeURIComponent(n.substring(r+1).trim());let s;var a;return e.length>0&&("string"!=typeof(a=e.join(Zt))&&(A.error("Cannot create baggage metadata from unknown type: "+typeof a),a=""),s={__TYPE__:E,toString:function(){return a}}),{key:o,value:i,metadata:s}}class ne{inject(t,e,n){const r=qt.getBaggage(t);if(!r||Xt(t))return;const o=function(t){return t.getAllEntries().map((([t,e])=>{let n=`${encodeURIComponent(t)}=${encodeURIComponent(e.value)}`;return void 0!==e.metadata&&(n+=Zt+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?Jt:""}${e}`;return n.length>8192?t:n}),"")}(o);i.length>0&&n.set(e,te,i)}extract(t,e,n){const r=n.get(e,te),o=Array.isArray(r)?r.join(Jt):r;if(!o)return t;const i={};if(0===o.length)return t;return o.split(Jt).forEach((t=>{const e=ee(t);if(e){const t={value:e.value};e.metadata&&(t.metadata=e.metadata),i[e.key]=t}})),0===Object.entries(i).length?t:qt.setBaggage(t,qt.createBaggage(i))}fields(){return[te]}}function re(t){const e={};if("object"!=typeof t||null==t)return e;for(const[n,r]of Object.entries(t))oe(n)?ie(r)?Array.isArray(r)?e[n]=r.slice():e[n]=r:xt.warn(`Invalid attribute value set for key: ${n}`):xt.warn(`Invalid attribute key: ${n}`);return e}function oe(t){return"string"==typeof t&&t.length>0}function ie(t){return null==t||(Array.isArray(t)?function(t){let e;for(const n of t)if(null!=n){if(!e){if(se(n)){e=typeof n;continue}return!1}if(typeof n!==e)return!1}return!0}(t):se(t))}function se(t){switch(typeof t){case"number":case"boolean":case"string":return!0}return!1}function ae(){return t=>{xt.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 ue=ae();function ce(t){try{ue(t)}catch{}}function le(t){}const pe="object"==typeof globalThis?globalThis:"object"==typeof self?self:"object"==typeof window?window:"object"==typeof global?global:{},de=performance,he="error.type",fe="exception.message",_e="exception.type",ge="http.request.method",me="http.request.method_original",Se="http.response.status_code",ve="server.address",Te="server.port",ye="service.name",be="telemetry.sdk.language",Ee="telemetry.sdk.name",Ae="telemetry.sdk.version",Oe="url.full",Ce="process.runtime.name",we={[Ee]:"opentelemetry",[Ce]:"browser",[be]:"webjs",[Ae]:"2.0.1"};function Re(t){}const Ne=Math.pow(10,6),Pe=Math.pow(10,9);function Le(t){const e=t/1e3;return[Math.trunc(e),Math.round(t%1e3*Ne)]}function xe(){let t=de.timeOrigin;if("number"!=typeof t){const e=de;t=e.timing&&e.timing.fetchStart}return t}function De(t){return He(Le(xe()),Le("number"==typeof t?t:de.now()))}function Ie(t){if(Ue(t))return t;if("number"==typeof t)return t<xe()?De(t):Le(t);if(t instanceof Date)return Le(t.getTime());throw TypeError("Invalid input type")}function Me(t,e){let n=e[0]-t[0],r=e[1]-t[1];return r<0&&(n-=1,r+=Pe),[n,r]}function ke(t){return t[0]*Pe+t[1]}function Ue(t){return Array.isArray(t)&&2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]}function je(t){return Ue(t)||"number"==typeof t||t instanceof Date}function He(t,e){const n=[t[0]+e[0],t[1]+e[1]];return n[1]>=Pe&&(n[1]-=Pe,n[0]+=1),n}var Be;!function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"}(Be||(Be={}));class Fe{_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){xt.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){xt.warn(`Failed to extract with ${r.constructor.name}. Err: ${t.message}`)}return t}),t)}fields(){return this._fields.slice()}}const Ve="[_0-9a-z-*/]",$e=new RegExp(`^(?:${`[a-z]${Ve}{0,255}`}|${`[a-z0-9]${Ve}{0,240}@[a-z]${Ve}{0,13}`})$`),ze=/^[ -~]{0,255}[!-~]$/,qe=/,|=/;class Ge{_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 o=n.slice(0,r),i=n.slice(r+1,e.length);(function(t){return $e.test(t)})(o)&&function(t){return ze.test(t)&&!qe.test(t)}(i)&&t.set(o,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 Ge;return t._internalState=new Map(this._internalState),t}}const Ke="traceparent",We="tracestate",Qe=new RegExp("^\\s?((?!ff)[\\da-f]{2})-((?![0]{32})[\\da-f]{32})-((?![0]{16})[\\da-f]{16})-([\\da-f]{2})(-.*)?\\s?$");function Xe(t){const e=Qe.exec(t);return e?"00"===e[1]&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}:null}class Ye{inject(t,e,n){const r=Kt.getSpanContext(t);if(!r||Xt(t)||!Tt(r))return;const o=`00-${r.traceId}-${r.spanId}-0${Number(r.traceFlags||R.NONE).toString(16)}`;n.set(e,Ke,o),r.traceState&&n.set(e,We,r.traceState.serialize())}extract(t,e,n){const r=n.get(e,Ke);if(!r)return t;const o=Array.isArray(r)?r[0]:r;if("string"!=typeof o)return t;const i=Xe(o);if(!i)return t;i.isRemote=!0;const s=n.get(e,We);if(s){const t=Array.isArray(s)?s.join(","):s;i.traceState=new Ge("string"==typeof t?t:void 0)}return Kt.setSpanContext(t,i)}fields(){return[Ke,We]}}const Ze=C("OpenTelemetry SDK Context Key RPC_METADATA");var Je;!function(t){t.HTTP="http"}(Je||(Je={}));const tn="[object Object]",en="[object Null]",nn="[object Undefined]",rn=Function.prototype.toString,on=rn.call(Object),sn=Object.getPrototypeOf,an=Object.prototype,un=an.hasOwnProperty,cn=Symbol?Symbol.toStringTag:void 0,ln=an.toString;function pn(t){if(!function(t){return null!=t&&"object"==typeof t}(t)||function(t){if(null==t)return void 0===t?nn:en;return cn&&cn in Object(t)?function(t){const e=un.call(t,cn),n=t[cn];let r=!1;try{t[cn]=void 0,r=!0}catch(t){}const o=ln.call(t);r&&(e?t[cn]=n:delete t[cn]);return o}(t):function(t){return ln.call(t)}(t)}(t)!==tn)return!1;const e=sn(t);if(null===e)return!0;const n=un.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&rn.call(n)===on}const dn=20;function hn(...t){let e=t.shift();const n=new WeakMap;for(;t.length>0;)e=_n(e,t.shift(),0,n);return e}function fn(t){return mn(t)?t.slice():t}function _n(t,e,n=0,r){let o;if(!(n>dn)){if(n++,Tn(t)||Tn(e)||Sn(e))o=fn(e);else if(mn(t)){if(o=t.slice(),mn(e))for(let t=0,n=e.length;t<n;t++)o.push(fn(e[t]));else if(vn(e)){const t=Object.keys(e);for(let n=0,r=t.length;n<r;n++){const r=t[n];o[r]=fn(e[r])}}}else if(vn(t))if(vn(e)){if(!function(t,e){if(!pn(t)||!pn(e))return!1;return!0}(t,e))return e;o=Object.assign({},t);const i=Object.keys(e);for(let s=0,a=i.length;s<a;s++){const a=i[s],u=e[a];if(Tn(u))void 0===u?delete o[a]:o[a]=u;else{const i=o[a],s=u;if(gn(t,a,r)||gn(e,a,r))delete o[a];else{if(vn(i)&&vn(s)){const n=r.get(i)||[],o=r.get(s)||[];n.push({obj:t,key:a}),o.push({obj:e,key:a}),r.set(i,n),r.set(s,o)}o[a]=_n(o[a],u,n,r)}}}}else o=e;return o}}function gn(t,e,n){const r=n.get(t[e])||[];for(let n=0,o=r.length;n<o;n++){const o=r[n];if(o.key===e&&o.obj===t)return!0}return!1}function mn(t){return Array.isArray(t)}function Sn(t){return"function"==typeof t}function vn(t){return!Tn(t)&&!mn(t)&&!Sn(t)&&"object"==typeof t}function Tn(t){return"string"==typeof t||"number"==typeof t||"boolean"==typeof t||void 0===t||t instanceof Date||t instanceof RegExp||null===t}class yn extends Error{constructor(t){super(t),Object.setPrototypeOf(this,yn.prototype)}}function bn(t,e){return"string"==typeof e?t===e:!!t.match(e)}function En(t,e){if(!e)return!1;for(const n of e)if(bn(t,n))return!0;return!1}class An{_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 On{_callback;_that;_isCalled=!1;_deferred=new An;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 Cn={ALL:d.ALL,VERBOSE:d.VERBOSE,DEBUG:d.DEBUG,INFO:d.INFO,WARN:d.WARN,ERROR:d.ERROR,NONE:d.NONE};const wn={_export:function(t,e){return new Promise((n=>{Lt.with(Qt(Lt.active()),(()=>{t.export(e,(t=>{n(t)}))}))}))}};var Rn=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:On,CompositePropagator:Fe,get ExportResultCode(){return Be},get RPCType(){return Je},SDK_INFO:we,TRACE_PARENT_HEADER:Ke,TRACE_STATE_HEADER:We,TimeoutError:yn,TraceState:Ge,W3CBaggagePropagator:ne,W3CTraceContextPropagator:Ye,_globalThis:pe,addHrTimes:He,callWithTimeout:function(t,e){let n;const r=new Promise((function(t,r){n=setTimeout((function(){r(new yn("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(Ze)},diagLogLevelFromString:function(t){if(null==t)return;const e=Cn[t.toUpperCase()];return null==e?(xt.warn(`Unknown log level "${t}", expected one of ${Object.keys(Cn)}, using default`),d.INFO):e},getBooleanFromEnv:function(t){},getNumberFromEnv:le,getRPCMetadata:function(t){return t.getValue(Ze)},getStringFromEnv:function(t){},getStringListFromEnv:function(t){},getTimeOrigin:xe,globalErrorHandler:ce,hrTime:De,hrTimeDuration:Me,hrTimeToMicroseconds:function(t){return 1e6*t[0]+t[1]/1e3},hrTimeToMilliseconds:function(t){return 1e3*t[0]+t[1]/1e6},hrTimeToNanoseconds:ke,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:wn,isAttributeValue:ie,isTimeInput:je,isTimeInputHrTime:Ue,isTracingSuppressed:Xt,isUrlIgnored:En,loggingErrorHandler:ae,merge:hn,millisToHrTime:Le,otperformance:de,parseKeyPairsIntoRecord:function(t){const e={};return"string"==typeof t&&t.length>0&&t.split(Jt).forEach((t=>{const n=ee(t);void 0!==n&&n.value.length>0&&(e[n.key]=n.value)})),e},parseTraceParent:Xe,sanitizeAttributes:re,setGlobalErrorHandler:function(t){ue=t},setRPCMetadata:function(t,e){return t.setValue(Ze,e)},suppressTracing:Qt,timeInputToHrTime:Ie,unrefTimer:Re,unsuppressTracing:function(t){return t.deleteValue(Wt)},urlMatches:bn});function Nn(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 Pn,Ln={},xn={};function Dn(){if(Pn)return xn;function t(t){return Object.keys(t).map((n=>e(n,t[n])))}function e(t,e){return{key:t,value:n(e)}}function n(t){const r=typeof t;return"string"===r?{stringValue:t}:"number"===r?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:"boolean"===r?{boolValue:t}:t instanceof Uint8Array?{bytesValue:t}:Array.isArray(t)?{arrayValue:{values:t.map(n)}}:"object"===r&&null!=t?{kvlistValue:{values:Object.entries(t).map((([t,n])=>e(t,n)))}}:{}}return Pn=1,Object.defineProperty(xn,"__esModule",{value:!0}),xn.toAnyValue=xn.toKeyValue=xn.toAttributes=xn.createInstrumentationScope=xn.createResource=void 0,xn.createResource=function(e){return{attributes:t(e.attributes),droppedAttributesCount:0}},xn.createInstrumentationScope=function(t){return{name:t.name,version:t.version}},xn.toAttributes=t,xn.toKeyValue=e,xn.toAnyValue=n,xn}var In,Mn,kn,Un={},jn=Nn(Rn),Hn={};function Bn(){if(In)return Hn;function t(t){return t>=48&&t<=57?t-48:t>=97&&t<=102?t-87:t-55}return In=1,Object.defineProperty(Hn,"__esModule",{value:!0}),Hn.hexToBinary=void 0,Hn.hexToBinary=function(e){const n=new Uint8Array(e.length/2);let r=0;for(let o=0;o<e.length;o+=2){const i=t(e.charCodeAt(o)),s=t(e.charCodeAt(o+1));n[r++]=i<<4|s}return n},Hn}function Fn(){if(Mn)return Un;Mn=1,Object.defineProperty(Un,"__esModule",{value:!0}),Un.getOtlpEncoder=Un.encodeAsString=Un.encodeAsLongBits=Un.toLongBits=Un.hrTimeToNanos=void 0;const t=jn,e=Bn();function n(t){const e=BigInt(1e9);return BigInt(t[0])*e+BigInt(t[1])}function r(t){return{low:Number(BigInt.asUintN(32,t)),high:Number(BigInt.asUintN(32,t>>BigInt(32)))}}function o(t){return r(n(t))}function i(t){return n(t).toString()}Un.hrTimeToNanos=n,Un.toLongBits=r,Un.encodeAsLongBits=o,Un.encodeAsString=i;const s="undefined"!=typeof BigInt?i:t.hrTimeToNanoseconds;function a(t){return t}function u(t){if(void 0!==t)return(0,e.hexToBinary)(t)}const c={encodeHrTime:o,encodeSpanContext:e.hexToBinary,encodeOptionalSpanContext:u};return Un.getOtlpEncoder=function(t){if(void 0===t)return c;const n=t.useLongBits??!0,r=t.useHex??!1;return{encodeHrTime:n?o:s,encodeSpanContext:r?a:e.hexToBinary,encodeOptionalSpanContext:r?a:u}},Un}function Vn(){if(kn)return Ln;kn=1,Object.defineProperty(Ln,"__esModule",{value:!0}),Ln.createExportTraceServiceRequest=Ln.toOtlpSpanEvent=Ln.toOtlpLink=Ln.sdkSpanToOtlpSpan=void 0;const t=Dn(),e=Fn();function n(e,n){const i=e.spanContext(),s=e.status,a=e.parentSpanContext?.spanId?n.encodeSpanContext(e.parentSpanContext?.spanId):void 0;return{traceId:n.encodeSpanContext(i.traceId),spanId:n.encodeSpanContext(i.spanId),parentSpanId:a,traceState:i.traceState?.serialize(),name:e.name,kind:null==e.kind?0:e.kind+1,startTimeUnixNano:n.encodeHrTime(e.startTime),endTimeUnixNano:n.encodeHrTime(e.endTime),attributes:(0,t.toAttributes)(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map((t=>o(t,n))),droppedEventsCount:e.droppedEventsCount,status:{code:s.code,message:s.message},links:e.links.map((t=>r(t,n))),droppedLinksCount:e.droppedLinksCount}}function r(e,n){return{attributes:e.attributes?(0,t.toAttributes)(e.attributes):[],spanId:n.encodeSpanContext(e.context.spanId),traceId:n.encodeSpanContext(e.context.traceId),traceState:e.context.traceState?.serialize(),droppedAttributesCount:e.droppedAttributesCount||0}}function o(e,n){return{attributes:e.attributes?(0,t.toAttributes)(e.attributes):[],name:e.name,timeUnixNano:n.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}function i(e,r){const o=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 o=t.get(r);o||(o=[],t.set(r,o)),o.push(n)}return e}(e),i=[],s=o.entries();let a=s.next();for(;!a.done;){const[e,o]=a.value,u=[],c=o.values();let l=c.next();for(;!l.done;){const e=l.value;if(e.length>0){const o=e.map((t=>n(t,r)));u.push({scope:(0,t.createInstrumentationScope)(e[0].instrumentationScope),spans:o,schemaUrl:e[0].instrumentationScope.schemaUrl})}l=c.next()}const p={resource:(0,t.createResource)(e),scopeSpans:u,schemaUrl:void 0};i.push(p),a=s.next()}return i}return Ln.sdkSpanToOtlpSpan=n,Ln.toOtlpLink=r,Ln.toOtlpSpanEvent=o,Ln.createExportTraceServiceRequest=function(t,n){return{resourceSpans:i(t,(0,e.getOtlpEncoder)(n))}},Ln}var $n,zn=Vn(),qn={};function Gn(){return $n||($n=1,function(t){var e,n;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"}(qn)),qn}var Kn=Gn();class Wn{constructor(t){this.config=t}export(t,n){const r=zn.createExportTraceServiceRequest(t,{useHex:!0,useLongBits:!1});this.config.api.pushTraces(r),function(t=[]){var n,r;for(const o of t){const{scopeSpans:t}=o;for(const o of t){const{scope:t,spans:i=[]}=o;for(const o of i){if(o.kind!==Kn.ESpanKind.SPAN_KIND_CLIENT)continue;const i={traceId:o.traceId.toString(),spanId:o.spanId.toString()},s={};for(const t of o.attributes)s[t.key]=String(Object.values(t.value)[0]);Number.isNaN(o.endTimeUnixNano)||Number.isNaN(o.startTimeUnixNano)||(s.duration_ns=String(Number(o.endTimeUnixNano)-Number(o.startTimeUnixNano)));const a=(null!==(n=null==t?void 0:t.name)&&void 0!==n?n:"").indexOf("-");let u=e.unknownString;(null==t?void 0:t.name)&&(-1===a&&(u=null!==(r=t.name.split("/")[1])&&void 0!==r?r:t.name),a>-1&&(u=null==t?void 0:t.name.substring(a+1))),e.faro.api.pushEvent(`faro.tracing.${u}`,s,void 0,{spanContext:i,timestampOverwriteMs:Number(o.endTimeUnixNano)/1e6,customPayloadTransformer:t=>{var e,n;return null!=s["faro.action.user.name"]&&null!=s["faro.action.user.parentId"]&&(t.action={name:s["faro.action.user.name"],parentId:s["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),n({code:Be.SUCCESS})}shutdown(){return Promise.resolve(void 0)}}const Qn="session.id";"function"==typeof SuppressedError&&SuppressedError;class Xn{emit(t){}}const Yn=new Xn;const Zn=new class{getLogger(t,e,n){return new Xn}};class Jn{constructor(t,e,n,r){this._provider=t,this.name=e,this.version=n,this.options=r}emit(t){this._getLogger().emit(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):Yn}}class tr{getLogger(t,e,n){var r;return null!==(r=this.getDelegateLogger(t,e,n))&&void 0!==r?r:new Jn(this,t,e,n)}getDelegate(){var t;return null!==(t=this._delegate)&&void 0!==t?t:Zn}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)}}const er="object"==typeof globalThis?globalThis:"object"==typeof self?self:"object"==typeof window?window:"object"==typeof global?global:{},nr=Symbol.for("io.opentelemetry.js.api.logs"),rr=er;class or{constructor(){this._proxyLoggerProvider=new tr}static getInstance(){return this._instance||(this._instance=new or),this._instance}setGlobalLoggerProvider(t){return rr[nr]?this.getLoggerProvider():(rr[nr]=(e=1,n=t,r=Zn,t=>t===e?n:r),this._proxyLoggerProvider.setDelegate(t),t);var e,n,r}getLoggerProvider(){var t,e;return null!==(e=null===(t=rr[nr])||void 0===t?void 0:t.call(rr,1))&&void 0!==e?e:this._proxyLoggerProvider}getLogger(t,e,n){return this.getLoggerProvider().getLogger(t,e,n)}disable(){delete rr[nr],this._proxyLoggerProvider=new tr}}const ir=or.getInstance();let sr=console.error.bind(console);function ar(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 ur=(t,e,n)=>{if(!t||!t[e])return void sr("no original function "+String(e)+" to wrap");if(!n)return sr("no wrapper function"),void sr((new Error).stack);const r=t[e];if("function"!=typeof r||"function"!=typeof n)return void sr("original object and wrapper must be functions");const o=n(r,e);return ar(o,"__original",r),ar(o,"__unwrap",(()=>{t[e]===o&&ar(t,e,r)})),ar(o,"__wrapped",!0),ar(t,e,o),o},cr=(t,e,n)=>{if(!t)return sr("must provide one or more modules to patch"),void sr((new Error).stack);Array.isArray(t)||(t=[t]),e&&Array.isArray(e)?t.forEach((t=>{e.forEach((e=>{ur(t,e,n)}))})):sr("must provide one or more functions to wrap on modules")},lr=(t,e)=>{if(!t||!t[e])return sr("no function to unwrap."),void sr((new Error).stack);const n=t[e];n.__unwrap?n.__unwrap():sr("no original to unwrap to -- has "+String(e)+" already been unwrapped?")},pr=(t,e)=>{if(!t)return sr("must provide one or more modules to patch"),void sr((new Error).stack);Array.isArray(t)||(t=[t]),e&&Array.isArray(e)?t.forEach((t=>{e.forEach((e=>{lr(t,e)}))})):sr("must provide one or more functions to unwrap on modules")};class dr{instrumentationName;instrumentationVersion;_config={};_tracer;_meter;_logger;_diag;constructor(t,e,n){this.instrumentationName=t,this.instrumentationVersion=e,this.setConfig(n),this._diag=xt.createComponentLogger({namespace:t}),this._tracer=Kt.getTracer(t,e),this._meter=Mt.getMeter(t,e),this._logger=ir.getLogger(t,e),this._updateMetricInstruments()}_wrap=ur;_unwrap=lr;_massWrap=cr;_massUnwrap=pr;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 hr extends dr{constructor(t,e,n){super(t,e,n),this._config.enabled&&this.enable()}}function fr(t,e,n){let r,o;try{o=t()}catch(t){r=t}finally{return e(r,o),o}}function _r(t){return"function"==typeof t&&"function"==typeof t.__original&&"function"==typeof t.__unwrap&&!0===t.__wrapped}var gr;function mr(t,e){let n=gr.OLD;const r=e?.split(",").map((t=>t.trim())).filter((t=>""!==t));for(const e of r??[]){if(e.toLowerCase()===t+"/dup"){n=gr.DUPLICATE;break}e.toLowerCase()===t&&(n=gr.STABLE)}return n}!function(t){t[t.STABLE=1]="STABLE",t[t.OLD=2]="OLD",t[t.DUPLICATE=3]="DUPLICATE"}(gr||(gr={}));const Sr=t=>null!==t&&"object"==typeof t&&"function"==typeof t.then;class vr{_rawAttributes;_asyncAttributesPending=!1;_memoizedAttributes;static FromAttributeList(t){const e=new vr({});return e._rawAttributes=br(t),e._asyncAttributesPending=t.filter((([t,e])=>Sr(e))).length>0,e}constructor(t){const e=t.attributes??{};this._rawAttributes=Object.entries(e).map((([t,e])=>(Sr(e)&&(this._asyncAttributesPending=!0),[t,e]))),this._rawAttributes=br(this._rawAttributes)}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,Sr(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&xt.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;const t={};for(const[e,n]of this._rawAttributes)Sr(n)?xt.debug(`Unsettled resource attribute ${e} skipped`):null!=n&&(t[e]??=n);return this._asyncAttributesPending||(this._memoizedAttributes=t),t}getRawAttributes(){return this._rawAttributes}merge(t){return null==t?this:vr.FromAttributeList([...t.getRawAttributes(),...this.getRawAttributes()])}}function Tr(t){return vr.FromAttributeList(Object.entries(t))}function yr(){return Tr({[ye]:"unknown_service",[be]:we[be],[Ee]:we[Ee],[Ae]:we[Ae]})}function br(t){return t.map((([t,e])=>Sr(e)?[t,e.catch((e=>{xt.debug("promise rejection for resource attribute: %s - %s",t,e)}))]:[t,e]))}class Er{_spanContext;kind;parentSpanContext;attributes={};links=[];events=[];startTime;resource;instrumentationScope;_droppedAttributesCount=0;_droppedEventsCount=0;_droppedLinksCount=0;name;status={code:Ct.UNSET};endTime=[0,0];_ended=!1;_duration=[-1,-1];_spanProcessor;_spanLimits;_attributeValueLengthLimit;_performanceStartTime;_performanceOffset;_startTimeProvided;constructor(t){const e=Date.now();this._spanContext=t.spanContext,this._performanceStartTime=de.now(),this._performanceOffset=e-(this._performanceStartTime+xe()),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,this.links=t.links||[],this.startTime=this._getTime(t.startTime??e),this.resource=t.resource,this.instrumentationScope=t.scope,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 xt.warn(`Invalid attribute key: ${t}`),this;if(!ie(e))return xt.warn(`Invalid attribute value set for key: ${t}`),this;const{attributeCountLimit:n}=this._spanLimits;return void 0!==n&&Object.keys(this.attributes).length>=n&&!Object.prototype.hasOwnProperty.call(this.attributes,t)?(this._droppedAttributesCount++,this):(this.attributes[t]=this._truncateToSize(e),this)}setAttributes(t){for(const[e,n]of Object.entries(t))this.setAttribute(e,n);return this}addEvent(t,e,n){if(this._isSpanEnded())return this;const{eventCountLimit:r}=this._spanLimits;if(0===r)return xt.warn("No events allowed."),this._droppedEventsCount++,this;void 0!==r&&this.events.length>=r&&(0===this._droppedEventsCount&&xt.debug("Dropping extra events."),this.events.shift(),this._droppedEventsCount++),je(e)&&(je(n)||(n=e),e=void 0);const o=re(e);return this.events.push({name:t,attributes:o,time:this._getTime(n),droppedAttributesCount:0}),this}addLink(t){return this.links.push(t),this}addLinks(t){return this.links.push(...t),this}setStatus(t){return this._isSpanEnded()||(this.status={...t},null!=this.status.message&&"string"!=typeof t.message&&(xt.warn(`Dropping invalid status.message of type '${typeof t.message}', expected 'string'`),delete this.status.message)),this}updateName(t){return this._isSpanEnded()||(this.name=t),this}end(t){this._isSpanEnded()?xt.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`):(this._ended=!0,this.endTime=this._getTime(t),this._duration=Me(this.startTime,this.endTime),this._duration[0]<0&&(xt.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&&xt.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`),this._spanProcessor.onEnd(this))}_getTime(t){if("number"==typeof t&&t<=de.now())return De(t+this._performanceOffset);if("number"==typeof t)return Le(t);if(t instanceof Date)return Le(t.getTime());if(Ue(t))return t;if(this._startTimeProvided)return Le(Date.now());const e=de.now()-this._performanceStartTime;return He(this.startTime,Le(e))}isRecording(){return!1===this._ended}recordException(t,e){const n={};"string"==typeof t?n[fe]=t:t&&(t.code?n[_e]=t.code.toString():t.name&&(n[_e]=t.name),t.message&&(n[fe]=t.message),t.stack&&(n["exception.stacktrace"]=t.stack)),n[_e]||n[fe]?this.addEvent("exception",n,e):xt.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}}`);xt.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?(xt.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 Ar;!function(t){t[t.NOT_RECORD=0]="NOT_RECORD",t[t.RECORD=1]="RECORD",t[t.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"}(Ar||(Ar={}));class Or{shouldSample(){return{decision:Ar.NOT_RECORD}}toString(){return"AlwaysOffSampler"}}class Cr{shouldSample(){return{decision:Ar.RECORD_AND_SAMPLED}}toString(){return"AlwaysOnSampler"}}class wr{_root;_remoteParentSampled;_remoteParentNotSampled;_localParentSampled;_localParentNotSampled;constructor(t){this._root=t.root,this._root||(ce(new Error("ParentBasedSampler must have a root sampler configured")),this._root=new Cr),this._remoteParentSampled=t.remoteParentSampled??new Cr,this._remoteParentNotSampled=t.remoteParentNotSampled??new Or,this._localParentSampled=t.localParentSampled??new Cr,this._localParentNotSampled=t.localParentNotSampled??new Or}shouldSample(t,e,n,r,o,i){const s=Kt.getSpanContext(t);return s&&Tt(s)?s.isRemote?s.traceFlags&R.SAMPLED?this._remoteParentSampled.shouldSample(t,e,n,r,o,i):this._remoteParentNotSampled.shouldSample(t,e,n,r,o,i):s.traceFlags&R.SAMPLED?this._localParentSampled.shouldSample(t,e,n,r,o,i):this._localParentNotSampled.shouldSample(t,e,n,r,o,i):this._root.shouldSample(t,e,n,r,o,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=t,this._ratio=this._normalize(t),this._upperBound=Math.floor(4294967295*this._ratio)}shouldSample(t,e){return{decision:vt(e)&&this._accumulate(e)<this._upperBound?Ar.RECORD_AND_SAMPLED:Ar.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}}const Nr=1;function Pr(){return{sampler:Lr(),forceFlushTimeoutMillis:3e4,generalLimits:{attributeValueLengthLimit:1/0,attributeCountLimit:128},spanLimits:{attributeValueLengthLimit:1/0,attributeCountLimit:128,linkCountLimit:128,eventCountLimit:128,attributePerEventCountLimit:128,attributePerLinkCountLimit:128}}}function Lr(){const t="parentbased_always_on";switch(t){case"always_on":return new Cr;case"always_off":return new Or;case"parentbased_always_on":return new wr({root:new Cr});case"parentbased_always_off":return new wr({root:new Or});case"traceidratio":return new Rr(xr());case"parentbased_traceidratio":return new wr({root:new Rr(xr())});default:return xt.error(`OTEL_TRACES_SAMPLER value "${t}" invalid, defaulting to "parentbased_always_on".`),new wr({root:new Cr})}}function xr(){return xt.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${Nr}.`),Nr}const Dr=1/0;class Ir{_exporter;_maxExportBatchSize;_maxQueueSize;_scheduledDelayMillis;_exportTimeoutMillis;_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 On(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(xt.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||t.spanContext().traceFlags&R.SAMPLED&&this._addToBuffer(t)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return Promise.resolve().then((()=>this.onShutdown())).