@grafana/faro-web-tracing 1.18.2 → 2.0.0-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle/faro-web-tracing.iife.js +1 -1
- package/dist/bundle/types/faroUserActionSpanProcessor.d.ts +0 -2
- package/dist/bundle/types/index.d.ts +0 -1
- package/dist/cjs/faroMetaAttributesSpanProcessor.js +0 -4
- package/dist/cjs/faroMetaAttributesSpanProcessor.js.map +1 -1
- package/dist/cjs/faroUserActionSpanProcessor.js +19 -19
- package/dist/cjs/faroUserActionSpanProcessor.js.map +1 -1
- package/dist/cjs/faroXhrInstrumentation.js +9 -2
- package/dist/cjs/faroXhrInstrumentation.js.map +1 -1
- package/dist/cjs/getDefaultOTELInstrumentations.js +8 -1
- package/dist/cjs/getDefaultOTELInstrumentations.js.map +1 -1
- package/dist/cjs/index.js +1 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/instrumentation.js +3 -3
- package/dist/cjs/instrumentation.js.map +1 -1
- package/dist/esm/faroMetaAttributesSpanProcessor.js +0 -4
- package/dist/esm/faroMetaAttributesSpanProcessor.js.map +1 -1
- package/dist/esm/faroUserActionSpanProcessor.js +19 -18
- package/dist/esm/faroUserActionSpanProcessor.js.map +1 -1
- package/dist/esm/faroXhrInstrumentation.js +9 -2
- package/dist/esm/faroXhrInstrumentation.js.map +1 -1
- package/dist/esm/getDefaultOTELInstrumentations.js +8 -1
- package/dist/esm/getDefaultOTELInstrumentations.js.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/instrumentation.js +3 -3
- package/dist/esm/instrumentation.js.map +1 -1
- package/dist/types/faroUserActionSpanProcessor.d.ts +0 -2
- package/dist/types/index.d.ts +0 -1
- package/package.json +13 -13
- package/dist/bundle/types/sessionSpanProcessor.d.ts +0 -16
- package/dist/cjs/sessionSpanProcessor.js +0 -37
- package/dist/cjs/sessionSpanProcessor.js.map +0 -1
- package/dist/esm/sessionSpanProcessor.js +0 -32
- package/dist/esm/sessionSpanProcessor.js.map +0 -1
- package/dist/types/sessionSpanProcessor.d.ts +0 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
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))},g=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 _("debug",this._namespace,t)},t.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return _("error",this._namespace,t)},t.prototype.info=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return _("info",this._namespace,t)},t.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return _("warn",this._namespace,t)},t.prototype.verbose=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return _("verbose",this._namespace,t)},t}();function _(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},v=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))},S=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,v([],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 g(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},b=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.")},y=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=b(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=S.instance();function w(t){return void 0===t&&(t={}),new y(new Map(Object.entries(t)))}function O(t){return Symbol.for(t)}var C,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=(C=function(t,e){return C=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])},C(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}C(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,S.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,S.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=O("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 gt(t,e){return ht(t,new ct(e))}function _t(t){var e;return null===(e=pt(t))||void 0===e?void 0:e.spanContext()}var mt=/^([0-9a-f]{32})$/i,vt=/^[0-9a-f]{16}$/i;function St(t){return mt.test(t)&&t!==at}function Tt(t){return St(t.traceId)&&(e=t.spanId,vt.test(e)&&e!==st);var e}function bt(t){return new ct(t)}var yt=it.getInstance(),Et=function(){function t(){}return t.prototype.startSpan=function(t,e,n){if(void 0===n&&(n=yt.active()),Boolean(null==e?void 0:e.root))return new ct;var r,o=n&&_t(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:yt.active(),u=this.startSpan(t,o,a),c=ht(a,u);return yt.with(c,s,void 0,u)}},t}();var At,wt,Ot,Ct=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):Ct},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"}(wt||(wt={})),function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"}(Ot||(Ot={}));var Lt=it.getInstance(),xt=S.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,S.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,S.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=O("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=w,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,S.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,S.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=bt,this.isSpanContextValid=Tt,this.deleteSpan=ft,this.getSpan=pt,this.getActiveSpan=dt,this.getSpanContext=_t,this.setSpan=ht,this.setSpanContext=gt}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(t){var e=c(Gt,this._proxyTracerProvider,S.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,S.instance()),this._proxyTracerProvider=new Pt},t}().getInstance();const Wt=O("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",ge="exception.type",_e="http.request.method",me="http.request.method_original",ve="http.response.status_code",Se="server.address",Te="server.port",be="service.name",ye="telemetry.sdk.language",Ee="telemetry.sdk.name",Ae="telemetry.sdk.version",we="url.full",Oe="process.runtime.name",Ce={[Ee]:"opentelemetry",[Oe]:"browser",[ye]:"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=O("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=gn(e,t.shift(),0,n);return e}function fn(t){return mn(t)?t.slice():t}function gn(t,e,n=0,r){let o;if(!(n>dn)){if(n++,Tn(t)||Tn(e)||vn(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(Sn(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(Sn(t))if(Sn(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(_n(t,a,r)||_n(e,a,r))delete o[a];else{if(Sn(i)&&Sn(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]=gn(o[a],u,n,r)}}}}else o=e;return o}}function _n(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 vn(t){return"function"==typeof t}function Sn(t){return!Tn(t)&&!mn(t)&&!vn(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 bn extends Error{constructor(t){super(t),Object.setPrototypeOf(this,bn.prototype)}}function yn(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(yn(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 wn{_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 On={ALL:d.ALL,VERBOSE:d.VERBOSE,DEBUG:d.DEBUG,INFO:d.INFO,WARN:d.WARN,ERROR:d.ERROR,NONE:d.NONE};const Cn={_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:wn,CompositePropagator:Fe,get ExportResultCode(){return Be},get RPCType(){return Je},SDK_INFO:Ce,TRACE_PARENT_HEADER:Ke,TRACE_STATE_HEADER:We,TimeoutError:bn,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 bn("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=On[t.toUpperCase()];return null==e?(xt.warn(`Unknown log level "${t}", expected one of ${Object.keys(On)}, 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:Cn,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:yn});function Nn(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if("function"==typeof e){var n=function t(){return this instanceof t?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;Object.defineProperty(t,"__esModule",{value:!0}),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"}(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();var sr,ar;var ur,cr=function(){if(ar)return sr;function t(t){return"function"==typeof t}ar=1;var e=console.error.bind(console);function n(t,e,n){var r=!!t[e]&&t.propertyIsEnumerable(e);Object.defineProperty(t,e,{configurable:!0,enumerable:r,writable:!0,value:n})}function r(n){n&&n.logger&&(t(n.logger)?e=n.logger:e("new logger isn't a function, not replacing"))}function o(r,o,i){if(r&&r[o]){if(!i)return e("no wrapper function"),void e((new Error).stack);if(t(r[o])&&t(i)){var s=r[o],a=i(s,o);return n(a,"__original",s),n(a,"__unwrap",(function(){r[o]===a&&n(r,o,s)})),n(a,"__wrapped",!0),n(r,o,a),a}e("original object and wrapper must be functions")}else e("no original function "+o+" to wrap")}function i(t,n){return t&&t[n]?t[n].__unwrap?t[n].__unwrap():void e("no original to unwrap to -- has "+n+" already been unwrapped?"):(e("no function to unwrap."),void e((new Error).stack))}return r.wrap=o,r.massWrap=function(t,n,r){if(!t)return e("must provide one or more modules to patch"),void e((new Error).stack);Array.isArray(t)||(t=[t]),n&&Array.isArray(n)?t.forEach((function(t){n.forEach((function(e){o(t,e,r)}))})):e("must provide one or more functions to wrap on modules")},r.unwrap=i,r.massUnwrap=function(t,n){if(!t)return e("must provide one or more modules to patch"),void e((new Error).stack);Array.isArray(t)||(t=[t]),n&&Array.isArray(n)?t.forEach((function(t){n.forEach((function(e){i(t,e)}))})):e("must provide one or more functions to unwrap on modules")},sr=r}();class lr{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=cr.wrap;_unwrap=cr.unwrap;_massWrap=cr.massWrap;_massUnwrap=cr.massUnwrap;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 pr extends lr{constructor(t,e,n){super(t,e,n),this._config.enabled&&this.enable()}}function dr(t,e,n){let r,o;try{o=t()}catch(t){r=t}finally{return e(r,o),o}}function hr(t){return"function"==typeof t&&"function"==typeof t.__original&&"function"==typeof t.__unwrap&&!0===t.__wrapped}function fr(t,e){let n=ur.OLD;const r=e?.split(",").map((t=>t.trim())).filter((t=>""!==t));for(const e of r??[]){if(e.toLowerCase()===t+"/dup"){n=ur.DUPLICATE;break}e.toLowerCase()===t&&(n=ur.STABLE)}return n}!function(t){t[t.STABLE=1]="STABLE",t[t.OLD=2]="OLD",t[t.DUPLICATE=3]="DUPLICATE"}(ur||(ur={}));const gr=t=>null!==t&&"object"==typeof t&&"function"==typeof t.then;class _r{_rawAttributes;_asyncAttributesPending=!1;_memoizedAttributes;static FromAttributeList(t){const e=new _r({});return e._rawAttributes=Sr(t),e._asyncAttributesPending=t.filter((([t,e])=>gr(e))).length>0,e}constructor(t){const e=t.attributes??{};this._rawAttributes=Object.entries(e).map((([t,e])=>(gr(e)&&(this._asyncAttributesPending=!0),[t,e]))),this._rawAttributes=Sr(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,gr(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)gr(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:_r.FromAttributeList([...t.getRawAttributes(),...this.getRawAttributes()])}}function mr(t){return _r.FromAttributeList(Object.entries(t))}function vr(){return mr({[be]:"unknown_service",[ye]:Ce[ye],[Ee]:Ce[Ee],[Ae]:Ce[Ae]})}function Sr(t){return t.map((([t,e])=>gr(e)?[t,e.catch((e=>{xt.debug("promise rejection for resource attribute: %s - %s",t,e)}))]:[t,e]))}class Tr{_spanContext;kind;parentSpanContext;attributes={};links=[];events=[];startTime;resource;instrumentationScope;_droppedAttributesCount=0;_droppedEventsCount=0;_droppedLinksCount=0;name;status={code:Ot.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[ge]=t.code.toString():t.name&&(n[ge]=t.name),t.message&&(n[fe]=t.message),t.stack&&(n["exception.stacktrace"]=t.stack)),n[ge]||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 br;!function(t){t[t.NOT_RECORD=0]="NOT_RECORD",t[t.RECORD=1]="RECORD",t[t.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"}(br||(br={}));class yr{shouldSample(){return{decision:br.NOT_RECORD}}toString(){return"AlwaysOffSampler"}}class Er{shouldSample(){return{decision:br.RECORD_AND_SAMPLED}}toString(){return"AlwaysOnSampler"}}class Ar{_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 Er),this._remoteParentSampled=t.remoteParentSampled??new Er,this._remoteParentNotSampled=t.remoteParentNotSampled??new yr,this._localParentSampled=t.localParentSampled??new Er,this._localParentNotSampled=t.localParentNotSampled??new yr}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 wr{_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:St(e)&&this._accumulate(e)<this._upperBound?br.RECORD_AND_SAMPLED:br.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 Or=1;function Cr(){return{sampler:Rr(),forceFlushTimeoutMillis:3e4,generalLimits:{attributeValueLengthLimit:1/0,attributeCountLimit:128},spanLimits:{attributeValueLengthLimit:1/0,attributeCountLimit:128,linkCountLimit:128,eventCountLimit:128,attributePerEventCountLimit:128,attributePerLinkCountLimit:128}}}function Rr(){const t="parentbased_always_on";switch(t){case"always_on":return new Er;case"always_off":return new yr;case"parentbased_always_on":return new Ar({root:new Er});case"parentbased_always_off":return new Ar({root:new yr});case"traceidratio":return new wr(Nr());case"parentbased_traceidratio":return new Ar({root:new wr(Nr())});default:return xt.error(`OTEL_TRACES_SAMPLER value "${t}" invalid, defaulting to "parentbased_always_on".`),new Ar({root:new Er})}}function Nr(){return xt.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${Or}.`),Or}const Pr=1/0;class Lr{_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 wn(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())).then((()=>this._flushAll())).then((()=>this._exporter.shutdown()))}_addToBuffer(t){if(this._finishedSpans.length>=this._maxQueueSize)return 0===this._droppedSpansCount&&xt.debug("maxQueueSize reached, dropping spans"),void this._droppedSpansCount++;this._droppedSpansCount>0&&(xt.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);Lt.with(Qt(Lt.active()),(()=>{let r;this._finishedSpans.length<=this._maxExportBatchSize?(r=this._finishedSpans,this._finishedSpans=[]):r=this._finishedSpans.splice(0,this._maxExportBatchSize);const o=()=>this._exporter.export(r,(r=>{clearTimeout(n),r.code===Be.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?o():Promise.all(i).then(o,(t=>{ce(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,ce(t)}))};if(this._finishedSpans.length>=this._maxExportBatchSize)return t();void 0===this._timer&&(this._timer=setTimeout((()=>t()),this._scheduledDelayMillis),this._timer)}_clearTimer(){void 0!==this._timer&&(clearTimeout(this._timer),this._timer=void 0)}}class xr extends Lr{_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=>{ce(t)}))},this._pageHideListener=()=>{this.forceFlush().catch((t=>{ce(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))}}class Dr{generateTraceId=Mr(16);generateSpanId=Mr(8)}const Ir=Array(32);function Mr(t){return function(){for(let e=0;e<2*t;e++)Ir[e]=Math.floor(16*Math.random())+48,Ir[e]>=58&&(Ir[e]+=39);return String.fromCharCode.apply(null,Ir.slice(0,2*t))}}class kr{_sampler;_generalLimits;_spanLimits;_idGenerator;instrumentationScope;_resource;_spanProcessor;constructor(t,e,n,r){const o=function(t){const e={sampler:Rr()},n=Cr(),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=o.sampler,this._generalLimits=o.generalLimits,this._spanLimits=o.spanLimits,this._idGenerator=e.idGenerator||new Dr,this._resource=n,this._spanProcessor=r,this.instrumentationScope=t}startSpan(t,e={},n=Lt.active()){e.root&&(n=Kt.deleteSpan(n));const r=Kt.getSpan(n);if(Xt(n)){xt.debug("Instrumentation suppressed, returning Noop Span");return Kt.wrapSpanContext(ut)}const o=r?.spanContext(),i=this._idGenerator.generateSpanId();let s,a,u;o&&Kt.isSpanContextValid(o)?(a=o.traceId,u=o.traceState,s=o):a=this._idGenerator.generateTraceId();const c=e.kind??wt.INTERNAL,l=(e.links??[]).map((t=>({context:t.context,attributes:re(t.attributes)}))),p=re(e.attributes),d=this._sampler.shouldSample(n,a,t,c,p,l);u=d.traceState??u;const h={traceId:a,spanId:i,traceFlags:d.decision===At.RECORD_AND_SAMPLED?R.SAMPLED:R.NONE,traceState:u};if(d.decision===At.NOT_RECORD){xt.debug("Recording is off, propagating context in a non-recording span");return Kt.wrapSpanContext(h)}const f=re(Object.assign(p,d.attributes));return new Tr({resource:this._resource,scope:this.instrumentationScope,context:n,spanContext:h,name:t,kind:c,links:l,parentSpanContext:s,attributes:f,startTime:e.startTime,spanProcessor:this._spanProcessor,spanLimits:this._spanLimits})}startActiveSpan(t,e,n,r){let o,i,s;if(arguments.length<2)return;2===arguments.length?s=e:3===arguments.length?(o=e,s=n):(o=e,i=n,s=r);const a=i??Lt.active(),u=this.startSpan(t,o,a),c=Kt.setSpan(a,u);return Lt.with(c,s,void 0,u)}getGeneralLimits(){return this._generalLimits}getSpanLimits(){return this._spanLimits}}class Ur{_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=>{ce(t||new Error("MultiSpanProcessor: forceFlush failed")),e()}))}))}onStart(t,e){for(const n of this._spanProcessors)n.onStart(t,e)}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 jr,Hr;!function(t){t[t.resolved=0]="resolved",t[t.timeout=1]="timeout",t[t.error=2]="error",t[t.unresolved=3]="unresolved"}(jr||(jr={}));class Br{_config;_tracers=new Map;_resource;_activeSpanProcessor;constructor(t={}){const e=hn({},Cr(),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??Pr,Object.assign({},t,{spanLimits:e})}(t));this._resource=e.resource??vr(),this._config=Object.assign({},e,{resource:this._resource});const n=[];t.spanProcessors?.length&&n.push(...t.spanProcessors),this._activeSpanProcessor=new Ur(n)}getTracer(t,e,n){const r=`${t}@${e||""}:${n?.schemaUrl||""}`;return this._tracers.has(r)||this._tracers.set(r,new kr({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 o=setTimeout((()=>{n(new Error(`Span processor did not completed within timeout period of ${t} ms`)),r=jr.timeout}),t);e.forceFlush().then((()=>{clearTimeout(o),r!==jr.timeout&&(r=jr.resolved,n(r))})).catch((t=>{clearTimeout(o),r=jr.error,n(t)}))}))));return new Promise(((t,n)=>{Promise.all(e).then((e=>{const r=e.filter((t=>t!==jr.resolved));r.length>0?n(r):t()})).catch((t=>n([t])))}))}shutdown(){return this._activeSpanProcessor.shutdown()}}class Fr{_enabled=!1;_currentContext=P;_bindFunction(t=P,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=P,this._enabled=!1,this}enable(){return this._enabled||(this._enabled=!0,this._currentContext=P),this}with(t,e,n,...r){const o=this._currentContext;this._currentContext=t||P;try{return e.call(n,...r)}finally{this._currentContext=o}}}class Vr extends Br{constructor(t={}){super(t)}register(t={}){var e;Kt.setGlobalTracerProvider(this),null!==(e=t.propagator)&&(void 0!==e?qt.setGlobalPropagator(e):qt.setGlobalPropagator(new Fe({propagators:[new Ye,new ne]}))),function(t){if(null!==t){if(void 0===t){const t=new Fr;return t.enable(),void Lt.setGlobalContextManager(t)}t.enable(),Lt.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"}(Hr||(Hr={}));let $r;function zr(t,e,n,r=!0){if(!(o=n,i=e,!(i in o)||"number"!=typeof n[e]||r&&0===n[e]))return t.addEvent(e,n[e]);var o,i}function qr(t,e,n=!1,r,o){if(void 0===r&&(r=0!==e[Hr.START_TIME]),n||(zr(t,Hr.FETCH_START,e,r),zr(t,Hr.DOMAIN_LOOKUP_START,e,r),zr(t,Hr.DOMAIN_LOOKUP_END,e,r),zr(t,Hr.CONNECT_START,e,r),zr(t,Hr.SECURE_CONNECTION_START,e,r),zr(t,Hr.CONNECT_END,e,r),zr(t,Hr.REQUEST_START,e,r),zr(t,Hr.RESPONSE_START,e,r),zr(t,Hr.RESPONSE_END,e,r)),!o){const n=e[Hr.ENCODED_BODY_SIZE];void 0!==n&&t.setAttribute("http.response_content_length",n);const r=e[Hr.DECODED_BODY_SIZE];void 0!==r&&n!==r&&t.setAttribute("http.response_content_length_uncompressed",r)}}function Gr(){return"undefined"!=typeof location?location.origin:void 0}function Kr(t,e,n,r,o=new WeakSet,i){const s=Wr(t),a=function(t,e,n,r,o,i){const s=ke(e),a=ke(n);let u=r.filter((e=>{const n=ke(Ie(e[Hr.FETCH_START])),r=ke(Ie(e[Hr.RESPONSE_END]));return e.initiatorType.toLowerCase()===(i||"xmlhttprequest")&&e.name===t&&n>=s&&r<=a}));u.length>0&&(u=u.filter((t=>!o.has(t))));return u}(t=s.toString(),e,n,r,o,i);if(0===a.length)return{mainRequest:void 0};if(1===a.length)return{mainRequest:a[0]};const u=function(t){return t.slice().sort(((t,e)=>{const n=t[Hr.FETCH_START],r=e[Hr.FETCH_START];return n>r?1:n<r?-1:0}))}(a);if(s.origin!==Gr()&&u.length>1){let t=u[0],e=function(t,e,n){const r=ke(n),o=ke(Ie(e));let i,s=t[1];const a=t.length;for(let e=1;e<a;e++){const n=t[e],a=ke(Ie(n[Hr.FETCH_START])),u=r-ke(Ie(n[Hr.RESPONSE_END]));a>=o&&(!i||u<i)&&(i=u,s=n)}return s}(u,t[Hr.RESPONSE_END],n);const r=t[Hr.RESPONSE_END];return e[Hr.FETCH_START]<r&&(e=t,t=void 0),{corsPreFlightRequest:t,mainRequest:e}}return{mainRequest:a[0]}}function Wr(t){if("function"==typeof URL)return new URL(t,"undefined"!=typeof document?document.baseURI:"undefined"!=typeof location?location.href:void 0);const e=($r||($r=document.createElement("a")),$r);return e.href=t,e}function Qr(t,e){let n=e||[];("string"==typeof n||n instanceof RegExp)&&(n=[n]);return Wr(t).origin===Gr()||n.some((e=>yn(t,e)))}var Xr;!function(t){t.COMPONENT="component",t.HTTP_STATUS_TEXT="http.status_text"}(Xr||(Xr={}));var Yr,Zr={};function Jr(){return Yr||(Yr=1,Object.defineProperty(Zr,"__esModule",{value:!0}),Zr.ATTR_HTTP_USER_AGENT=Zr.ATTR_HTTP_URL=Zr.ATTR_HTTP_STATUS_CODE=Zr.ATTR_HTTP_SCHEME=Zr.ATTR_HTTP_RESPONSE_CONTENT_LENGTH=Zr.ATTR_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED=Zr.ATTR_HTTP_REQUEST_BODY_SIZE=Zr.ATTR_HTTP_METHOD=Zr.ATTR_HTTP_HOST=void 0,Zr.ATTR_HTTP_HOST="http.host",Zr.ATTR_HTTP_METHOD="http.method",Zr.ATTR_HTTP_REQUEST_BODY_SIZE="http.request.body.size",Zr.ATTR_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED="http.request_content_length_uncompressed",Zr.ATTR_HTTP_RESPONSE_CONTENT_LENGTH="http.response_content_length",Zr.ATTR_HTTP_SCHEME="http.scheme",Zr.ATTR_HTTP_STATUS_CODE="http.status_code",Zr.ATTR_HTTP_URL="http.url",Zr.ATTR_HTTP_USER_AGENT="http.user_agent"),Zr}var to=Jr();const eo=xt.createComponentLogger({namespace:"@opentelemetry/opentelemetry-instrumentation-fetch/utils"});function no(...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 eo.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})),o=new TransformStream({start(){},async transform(t,e){const r=await t;n+=r.byteLength,e.enqueue(t)},flush(){e(n)}});return{body:t.pipeThrough(o),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 oo(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 oo(t.toString());if(void 0!==t.byteLength)return t.byteLength;return void eo.warn("unknown body type")}(e.body))}{const e=t[0];return e?.body?e.clone().text().then((t=>oo(t))):Promise.resolve()}}const ro=new TextEncoder;function oo(t){return ro.encode(t).byteLength}function io(t){const e=function(){void 0===ao&&(ao=so);return ao}(),n=t.toUpperCase();return n in e?n:"_OTHER"}const so={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0};let ao;const uo={"https:":"443","http:":"80"};const co="0.201.1",lo="object"==typeof process&&"node"===process.release?.name;class po extends pr{component="fetch";version=co;moduleName=this.component;_usedResources=new WeakSet;_tasksCount=0;_semconvStability;constructor(t={}){super("@opentelemetry/instrumentation-fetch",co,t),this._semconvStability=fr("http",t?.semconvStabilityOptIn)}init(){}_addChildSpan(t,e){const n=this.tracer.startSpan("CORS Preflight",{startTime:e[Hr.FETCH_START]},Kt.setSpan(Lt.active(),t)),r=!(this._semconvStability&ur.OLD);qr(n,e,this.getConfig().ignoreNetworkEvents,void 0,r),n.end(e[Hr.RESPONSE_END])}_addFinalSpanAttributes(t,e){const n=Wr(e.url);if(this._semconvStability&ur.OLD&&(t.setAttribute(to.ATTR_HTTP_STATUS_CODE,e.status),null!=e.statusText&&t.setAttribute(Xr.HTTP_STATUS_TEXT,e.statusText),t.setAttribute(to.ATTR_HTTP_HOST,n.host),t.setAttribute(to.ATTR_HTTP_SCHEME,n.protocol.replace(":","")),"undefined"!=typeof navigator&&t.setAttribute(to.ATTR_HTTP_USER_AGENT,navigator.userAgent)),this._semconvStability&ur.STABLE){t.setAttribute(ve,e.status),t.setAttribute(Se,n.hostname);const r=function(t){const e=Number(t.port||uo[t.protocol]);return e&&!isNaN(e)?e:void 0}(n);r&&t.setAttribute(Te,r)}}_addHeaders(t,e){if(!Qr(e,this.getConfig().propagateTraceHeaderCorsUrls)){const t={};return qt.inject(Lt.active(),t),void(Object.keys(t).length>0&&this._diag.debug("headers inject skipped due to CORS policy"))}if(t instanceof Request)qt.inject(Lt.active(),t.headers,{set:(t,e,n)=>t.set(e,"string"==typeof n?n:String(n))});else if(t.headers instanceof Headers)qt.inject(Lt.active(),t.headers,{set:(t,e,n)=>t.set(e,"string"==typeof n?n:String(n))});else if(t.headers instanceof Map)qt.inject(Lt.active(),t.headers,{set:(t,e,n)=>t.set(e,"string"==typeof n?n:String(n))});else{const e={};qt.inject(Lt.active(),e),t.headers=Object.assign({},e,t.headers||{})}}_clearResources(){0===this._tasksCount&&this.getConfig().clearTimingResources&&(performance.clearResourceTimings(),this._usedResources=new WeakSet)}_createSpan(t,e={}){if(En(t,this.getConfig().ignoreUrls))return void this._diag.debug("ignoring span as url matches ignored url");let n="";const r={};if(this._semconvStability&ur.OLD){const o=(e.method||"GET").toUpperCase();n=`HTTP ${o}`,r[Xr.COMPONENT]=this.moduleName,r[to.ATTR_HTTP_METHOD]=o,r[to.ATTR_HTTP_URL]=t}if(this._semconvStability&ur.STABLE){const o=e.method,i=io(e.method||"GET");n||(n=i),r[_e]=i,i!==o&&(r[me]=o),r[we]=t}return this.tracer.startSpan(n,{kind:wt.CLIENT,attributes:r})}_findResourceAndAddNetworkEvents(t,e,n){let r=e.entries;if(!r.length){if(!performance.getEntriesByType)return;r=performance.getEntriesByType("resource")}const o=Kr(e.spanUrl,e.startTime,n,r,this._usedResources,"fetch");if(o.mainRequest){const e=o.mainRequest;this._markResourceAsUsed(e);const n=o.corsPreFlightRequest;n&&(this._addChildSpan(t,n),this._markResourceAsUsed(n));const r=!(this._semconvStability&ur.OLD);qr(t,e,this.getConfig().ignoreNetworkEvents,void 0,r)}}_markResourceAsUsed(t){this._usedResources.add(t)}_endSpan(t,e,n){const r=Le(Date.now()),o=De();this._addFinalSpanAttributes(t,n),this._semconvStability&ur.STABLE&&n.status>=400&&(t.setStatus({code:Ot.ERROR}),t.setAttribute(he,String(n.status))),setTimeout((()=>{e.observer?.disconnect(),this._findResourceAndAddNetworkEvents(t,e,o),this._tasksCount--,this._clearResources(),t.end(r)}),300)}_patchConstructor(){return t=>{const e=this;return function(...n){const r=this,o=Wr(n[0]instanceof Request?n[0].url:String(n[0])).href,i=n[0]instanceof Request?n[0]:n[1]||{},s=e._createSpan(o,i);if(!s)return t.apply(this,n);const a=e._prepareSpanData(o);function u(t,n){e._applyAttributesAfterFetch(t,i,n),e._endSpan(t,a,{status:n.status||0,statusText:n.message,url:o})}function c(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:o})}function l(t,e,n){try{const e=n.clone().body;if(e){const r=e.getReader(),o=()=>{r.read().then((({done:e})=>{e?c(t,n):o()}),(e=>{u(t,e)}))};o()}else c(t,n)}finally{e(n)}}function p(t,e,n){try{u(t,n)}finally{e(n)}}return e.getConfig().measureRequestSize&&no(...n).then((t=>{t&&(e._semconvStability&ur.OLD&&s.setAttribute(to.ATTR_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED,t),e._semconvStability&ur.STABLE&&s.setAttribute(to.ATTR_HTTP_REQUEST_BODY_SIZE,t))})).catch((t=>{e._diag.warn("getFetchBodyLength",t)})),new Promise(((n,a)=>Lt.with(Kt.setSpan(Lt.active(),s),(()=>(e._addHeaders(i,o),e._callRequestHook(s,i),e._tasksCount++,t.apply(r,i instanceof Request?[i]:[o,i]).then(l.bind(r,s,n),p.bind(r,s,a)))))))}}}_applyAttributesAfterFetch(t,e,n){const r=this.getConfig().applyCustomAttributesOnSpan;r&&dr((()=>r(t,e,n)),(t=>{t&&this._diag.error("applyCustomAttributesOnSpan",t)}))}_callRequestHook(t,e){const n=this.getConfig().requestHook;n&&dr((()=>n(t,e)),(t=>{t&&this._diag.error("requestHook",t)}))}_prepareSpanData(t){const e=De(),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(){lo?this._diag.warn("this instrumentation is intended for web usage only, it does not instrument Node.js's fetch()"):(hr(fetch)&&(this._unwrap(pe,"fetch"),this._diag.debug("removing previous patch for constructor")),this._wrap(pe,"fetch",this._patchConstructor()))}disable(){lo||(this._unwrap(pe,"fetch"),this._usedResources=new WeakSet)}}var ho;!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"}(ho||(ho={}));const fo=xt.createComponentLogger({namespace:"@opentelemetry/opentelemetry-instrumentation-xml-http-request/utils"});function go(t){return e=t,"undefined"!=typeof Document&&e instanceof Document?(new XMLSerializer).serializeToString(document).length:"string"==typeof t?mo(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?mo(t.toString()):void 0!==t.byteLength?t.byteLength:void fo.warn("unknown body type");var e}const _o=new TextEncoder;function mo(t){return _o.encode(t).byteLength}const vo={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0};let So;function To(){return void 0===So&&(So=vo),So}const bo={"https:":"443","http:":"80"};const yo="0.201.1";var Eo;!function(t){t.HTTP_STATUS_TEXT="http.status_text"}(Eo||(Eo={}));class Ao extends pr{component="xml-http-request";version=yo;moduleName=this.component;_tasksCount=0;_xhrMem=new WeakMap;_usedResources=new WeakSet;_semconvStability;constructor(t={}){super("@opentelemetry/instrumentation-xml-http-request",yo,t),this._semconvStability=fr("http",t?.semconvStabilityOptIn)}init(){}_addHeaders(t,e){if(!Qr(Wr(e).href,this.getConfig().propagateTraceHeaderCorsUrls)){const t={};return qt.inject(Lt.active(),t),void(Object.keys(t).length>0&&this._diag.debug("headers inject skipped due to CORS policy"))}const n={};qt.inject(Lt.active(),n),Object.keys(n).forEach((e=>{t.setRequestHeader(e,String(n[e]))}))}_addChildSpan(t,e){Lt.with(Kt.setSpan(Lt.active(),t),(()=>{const t=this.tracer.startSpan("CORS Preflight",{startTime:e[Hr.FETCH_START]}),n=!(this._semconvStability&ur.OLD);qr(t,e,this.getConfig().ignoreNetworkEvents,void 0,n),t.end(e[Hr.RESPONSE_END])}))}_addFinalSpanAttributes(t,e,n){if(this._semconvStability&ur.OLD){if(void 0!==e.status&&t.setAttribute("http.status_code",e.status),void 0!==e.statusText&&t.setAttribute(Eo.HTTP_STATUS_TEXT,e.statusText),"string"==typeof n){const e=Wr(n);t.setAttribute("http.host",e.host),t.setAttribute("http.scheme",e.protocol.replace(":",""))}t.setAttribute("http.user_agent",navigator.userAgent)}this._semconvStability&ur.STABLE&&e.status&&t.setAttribute(ve,e.status)}_applyAttributesAfterXHR(t,e){const n=this.getConfig().applyCustomAttributesOnSpan;"function"==typeof n&&dr((()=>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(),o=Wr(e);r.forEach((t=>{"xmlhttprequest"===t.initiatorType&&t.name===o.href&&n.createdResources&&n.createdResources.entries.push(t)}))})),entries:[]},n.createdResources.observer.observe({entryTypes:["resource"]}))}_clearResources(){0===this._tasksCount&&this.getConfig().clearTimingResources&&(de.clearResourceTimings(),this._xhrMem=new WeakMap,this._usedResources=new WeakSet)}_findResourceAndAddNetworkEvents(t,e,n,r,o){if(!(n&&r&&o&&t.createdResources))return;let i=t.createdResources.entries;i&&i.length||(i=de.getEntriesByType("resource"));const s=Kr(Wr(n).href,r,o,i,this._usedResources);if(s.mainRequest){const t=s.mainRequest;this._markResourceAsUsed(t);const n=s.corsPreFlightRequest;n&&(this._addChildSpan(e,n),this._markResourceAsUsed(n));const r=!(this._semconvStability&ur.OLD);qr(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(En(e,this.getConfig().ignoreUrls))return void this._diag.debug("ignoring span as url matches ignored url");let r="";const o=Wr(e),i={};if(this._semconvStability&ur.OLD&&(r=n.toUpperCase(),i["http.method"]=n,i["http.url"]=o.toString()),this._semconvStability&ur.STABLE){const t=n,e=function(t){const e=To(),n=t.toUpperCase();return n in e?n:"_OTHER"}(n);r||(r=e),i[_e]=e,e!==t&&(i[me]=t),i[we]=o.toString(),i[Se]=o.hostname;const s=function(t){const e=Number(t.port||bo[t.protocol]);return e&&!isNaN(e)?e:void 0}(o);s&&(i[Te]=s)}const s=this.tracer.startSpan(r,{kind:wt.CLIENT,attributes:i});return s.addEvent(ho.METHOD_OPEN),this._cleanPreviousSpanInformation(t),this._xhrMem.set(t,{span:s,spanUrl:e}),s}_markResourceAsUsed(t){this._usedResources.add(t)}_patchOpen(){return t=>{const e=this;return function(...n){const r=n[0],o=n[1];return e._createSpan(this,o,r),t.apply(this,n)}}}_patchSend(){const t=this;function e(e,n,r,o){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&ur.STABLE&&(r?o&&(e.setStatus({code:Ot.ERROR,message:o}),e.setAttribute(he,o)):i.status&&i.status>=400&&(e.setStatus({code:Ot.ERROR}),e.setAttribute(he,String(i.status))))}const s=De(),a=Date.now();setTimeout((()=>{!function(e,n,r,o){const i=n.callbackToRemoveEvents;"function"==typeof i&&i();const{span:s,spanUrl:a,sendStartTime:u}=n;s&&(t._findResourceAndAddNetworkEvents(n,s,a,u,r),s.addEvent(e,o),t._addFinalSpanAttributes(s,n,a),s.end(o),t._tasksCount--),t._clearResources()}(e,i,s,a)}),300)}function n(){e(ho.EVENT_ERROR,this,!0,"error")}function r(){e(ho.EVENT_ABORT,this,!1)}function o(){e(ho.EVENT_TIMEOUT,this,!0,"timeout")}function i(){this.status<299?e(ho.EVENT_LOAD,this,!1):e(ho.EVENT_ERROR,this,!1)}return e=>function(...s){const a=t._xhrMem.get(this);if(!a)return e.apply(this,s);const u=a.span,c=a.spanUrl;if(u&&c){if(t.getConfig().measureRequestSize&&s?.[0]){const e=go(s[0]);void 0!==e&&(t._semconvStability&ur.OLD&&u.setAttribute("http.request_content_length_uncompressed",e),t._semconvStability&ur.STABLE&&u.setAttribute("http.request.body.size",e))}Lt.with(Kt.setSpan(Lt.active(),u),(()=>{t._tasksCount++,a.sendStartTime=De(),u.addEvent(ho.METHOD_SEND),this.addEventListener("abort",r),this.addEventListener("error",n),this.addEventListener("load",i),this.addEventListener("timeout",o),a.callbackToRemoveEvents=()=>{!function(e){e.removeEventListener("abort",r),e.removeEventListener("error",n),e.removeEventListener("load",i),e.removeEventListener("timeout",o);const s=t._xhrMem.get(e);s&&(s.callbackToRemoveEvents=void 0)}(this),a.createdResources&&a.createdResources.observer.disconnect()},t._addHeaders(this,c),t._addResourceObserver(this,c)}))}return e.apply(this,s)}}enable(){this._diag.debug("applying patch to",this.moduleName,this.version),hr(XMLHttpRequest.prototype.open)&&(this._unwrap(XMLHttpRequest.prototype,"open"),this._diag.debug("removing previous patch from method open")),hr(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 wo extends Ao{constructor(t={}){super(t);this.parentCreateSpan=this._createSpan.bind(this)}_patchOpen(){return t=>{const n=this;return function(...r){try{const t=r[0];let o=e.getUrlFromResource(r[1]);n.parentCreateSpan(this,o,t)}catch(t){e.faro.internalLogger.error(t)}return t.apply(this,r)}}}}function Oo(t,e,n){Co(t,n instanceof Error?0:n.status)}function Co(t,e){if(null==e)return;(0===e||e>=400&&e<600)&&t.setStatus({code:Ot.ERROR})}function Ro(t){return(e,n,r)=>{Oo(e,0,r),null==t||t(e,n,r)}}function No(t){return(e,n)=>{!function(t,e){Co(t,e.status)}(e,n),null==t||t(e,n)}}function Po(t={}){const{fetchInstrumentationOptions:e,xhrInstrumentationOptions:n}=t,r=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 o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}(t,["fetchInstrumentationOptions","xhrInstrumentationOptions"]),o=function(t,e){return Object.assign(Object.assign(Object.assign(Object.assign({},e),{ignoreNetworkEvents:!0}),t),{applyCustomAttributesOnSpan:Ro(null==t?void 0:t.applyCustomAttributesOnSpan)})}(e,r),i=function(t,e){return Object.assign(Object.assign(Object.assign(Object.assign({},e),{ignoreNetworkEvents:!0}),t),{applyCustomAttributesOnSpan:No(null==t?void 0:t.applyCustomAttributesOnSpan)})}(n,r);return[new po(o),new wo(i)]}class Lo{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[Qn]=r.id,t.attributes.session_id=r.id);const o=null!==(n=this.metas.value.user)&&void 0!==n?n:{};o.email&&(t.attributes["user.email"]=o.email),o.id&&(t.attributes["user.id"]=o.id),o.username&&(t.attributes["user.name"]=o.username),o.fullName&&(t.attributes["user.full_name"]=o.fullName),o.roles&&(t.attributes["user.roles"]=o.roles.split(",").map((t=>t.trim()))),o.hash&&(t.attributes["user.hash"]=o.hash),this.processor.onStart(t,e)}onEnd(t){this.processor.onEnd(t)}shutdown(){return this.processor.shutdown()}}class xo{constructor(t){this.processor=t,e.apiMessageBus.subscribe((t=>{t.type!==e.USER_ACTION_START?[e.USER_ACTION_END,e.USER_ACTION_HALT,e.USER_ACTION_CANCEL].includes(t.type)&&(this.message=void 0):this.message=t}))}forceFlush(){return this.processor.forceFlush()}onStart(t,e){var n,r;t.kind===wt.CLIENT&&this.message&&(t.attributes["faro.action.user.name"]=null===(n=this.message)||void 0===n?void 0:n.name,t.attributes["faro.action.user.parentId"]=null===(r=this.message)||void 0===r?void 0:r.parentId),this.processor.onStart(t,e)}onEnd(t){this.processor.onEnd(t)}shutdown(){return this.processor.shutdown()}}function Do(t={}){var e;return"true"===(null===(e=t.attributes)||void 0===e?void 0:e.isSampled)?br.RECORD_AND_SAMPLED:br.NOT_RECORD}class Io extends e.BaseInstrumentation{constructor(t={}){super(),this.options=t,this.name="@grafana/faro-web-tracing",this.version=e.VERSION}initialize(){var t,n,r,o,i;const s=this.options,a={};this.config.app.name&&(a[be]=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 u=this.metas.value.browser;e.isArray(null==u?void 0:u.brands)&&(a["browser.brands"]=u.brands.map((t=>t.brand))),(null==u?void 0:u.language)&&(a["browser.language"]=u.language),"boolean"==typeof(null==u?void 0:u.mobile)&&(a["browser.mobile"]=Boolean(u.mobile)),(null==u?void 0:u.os)&&(a["browser.platform"]=u.os),(null==u?void 0:u.userAgent)&&(a["user_agent.original"]=u.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,s.resourceAttributes);const c=vr().merge(mr(a));new Vr({resource:c,sampler:{shouldSample:()=>({decision:Do(this.api.getSession())})},spanProcessors:[null!==(n=s.spanProcessor)&&void 0!==n?n:new xo(new Lo(new xr(new Wn({api:this.api}),{scheduledDelayMillis:Io.SCHEDULED_BATCH_DELAY_MS,maxExportBatchSize:30}),this.metas))]}).register({propagator:null!==(r=s.propagator)&&void 0!==r?r:new Ye,contextManager:s.contextManager});const{propagateTraceHeaderCorsUrls:l,fetchInstrumentationOptions:p,xhrInstrumentationOptions:d}=null!==(o=this.options.instrumentationOptions)&&void 0!==o?o:{};!function(t){const e=t.tracerProvider||Kt.getTracerProvider(),n=t.meterProvider||Mt.getMeterProvider(),r=t.loggerProvider||ir.getLoggerProvider(),o=t.instrumentations?.flat()??[];(function(t,e,n,r){for(let o=0,i=t.length;o<i;o++){const i=t[o];e&&i.setTracerProvider(e),n&&i.setMeterProvider(n),r&&i.setLoggerProvider&&i.setLoggerProvider(r),i.getConfig().enabled||i.enable()}})(o,e,n,r)}({instrumentations:null!==(i=s.instrumentations)&&void 0!==i?i:Po({ignoreUrls:this.getIgnoreUrls(),propagateTraceHeaderCorsUrls:l,fetchInstrumentationOptions:p,xhrInstrumentationOptions:d})}),this.api.initOTEL(Kt,Lt)}getIgnoreUrls(){return this.transports.transports.flatMap((t=>t.getIgnoreUrls()))}}return Io.SCHEDULED_BATCH_DELAY_MS=1e3,t.FaroSessionSpanProcessor=class{constructor(t,e){this.processor=t,this.metas=e}forceFlush(){return this.processor.forceFlush()}onStart(t,e){const n=this.metas.value.session;(null==n?void 0:n.id)&&(t.attributes[Qn]=n.id,t.attributes.session_id=n.id),this.processor.onStart(t,e)}onEnd(t){this.processor.onEnd(t)}shutdown(){return this.processor.shutdown()}},t.FaroTraceExporter=Wn,t.TracingInstrumentation=Io,t.fetchCustomAttributeFunctionWithDefaults=Ro,t.getDefaultOTELInstrumentations=Po,t.getSamplingDecision=Do,t.setSpanStatusOnFetchError=Oo,t}({},GrafanaFaroWebSdk);
|
|
1
|
+
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 $},t.prototype.createHistogram=function(t,e){return q},t.prototype.createCounter=function(t,e){return z},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,z=new I,$=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",zt=new kt,$t=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)||zt},t}(),qt=$t.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="baggage";function Jt(t){const e=t.split(";");if(e.length<=0)return;const n=e.shift();if(!n)return;const r=n.indexOf("=");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(";"))&&(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 te{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+=";"+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?Yt:""}${e}`;return n.length>8192?t:n},"")}(o);i.length>0&&n.set(e,Zt,i)}extract(t,e,n){const r=n.get(e,Zt),o=Array.isArray(r)?r.join(Yt):r;if(!o)return t;const i={};if(0===o.length)return t;return o.split(Yt).forEach(t=>{const e=Jt(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[Zt]}}function ee(t){const e={};if("object"!=typeof t||null==t)return e;for(const[n,r]of Object.entries(t))ne(n)?re(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 ne(t){return"string"==typeof t&&t.length>0}function re(t){return null==t||(Array.isArray(t)?function(t){let e;for(const n of t)if(null!=n){if(!e){if(oe(n)){e=typeof n;continue}return!1}if(typeof n!==e)return!1}return!0}(t):oe(t))}function oe(t){switch(typeof t){case"number":case"boolean":case"string":return!0}return!1}function ie(){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 se=ie();function ae(t){try{se(t)}catch{}}function ue(t){}const ce="object"==typeof globalThis?globalThis:"object"==typeof self?self:"object"==typeof window?window:"object"==typeof global?global:{},le=performance,pe="error.type",de="exception.message",he="exception.type",fe="http.request.method",_e="http.request.method_original",ge="http.response.status_code",me="server.address",Se="server.port",ve="service.name",Te="telemetry.sdk.language",ye="telemetry.sdk.name",be="telemetry.sdk.version",Ee="url.full",Ae="process.runtime.name",Oe={[ye]:"opentelemetry",[Ae]:"browser",[Te]:"webjs",[be]:"2.0.1"};function Ce(t){}const we=Math.pow(10,6),Re=Math.pow(10,9);function Ne(t){const e=t/1e3;return[Math.trunc(e),Math.round(t%1e3*we)]}function Pe(){let t=le.timeOrigin;if("number"!=typeof t){const e=le;t=e.timing&&e.timing.fetchStart}return t}function Le(t){return Ue(Ne(Pe()),Ne("number"==typeof t?t:le.now()))}function xe(t){if(Me(t))return t;if("number"==typeof t)return t<Pe()?Le(t):Ne(t);if(t instanceof Date)return Ne(t.getTime());throw TypeError("Invalid input type")}function De(t,e){let n=e[0]-t[0],r=e[1]-t[1];return r<0&&(n-=1,r+=Re),[n,r]}function Ie(t){return t[0]*Re+t[1]}function Me(t){return Array.isArray(t)&&2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]}function ke(t){return Me(t)||"number"==typeof t||t instanceof Date}function Ue(t,e){const n=[t[0]+e[0],t[1]+e[1]];return n[1]>=Re&&(n[1]-=Re,n[0]+=1),n}var je;!function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"}(je||(je={}));class He{_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 Be="[_0-9a-z-*/]",Fe=new RegExp(`^(?:${`[a-z]${Be}{0,255}`}|${`[a-z0-9]${Be}{0,240}@[a-z]${Be}{0,13}`})$`),Ve=/^[ -~]{0,255}[!-~]$/,ze=/,|=/;class $e{_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 Fe.test(t)})(o)&&function(t){return Ve.test(t)&&!ze.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 $e;return t._internalState=new Map(this._internalState),t}}const qe="traceparent",Ge="tracestate",Ke=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=Ke.exec(t);return e?"00"===e[1]&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}:null}class Qe{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,qe,o),r.traceState&&n.set(e,Ge,r.traceState.serialize())}extract(t,e,n){const r=n.get(e,qe);if(!r)return t;const o=Array.isArray(r)?r[0]:r;if("string"!=typeof o)return t;const i=We(o);if(!i)return t;i.isRemote=!0;const s=n.get(e,Ge);if(s){const t=Array.isArray(s)?s.join(","):s;i.traceState=new $e("string"==typeof t?t:void 0)}return Kt.setSpanContext(t,i)}fields(){return[qe,Ge]}}const Xe=C("OpenTelemetry SDK Context Key RPC_METADATA");var Ye;!function(t){t.HTTP="http"}(Ye||(Ye={}));const Ze="[object Null]",Je="[object Undefined]",tn=Function.prototype.toString,en=tn.call(Object),nn=Object.getPrototypeOf,rn=Object.prototype,on=rn.hasOwnProperty,sn=Symbol?Symbol.toStringTag:void 0,an=rn.toString;function un(t){if(!function(t){return null!=t&&"object"==typeof t}(t)||"[object Object]"!==function(t){if(null==t)return void 0===t?Je:Ze;return sn&&sn in Object(t)?function(t){const e=on.call(t,sn),n=t[sn];let r=!1;try{t[sn]=void 0,r=!0}catch(t){}const o=an.call(t);r&&(e?t[sn]=n:delete t[sn]);return o}(t):function(t){return an.call(t)}(t)}(t))return!1;const e=nn(t);if(null===e)return!0;const n=on.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&tn.call(n)===en}function cn(...t){let e=t.shift();const n=new WeakMap;for(;t.length>0;)e=pn(e,t.shift(),0,n);return e}function ln(t){return hn(t)?t.slice():t}function pn(t,e,n=0,r){let o;if(!(n>20)){if(n++,gn(t)||gn(e)||fn(e))o=ln(e);else if(hn(t)){if(o=t.slice(),hn(e))for(let t=0,n=e.length;t<n;t++)o.push(ln(e[t]));else if(_n(e)){const t=Object.keys(e);for(let n=0,r=t.length;n<r;n++){const r=t[n];o[r]=ln(e[r])}}}else if(_n(t))if(_n(e)){if(!function(t,e){if(!un(t)||!un(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(gn(u))void 0===u?delete o[a]:o[a]=u;else{const i=o[a],s=u;if(dn(t,a,r)||dn(e,a,r))delete o[a];else{if(_n(i)&&_n(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]=pn(o[a],u,n,r)}}}}else o=e;return o}}function dn(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 hn(t){return Array.isArray(t)}function fn(t){return"function"==typeof t}function _n(t){return!gn(t)&&!hn(t)&&!fn(t)&&"object"==typeof t}function gn(t){return"string"==typeof t||"number"==typeof t||"boolean"==typeof t||void 0===t||t instanceof Date||t instanceof RegExp||null===t}class mn extends Error{constructor(t){super(t),Object.setPrototypeOf(this,mn.prototype)}}function Sn(t,e){return"string"==typeof e?t===e:!!t.match(e)}function vn(t,e){if(!e)return!1;for(const n of e)if(Sn(t,n))return!0;return!1}class Tn{_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 yn{_callback;_that;_isCalled=!1;_deferred=new Tn;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 bn={ALL:d.ALL,VERBOSE:d.VERBOSE,DEBUG:d.DEBUG,INFO:d.INFO,WARN:d.WARN,ERROR:d.ERROR,NONE:d.NONE};const En={_export:function(t,e){return new Promise(n=>{Lt.with(Qt(Lt.active()),()=>{t.export(e,t=>{n(t)})})})}};var An=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:yn,CompositePropagator:He,get ExportResultCode(){return je},get RPCType(){return Ye},SDK_INFO:Oe,TRACE_PARENT_HEADER:qe,TRACE_STATE_HEADER:Ge,TimeoutError:mn,TraceState:$e,W3CBaggagePropagator:te,W3CTraceContextPropagator:Qe,_globalThis:ce,addHrTimes:Ue,callWithTimeout:function(t,e){let n;const r=new Promise(function(t,r){n=setTimeout(function(){r(new mn("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(Xe)},diagLogLevelFromString:function(t){if(null==t)return;const e=bn[t.toUpperCase()];return null==e?(xt.warn(`Unknown log level "${t}", expected one of ${Object.keys(bn)}, using default`),d.INFO):e},getBooleanFromEnv:function(t){},getNumberFromEnv:ue,getRPCMetadata:function(t){return t.getValue(Xe)},getStringFromEnv:function(t){},getStringListFromEnv:function(t){},getTimeOrigin:Pe,globalErrorHandler:ae,hrTime:Le,hrTimeDuration:De,hrTimeToMicroseconds:function(t){return 1e6*t[0]+t[1]/1e3},hrTimeToMilliseconds:function(t){return 1e3*t[0]+t[1]/1e6},hrTimeToNanoseconds:Ie,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:re,isTimeInput:ke,isTimeInputHrTime:Me,isTracingSuppressed:Xt,isUrlIgnored:vn,loggingErrorHandler:ie,merge:cn,millisToHrTime:Ne,otperformance:le,parseKeyPairsIntoRecord:function(t){const e={};return"string"==typeof t&&t.length>0&&t.split(Yt).forEach(t=>{const n=Jt(t);void 0!==n&&n.value.length>0&&(e[n.key]=n.value)}),e},parseTraceParent:We,sanitizeAttributes:ee,setGlobalErrorHandler:function(t){se=t},setRPCMetadata:function(t,e){return t.setValue(Xe,e)},suppressTracing:Qt,timeInputToHrTime:xe,unrefTimer:Ce,unsuppressTracing:function(t){return t.deleteValue(Wt)},urlMatches:Sn});function On(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 Cn,wn={},Rn={};function Nn(){if(Cn)return Rn;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 Cn=1,Object.defineProperty(Rn,"__esModule",{value:!0}),Rn.toAnyValue=Rn.toKeyValue=Rn.toAttributes=Rn.createInstrumentationScope=Rn.createResource=void 0,Rn.createResource=function(e){return{attributes:t(e.attributes),droppedAttributesCount:0}},Rn.createInstrumentationScope=function(t){return{name:t.name,version:t.version}},Rn.toAttributes=t,Rn.toKeyValue=e,Rn.toAnyValue=n,Rn}var Pn,Ln,xn,Dn={},In=On(An),Mn={};function kn(){if(Pn)return Mn;function t(t){return t>=48&&t<=57?t-48:t>=97&&t<=102?t-87:t-55}return Pn=1,Object.defineProperty(Mn,"__esModule",{value:!0}),Mn.hexToBinary=void 0,Mn.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},Mn}function Un(){if(Ln)return Dn;Ln=1,Object.defineProperty(Dn,"__esModule",{value:!0}),Dn.getOtlpEncoder=Dn.encodeAsString=Dn.encodeAsLongBits=Dn.toLongBits=Dn.hrTimeToNanos=void 0;const t=In,e=kn();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()}Dn.hrTimeToNanos=n,Dn.toLongBits=r,Dn.encodeAsLongBits=o,Dn.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 Dn.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}},Dn}function jn(){if(xn)return wn;xn=1,Object.defineProperty(wn,"__esModule",{value:!0}),wn.createExportTraceServiceRequest=wn.toOtlpSpanEvent=wn.toOtlpLink=wn.sdkSpanToOtlpSpan=void 0;const t=Nn(),e=Un();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 wn.sdkSpanToOtlpSpan=n,wn.toOtlpLink=r,wn.toOtlpSpanEvent=o,wn.createExportTraceServiceRequest=function(t,n){return{resourceSpans:i(t,(0,e.getOtlpEncoder)(n))}},wn}var Hn,Bn=jn(),Fn={};function Vn(){return Hn||(Hn=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"}(Fn)),Fn}var zn=Vn();class $n{constructor(t){this.config=t}export(t,n){const r=Bn.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!==zn.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:je.SUCCESS})}shutdown(){return Promise.resolve(void 0)}}"function"==typeof SuppressedError&&SuppressedError;class qn{emit(t){}}const Gn=new qn;const Kn=new class{getLogger(t,e,n){return new qn}};class Wn{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):Gn}}class Qn{getLogger(t,e,n){var r;return null!==(r=this.getDelegateLogger(t,e,n))&&void 0!==r?r:new Wn(this,t,e,n)}getDelegate(){var t;return null!==(t=this._delegate)&&void 0!==t?t:Kn}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 Xn="object"==typeof globalThis?globalThis:"object"==typeof self?self:"object"==typeof window?window:"object"==typeof global?global:{},Yn=Symbol.for("io.opentelemetry.js.api.logs"),Zn=Xn;class Jn{constructor(){this._proxyLoggerProvider=new Qn}static getInstance(){return this._instance||(this._instance=new Jn),this._instance}setGlobalLoggerProvider(t){return Zn[Yn]?this.getLoggerProvider():(Zn[Yn]=(e=1,n=t,r=Kn,t=>t===e?n:r),this._proxyLoggerProvider.setDelegate(t),t);var e,n,r}getLoggerProvider(){var t,e;return null!==(e=null===(t=Zn[Yn])||void 0===t?void 0:t.call(Zn,1))&&void 0!==e?e:this._proxyLoggerProvider}getLogger(t,e,n){return this.getLoggerProvider().getLogger(t,e,n)}disable(){delete Zn[Yn],this._proxyLoggerProvider=new Qn}}const tr=Jn.getInstance();let er=console.error.bind(console);function nr(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 rr=(t,e,n)=>{if(!t||!t[e])return void er("no original function "+String(e)+" to wrap");if(!n)return er("no wrapper function"),void er((new Error).stack);const r=t[e];if("function"!=typeof r||"function"!=typeof n)return void er("original object and wrapper must be functions");const o=n(r,e);return nr(o,"__original",r),nr(o,"__unwrap",()=>{t[e]===o&&nr(t,e,r)}),nr(o,"__wrapped",!0),nr(t,e,o),o},or=(t,e,n)=>{if(!t)return er("must provide one or more modules to patch"),void er((new Error).stack);Array.isArray(t)||(t=[t]),e&&Array.isArray(e)?t.forEach(t=>{e.forEach(e=>{rr(t,e,n)})}):er("must provide one or more functions to wrap on modules")},ir=(t,e)=>{if(!t||!t[e])return er("no function to unwrap."),void er((new Error).stack);const n=t[e];n.__unwrap?n.__unwrap():er("no original to unwrap to -- has "+String(e)+" already been unwrapped?")},sr=(t,e)=>{if(!t)return er("must provide one or more modules to patch"),void er((new Error).stack);Array.isArray(t)||(t=[t]),e&&Array.isArray(e)?t.forEach(t=>{e.forEach(e=>{ir(t,e)})}):er("must provide one or more functions to unwrap on modules")};class ar{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=tr.getLogger(t,e),this._updateMetricInstruments()}_wrap=rr;_unwrap=ir;_massWrap=or;_massUnwrap=sr;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 ur extends ar{constructor(t,e,n){super(t,e,n),this._config.enabled&&this.enable()}}function cr(t,e,n){let r,o;try{o=t()}catch(t){r=t}finally{return e(r,o),o}}function lr(t){return"function"==typeof t&&"function"==typeof t.__original&&"function"==typeof t.__unwrap&&!0===t.__wrapped}var pr;function dr(t,e){let n=pr.OLD;const r=e?.split(",").map(t=>t.trim()).filter(t=>""!==t);for(const e of r??[]){if(e.toLowerCase()===t+"/dup"){n=pr.DUPLICATE;break}e.toLowerCase()===t&&(n=pr.STABLE)}return n}!function(t){t[t.STABLE=1]="STABLE",t[t.OLD=2]="OLD",t[t.DUPLICATE=3]="DUPLICATE"}(pr||(pr={}));const hr=t=>null!==t&&"object"==typeof t&&"function"==typeof t.then;class fr{_rawAttributes;_asyncAttributesPending=!1;_memoizedAttributes;static FromAttributeList(t){const e=new fr({});return e._rawAttributes=mr(t),e._asyncAttributesPending=t.filter(([t,e])=>hr(e)).length>0,e}constructor(t){const e=t.attributes??{};this._rawAttributes=Object.entries(e).map(([t,e])=>(hr(e)&&(this._asyncAttributesPending=!0),[t,e])),this._rawAttributes=mr(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,hr(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)hr(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:fr.FromAttributeList([...t.getRawAttributes(),...this.getRawAttributes()])}}function _r(t){return fr.FromAttributeList(Object.entries(t))}function gr(){return _r({[ve]:"unknown_service",[Te]:Oe[Te],[ye]:Oe[ye],[be]:Oe[be]})}function mr(t){return t.map(([t,e])=>hr(e)?[t,e.catch(e=>{xt.debug("promise rejection for resource attribute: %s - %s",t,e)})]:[t,e])}class Sr{_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=le.now(),this._performanceOffset=e-(this._performanceStartTime+Pe()),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(!re(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++),ke(e)&&(ke(n)||(n=e),e=void 0);const o=ee(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=De(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<=le.now())return Le(t+this._performanceOffset);if("number"==typeof t)return Ne(t);if(t instanceof Date)return Ne(t.getTime());if(Me(t))return t;if(this._startTimeProvided)return Ne(Date.now());const e=le.now()-this._performanceStartTime;return Ue(this.startTime,Ne(e))}isRecording(){return!1===this._ended}recordException(t,e){const n={};"string"==typeof t?n[de]=t:t&&(t.code?n[he]=t.code.toString():t.name&&(n[he]=t.name),t.message&&(n[de]=t.message),t.stack&&(n["exception.stacktrace"]=t.stack)),n[he]||n[de]?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 vr;!function(t){t[t.NOT_RECORD=0]="NOT_RECORD",t[t.RECORD=1]="RECORD",t[t.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"}(vr||(vr={}));class Tr{shouldSample(){return{decision:vr.NOT_RECORD}}toString(){return"AlwaysOffSampler"}}class yr{shouldSample(){return{decision:vr.RECORD_AND_SAMPLED}}toString(){return"AlwaysOnSampler"}}class br{_root;_remoteParentSampled;_remoteParentNotSampled;_localParentSampled;_localParentNotSampled;constructor(t){this._root=t.root,this._root||(ae(new Error("ParentBasedSampler must have a root sampler configured")),this._root=new yr),this._remoteParentSampled=t.remoteParentSampled??new yr,this._remoteParentNotSampled=t.remoteParentNotSampled??new Tr,this._localParentSampled=t.localParentSampled??new yr,this._localParentNotSampled=t.localParentNotSampled??new Tr}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 Er{_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?vr.RECORD_AND_SAMPLED:vr.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 Ar(){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="parentbased_always_on";switch(t){case"always_on":return new yr;case"always_off":return new Tr;case"parentbased_always_on":return new br({root:new yr});case"parentbased_always_off":return new br({root:new Tr});case"traceidratio":return new Er(Cr());case"parentbased_traceidratio":return new br({root:new Er(Cr())});default:return xt.error(`OTEL_TRACES_SAMPLER value "${t}" invalid, defaulting to "parentbased_always_on".`),new br({root:new yr})}}function Cr(){return xt.error("OTEL_TRACES_SAMPLER_ARG is blank, defaulting to 1."),1}const wr=1/0;class Rr{_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 yn(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||0!==(t.spanContext().traceFlags&R.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&&xt.debug("maxQueueSize reached, dropping spans"),void this._droppedSpansCount++;this._droppedSpansCount>0&&(xt.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);Lt.with(Qt(Lt.active()),()=>{let r;this._finishedSpans.length<=this._maxExportBatchSize?(r=this._finishedSpans,this._finishedSpans=[]):r=this._finishedSpans.splice(0,this._maxExportBatchSize);const o=()=>this._exporter.export(r,r=>{clearTimeout(n),r.code===je.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?o():Promise.all(i).then(o,t=>{ae(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,ae(t)})};if(this._finishedSpans.length>=this._maxExportBatchSize)return t();void 0===this._timer&&(this._timer=setTimeout(()=>t(),this._scheduledDelayMillis),this._timer)}_clearTimer(){void 0!==this._timer&&(clearTimeout(this._timer),this._timer=void 0)}}class Nr extends Rr{_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=>{ae(t)})},this._pageHideListener=()=>{this.forceFlush().catch(t=>{ae(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))}}class Pr{generateTraceId=xr(16);generateSpanId=xr(8)}const Lr=Array(32);function xr(t){return function(){for(let e=0;e<2*t;e++)Lr[e]=Math.floor(16*Math.random())+48,Lr[e]>=58&&(Lr[e]+=39);return String.fromCharCode.apply(null,Lr.slice(0,2*t))}}class Dr{_sampler;_generalLimits;_spanLimits;_idGenerator;instrumentationScope;_resource;_spanProcessor;constructor(t,e,n,r){const o=function(t){const e={sampler:Or()},n=Ar(),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=o.sampler,this._generalLimits=o.generalLimits,this._spanLimits=o.spanLimits,this._idGenerator=e.idGenerator||new Pr,this._resource=n,this._spanProcessor=r,this.instrumentationScope=t}startSpan(t,e={},n=Lt.active()){e.root&&(n=Kt.deleteSpan(n));const r=Kt.getSpan(n);if(Xt(n)){xt.debug("Instrumentation suppressed, returning Noop Span");return Kt.wrapSpanContext(ut)}const o=r?.spanContext(),i=this._idGenerator.generateSpanId();let s,a,u;o&&Kt.isSpanContextValid(o)?(a=o.traceId,u=o.traceState,s=o):a=this._idGenerator.generateTraceId();const c=e.kind??Ot.INTERNAL,l=(e.links??[]).map(t=>({context:t.context,attributes:ee(t.attributes)})),p=ee(e.attributes),d=this._sampler.shouldSample(n,a,t,c,p,l);u=d.traceState??u;const h={traceId:a,spanId:i,traceFlags:d.decision===At.RECORD_AND_SAMPLED?R.SAMPLED:R.NONE,traceState:u};if(d.decision===At.NOT_RECORD){xt.debug("Recording is off, propagating context in a non-recording span");return Kt.wrapSpanContext(h)}const f=ee(Object.assign(p,d.attributes));return new Sr({resource:this._resource,scope:this.instrumentationScope,context:n,spanContext:h,name:t,kind:c,links:l,parentSpanContext:s,attributes:f,startTime:e.startTime,spanProcessor:this._spanProcessor,spanLimits:this._spanLimits})}startActiveSpan(t,e,n,r){let o,i,s;if(arguments.length<2)return;2===arguments.length?s=e:3===arguments.length?(o=e,s=n):(o=e,i=n,s=r);const a=i??Lt.active(),u=this.startSpan(t,o,a),c=Kt.setSpan(a,u);return Lt.with(c,s,void 0,u)}getGeneralLimits(){return this._generalLimits}getSpanLimits(){return this._spanLimits}}class Ir{_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=>{ae(t||new Error("MultiSpanProcessor: forceFlush failed")),e()})})}onStart(t,e){for(const n of this._spanProcessors)n.onStart(t,e)}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 Mr,kr;!function(t){t[t.resolved=0]="resolved",t[t.timeout=1]="timeout",t[t.error=2]="error",t[t.unresolved=3]="unresolved"}(Mr||(Mr={}));class Ur{_config;_tracers=new Map;_resource;_activeSpanProcessor;constructor(t={}){const e=cn({},Ar(),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??wr,Object.assign({},t,{spanLimits:e})}(t));this._resource=e.resource??gr(),this._config=Object.assign({},e,{resource:this._resource});const n=[];t.spanProcessors?.length&&n.push(...t.spanProcessors),this._activeSpanProcessor=new Ir(n)}getTracer(t,e,n){const r=`${t}@${e||""}:${n?.schemaUrl||""}`;return this._tracers.has(r)||this._tracers.set(r,new Dr({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 o=setTimeout(()=>{n(new Error(`Span processor did not completed within timeout period of ${t} ms`)),r=Mr.timeout},t);e.forceFlush().then(()=>{clearTimeout(o),r!==Mr.timeout&&(r=Mr.resolved,n(r))}).catch(t=>{clearTimeout(o),r=Mr.error,n(t)})}));return new Promise((t,n)=>{Promise.all(e).then(e=>{const r=e.filter(t=>t!==Mr.resolved);r.length>0?n(r):t()}).catch(t=>n([t]))})}shutdown(){return this._activeSpanProcessor.shutdown()}}class jr{_enabled=!1;_currentContext=P;_bindFunction(t=P,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=P,this._enabled=!1,this}enable(){return this._enabled||(this._enabled=!0,this._currentContext=P),this}with(t,e,n,...r){const o=this._currentContext;this._currentContext=t||P;try{return e.call(n,...r)}finally{this._currentContext=o}}}class Hr extends Ur{constructor(t={}){super(t)}register(t={}){var e;Kt.setGlobalTracerProvider(this),null!==(e=t.propagator)&&(void 0!==e?qt.setGlobalPropagator(e):qt.setGlobalPropagator(new He({propagators:[new Qe,new te]}))),function(t){if(null!==t){if(void 0===t){const t=new jr;return t.enable(),void Lt.setGlobalContextManager(t)}t.enable(),Lt.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"}(kr||(kr={}));let Br;function Fr(t,e,n,r=!0){if(!(o=n,i=e,!(i in o)||"number"!=typeof n[e]||r&&0===n[e]))return t.addEvent(e,n[e]);var o,i}function Vr(t,e,n=!1,r,o){if(void 0===r&&(r=0!==e[kr.START_TIME]),n||(Fr(t,kr.FETCH_START,e,r),Fr(t,kr.DOMAIN_LOOKUP_START,e,r),Fr(t,kr.DOMAIN_LOOKUP_END,e,r),Fr(t,kr.CONNECT_START,e,r),Fr(t,kr.SECURE_CONNECTION_START,e,r),Fr(t,kr.CONNECT_END,e,r),Fr(t,kr.REQUEST_START,e,r),Fr(t,kr.RESPONSE_START,e,r),Fr(t,kr.RESPONSE_END,e,r)),!o){const n=e[kr.ENCODED_BODY_SIZE];void 0!==n&&t.setAttribute("http.response_content_length",n);const r=e[kr.DECODED_BODY_SIZE];void 0!==r&&n!==r&&t.setAttribute("http.response_content_length_uncompressed",r)}}function zr(){return"undefined"!=typeof location?location.origin:void 0}function $r(t,e,n,r,o=new WeakSet,i){const s=qr(t),a=function(t,e,n,r,o,i){const s=Ie(e),a=Ie(n);let u=r.filter(e=>{const n=Ie(xe(e[kr.FETCH_START])),r=Ie(xe(e[kr.RESPONSE_END]));return e.initiatorType.toLowerCase()===(i||"xmlhttprequest")&&e.name===t&&n>=s&&r<=a});u.length>0&&(u=u.filter(t=>!o.has(t)));return u}(t=s.toString(),e,n,r,o,i);if(0===a.length)return{mainRequest:void 0};if(1===a.length)return{mainRequest:a[0]};const u=function(t){return t.slice().sort((t,e)=>{const n=t[kr.FETCH_START],r=e[kr.FETCH_START];return n>r?1:n<r?-1:0})}(a);if(s.origin!==zr()&&u.length>1){let t=u[0],e=function(t,e,n){const r=Ie(n),o=Ie(xe(e));let i,s=t[1];const a=t.length;for(let e=1;e<a;e++){const n=t[e],a=Ie(xe(n[kr.FETCH_START])),u=r-Ie(xe(n[kr.RESPONSE_END]));a>=o&&(!i||u<i)&&(i=u,s=n)}return s}(u,t[kr.RESPONSE_END],n);const r=t[kr.RESPONSE_END];return e[kr.FETCH_START]<r&&(e=t,t=void 0),{corsPreFlightRequest:t,mainRequest:e}}return{mainRequest:a[0]}}function qr(t){if("function"==typeof URL)return new URL(t,"undefined"!=typeof document?document.baseURI:"undefined"!=typeof location?location.href:void 0);const e=(Br||(Br=document.createElement("a")),Br);return e.href=t,e}function Gr(t,e){let n=e||[];("string"==typeof n||n instanceof RegExp)&&(n=[n]);return qr(t).origin===zr()||n.some(e=>Sn(t,e))}var Kr;!function(t){t.COMPONENT="component",t.HTTP_STATUS_TEXT="http.status_text"}(Kr||(Kr={}));var Wr,Qr={};function Xr(){return Wr||(Wr=1,Object.defineProperty(Qr,"__esModule",{value:!0}),Qr.ATTR_HTTP_USER_AGENT=Qr.ATTR_HTTP_URL=Qr.ATTR_HTTP_STATUS_CODE=Qr.ATTR_HTTP_SCHEME=Qr.ATTR_HTTP_RESPONSE_CONTENT_LENGTH=Qr.ATTR_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED=Qr.ATTR_HTTP_REQUEST_BODY_SIZE=Qr.ATTR_HTTP_METHOD=Qr.ATTR_HTTP_HOST=void 0,Qr.ATTR_HTTP_HOST="http.host",Qr.ATTR_HTTP_METHOD="http.method",Qr.ATTR_HTTP_REQUEST_BODY_SIZE="http.request.body.size",Qr.ATTR_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED="http.request_content_length_uncompressed",Qr.ATTR_HTTP_RESPONSE_CONTENT_LENGTH="http.response_content_length",Qr.ATTR_HTTP_SCHEME="http.scheme",Qr.ATTR_HTTP_STATUS_CODE="http.status_code",Qr.ATTR_HTTP_URL="http.url",Qr.ATTR_HTTP_USER_AGENT="http.user_agent"),Qr}var Yr=Xr();const Zr=xt.createComponentLogger({namespace:"@opentelemetry/opentelemetry-instrumentation-fetch/utils"});function Jr(...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 Zr.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}),o=new TransformStream({start(){},async transform(t,e){const r=await t;n+=r.byteLength,e.enqueue(t)},flush(){e(n)}});return{body:t.pipeThrough(o),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 eo(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 eo(t.toString());if(void 0!==t.byteLength)return t.byteLength;return void Zr.warn("unknown body type")}(e.body))}{const e=t[0];return e?.body?e.clone().text().then(t=>eo(t)):Promise.resolve()}}const to=new TextEncoder;function eo(t){return to.encode(t).byteLength}function no(t){const e=function(){void 0===oo&&(oo=ro);return oo}(),n=t.toUpperCase();return n in e?n:"_OTHER"}const ro={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0};let oo;const io={"https:":"443","http:":"80"};const so="0.203.0",ao="object"==typeof process&&"node"===process.release?.name;class uo extends ur{component="fetch";version=so;moduleName=this.component;_usedResources=new WeakSet;_tasksCount=0;_semconvStability;constructor(t={}){super("@opentelemetry/instrumentation-fetch",so,t),this._semconvStability=dr("http",t?.semconvStabilityOptIn)}init(){}_addChildSpan(t,e){const n=this.tracer.startSpan("CORS Preflight",{startTime:e[kr.FETCH_START]},Kt.setSpan(Lt.active(),t)),r=!(this._semconvStability&pr.OLD);Vr(n,e,this.getConfig().ignoreNetworkEvents,void 0,r),n.end(e[kr.RESPONSE_END])}_addFinalSpanAttributes(t,e){const n=qr(e.url);if(this._semconvStability&pr.OLD&&(t.setAttribute(Yr.ATTR_HTTP_STATUS_CODE,e.status),null!=e.statusText&&t.setAttribute(Kr.HTTP_STATUS_TEXT,e.statusText),t.setAttribute(Yr.ATTR_HTTP_HOST,n.host),t.setAttribute(Yr.ATTR_HTTP_SCHEME,n.protocol.replace(":","")),"undefined"!=typeof navigator&&t.setAttribute(Yr.ATTR_HTTP_USER_AGENT,navigator.userAgent)),this._semconvStability&pr.STABLE){t.setAttribute(ge,e.status),t.setAttribute(me,n.hostname);const r=function(t){const e=Number(t.port||io[t.protocol]);return e&&!isNaN(e)?e:void 0}(n);r&&t.setAttribute(Se,r)}}_addHeaders(t,e){if(!Gr(e,this.getConfig().propagateTraceHeaderCorsUrls)){const t={};return qt.inject(Lt.active(),t),void(Object.keys(t).length>0&&this._diag.debug("headers inject skipped due to CORS policy"))}if(t instanceof Request)qt.inject(Lt.active(),t.headers,{set:(t,e,n)=>t.set(e,"string"==typeof n?n:String(n))});else if(t.headers instanceof Headers)qt.inject(Lt.active(),t.headers,{set:(t,e,n)=>t.set(e,"string"==typeof n?n:String(n))});else if(t.headers instanceof Map)qt.inject(Lt.active(),t.headers,{set:(t,e,n)=>t.set(e,"string"==typeof n?n:String(n))});else{const e={};qt.inject(Lt.active(),e),t.headers=Object.assign({},e,t.headers||{})}}_clearResources(){0===this._tasksCount&&this.getConfig().clearTimingResources&&(performance.clearResourceTimings(),this._usedResources=new WeakSet)}_createSpan(t,e={}){if(vn(t,this.getConfig().ignoreUrls))return void this._diag.debug("ignoring span as url matches ignored url");let n="";const r={};if(this._semconvStability&pr.OLD){const o=(e.method||"GET").toUpperCase();n=`HTTP ${o}`,r[Kr.COMPONENT]=this.moduleName,r[Yr.ATTR_HTTP_METHOD]=o,r[Yr.ATTR_HTTP_URL]=t}if(this._semconvStability&pr.STABLE){const o=e.method,i=no(e.method||"GET");n||(n=i),r[fe]=i,i!==o&&(r[_e]=o),r[Ee]=t}return this.tracer.startSpan(n,{kind:Ot.CLIENT,attributes:r})}_findResourceAndAddNetworkEvents(t,e,n){let r=e.entries;if(!r.length){if(!performance.getEntriesByType)return;r=performance.getEntriesByType("resource")}const o=$r(e.spanUrl,e.startTime,n,r,this._usedResources,"fetch");if(o.mainRequest){const e=o.mainRequest;this._markResourceAsUsed(e);const n=o.corsPreFlightRequest;n&&(this._addChildSpan(t,n),this._markResourceAsUsed(n));const r=!(this._semconvStability&pr.OLD);Vr(t,e,this.getConfig().ignoreNetworkEvents,void 0,r)}}_markResourceAsUsed(t){this._usedResources.add(t)}_endSpan(t,e,n){const r=Ne(Date.now()),o=Le();this._addFinalSpanAttributes(t,n),this._semconvStability&pr.STABLE&&n.status>=400&&(t.setStatus({code:Ct.ERROR}),t.setAttribute(pe,String(n.status))),setTimeout(()=>{e.observer?.disconnect(),this._findResourceAndAddNetworkEvents(t,e,o),this._tasksCount--,this._clearResources(),t.end(r)},300)}_patchConstructor(){return t=>{const e=this;return function(...n){const r=this,o=qr(n[0]instanceof Request?n[0].url:String(n[0])).href,i=n[0]instanceof Request?n[0]:n[1]||{},s=e._createSpan(o,i);if(!s)return t.apply(this,n);const a=e._prepareSpanData(o);function u(t,n){e._applyAttributesAfterFetch(t,i,n),e._endSpan(t,a,{status:n.status||0,statusText:n.message,url:o})}function c(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:o})}function l(t,e,n){try{const e=n.clone().body;if(e){const r=e.getReader(),o=()=>{r.read().then(({done:e})=>{e?c(t,n):o()},e=>{u(t,e)})};o()}else c(t,n)}finally{e(n)}}function p(t,e,n){try{u(t,n)}finally{e(n)}}return e.getConfig().measureRequestSize&&Jr(...n).then(t=>{t&&(e._semconvStability&pr.OLD&&s.setAttribute(Yr.ATTR_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED,t),e._semconvStability&pr.STABLE&&s.setAttribute(Yr.ATTR_HTTP_REQUEST_BODY_SIZE,t))}).catch(t=>{e._diag.warn("getFetchBodyLength",t)}),new Promise((n,a)=>Lt.with(Kt.setSpan(Lt.active(),s),()=>(e._addHeaders(i,o),e._callRequestHook(s,i),e._tasksCount++,t.apply(r,i instanceof Request?[i]:[o,i]).then(l.bind(r,s,n),p.bind(r,s,a)))))}}}_applyAttributesAfterFetch(t,e,n){const r=this.getConfig().applyCustomAttributesOnSpan;r&&cr(()=>r(t,e,n),t=>{t&&this._diag.error("applyCustomAttributesOnSpan",t)})}_callRequestHook(t,e){const n=this.getConfig().requestHook;n&&cr(()=>n(t,e),t=>{t&&this._diag.error("requestHook",t)})}_prepareSpanData(t){const e=Le(),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(){ao?this._diag.warn("this instrumentation is intended for web usage only, it does not instrument Node.js's fetch()"):(lr(fetch)&&(this._unwrap(ce,"fetch"),this._diag.debug("removing previous patch for constructor")),this._wrap(ce,"fetch",this._patchConstructor()))}disable(){ao||(this._unwrap(ce,"fetch"),this._usedResources=new WeakSet)}}var co;!function(t){t[t.Started=0]="Started",t[t.Halted=1]="Halted",t[t.Cancelled=2]="Cancelled",t[t.Ended=3]="Ended"}(co||(co={}));let lo={};var po;!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"}(po||(po={}));const ho=xt.createComponentLogger({namespace:"@opentelemetry/opentelemetry-instrumentation-xml-http-request/utils"});function fo(t){return e=t,"undefined"!=typeof Document&&e instanceof Document?(new XMLSerializer).serializeToString(document).length:"string"==typeof t?go(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?go(t.toString()):void 0!==t.byteLength?t.byteLength:void ho.warn("unknown body type");var e}const _o=new TextEncoder;function go(t){return _o.encode(t).byteLength}const mo={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0};let So;function vo(){return void 0===So&&(So=mo),So}const To={"https:":"443","http:":"80"};const yo="0.203.0";var bo;!function(t){t.HTTP_STATUS_TEXT="http.status_text"}(bo||(bo={}));class Eo extends ur{component="xml-http-request";version=yo;moduleName=this.component;_tasksCount=0;_xhrMem=new WeakMap;_usedResources=new WeakSet;_semconvStability;constructor(t={}){super("@opentelemetry/instrumentation-xml-http-request",yo,t),this._semconvStability=dr("http",t?.semconvStabilityOptIn)}init(){}_addHeaders(t,e){if(!Gr(qr(e).href,this.getConfig().propagateTraceHeaderCorsUrls)){const t={};return qt.inject(Lt.active(),t),void(Object.keys(t).length>0&&this._diag.debug("headers inject skipped due to CORS policy"))}const n={};qt.inject(Lt.active(),n),Object.keys(n).forEach(e=>{t.setRequestHeader(e,String(n[e]))})}_addChildSpan(t,e){Lt.with(Kt.setSpan(Lt.active(),t),()=>{const t=this.tracer.startSpan("CORS Preflight",{startTime:e[kr.FETCH_START]}),n=!(this._semconvStability&pr.OLD);Vr(t,e,this.getConfig().ignoreNetworkEvents,void 0,n),t.end(e[kr.RESPONSE_END])})}_addFinalSpanAttributes(t,e,n){if(this._semconvStability&pr.OLD){if(void 0!==e.status&&t.setAttribute("http.status_code",e.status),void 0!==e.statusText&&t.setAttribute(bo.HTTP_STATUS_TEXT,e.statusText),"string"==typeof n){const e=qr(n);t.setAttribute("http.host",e.host),t.setAttribute("http.scheme",e.protocol.replace(":",""))}t.setAttribute("http.user_agent",navigator.userAgent)}this._semconvStability&pr.STABLE&&e.status&&t.setAttribute(ge,e.status)}_applyAttributesAfterXHR(t,e){const n=this.getConfig().applyCustomAttributesOnSpan;"function"==typeof n&&cr(()=>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(),o=qr(e);r.forEach(t=>{"xmlhttprequest"===t.initiatorType&&t.name===o.href&&n.createdResources&&n.createdResources.entries.push(t)})}),entries:[]},n.createdResources.observer.observe({entryTypes:["resource"]}))}_clearResources(){0===this._tasksCount&&this.getConfig().clearTimingResources&&(le.clearResourceTimings(),this._xhrMem=new WeakMap,this._usedResources=new WeakSet)}_findResourceAndAddNetworkEvents(t,e,n,r,o){if(!(n&&r&&o&&t.createdResources))return;let i=t.createdResources.entries;i&&i.length||(i=le.getEntriesByType("resource"));const s=$r(qr(n).href,r,o,i,this._usedResources);if(s.mainRequest){const t=s.mainRequest;this._markResourceAsUsed(t);const n=s.corsPreFlightRequest;n&&(this._addChildSpan(e,n),this._markResourceAsUsed(n));const r=!(this._semconvStability&pr.OLD);Vr(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(vn(e,this.getConfig().ignoreUrls))return void this._diag.debug("ignoring span as url matches ignored url");let r="";const o=qr(e),i={};if(this._semconvStability&pr.OLD&&(r=n.toUpperCase(),i["http.method"]=n,i["http.url"]=o.toString()),this._semconvStability&pr.STABLE){const t=n,e=function(t){const e=vo(),n=t.toUpperCase();return n in e?n:"_OTHER"}(n);r||(r=e),i[fe]=e,e!==t&&(i[_e]=t),i[Ee]=o.toString(),i[me]=o.hostname;const s=function(t){const e=Number(t.port||To[t.protocol]);return e&&!isNaN(e)?e:void 0}(o);s&&(i[Se]=s)}const s=this.tracer.startSpan(r,{kind:Ot.CLIENT,attributes:i});return s.addEvent(po.METHOD_OPEN),this._cleanPreviousSpanInformation(t),this._xhrMem.set(t,{span:s,spanUrl:e}),s}_markResourceAsUsed(t){this._usedResources.add(t)}_patchOpen(){return t=>{const e=this;return function(...n){const r=n[0],o=n[1];return e._createSpan(this,o,r),t.apply(this,n)}}}_patchSend(){const t=this;function e(e,n,r,o){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&pr.STABLE&&(r?o&&(e.setStatus({code:Ct.ERROR,message:o}),e.setAttribute(pe,o)):i.status&&i.status>=400&&(e.setStatus({code:Ct.ERROR}),e.setAttribute(pe,String(i.status))))}const s=Le(),a=Date.now();setTimeout(()=>{!function(e,n,r,o){const i=n.callbackToRemoveEvents;"function"==typeof i&&i();const{span:s,spanUrl:a,sendStartTime:u}=n;s&&(t._findResourceAndAddNetworkEvents(n,s,a,u,r),s.addEvent(e,o),t._addFinalSpanAttributes(s,n,a),s.end(o),t._tasksCount--),t._clearResources()}(e,i,s,a)},300)}function n(){e(po.EVENT_ERROR,this,!0,"error")}function r(){e(po.EVENT_ABORT,this,!1)}function o(){e(po.EVENT_TIMEOUT,this,!0,"timeout")}function i(){this.status<299?e(po.EVENT_LOAD,this,!1):e(po.EVENT_ERROR,this,!1)}return e=>function(...s){const a=t._xhrMem.get(this);if(!a)return e.apply(this,s);const u=a.span,c=a.spanUrl;if(u&&c){if(t.getConfig().measureRequestSize&&s?.[0]){const e=fo(s[0]);void 0!==e&&(t._semconvStability&pr.OLD&&u.setAttribute("http.request_content_length_uncompressed",e),t._semconvStability&pr.STABLE&&u.setAttribute("http.request.body.size",e))}Lt.with(Kt.setSpan(Lt.active(),u),()=>{t._tasksCount++,a.sendStartTime=Le(),u.addEvent(po.METHOD_SEND),this.addEventListener("abort",r),this.addEventListener("error",n),this.addEventListener("load",i),this.addEventListener("timeout",o),a.callbackToRemoveEvents=()=>{!function(e){e.removeEventListener("abort",r),e.removeEventListener("error",n),e.removeEventListener("load",i),e.removeEventListener("timeout",o);const s=t._xhrMem.get(e);s&&(s.callbackToRemoveEvents=void 0)}(this),a.createdResources&&a.createdResources.observer.disconnect()},t._addHeaders(this,c),t._addResourceObserver(this,c)})}return e.apply(this,s)}}enable(){this._diag.debug("applying patch to",this.moduleName,this.version),lr(XMLHttpRequest.prototype.open)&&(this._unwrap(XMLHttpRequest.prototype,"open"),this._diag.debug("removing previous patch from method open")),lr(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 Ao extends Eo{constructor(t={}){super(t);this.parentCreateSpan=this._createSpan.bind(this)}_patchOpen(){return t=>{const n=this;return function(...r){let o;try{const t=r[0];let i=e.getUrlFromResource(r[1]);o=n.parentCreateSpan(this,i,t)}catch(t){lo.internalLogger.error(t)}const i=lo.api.getActiveUserAction();return o&&i&&i.getState()===co.Started&&(o.setAttribute("faro.action.user.name",i.name),o.setAttribute("faro.action.user.parentId",i.parentId)),t.apply(this,r)}}}}function Oo(t,e,n){Co(t,n instanceof Error?0:n.status)}function Co(t,e){if(null==e)return;(0===e||e>=400&&e<600)&&t.setStatus({code:Ct.ERROR})}function wo(t){return(e,n,r)=>{Oo(e,0,r),null==t||t(e,n,r)}}function Ro(t){return(e,n)=>{!function(t,e){Co(t,e.status)}(e,n),null==t||t(e,n)}}function No(t={}){const{fetchInstrumentationOptions:e,xhrInstrumentationOptions:n}=t,r=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 o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}(t,["fetchInstrumentationOptions","xhrInstrumentationOptions"]),o=function(t,e){return Object.assign(Object.assign(Object.assign(Object.assign({},e),{ignoreNetworkEvents:!0}),t),{applyCustomAttributesOnSpan:wo(null==t?void 0:t.applyCustomAttributesOnSpan),requestHook:(t,e)=>{const n=lo.api.getActiveUserAction();n&&n.getState()===co.Started&&(t.setAttribute("faro.action.user.name",n.name),t.setAttribute("faro.action.user.parentId",n.parentId))}})}(e,r),i=function(t,e){return Object.assign(Object.assign(Object.assign(Object.assign({},e),{ignoreNetworkEvents:!0}),t),{applyCustomAttributesOnSpan:Ro(null==t?void 0:t.applyCustomAttributesOnSpan)})}(n,r);return[new uo(o),new Ao(i)]}class Po{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 o=null!==(n=this.metas.value.user)&&void 0!==n?n:{};o.email&&(t.attributes["user.email"]=o.email),o.id&&(t.attributes["user.id"]=o.id),o.username&&(t.attributes["user.name"]=o.username),o.fullName&&(t.attributes["user.full_name"]=o.fullName),o.roles&&(t.attributes["user.roles"]=o.roles.split(",").map(t=>t.trim())),o.hash&&(t.attributes["user.hash"]=o.hash),this.processor.onStart(t,e)}onEnd(t){this.processor.onEnd(t)}shutdown(){return this.processor.shutdown()}}function Lo(t={}){var e;return"true"===(null===(e=t.attributes)||void 0===e?void 0:e.isSampled)?vr.RECORD_AND_SAMPLED:vr.NOT_RECORD}class xo extends e.BaseInstrumentation{constructor(t={}){super(),this.options=t,this.name="@grafana/faro-web-tracing",this.version=e.VERSION}initialize(){var t,n,r,o,i;const s=this.options,a={};this.config.app.name&&(a[ve]=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 u=this.metas.value.browser;e.isArray(null==u?void 0:u.brands)&&(a["browser.brands"]=u.brands.map(t=>t.brand)),(null==u?void 0:u.language)&&(a["browser.language"]=u.language),"boolean"==typeof(null==u?void 0:u.mobile)&&(a["browser.mobile"]=Boolean(u.mobile)),(null==u?void 0:u.os)&&(a["browser.platform"]=u.os),(null==u?void 0:u.userAgent)&&(a["user_agent.original"]=u.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,s.resourceAttributes);const c=gr().merge(_r(a));new Hr({resource:c,sampler:{shouldSample:()=>({decision:Lo(this.api.getSession())})},spanProcessors:[null!==(n=s.spanProcessor)&&void 0!==n?n:new Po(new Nr(new $n({api:this.api}),{scheduledDelayMillis:xo.SCHEDULED_BATCH_DELAY_MS,maxExportBatchSize:30}),this.metas)]}).register({propagator:null!==(r=s.propagator)&&void 0!==r?r:new Qe,contextManager:s.contextManager});const{propagateTraceHeaderCorsUrls:l,fetchInstrumentationOptions:p,xhrInstrumentationOptions:d}=null!==(o=this.options.instrumentationOptions)&&void 0!==o?o:{};!function(t){const e=t.tracerProvider||Kt.getTracerProvider(),n=t.meterProvider||Mt.getMeterProvider(),r=t.loggerProvider||tr.getLoggerProvider(),o=t.instrumentations?.flat()??[];(function(t,e,n,r){for(let o=0,i=t.length;o<i;o++){const i=t[o];e&&i.setTracerProvider(e),n&&i.setMeterProvider(n),r&&i.setLoggerProvider&&i.setLoggerProvider(r),i.getConfig().enabled||i.enable()}})(o,e,n,r)}({instrumentations:null!==(i=s.instrumentations)&&void 0!==i?i:No({ignoreUrls:this.getIgnoreUrls(),propagateTraceHeaderCorsUrls:l,fetchInstrumentationOptions:p,xhrInstrumentationOptions:d})}),this.api.initOTEL(Kt,Lt)}getIgnoreUrls(){return this.transports.transports.flatMap(t=>t.getIgnoreUrls())}}return xo.SCHEDULED_BATCH_DELAY_MS=1e3,t.FaroTraceExporter=$n,t.TracingInstrumentation=xo,t.fetchCustomAttributeFunctionWithDefaults=wo,t.getDefaultOTELInstrumentations=No,t.getSamplingDecision=Lo,t.setSpanStatusOnFetchError=Oo,t}({},GrafanaFaroWebSdk);
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { type Context } from '@opentelemetry/api';
|
|
2
2
|
import type { ReadableSpan, Span, SpanProcessor } from '@opentelemetry/sdk-trace-web';
|
|
3
|
-
import type { UserActionStartMessage } from '@grafana/faro-web-sdk';
|
|
4
3
|
export declare class FaroUserActionSpanProcessor implements SpanProcessor {
|
|
5
4
|
private processor;
|
|
6
|
-
message: UserActionStartMessage | undefined;
|
|
7
5
|
constructor(processor: SpanProcessor);
|
|
8
6
|
forceFlush(): Promise<void>;
|
|
9
7
|
onStart(span: Span, parentContext: Context): void;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { FaroTraceExporter } from './faroTraceExporter';
|
|
2
|
-
export { FaroSessionSpanProcessor } from './sessionSpanProcessor';
|
|
3
2
|
export { getDefaultOTELInstrumentations } from './getDefaultOTELInstrumentations';
|
|
4
3
|
export { TracingInstrumentation } from './instrumentation';
|
|
5
4
|
export { getSamplingDecision } from './sampler';
|
|
@@ -15,10 +15,6 @@ var FaroMetaAttributesSpanProcessor = /** @class */ (function () {
|
|
|
15
15
|
var session = this.metas.value.session;
|
|
16
16
|
if (session === null || session === void 0 ? void 0 : session.id) {
|
|
17
17
|
span.attributes[semconv_1.ATTR_SESSION_ID] = session.id;
|
|
18
|
-
/**
|
|
19
|
-
* @deprecated will be removed in the future and has been replaced by ATTR_SESSION_ID (session.id)
|
|
20
|
-
*/
|
|
21
|
-
span.attributes['session_id'] = session.id;
|
|
22
18
|
}
|
|
23
19
|
var user = (_a = this.metas.value.user) !== null && _a !== void 0 ? _a : {};
|
|
24
20
|
if (user.email) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faroMetaAttributesSpanProcessor.js","sourceRoot":"","sources":["../../src/faroMetaAttributesSpanProcessor.ts"],"names":[],"mappings":";;;AAKA,qCAA4C;AAE5C;IACE,yCACU,SAAwB,EACxB,KAAY;QADZ,cAAS,GAAT,SAAS,CAAe;QACxB,UAAK,GAAL,KAAK,CAAO;IACnB,CAAC;IAEJ,oDAAU,GAAV;QACE,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;IACrC,CAAC;IAED,iDAAO,GAAP,UAAQ,IAAU,EAAE,aAAsB;;QACxC,IAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;QAEzC,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,EAAE,EAAE,CAAC;YAChB,IAAI,CAAC,UAAU,CAAC,yBAAe,CAAC,GAAG,OAAO,CAAC,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"faroMetaAttributesSpanProcessor.js","sourceRoot":"","sources":["../../src/faroMetaAttributesSpanProcessor.ts"],"names":[],"mappings":";;;AAKA,qCAA4C;AAE5C;IACE,yCACU,SAAwB,EACxB,KAAY;QADZ,cAAS,GAAT,SAAS,CAAe;QACxB,UAAK,GAAL,KAAK,CAAO;IACnB,CAAC;IAEJ,oDAAU,GAAV;QACE,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;IACrC,CAAC;IAED,iDAAO,GAAP,UAAQ,IAAU,EAAE,aAAsB;;QACxC,IAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;QAEzC,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,EAAE,EAAE,CAAC;YAChB,IAAI,CAAC,UAAU,CAAC,yBAAe,CAAC,GAAG,OAAO,CAAC,EAAE,CAAC;QAChD,CAAC;QAED,IAAM,IAAI,GAAG,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,mCAAI,EAAE,CAAC;QAEzC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;QAC7C,CAAC;QAED,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACZ,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;QACvC,CAAC;QAED,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/C,CAAC;QAED,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;QACpD,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,UAAC,IAAI,IAAK,OAAA,IAAI,CAAC,IAAI,EAAE,EAAX,CAAW,CAAC,CAAC;QACnF,CAAC;QAED,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;QAC3C,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;IAC9C,CAAC;IAED,+CAAK,GAAL,UAAM,IAAkB;QACtB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,kDAAQ,GAAR;QACE,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IACnC,CAAC;IACH,sCAAC;AAAD,CAAC,AArDD,IAqDC;AArDY,0EAA+B","sourcesContent":["import type { Context } from '@opentelemetry/api';\nimport type { ReadableSpan, Span, SpanProcessor } from '@opentelemetry/sdk-trace-web';\n\nimport type { Metas } from '@grafana/faro-web-sdk';\n\nimport { ATTR_SESSION_ID } from './semconv';\n\nexport class FaroMetaAttributesSpanProcessor implements SpanProcessor {\n constructor(\n private processor: SpanProcessor,\n private metas: Metas\n ) {}\n\n forceFlush(): Promise<void> {\n return this.processor.forceFlush();\n }\n\n onStart(span: Span, parentContext: Context): void {\n const session = this.metas.value.session;\n\n if (session?.id) {\n span.attributes[ATTR_SESSION_ID] = session.id;\n }\n\n const user = this.metas.value.user ?? {};\n\n if (user.email) {\n span.attributes['user.email'] = user.email;\n }\n\n if (user.id) {\n span.attributes['user.id'] = user.id;\n }\n\n if (user.username) {\n span.attributes['user.name'] = user.username;\n }\n\n if (user.fullName) {\n span.attributes['user.full_name'] = user.fullName;\n }\n\n if (user.roles) {\n span.attributes['user.roles'] = user.roles.split(',').map((role) => role.trim());\n }\n\n if (user.hash) {\n span.attributes['user.hash'] = user.hash;\n }\n\n this.processor.onStart(span, parentContext);\n }\n\n onEnd(span: ReadableSpan): void {\n this.processor.onEnd(span);\n }\n\n shutdown(): Promise<void> {\n return this.processor.shutdown();\n }\n}\n"]}
|
|
@@ -2,33 +2,33 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FaroUserActionSpanProcessor = void 0;
|
|
4
4
|
var api_1 = require("@opentelemetry/api");
|
|
5
|
-
var
|
|
5
|
+
var faro_core_1 = require("@grafana/faro-core");
|
|
6
|
+
// There is very rare race condition that would result in span being attached to different user action. As shown in the diagram below.
|
|
7
|
+
// The scenario is the following
|
|
8
|
+
//
|
|
9
|
+
// 1. User action (id = 1) starts
|
|
10
|
+
// 2. Things happen for a given amount of time
|
|
11
|
+
// 3. User action ends
|
|
12
|
+
// 4. Span processor starts
|
|
13
|
+
// 5. A new user action (id = 2) starts
|
|
14
|
+
// 6. Span processor tries to attach the `faro.user.action` attributes based on the state of the current user action which is id = 2.
|
|
15
|
+
//
|
|
16
|
+
// This ultimately depends on the processing delay of the span processor which deems this race condition highly unlikely.
|
|
6
17
|
var FaroUserActionSpanProcessor = /** @class */ (function () {
|
|
7
18
|
function FaroUserActionSpanProcessor(processor) {
|
|
8
|
-
var _this = this;
|
|
9
19
|
this.processor = processor;
|
|
10
|
-
faro_web_sdk_1.apiMessageBus.subscribe(function (msg) {
|
|
11
|
-
if (msg.type === faro_web_sdk_1.USER_ACTION_START) {
|
|
12
|
-
_this.message = msg;
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
if ([faro_web_sdk_1.USER_ACTION_END, faro_web_sdk_1.USER_ACTION_HALT, faro_web_sdk_1.USER_ACTION_CANCEL].includes(msg.type)) {
|
|
16
|
-
_this.message = undefined;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
20
|
}
|
|
20
21
|
FaroUserActionSpanProcessor.prototype.forceFlush = function () {
|
|
21
22
|
return this.processor.forceFlush();
|
|
22
23
|
};
|
|
23
24
|
FaroUserActionSpanProcessor.prototype.onStart = function (span, parentContext) {
|
|
24
|
-
var
|
|
25
|
-
if (span.kind === api_1.SpanKind.CLIENT) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (
|
|
30
|
-
span.attributes['faro.action.user.
|
|
31
|
-
span.attributes['faro.action.user.parentId'] = (_b = this.message) === null || _b === void 0 ? void 0 : _b.parentId;
|
|
25
|
+
var userAction = faro_core_1.faro.api.getActiveUserAction();
|
|
26
|
+
if (userAction && userAction.getState() === faro_core_1.UserActionState.Started && span.kind === api_1.SpanKind.CLIENT) {
|
|
27
|
+
if (!span.attributes['faro.action.user.name']) {
|
|
28
|
+
span.attributes['faro.action.user.name'] = userAction === null || userAction === void 0 ? void 0 : userAction.name;
|
|
29
|
+
}
|
|
30
|
+
if (!span.attributes['faro.action.user.parentId']) {
|
|
31
|
+
span.attributes['faro.action.user.parentId'] = userAction === null || userAction === void 0 ? void 0 : userAction.parentId;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
this.processor.onStart(span, parentContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faroUserActionSpanProcessor.js","sourceRoot":"","sources":["../../src/faroUserActionSpanProcessor.ts"],"names":[],"mappings":";;;AAAA,0CAA4D;AAG5D,
|
|
1
|
+
{"version":3,"file":"faroUserActionSpanProcessor.js","sourceRoot":"","sources":["../../src/faroUserActionSpanProcessor.ts"],"names":[],"mappings":";;;AAAA,0CAA4D;AAG5D,gDAA2D;AAE3D,sIAAsI;AACtI,gCAAgC;AAChC,EAAE;AACF,iCAAiC;AACjC,8CAA8C;AAC9C,sBAAsB;AACtB,2BAA2B;AAC3B,uCAAuC;AACvC,qIAAqI;AACrI,EAAE;AACF,yHAAyH;AACzH;IACE,qCAAoB,SAAwB;QAAxB,cAAS,GAAT,SAAS,CAAe;IAAG,CAAC;IAEhD,gDAAU,GAAV;QACE,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;IACrC,CAAC;IAED,6CAAO,GAAP,UAAQ,IAAU,EAAE,aAAsB;QACxC,IAAM,UAAU,GAAG,gBAAI,CAAC,GAAG,CAAC,mBAAmB,EAAE,CAAC;QAClD,IAAI,UAAU,IAAI,UAAU,CAAC,QAAQ,EAAE,KAAK,2BAAe,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,KAAK,cAAQ,CAAC,MAAM,EAAE,CAAC;YACrG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,uBAAuB,CAAC,EAAE,CAAC;gBAC9C,IAAI,CAAC,UAAU,CAAC,uBAAuB,CAAC,GAAG,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI,CAAC;YAC9D,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,2BAA2B,CAAC,EAAE,CAAC;gBAClD,IAAI,CAAC,UAAU,CAAC,2BAA2B,CAAC,GAAG,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,CAAC;YACtE,CAAC;QACH,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;IAC9C,CAAC;IAED,2CAAK,GAAL,UAAM,IAAkB;QACtB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,8CAAQ,GAAR;QACE,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IACnC,CAAC;IACH,kCAAC;AAAD,CAAC,AA5BD,IA4BC;AA5BY,kEAA2B","sourcesContent":["import { type Context, SpanKind } from '@opentelemetry/api';\nimport type { ReadableSpan, Span, SpanProcessor } from '@opentelemetry/sdk-trace-web';\n\nimport { faro, UserActionState } from '@grafana/faro-core';\n\n// There is very rare race condition that would result in span being attached to different user action. As shown in the diagram below.\n// The scenario is the following\n//\n// 1. User action (id = 1) starts\n// 2. Things happen for a given amount of time\n// 3. User action ends\n// 4. Span processor starts\n// 5. A new user action (id = 2) starts\n// 6. Span processor tries to attach the `faro.user.action` attributes based on the state of the current user action which is id = 2.\n//\n// This ultimately depends on the processing delay of the span processor which deems this race condition highly unlikely.\nexport class FaroUserActionSpanProcessor implements SpanProcessor {\n constructor(private processor: SpanProcessor) {}\n\n forceFlush(): Promise<void> {\n return this.processor.forceFlush();\n }\n\n onStart(span: Span, parentContext: Context): void {\n const userAction = faro.api.getActiveUserAction();\n if (userAction && userAction.getState() === UserActionState.Started && span.kind === SpanKind.CLIENT) {\n if (!span.attributes['faro.action.user.name']) {\n span.attributes['faro.action.user.name'] = userAction?.name;\n }\n if (!span.attributes['faro.action.user.parentId']) {\n span.attributes['faro.action.user.parentId'] = userAction?.parentId;\n }\n }\n\n this.processor.onStart(span, parentContext);\n }\n\n onEnd(span: ReadableSpan): void {\n this.processor.onEnd(span);\n }\n\n shutdown(): Promise<void> {\n return this.processor.shutdown();\n }\n}\n"]}
|
|
@@ -17,6 +17,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.FaroXhrInstrumentation = void 0;
|
|
19
19
|
var instrumentation_xml_http_request_1 = require("@opentelemetry/instrumentation-xml-http-request");
|
|
20
|
+
var faro_core_1 = require("@grafana/faro-core");
|
|
20
21
|
var faro_web_sdk_1 = require("@grafana/faro-web-sdk");
|
|
21
22
|
var FaroXhrInstrumentation = /** @class */ (function (_super) {
|
|
22
23
|
__extends(FaroXhrInstrumentation, _super);
|
|
@@ -37,13 +38,19 @@ var FaroXhrInstrumentation = /** @class */ (function (_super) {
|
|
|
37
38
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
38
39
|
args[_i] = arguments[_i];
|
|
39
40
|
}
|
|
41
|
+
var span;
|
|
40
42
|
try {
|
|
41
43
|
var method = args[0];
|
|
42
44
|
var url = (0, faro_web_sdk_1.getUrlFromResource)(args[1]);
|
|
43
|
-
plugin.parentCreateSpan(this, url, method);
|
|
45
|
+
span = plugin.parentCreateSpan(this, url, method);
|
|
44
46
|
}
|
|
45
47
|
catch (error) {
|
|
46
|
-
|
|
48
|
+
faro_core_1.faro.internalLogger.error(error);
|
|
49
|
+
}
|
|
50
|
+
var currentAction = faro_core_1.faro.api.getActiveUserAction();
|
|
51
|
+
if (span && currentAction && currentAction.getState() === faro_core_1.UserActionState.Started) {
|
|
52
|
+
span.setAttribute('faro.action.user.name', currentAction.name);
|
|
53
|
+
span.setAttribute('faro.action.user.parentId', currentAction.parentId);
|
|
47
54
|
}
|
|
48
55
|
return original.apply(this, args);
|
|
49
56
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faroXhrInstrumentation.js","sourceRoot":"","sources":["../../src/faroXhrInstrumentation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,oGAAgG;AAIhG,
|
|
1
|
+
{"version":3,"file":"faroXhrInstrumentation.js","sourceRoot":"","sources":["../../src/faroXhrInstrumentation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,oGAAgG;AAIhG,gDAA2D;AAC3D,sDAA2D;AAM3D;IAA4C,0CAA6B;IAGvE,gCAAY,MAAgD;QAAhD,uBAAA,EAAA,WAAgD;QAC1D,YAAA,MAAK,YAAC,MAAM,CAAC,SAAC;QAEd,IAAM,IAAI,GAAG,KAAqB,CAAC;QACnC,KAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAI,CAAC,CAAC;;IACtD,CAAC;IAED,wEAAwE;IACrD,2CAAU,GAA7B;QAAA,iBAuBC;QAtBC,OAAO,UAAC,QAAsB;YAC5B,IAAM,MAAM,GAAG,KAAI,CAAC;YACpB,OAAO,SAAS,SAAS;gBAAuB,cAAO;qBAAP,UAAO,EAAP,qBAAO,EAAP,IAAO;oBAAP,yBAAO;;gBACrD,IAAI,IAAsB,CAAC;gBAC3B,IAAI,CAAC;oBACH,IAAM,MAAM,GAAW,IAAI,CAAC,CAAC,CAAC,CAAC;oBAC/B,IAAI,GAAG,GAAiB,IAAA,iCAAkB,EAAC,IAAI,CAAC,CAAC,CAAC,CAAE,CAAC;oBAErD,IAAI,GAAG,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;gBACpD,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,gBAAI,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBACnC,CAAC;gBAED,IAAM,aAAa,GAAG,gBAAI,CAAC,GAAG,CAAC,mBAAmB,EAAE,CAAC;gBACrD,IAAI,IAAI,IAAI,aAAa,IAAI,aAAa,CAAC,QAAQ,EAAE,KAAK,2BAAe,CAAC,OAAO,EAAE,CAAC;oBAClF,IAAI,CAAC,YAAY,CAAC,uBAAuB,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;oBAC/D,IAAI,CAAC,YAAY,CAAC,2BAA2B,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;gBACzE,CAAC;gBAED,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACpC,CAAC,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;IACH,6BAAC;AAAD,CAAC,AAnCD,CAA4C,gEAA6B,GAmCxE;AAnCY,wDAAsB","sourcesContent":["import type { Span } from '@opentelemetry/api';\nimport { XMLHttpRequestInstrumentation } from '@opentelemetry/instrumentation-xml-http-request';\nimport type { XMLHttpRequestInstrumentationConfig } from '@opentelemetry/instrumentation-xml-http-request';\nimport type { OpenFunction } from '@opentelemetry/instrumentation-xml-http-request/build/src/types';\n\nimport { faro, UserActionState } from '@grafana/faro-core';\nimport { getUrlFromResource } from '@grafana/faro-web-sdk';\n\ntype Parent = {\n _createSpan: (xhr: XMLHttpRequest, url: string, method: string) => Span | undefined;\n};\n\nexport class FaroXhrInstrumentation extends XMLHttpRequestInstrumentation {\n private parentCreateSpan: Parent['_createSpan'];\n\n constructor(config: XMLHttpRequestInstrumentationConfig = {}) {\n super(config);\n\n const self = this as any as Parent;\n this.parentCreateSpan = self._createSpan.bind(this);\n }\n\n // Patching the parent's private method to handle url type string or URL\n protected override _patchOpen() {\n return (original: OpenFunction): OpenFunction => {\n const plugin = this;\n return function patchOpen(this: XMLHttpRequest, ...args): void {\n let span: Span | undefined;\n try {\n const method: string = args[0];\n let url: string | URL = getUrlFromResource(args[1])!;\n\n span = plugin.parentCreateSpan(this, url, method);\n } catch (error) {\n faro.internalLogger.error(error);\n }\n\n const currentAction = faro.api.getActiveUserAction();\n if (span && currentAction && currentAction.getState() === UserActionState.Started) {\n span.setAttribute('faro.action.user.name', currentAction.name);\n span.setAttribute('faro.action.user.parentId', currentAction.parentId);\n }\n\n return original.apply(this, args);\n };\n };\n }\n}\n"]}
|