UNPKG

@sumologic/opentelemetry-rum

Version:

Adds OpenTelemetry tracing auto-instrumentation in the browser. Collects spans on network events and sends them to Sumo Logic.

1 lines 131 kB
!function(t){"use strict";const e="object"==typeof globalThis?globalThis:"object"==typeof self?self:"object"==typeof window?window:"object"==typeof global?global:{},n="1.8.0",r=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;const s=function(t){const e=new Set([t]),n=new Set,s=t.match(r);if(!s)return()=>!1;const i=+s[1],o=+s[2],a=+s[3];if(null!=s[4])return function(e){return e===t};function c(t){return n.add(t),!1}function u(t){return e.add(t),!0}return function(t){if(e.has(t))return!0;if(n.has(t))return!1;const s=t.match(r);if(!s)return c(t);const l=+s[1],d=+s[2],h=+s[3];return null!=s[4]||i!==l?c(t):0===i?o===d&&a<=h?u(t):c(t):o<=d?u(t):c(t)}}(n),i=n.split(".")[0],o=Symbol.for(`opentelemetry.js.api.${i}`),a=e;function c(t,e,r,s=!1){var i;const c=a[o]=null!==(i=a[o])&&void 0!==i?i:{version:n};if(!s&&c[t]){const e=new Error(`@opentelemetry/api: Attempted duplicate registration of API: ${t}`);return r.error(e.stack||e.message),!1}if(c.version!==n){const e=new Error(`@opentelemetry/api: Registration of version v${c.version} for ${t} does not match previously registered API v${n}`);return r.error(e.stack||e.message),!1}return c[t]=e,r.debug(`@opentelemetry/api: Registered a global for ${t} v${n}.`),!0}function u(t){var e,n;const r=null===(e=a[o])||void 0===e?void 0:e.version;if(r&&s(r))return null===(n=a[o])||void 0===n?void 0:n[t]}function l(t,e){e.debug(`@opentelemetry/api: Unregistering a global for ${t} v${n}.`);const r=a[o];r&&delete r[t]}class d{constructor(t){this._namespace=t.namespace||"DiagComponentLogger"}debug(...t){return h("debug",this._namespace,t)}error(...t){return h("error",this._namespace,t)}info(...t){return h("info",this._namespace,t)}warn(...t){return h("warn",this._namespace,t)}verbose(...t){return h("verbose",this._namespace,t)}}function h(t,e,n){const r=u("diag");if(r)return n.unshift(e),r[t](...n)}var _;!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"}(_||(_={}));class p{constructor(){function t(t){return function(...e){const n=u("diag");if(n)return n[t](...e)}}const e=this;e.setLogger=(t,n={logLevel:_.INFO})=>{var r,s,i;if(t===e){const t=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return e.error(null!==(r=t.stack)&&void 0!==r?r:t.message),!1}"number"==typeof n&&(n={logLevel:n});const o=u("diag"),a=function(t,e){function n(n,r){const s=e[n];return"function"==typeof s&&t>=r?s.bind(e):function(){}}return t<_.NONE?t=_.NONE:t>_.ALL&&(t=_.ALL),e=e||{},{error:n("error",_.ERROR),warn:n("warn",_.WARN),info:n("info",_.INFO),debug:n("debug",_.DEBUG),verbose:n("verbose",_.VERBOSE)}}(null!==(s=n.logLevel)&&void 0!==s?s:_.INFO,t);if(o&&!n.suppressOverrideMessage){const t=null!==(i=(new Error).stack)&&void 0!==i?i:"<failed to generate stacktrace>";o.warn(`Current logger will be overwritten from ${t}`),a.warn(`Current logger will overwrite one already registered from ${t}`)}return c("diag",a,e,!0)},e.disable=()=>{l("diag",e)},e.createComponentLogger=t=>new d(t),e.verbose=t("verbose"),e.debug=t("debug"),e.info=t("info"),e.warn=t("warn"),e.error=t("error")}static instance(){return this._instance||(this._instance=new p),this._instance}}class m{constructor(t){this._entries=t?new Map(t):new Map}getEntry(t){const e=this._entries.get(t);if(e)return Object.assign({},e)}getAllEntries(){return Array.from(this._entries.entries()).map((([t,e])=>[t,e]))}setEntry(t,e){const n=new m(this._entries);return n._entries.set(t,e),n}removeEntry(t){const e=new m(this._entries);return e._entries.delete(t),e}removeEntries(...t){const e=new m(this._entries);for(const n of t)e._entries.delete(n);return e}clear(){return new m}}const E=Symbol("BaggageEntryMetadata"),T=p.instance();function g(t={}){return new m(new Map(Object.entries(t)))}function f(t){return"string"!=typeof t&&(T.error("Cannot create baggage metadata from unknown type: "+typeof t),t=""),{__TYPE__:E,toString:()=>t}}function v(t){return Symbol.for(t)}class S{constructor(t){const e=this;e._currentContext=t?new Map(t):new Map,e.getValue=t=>e._currentContext.get(t),e.setValue=(t,n)=>{const r=new S(e._currentContext);return r._currentContext.set(t,n),r},e.deleteValue=t=>{const n=new S(e._currentContext);return n._currentContext.delete(t),n}}}const b=new S,O=[{n:"error",c:"error"},{n:"warn",c:"warn"},{n:"info",c:"info"},{n:"debug",c:"debug"},{n:"verbose",c:"trace"}];class R{}class L{addCallback(t){}removeCallback(t){}}const A=new class{constructor(){}createHistogram(t,e){return y}createCounter(t,e){return w}createUpDownCounter(t,e){return N}createObservableGauge(t,e){return C}createObservableCounter(t,e){return P}createObservableUpDownCounter(t,e){return I}addBatchObservableCallback(t,e){}removeBatchObservableCallback(t){}},w=new class extends R{add(t,e){}},y=new class extends R{record(t,e){}},N=new class extends R{add(t,e){}},P=new class extends L{},C=new class extends L{},I=new class extends L{};var x;!function(t){t[t.INT=0]="INT",t[t.DOUBLE=1]="DOUBLE"}(x||(x={}));const M={get(t,e){if(null!=t)return t[e]},keys:t=>null==t?[]:Object.keys(t)},U={set(t,e,n){null!=t&&(t[e]=n)}};const D="context",k=new class{active(){return b}with(t,e,n,...r){return e.call(n,...r)}bind(t,e){return e}enable(){return this}disable(){return this}};class B{constructor(){}static getInstance(){return this._instance||(this._instance=new B),this._instance}setGlobalContextManager(t){return c(D,t,p.instance())}active(){return this._getContextManager().active()}with(t,e,n,...r){return this._getContextManager().with(t,e,n,...r)}bind(t,e){return this._getContextManager().bind(t,e)}_getContextManager(){return u(D)||k}disable(){this._getContextManager().disable(),l(D,p.instance())}}var H;!function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"}(H||(H={}));const j="0000000000000000",F="00000000000000000000000000000000",V={traceId:F,spanId:j,traceFlags:H.NONE};class G{constructor(t=V){this._spanContext=t}spanContext(){return this._spanContext}setAttribute(t,e){return this}setAttributes(t){return this}addEvent(t,e){return this}setStatus(t){return this}updateName(t){return this}end(t){}isRecording(){return!1}recordException(t,e){}}const $=v("OpenTelemetry Context Key SPAN");function X(t){return t.getValue($)||void 0}function z(){return X(B.getInstance().active())}function q(t,e){return t.setValue($,e)}function W(t){return t.deleteValue($)}function K(t,e){return q(t,new G(e))}function Y(t){var e;return null===(e=X(t))||void 0===e?void 0:e.spanContext()}const Q=/^([0-9a-f]{32})$/i,Z=/^[0-9a-f]{16}$/i;function J(t){return Q.test(t)&&t!==F}function tt(t){return Z.test(t)&&t!==j}function et(t){return J(t.traceId)&&tt(t.spanId)}function nt(t){return new G(t)}const rt=B.getInstance();class st{startSpan(t,e,n=rt.active()){if(Boolean(null==e?void 0:e.root))return new G;const r=n&&Y(n);return"object"==typeof(s=r)&&"string"==typeof s.spanId&&"string"==typeof s.traceId&&"number"==typeof s.traceFlags&&et(r)?new G(r):new G;var s}startActiveSpan(t,e,n,r){let s,i,o;if(arguments.length<2)return;2===arguments.length?o=e:3===arguments.length?(s=e,o=n):(s=e,i=n,o=r);const a=null!=i?i:rt.active(),c=this.startSpan(t,s,a),u=q(a,c);return rt.with(u,o,void 0,c)}}const it=new st;class ot{constructor(t,e,n,r){this._provider=t,this.name=e,this.version=n,this.options=r}startSpan(t,e,n){return this._getTracer().startSpan(t,e,n)}startActiveSpan(t,e,n,r){const s=this._getTracer();return Reflect.apply(s.startActiveSpan,s,arguments)}_getTracer(){if(this._delegate)return this._delegate;const t=this._provider.getDelegateTracer(this.name,this.version,this.options);return t?(this._delegate=t,this._delegate):it}}const at=new class{getTracer(t,e,n){return new st}};class ct{getTracer(t,e,n){var r;return null!==(r=this.getDelegateTracer(t,e,n))&&void 0!==r?r:new ot(this,t,e,n)}getDelegate(){var t;return null!==(t=this._delegate)&&void 0!==t?t:at}setDelegate(t){this._delegate=t}getDelegateTracer(t,e,n){var r;return null===(r=this._delegate)||void 0===r?void 0:r.getTracer(t,e,n)}}var ut,lt,dt;!function(t){t[t.NOT_RECORD=0]="NOT_RECORD",t[t.RECORD=1]="RECORD",t[t.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"}(ut||(ut={})),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"}(lt||(lt={})),function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"}(dt||(dt={}));const ht="[_0-9a-z-*/]",_t=new RegExp(`^(?:${`[a-z]${ht}{0,255}`}|${`[a-z0-9]${ht}{0,240}@[a-z]${ht}{0,13}`})$`),pt=/^[ -~]{0,255}[!-~]$/,mt=/,|=/;class Et{constructor(t){this._internalState=new Map,t&&this._parse(t)}set(t,e){const n=this._clone();return n._internalState.has(t)&&n._internalState.delete(t),n._internalState.set(t,e),n}unset(t){const e=this._clone();return e._internalState.delete(t),e}get(t){return this._internalState.get(t)}serialize(){return this._keys().reduce(((t,e)=>(t.push(e+"="+this.get(e)),t)),[]).join(",")}_parse(t){t.length>512||(this._internalState=t.split(",").reverse().reduce(((t,e)=>{const n=e.trim(),r=n.indexOf("=");if(-1!==r){const s=n.slice(0,r),i=n.slice(r+1,e.length);(function(t){return _t.test(t)})(s)&&function(t){return pt.test(t)&&!mt.test(t)}(i)&&t.set(s,i)}return t}),new Map),this._internalState.size>32&&(this._internalState=new Map(Array.from(this._internalState.entries()).reverse().slice(0,32))))}_keys(){return Array.from(this._internalState.keys()).reverse()}_clone(){const t=new Et;return t._internalState=new Map(this._internalState),t}}const Tt=B.getInstance(),gt=p.instance();const ft=new class{getMeter(t,e,n){return A}},vt="metrics";class St{constructor(){}static getInstance(){return this._instance||(this._instance=new St),this._instance}setGlobalMeterProvider(t){return c(vt,t,p.instance())}getMeterProvider(){return u(vt)||ft}getMeter(t,e,n){return this.getMeterProvider().getMeter(t,e,n)}disable(){l(vt,p.instance())}}const bt=St.getInstance();const Ot=v("OpenTelemetry Baggage Key");function Rt(t){return t.getValue(Ot)||void 0}function Lt(){return Rt(B.getInstance().active())}function At(t,e){return t.setValue(Ot,e)}function wt(t){return t.deleteValue(Ot)}const yt="propagation",Nt=new class{inject(t,e){}extract(t,e){return t}fields(){return[]}};class Pt{constructor(){this.createBaggage=g,this.getBaggage=Rt,this.getActiveBaggage=Lt,this.setBaggage=At,this.deleteBaggage=wt}static getInstance(){return this._instance||(this._instance=new Pt),this._instance}setGlobalPropagator(t){return c(yt,t,p.instance())}inject(t,e,n=U){return this._getGlobalPropagator().inject(t,e,n)}extract(t,e,n=M){return this._getGlobalPropagator().extract(t,e,n)}fields(){return this._getGlobalPropagator().fields()}disable(){l(yt,p.instance())}_getGlobalPropagator(){return u(yt)||Nt}}const Ct=Pt.getInstance(),It="trace";class xt{constructor(){this._proxyTracerProvider=new ct,this.wrapSpanContext=nt,this.isSpanContextValid=et,this.deleteSpan=W,this.getSpan=X,this.getActiveSpan=z,this.getSpanContext=Y,this.setSpan=q,this.setSpanContext=K}static getInstance(){return this._instance||(this._instance=new xt),this._instance}setGlobalTracerProvider(t){const e=c(It,this._proxyTracerProvider,p.instance());return e&&this._proxyTracerProvider.setDelegate(t),e}getTracerProvider(){return u(It)||this._proxyTracerProvider}getTracer(t,e){return this.getTracerProvider().getTracer(t,e)}disable(){l(It,p.instance()),this._proxyTracerProvider=new ct}}const Mt=xt.getInstance();var Ut={context:Tt,diag:gt,metrics:bt,propagation:Ct,trace:Mt},Dt=Object.freeze({__proto__:null,context:Tt,diag:gt,metrics:bt,propagation:Ct,trace:Mt,default:Ut,baggageEntryMetadataFromString:f,createContextKey:v,ROOT_CONTEXT:b,DiagConsoleLogger:class{constructor(){function t(t){return function(...e){if(console){let n=console[t];if("function"!=typeof n&&(n=console.log),"function"==typeof n)return n.apply(console,e)}}}for(let e=0;e<O.length;e++)this[O[e].n]=t(O[e].c)}},get DiagLogLevel(){return _},createNoopMeter:function(){return A},get ValueType(){return x},defaultTextMapGetter:M,defaultTextMapSetter:U,ProxyTracer:ot,ProxyTracerProvider:ct,get SamplingDecision(){return ut},get SpanKind(){return lt},get SpanStatusCode(){return dt},get TraceFlags(){return H},createTraceState:function(t){return new Et(t)},isSpanContextValid:et,isValidTraceId:J,isValidSpanId:tt,INVALID_SPANID:j,INVALID_TRACEID:F,INVALID_SPAN_CONTEXT:V});const kt=v("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function Bt(t){return!0===t.getValue(kt)}const Ht="=",jt=";",Ft=",",Vt="baggage";function Gt(t){const e=t.split(jt);if(e.length<=0)return;const n=e.shift();if(!n)return;const r=n.indexOf(Ht);if(r<=0)return;const s=decodeURIComponent(n.substring(0,r).trim()),i=decodeURIComponent(n.substring(r+1).trim());let o;return e.length>0&&(o=f(e.join(jt))),{key:s,value:i,metadata:o}}function $t(t){return"string"!=typeof t||0===t.length?{}:t.split(Ft).map((t=>Gt(t))).filter((t=>void 0!==t&&t.value.length>0)).reduce(((t,e)=>(t[e.key]=e.value,t)),{})}class Xt{inject(t,e,n){const r=Ct.getBaggage(t);if(!r||Bt(t))return;const s=function(t){return t.getAllEntries().map((([t,e])=>{let n=`${encodeURIComponent(t)}=${encodeURIComponent(e.value)}`;return void 0!==e.metadata&&(n+=jt+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?Ft:""}${e}`;return n.length>8192?t:n}),"")}(s);i.length>0&&n.set(e,Vt,i)}extract(t,e,n){const r=n.get(e,Vt),s=Array.isArray(r)?r.join(Ft):r;if(!s)return t;const i={};if(0===s.length)return t;return s.split(Ft).forEach((t=>{const e=Gt(t);if(e){const t={value:e.value};e.metadata&&(t.metadata=e.metadata),i[e.key]=t}})),0===Object.entries(i).length?t:Ct.setBaggage(t,Ct.createBaggage(i))}fields(){return[Vt]}}function zt(t){const e={};if("object"!=typeof t||null==t)return e;for(const[n,r]of Object.entries(t))qt(n)?Wt(r)?Array.isArray(r)?e[n]=r.slice():e[n]=r:gt.warn(`Invalid attribute value set for key: ${n}`):gt.warn(`Invalid attribute key: ${n}`);return e}function qt(t){return"string"==typeof t&&t.length>0}function Wt(t){return null==t||(Array.isArray(t)?function(t){let e;for(const n of t)if(null!=n){if(!e){if(Kt(n)){e=typeof n;continue}return!1}if(typeof n!==e)return!1}return!0}(t):Kt(t))}function Kt(t){switch(typeof t){case"number":case"boolean":case"string":return!0}return!1}let Yt=t=>{gt.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))};function Qt(t){try{Yt(t)}catch(t){}}var Zt;!function(t){t.AlwaysOff="always_off",t.AlwaysOn="always_on",t.ParentBasedAlwaysOff="parentbased_always_off",t.ParentBasedAlwaysOn="parentbased_always_on",t.ParentBasedTraceIdRatio="parentbased_traceidratio",t.TraceIdRatio="traceidratio"}(Zt||(Zt={}));const Jt="object"==typeof globalThis?globalThis:"object"==typeof self?self:"object"==typeof window?window:"object"==typeof global?global:{},te=",",ee=["OTEL_SDK_DISABLED"];function ne(t){return ee.indexOf(t)>-1}const re=["OTEL_BSP_EXPORT_TIMEOUT","OTEL_BSP_MAX_EXPORT_BATCH_SIZE","OTEL_BSP_MAX_QUEUE_SIZE","OTEL_BSP_SCHEDULE_DELAY","OTEL_BLRP_EXPORT_TIMEOUT","OTEL_BLRP_MAX_EXPORT_BATCH_SIZE","OTEL_BLRP_MAX_QUEUE_SIZE","OTEL_BLRP_SCHEDULE_DELAY","OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT","OTEL_ATTRIBUTE_COUNT_LIMIT","OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT","OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT","OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT","OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT","OTEL_SPAN_EVENT_COUNT_LIMIT","OTEL_SPAN_LINK_COUNT_LIMIT","OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT","OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT","OTEL_EXPORTER_OTLP_TIMEOUT","OTEL_EXPORTER_OTLP_TRACES_TIMEOUT","OTEL_EXPORTER_OTLP_METRICS_TIMEOUT","OTEL_EXPORTER_OTLP_LOGS_TIMEOUT","OTEL_EXPORTER_JAEGER_AGENT_PORT"];function se(t){return re.indexOf(t)>-1}const ie=["OTEL_NO_PATCH_MODULES","OTEL_PROPAGATORS"];function oe(t){return ie.indexOf(t)>-1}const ae=1/0,ce=128,ue={OTEL_SDK_DISABLED:!1,CONTAINER_NAME:"",ECS_CONTAINER_METADATA_URI_V4:"",ECS_CONTAINER_METADATA_URI:"",HOSTNAME:"",KUBERNETES_SERVICE_HOST:"",NAMESPACE:"",OTEL_BSP_EXPORT_TIMEOUT:3e4,OTEL_BSP_MAX_EXPORT_BATCH_SIZE:512,OTEL_BSP_MAX_QUEUE_SIZE:2048,OTEL_BSP_SCHEDULE_DELAY:5e3,OTEL_BLRP_EXPORT_TIMEOUT:3e4,OTEL_BLRP_MAX_EXPORT_BATCH_SIZE:512,OTEL_BLRP_MAX_QUEUE_SIZE:2048,OTEL_BLRP_SCHEDULE_DELAY:5e3,OTEL_EXPORTER_JAEGER_AGENT_HOST:"",OTEL_EXPORTER_JAEGER_AGENT_PORT:6832,OTEL_EXPORTER_JAEGER_ENDPOINT:"",OTEL_EXPORTER_JAEGER_PASSWORD:"",OTEL_EXPORTER_JAEGER_USER:"",OTEL_EXPORTER_OTLP_ENDPOINT:"",OTEL_EXPORTER_OTLP_TRACES_ENDPOINT:"",OTEL_EXPORTER_OTLP_METRICS_ENDPOINT:"",OTEL_EXPORTER_OTLP_LOGS_ENDPOINT:"",OTEL_EXPORTER_OTLP_HEADERS:"",OTEL_EXPORTER_OTLP_TRACES_HEADERS:"",OTEL_EXPORTER_OTLP_METRICS_HEADERS:"",OTEL_EXPORTER_OTLP_LOGS_HEADERS:"",OTEL_EXPORTER_OTLP_TIMEOUT:1e4,OTEL_EXPORTER_OTLP_TRACES_TIMEOUT:1e4,OTEL_EXPORTER_OTLP_METRICS_TIMEOUT:1e4,OTEL_EXPORTER_OTLP_LOGS_TIMEOUT:1e4,OTEL_EXPORTER_ZIPKIN_ENDPOINT:"http://localhost:9411/api/v2/spans",OTEL_LOG_LEVEL:_.INFO,OTEL_NO_PATCH_MODULES:[],OTEL_PROPAGATORS:["tracecontext","baggage"],OTEL_RESOURCE_ATTRIBUTES:"",OTEL_SERVICE_NAME:"",OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT:ae,OTEL_ATTRIBUTE_COUNT_LIMIT:ce,OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT:ae,OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT:ce,OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT:ae,OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT:ce,OTEL_SPAN_EVENT_COUNT_LIMIT:128,OTEL_SPAN_LINK_COUNT_LIMIT:128,OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT:128,OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT:128,OTEL_TRACES_EXPORTER:"",OTEL_TRACES_SAMPLER:Zt.ParentBasedAlwaysOn,OTEL_TRACES_SAMPLER_ARG:"",OTEL_LOGS_EXPORTER:"",OTEL_EXPORTER_OTLP_INSECURE:"",OTEL_EXPORTER_OTLP_TRACES_INSECURE:"",OTEL_EXPORTER_OTLP_METRICS_INSECURE:"",OTEL_EXPORTER_OTLP_LOGS_INSECURE:"",OTEL_EXPORTER_OTLP_CERTIFICATE:"",OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE:"",OTEL_EXPORTER_OTLP_METRICS_CERTIFICATE:"",OTEL_EXPORTER_OTLP_LOGS_CERTIFICATE:"",OTEL_EXPORTER_OTLP_COMPRESSION:"",OTEL_EXPORTER_OTLP_TRACES_COMPRESSION:"",OTEL_EXPORTER_OTLP_METRICS_COMPRESSION:"",OTEL_EXPORTER_OTLP_LOGS_COMPRESSION:"",OTEL_EXPORTER_OTLP_CLIENT_KEY:"",OTEL_EXPORTER_OTLP_TRACES_CLIENT_KEY:"",OTEL_EXPORTER_OTLP_METRICS_CLIENT_KEY:"",OTEL_EXPORTER_OTLP_LOGS_CLIENT_KEY:"",OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE:"",OTEL_EXPORTER_OTLP_TRACES_CLIENT_CERTIFICATE:"",OTEL_EXPORTER_OTLP_METRICS_CLIENT_CERTIFICATE:"",OTEL_EXPORTER_OTLP_LOGS_CLIENT_CERTIFICATE:"",OTEL_EXPORTER_OTLP_PROTOCOL:"http/protobuf",OTEL_EXPORTER_OTLP_TRACES_PROTOCOL:"http/protobuf",OTEL_EXPORTER_OTLP_METRICS_PROTOCOL:"http/protobuf",OTEL_EXPORTER_OTLP_LOGS_PROTOCOL:"http/protobuf",OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE:"cumulative"};function le(t,e,n){if(void 0===n[t])return;const r=String(n[t]);e[t]="true"===r.toLowerCase()}function de(t,e,n,r=-1/0,s=1/0){if(void 0!==n[t]){const i=Number(n[t]);isNaN(i)||(e[t]=i<r?r:i>s?s:i)}}function he(t,e,n,r=te){const s=n[t];"string"==typeof s&&(e[t]=s.split(r).map((t=>t.trim())))}const _e={ALL:_.ALL,VERBOSE:_.VERBOSE,DEBUG:_.DEBUG,INFO:_.INFO,WARN:_.WARN,ERROR:_.ERROR,NONE:_.NONE};function pe(t,e,n){const r=n[t];if("string"==typeof r){const n=_e[r.toUpperCase()];null!=n&&(e[t]=n)}}function me(t){const e={};for(const n in ue){const r=n;if("OTEL_LOG_LEVEL"===r)pe(r,e,t);else if(ne(r))le(r,e,t);else if(se(r))de(r,e,t);else if(oe(r))he(r,e,t);else{const n=t[r];null!=n&&(e[r]=String(n))}}return e}function Ee(){const t=me(Jt);return Object.assign({},ue,t)}function Te(t){return t>=48&&t<=57?t-48:t>=97&&t<=102?t-87:t-55}function ge(t){const e=new Uint8Array(t.length/2);let n=0;for(let r=0;r<t.length;r+=2){const s=Te(t.charCodeAt(r)),i=Te(t.charCodeAt(r+1));e[n++]=s<<4|i}return e}const fe=Array(32);function ve(t){return function(){for(let e=0;e<2*t;e++)fe[e]=Math.floor(16*Math.random())+48,fe[e]>=58&&(fe[e]+=39);return String.fromCharCode.apply(null,fe.slice(0,2*t))}}const Se=performance;function be(t){let e={};const n=t.length;for(let r=0;r<n;r++){const n=t[r];n&&(e[String(n).toUpperCase().replace(/[-.]/g,"_")]=n)}return e}const Oe=be(["aws.lambda.invoked_arn","db.system","db.connection_string","db.user","db.jdbc.driver_classname","db.name","db.statement","db.operation","db.mssql.instance_name","db.cassandra.keyspace","db.cassandra.page_size","db.cassandra.consistency_level","db.cassandra.table","db.cassandra.idempotence","db.cassandra.speculative_execution_count","db.cassandra.coordinator.id","db.cassandra.coordinator.dc","db.hbase.namespace","db.redis.database_index","db.mongodb.collection","db.sql.table","exception.type","exception.message","exception.stacktrace","exception.escaped","faas.trigger","faas.execution","faas.document.collection","faas.document.operation","faas.document.time","faas.document.name","faas.time","faas.cron","faas.coldstart","faas.invoked_name","faas.invoked_provider","faas.invoked_region","net.transport","net.peer.ip","net.peer.port","net.peer.name","net.host.ip","net.host.port","net.host.name","net.host.connection.type","net.host.connection.subtype","net.host.carrier.name","net.host.carrier.mcc","net.host.carrier.mnc","net.host.carrier.icc","peer.service","enduser.id","enduser.role","enduser.scope","thread.id","thread.name","code.function","code.namespace","code.filepath","code.lineno","http.method","http.url","http.target","http.host","http.scheme","http.status_code","http.flavor","http.user_agent","http.request_content_length","http.request_content_length_uncompressed","http.response_content_length","http.response_content_length_uncompressed","http.server_name","http.route","http.client_ip","aws.dynamodb.table_names","aws.dynamodb.consumed_capacity","aws.dynamodb.item_collection_metrics","aws.dynamodb.provisioned_read_capacity","aws.dynamodb.provisioned_write_capacity","aws.dynamodb.consistent_read","aws.dynamodb.projection","aws.dynamodb.limit","aws.dynamodb.attributes_to_get","aws.dynamodb.index_name","aws.dynamodb.select","aws.dynamodb.global_secondary_indexes","aws.dynamodb.local_secondary_indexes","aws.dynamodb.exclusive_start_table","aws.dynamodb.table_count","aws.dynamodb.scan_forward","aws.dynamodb.segment","aws.dynamodb.total_segments","aws.dynamodb.count","aws.dynamodb.scanned_count","aws.dynamodb.attribute_definitions","aws.dynamodb.global_secondary_index_updates","messaging.system","messaging.destination","messaging.destination_kind","messaging.temp_destination","messaging.protocol","messaging.protocol_version","messaging.url","messaging.message_id","messaging.conversation_id","messaging.message_payload_size_bytes","messaging.message_payload_compressed_size_bytes","messaging.operation","messaging.consumer_id","messaging.rabbitmq.routing_key","messaging.kafka.message_key","messaging.kafka.consumer_group","messaging.kafka.client_id","messaging.kafka.partition","messaging.kafka.tombstone","rpc.system","rpc.service","rpc.method","rpc.grpc.status_code","rpc.jsonrpc.version","rpc.jsonrpc.request_id","rpc.jsonrpc.error_code","rpc.jsonrpc.error_message","message.type","message.id","message.compressed_size","message.uncompressed_size"]),Re=be(["cloud.provider","cloud.account.id","cloud.region","cloud.availability_zone","cloud.platform","aws.ecs.container.arn","aws.ecs.cluster.arn","aws.ecs.launchtype","aws.ecs.task.arn","aws.ecs.task.family","aws.ecs.task.revision","aws.eks.cluster.arn","aws.log.group.names","aws.log.group.arns","aws.log.stream.names","aws.log.stream.arns","container.name","container.id","container.runtime","container.image.name","container.image.tag","deployment.environment","device.id","device.model.identifier","device.model.name","faas.name","faas.id","faas.version","faas.instance","faas.max_memory","host.id","host.name","host.type","host.arch","host.image.name","host.image.id","host.image.version","k8s.cluster.name","k8s.node.name","k8s.node.uid","k8s.namespace.name","k8s.pod.uid","k8s.pod.name","k8s.container.name","k8s.replicaset.uid","k8s.replicaset.name","k8s.deployment.uid","k8s.deployment.name","k8s.statefulset.uid","k8s.statefulset.name","k8s.daemonset.uid","k8s.daemonset.name","k8s.job.uid","k8s.job.name","k8s.cronjob.uid","k8s.cronjob.name","os.type","os.description","os.name","os.version","process.pid","process.executable.name","process.executable.path","process.command","process.command_line","process.command_args","process.owner","process.runtime.name","process.runtime.version","process.runtime.description","service.name","service.namespace","service.instance.id","service.version","telemetry.sdk.name","telemetry.sdk.language","telemetry.sdk.version","telemetry.auto.version","webengine.name","webengine.version","webengine.description"]),Le=be(["cpp","dotnet","erlang","go","java","nodejs","php","python","ruby","webjs"]),Ae={[Re.TELEMETRY_SDK_NAME]:"opentelemetry",[Re.PROCESS_RUNTIME_NAME]:"browser",[Re.TELEMETRY_SDK_LANGUAGE]:Le.WEBJS,[Re.TELEMETRY_SDK_VERSION]:"1.22.0"};const we=Math.pow(10,6),ye=Math.pow(10,9);function Ne(t){const e=t/1e3;return[Math.trunc(e),Math.round(t%1e3*we)]}function Pe(){let t=Se.timeOrigin;if("number"!=typeof t){const e=Se;t=e.timing&&e.timing.fetchStart}return t}function Ce(t){return ke(Ne(Pe()),Ne("number"==typeof t?t:Se.now()))}function Ie(t){if(Ue(t))return t;if("number"==typeof t)return t<Pe()?Ce(t):Ne(t);if(t instanceof Date)return Ne(t.getTime());throw TypeError("Invalid input type")}function xe(t){return t[0]*ye+t[1]}function Me(t){return 1e6*t[0]+t[1]/1e3}function Ue(t){return Array.isArray(t)&&2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]}function De(t){return Ue(t)||"number"==typeof t||t instanceof Date}function ke(t,e){const n=[t[0]+e[0],t[1]+e[1]];return n[1]>=ye&&(n[1]-=ye,n[0]+=1),n}var Be;!function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"}(Be||(Be={}));class He{constructor(t={}){var e;this._propagators=null!==(e=t.propagators)&&void 0!==e?e:[],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){gt.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){gt.warn(`Failed to inject with ${r.constructor.name}. Err: ${t.message}`)}return t}),t)}fields(){return this._fields.slice()}}const je="[_0-9a-z-*/]",Fe=new RegExp(`^(?:${`[a-z]${je}{0,255}`}|${`[a-z0-9]${je}{0,240}@[a-z]${je}{0,13}`})$`),Ve=/^[ -~]{0,255}[!-~]$/,Ge=/,|=/;class $e{constructor(t){this._internalState=new Map,t&&this._parse(t)}set(t,e){const n=this._clone();return n._internalState.has(t)&&n._internalState.delete(t),n._internalState.set(t,e),n}unset(t){const e=this._clone();return e._internalState.delete(t),e}get(t){return this._internalState.get(t)}serialize(){return this._keys().reduce(((t,e)=>(t.push(e+"="+this.get(e)),t)),[]).join(",")}_parse(t){t.length>512||(this._internalState=t.split(",").reverse().reduce(((t,e)=>{const n=e.trim(),r=n.indexOf("=");if(-1!==r){const s=n.slice(0,r),i=n.slice(r+1,e.length);(function(t){return Fe.test(t)})(s)&&function(t){return Ve.test(t)&&!Ge.test(t)}(i)&&t.set(s,i)}return t}),new Map),this._internalState.size>32&&(this._internalState=new Map(Array.from(this._internalState.entries()).reverse().slice(0,32))))}_keys(){return Array.from(this._internalState.keys()).reverse()}_clone(){const t=new $e;return t._internalState=new Map(this._internalState),t}}const Xe="traceparent",ze="tracestate",qe=new RegExp("^\\s?((?!ff)[\\da-f]{2})-((?![0]{32})[\\da-f]{32})-((?![0]{16})[\\da-f]{16})-([\\da-f]{2})(-.*)?\\s?$");class We{inject(t,e,n){const r=Mt.getSpanContext(t);if(!r||Bt(t)||!et(r))return;const s=`00-${r.traceId}-${r.spanId}-0${Number(r.traceFlags||H.NONE).toString(16)}`;n.set(e,Xe,s),r.traceState&&n.set(e,ze,r.traceState.serialize())}extract(t,e,n){const r=n.get(e,Xe);if(!r)return t;const s=Array.isArray(r)?r[0]:r;if("string"!=typeof s)return t;const i=function(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}(s);if(!i)return t;i.isRemote=!0;const o=n.get(e,ze);if(o){const t=Array.isArray(o)?o.join(","):o;i.traceState=new $e("string"==typeof t?t:void 0)}return Mt.setSpanContext(t,i)}fields(){return[Xe,ze]}}var Ke;!function(t){t.HTTP="http"}(Ke||(Ke={}));const Ye="[object Object]",Qe="[object Null]",Ze="[object Undefined]",Je=Function.prototype.toString,tn=Je.call(Object),en=(nn=Object.getPrototypeOf,rn=Object,function(t){return nn(rn(t))});var nn,rn;const sn=Object.prototype,on=sn.hasOwnProperty,an=Symbol?Symbol.toStringTag:void 0,cn=sn.toString;function un(t){if(!function(t){return null!=t&&"object"==typeof t}(t)||function(t){if(null==t)return void 0===t?Ze:Qe;return an&&an in Object(t)?function(t){const e=on.call(t,an),n=t[an];let r=!1;try{t[an]=void 0,r=!0}catch(t){}const s=cn.call(t);r&&(e?t[an]=n:delete t[an]);return s}(t):function(t){return cn.call(t)}(t)}(t)!==Ye)return!1;const e=en(t);if(null===e)return!0;const n=on.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Je.call(n)===tn}const ln=20;function dn(t){return pn(t)?t.slice():t}function hn(t,e,n=0,r){let s;if(!(n>ln)){if(n++,Tn(t)||Tn(e)||mn(e))s=dn(e);else if(pn(t)){if(s=t.slice(),pn(e))for(let t=0,n=e.length;t<n;t++)s.push(dn(e[t]));else if(En(e)){const t=Object.keys(e);for(let n=0,r=t.length;n<r;n++){const r=t[n];s[r]=dn(e[r])}}}else if(En(t))if(En(e)){if(!function(t,e){if(!un(t)||!un(e))return!1;return!0}(t,e))return e;s=Object.assign({},t);const i=Object.keys(e);for(let o=0,a=i.length;o<a;o++){const a=i[o],c=e[a];if(Tn(c))void 0===c?delete s[a]:s[a]=c;else{const i=s[a],o=c;if(_n(t,a,r)||_n(e,a,r))delete s[a];else{if(En(i)&&En(o)){const n=r.get(i)||[],s=r.get(o)||[];n.push({obj:t,key:a}),s.push({obj:e,key:a}),r.set(i,n),r.set(o,s)}s[a]=hn(s[a],c,n,r)}}}}else s=e;return s}}function _n(t,e,n){const r=n.get(t[e])||[];for(let n=0,s=r.length;n<s;n++){const s=r[n];if(s.key===e&&s.obj===t)return!0}return!1}function pn(t){return Array.isArray(t)}function mn(t){return"function"==typeof t}function En(t){return!Tn(t)&&!pn(t)&&!mn(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}function gn(t,e){return"string"==typeof e?t===e:!!t.match(e)}function fn(t,e){if(!e)return!1;for(const n of e)if(gn(t,n))return!0;return!1}class vn{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 Sn{constructor(t,e){this._callback=t,this._that=e,this._isCalled=!1,this._deferred=new vn}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}}class bn{constructor(t,e,n,r,s,i,o=[],a,c,u){this.attributes={},this.links=[],this.events=[],this._droppedAttributesCount=0,this._droppedEventsCount=0,this._droppedLinksCount=0,this.status={code:dt.UNSET},this.endTime=[0,0],this._ended=!1,this._duration=[-1,-1],this.name=n,this._spanContext=r,this.parentSpanId=i,this.kind=s,this.links=o;const l=Date.now();this._performanceStartTime=Se.now(),this._performanceOffset=l-(this._performanceStartTime+Pe()),this._startTimeProvided=null!=a,this.startTime=this._getTime(null!=a?a:l),this.resource=t.resource,this.instrumentationLibrary=t.instrumentationLibrary,this._spanLimits=t.getSpanLimits(),this._attributeValueLengthLimit=this._spanLimits.attributeValueLengthLimit||0,null!=u&&this.setAttributes(u),this._spanProcessor=t.getActiveSpanProcessor(),this._spanProcessor.onStart(this,e)}spanContext(){return this._spanContext}setAttribute(t,e){return null==e||this._isSpanEnded()?this:0===t.length?(gt.warn(`Invalid attribute key: ${t}`),this):Wt(e)?Object.keys(this.attributes).length>=this._spanLimits.attributeCountLimit&&!Object.prototype.hasOwnProperty.call(this.attributes,t)?(this._droppedAttributesCount++,this):(this.attributes[t]=this._truncateToSize(e),this):(gt.warn(`Invalid attribute value set for key: ${t}`),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;if(0===this._spanLimits.eventCountLimit)return gt.warn("No events allowed."),this._droppedEventsCount++,this;this.events.length>=this._spanLimits.eventCountLimit&&(0===this._droppedEventsCount&&gt.debug("Dropping extra events."),this.events.shift(),this._droppedEventsCount++),De(e)&&(De(n)||(n=e),e=void 0);const r=zt(e);return this.events.push({name:t,attributes:r,time:this._getTime(n),droppedAttributesCount:0}),this}setStatus(t){return this._isSpanEnded()||(this.status=t),this}updateName(t){return this._isSpanEnded()||(this.name=t),this}end(t){this._isSpanEnded()?gt.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=function(t,e){let n=e[0]-t[0],r=e[1]-t[1];return r<0&&(n-=1,r+=ye),[n,r]}(this.startTime,this.endTime),this._duration[0]<0&&(gt.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&&gt.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`),this._spanProcessor.onEnd(this))}_getTime(t){if("number"==typeof t&&t<Se.now())return Ce(t+this._performanceOffset);if("number"==typeof t)return Ne(t);if(t instanceof Date)return Ne(t.getTime());if(Ue(t))return t;if(this._startTimeProvided)return Ne(Date.now());const e=Se.now()-this._performanceStartTime;return ke(this.startTime,Ne(e))}isRecording(){return!1===this._ended}recordException(t,e){const n={};"string"==typeof t?n[Oe.EXCEPTION_MESSAGE]=t:t&&(t.code?n[Oe.EXCEPTION_TYPE]=t.code.toString():t.name&&(n[Oe.EXCEPTION_TYPE]=t.name),t.message&&(n[Oe.EXCEPTION_MESSAGE]=t.message),t.stack&&(n[Oe.EXCEPTION_STACKTRACE]=t.stack)),n[Oe.EXCEPTION_TYPE]||n[Oe.EXCEPTION_MESSAGE]?this.addEvent("exception",n,e):gt.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(){return this._ended&&gt.warn(`Can not execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`),this._ended}_truncateToLimitUtil(t,e){return t.length<=e?t:t.substr(0,e)}_truncateToSize(t){const e=this._attributeValueLengthLimit;return e<=0?(gt.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 On;!function(t){t[t.NOT_RECORD=0]="NOT_RECORD",t[t.RECORD=1]="RECORD",t[t.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"}(On||(On={}));class Rn{shouldSample(){return{decision:On.NOT_RECORD}}toString(){return"AlwaysOffSampler"}}class Ln{shouldSample(){return{decision:On.RECORD_AND_SAMPLED}}toString(){return"AlwaysOnSampler"}}class An{constructor(t){var e,n,r,s;this._root=t.root,this._root||(Qt(new Error("ParentBasedSampler must have a root sampler configured")),this._root=new Ln),this._remoteParentSampled=null!==(e=t.remoteParentSampled)&&void 0!==e?e:new Ln,this._remoteParentNotSampled=null!==(n=t.remoteParentNotSampled)&&void 0!==n?n:new Rn,this._localParentSampled=null!==(r=t.localParentSampled)&&void 0!==r?r:new Ln,this._localParentNotSampled=null!==(s=t.localParentNotSampled)&&void 0!==s?s:new Rn}shouldSample(t,e,n,r,s,i){const o=Mt.getSpanContext(t);return o&&et(o)?o.isRemote?o.traceFlags&H.SAMPLED?this._remoteParentSampled.shouldSample(t,e,n,r,s,i):this._remoteParentNotSampled.shouldSample(t,e,n,r,s,i):o.traceFlags&H.SAMPLED?this._localParentSampled.shouldSample(t,e,n,r,s,i):this._localParentNotSampled.shouldSample(t,e,n,r,s,i):this._root.shouldSample(t,e,n,r,s,i)}toString(){return`ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`}}class wn{constructor(t=0){this._ratio=t,this._ratio=this._normalize(t),this._upperBound=Math.floor(4294967295*this._ratio)}shouldSample(t,e){return{decision:J(e)&&this._accumulate(e)<this._upperBound?On.RECORD_AND_SAMPLED:On.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 yn=Ee(),Nn=Zt.AlwaysOn,Pn=1;function Cn(){return{sampler:In(yn),forceFlushTimeoutMillis:3e4,generalLimits:{attributeValueLengthLimit:Ee().OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT,attributeCountLimit:Ee().OTEL_ATTRIBUTE_COUNT_LIMIT},spanLimits:{attributeValueLengthLimit:Ee().OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT,attributeCountLimit:Ee().OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT,linkCountLimit:Ee().OTEL_SPAN_LINK_COUNT_LIMIT,eventCountLimit:Ee().OTEL_SPAN_EVENT_COUNT_LIMIT,attributePerEventCountLimit:Ee().OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT,attributePerLinkCountLimit:Ee().OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT}}}function In(t=Ee()){switch(t.OTEL_TRACES_SAMPLER){case Zt.AlwaysOn:return new Ln;case Zt.AlwaysOff:return new Rn;case Zt.ParentBasedAlwaysOn:return new An({root:new Ln});case Zt.ParentBasedAlwaysOff:return new An({root:new Rn});case Zt.TraceIdRatio:return new wn(xn(t));case Zt.ParentBasedTraceIdRatio:return new An({root:new wn(xn(t))});default:return gt.error(`OTEL_TRACES_SAMPLER value "${t.OTEL_TRACES_SAMPLER} invalid, defaulting to ${Nn}".`),new Ln}}function xn(t){if(void 0===t.OTEL_TRACES_SAMPLER_ARG||""===t.OTEL_TRACES_SAMPLER_ARG)return gt.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${Pn}.`),Pn;const e=Number(t.OTEL_TRACES_SAMPLER_ARG);return isNaN(e)?(gt.error(`OTEL_TRACES_SAMPLER_ARG=${t.OTEL_TRACES_SAMPLER_ARG} was given, but it is invalid, defaulting to ${Pn}.`),Pn):e<0||e>1?(gt.error(`OTEL_TRACES_SAMPLER_ARG=${t.OTEL_TRACES_SAMPLER_ARG} was given, but it is out of range ([0..1]), defaulting to ${Pn}.`),Pn):e}function Mn(t){var e,n,r,s,i,o,a,c,u,l,d,h;const _=Object.assign({},t.spanLimits),p="undefined"!=typeof process&&process&&process.env?me(process.env):me(Jt);return _.attributeCountLimit=null!==(o=null!==(i=null!==(s=null!==(n=null===(e=t.spanLimits)||void 0===e?void 0:e.attributeCountLimit)&&void 0!==n?n:null===(r=t.generalLimits)||void 0===r?void 0:r.attributeCountLimit)&&void 0!==s?s:p.OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT)&&void 0!==i?i:p.OTEL_ATTRIBUTE_COUNT_LIMIT)&&void 0!==o?o:ce,_.attributeValueLengthLimit=null!==(h=null!==(d=null!==(l=null!==(c=null===(a=t.spanLimits)||void 0===a?void 0:a.attributeValueLengthLimit)&&void 0!==c?c:null===(u=t.generalLimits)||void 0===u?void 0:u.attributeValueLengthLimit)&&void 0!==l?l:p.OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT)&&void 0!==d?d:p.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT)&&void 0!==h?h:ae,Object.assign({},t,{spanLimits:_})}class Un{constructor(t,e){this._exporter=t,this._isExporting=!1,this._finishedSpans=[],this._droppedSpansCount=0;const n=Ee();this._maxExportBatchSize="number"==typeof(null==e?void 0:e.maxExportBatchSize)?e.maxExportBatchSize:n.OTEL_BSP_MAX_EXPORT_BATCH_SIZE,this._maxQueueSize="number"==typeof(null==e?void 0:e.maxQueueSize)?e.maxQueueSize:n.OTEL_BSP_MAX_QUEUE_SIZE,this._scheduledDelayMillis="number"==typeof(null==e?void 0:e.scheduledDelayMillis)?e.scheduledDelayMillis:n.OTEL_BSP_SCHEDULE_DELAY,this._exportTimeoutMillis="number"==typeof(null==e?void 0:e.exportTimeoutMillis)?e.exportTimeoutMillis:n.OTEL_BSP_EXPORT_TIMEOUT,this._shutdownOnce=new Sn(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(gt.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&H.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&&gt.debug("maxQueueSize reached, dropping spans"),void this._droppedSpansCount++;this._droppedSpansCount>0&&(gt.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=window.setTimeout((()=>{e(new Error("Timeout"))}),this._exportTimeoutMillis);Tt.with(function(t){return t.setValue(kt,!0)}(Tt.active()),(()=>{const r=this._finishedSpans.splice(0,this._maxExportBatchSize),s=()=>this._exporter.export(r,(r=>{var s;clearTimeout(n),r.code===Be.SUCCESS?t():e(null!==(s=r.error)&&void 0!==s?s:new Error("BatchSpanProcessor: span export failed"))})),i=r.map((t=>t.resource)).filter((t=>t.asyncAttributesPending));0===i.length?s():Promise.all(i.map((t=>{var e;return null===(e=t.waitForAsyncAttributes)||void 0===e?void 0:e.call(t)}))).then(s,(t=>{Qt(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,Qt(t)}))};if(this._finishedSpans.length>=this._maxExportBatchSize)return t();void 0===this._timer&&(this._timer=window.setTimeout((()=>t()),this._scheduledDelayMillis),this._timer)}_clearTimer(){void 0!==this._timer&&(clearTimeout(this._timer),this._timer=void 0)}}class Dn extends Un{constructor(t,e){super(t,e),this.onInit(e)}onInit(t){!0!==(null==t?void 0:t.disableAutoFlushOnDocumentHide)&&"undefined"!=typeof document&&(this._visibilityChangeListener=()=>{"hidden"===document.visibilityState&&this.forceFlush()},this._pageHideListener=()=>{this.forceFlush()},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 kn{constructor(){this.generateTraceId=Hn(16),this.generateSpanId=Hn(8)}}const Bn=Array(32);function Hn(t){return function(){for(let e=0;e<2*t;e++)Bn[e]=Math.floor(16*Math.random())+48,Bn[e]>=58&&(Bn[e]+=39);return String.fromCharCode.apply(null,Bn.slice(0,2*t))}}class jn{constructor(t,e,n){this._tracerProvider=n;const r=function(t){const e={sampler:In()},n=Cn(),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=r.sampler,this._generalLimits=r.generalLimits,this._spanLimits=r.spanLimits,this._idGenerator=e.idGenerator||new kn,this.resource=n.resource,this.instrumentationLibrary=t}startSpan(t,e={},n=Tt.active()){var r,s,i;e.root&&(n=Mt.deleteSpan(n));const o=Mt.getSpan(n);if(Bt(n)){gt.debug("Instrumentation suppressed, returning Noop Span");return Mt.wrapSpanContext(V)}const a=null==o?void 0:o.spanContext(),c=this._idGenerator.generateSpanId();let u,l,d;a&&Mt.isSpanContextValid(a)?(u=a.traceId,l=a.traceState,d=a.spanId):u=this._idGenerator.generateTraceId();const h=null!==(r=e.kind)&&void 0!==r?r:lt.INTERNAL,_=(null!==(s=e.links)&&void 0!==s?s:[]).map((t=>({context:t.context,attributes:zt(t.attributes)}))),p=zt(e.attributes),m=this._sampler.shouldSample(n,u,t,h,p,_);l=null!==(i=m.traceState)&&void 0!==i?i:l;const E={traceId:u,spanId:c,traceFlags:m.decision===ut.RECORD_AND_SAMPLED?H.SAMPLED:H.NONE,traceState:l};if(m.decision===ut.NOT_RECORD){gt.debug("Recording is off, propagating context in a non-recording span");return Mt.wrapSpanContext(E)}const T=zt(Object.assign(p,m.attributes));return new bn(this,n,t,E,h,d,_,e.startTime,void 0,T)}startActiveSpan(t,e,n,r){let s,i,o;if(arguments.length<2)return;2===arguments.length?o=e:3===arguments.length?(s=e,o=n):(s=e,i=n,o=r);const a=null!=i?i:Tt.active(),c=this.startSpan(t,s,a),u=Mt.setSpan(a,c);return Tt.with(u,o,void 0,c)}getGeneralLimits(){return this._generalLimits}getSpanLimits(){return this._spanLimits}getActiveSpanProcessor(){return this._tracerProvider.getActiveSpanProcessor()}}function Fn(t,e,n,r){return new(n||(n=Promise))((function(s,i){function o(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((r=r.apply(t,e||[])).next())}))}class Vn{constructor(t,e){var n;this._attributes=t,this.asyncAttributesPending=null!=e,this._syncAttributes=null!==(n=this._attributes)&&void 0!==n?n:{},this._asyncAttributesPromise=null==e?void 0:e.then((t=>(this._attributes=Object.assign({},this._attributes,t),this.asyncAttributesPending=!1,t)),(t=>(gt.debug("a resource's async attributes promise rejected: %s",t),this.asyncAttributesPending=!1,{})))}static empty(){return Vn.EMPTY}static default(){return new Vn({[Re.SERVICE_NAME]:"unknown_service",[Re.TELEMETRY_SDK_LANGUAGE]:Ae[Re.TELEMETRY_SDK_LANGUAGE],[Re.TELEMETRY_SDK_NAME]:Ae[Re.TELEMETRY_SDK_NAME],[Re.TELEMETRY_SDK_VERSION]:Ae[Re.TELEMETRY_SDK_VERSION]})}get attributes(){var t;return this.asyncAttributesPending&&gt.error("Accessing resource attributes before async attributes settled"),null!==(t=this._attributes)&&void 0!==t?t:{}}waitForAsyncAttributes(){return Fn(this,void 0,void 0,(function*(){this.asyncAttributesPending&&(yield this._asyncAttributesPromise)}))}merge(t){var e;if(!t)return this;const n=Object.assign(Object.assign({},this._syncAttributes),null!==(e=t._syncAttributes)&&void 0!==e?e:t.attributes);if(!this._asyncAttributesPromise&&!t._asyncAttributesPromise)return new Vn(n);const r=Promise.all([this._asyncAttributesPromise,t._asyncAttributesPromise]).then((([e,n])=>{var r;return Object.assign(Object.assign(Object.assign(Object.assign({},this._syncAttributes),e),null!==(r=t._syncAttributes)&&void 0!==r?r:t.attributes),n)}));return new Vn(n,r)}}Vn.EMPTY=new Vn({});class Gn{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=>{Qt(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)}))}}class $n{onStart(t,e){}onEnd(t){}shutdown(){return Promise.resolve()}forceFlush(){return Promise.resolve()}}var Xn,zn;!function(t){t[t.resolved=0]="resolved",t[t.timeout=1]="timeout",t[t.error=2]="error",t[t.unresolved=3]="unresolved"}(Xn||(Xn={}));class qn{constructor(t={}){var e;this._registeredSpanProcessors=[],this._tracers=new Map;const n=function(...t){let e=t.shift();const n=new WeakMap;for(;t.length>0;)e=hn(e,t.shift(),0,n);return e}({},Cn(),Mn(t));this.resource=null!==(e=n.resource)&&void 0!==e?e:Vn.empty(),this.resource=Vn.default().merge(this.resource),this._config=Object.assign({},n,{resource:this.resource});const r=this._buildExporterFromEnv();if(void 0!==r){const t=new Dn(r);this.activeSpanProcessor=t}else this.activeSpanProcessor=new $n}getTracer(t,e,n){const r=`${t}@${e||""}:${(null==n?void 0:n.schemaUrl)||""}`;return this._tracers.has(r)||this._tracers.set(r,new jn({name:t,version:e,schemaUrl:null==n?void 0:n.schemaUrl},this._config,this)),this._tracers.get(r)}addSpanProcessor(t){0===this._registeredSpanProcessors.length&&this.activeSpanProcessor.shutdown().catch((t=>gt.error("Error while trying to shutdown current span processor",t))),this._registeredSpanProcessors.push(t),this.activeSpanProcessor=new Gn(this._registeredSpanProcessors)}getActiveSpanProcessor(){return this.activeSpanProcessor}register(t={}){Mt.setGlobalTracerProvider(this),void 0===t.propagator&&(t.propagator=this._buildPropagatorFromEnv()),t.contextManager&&Tt.setGlobalContextManager(t.contextManager),t.propagator&&Ct.setGlobalPropagator(t.propagator)}forceFlush(){const t=this._config.forceFlushTimeoutMillis,e=this._registeredSpanProcessors.map((e=>new Promise((n=>{let r;const s=setTimeout((()=>{n(new Error(`Span processor did not completed within timeout period of ${t} ms`)),r=Xn.timeout}),t);e.forceFlush().then((()=>{clearTimeout(s),r!==Xn.timeout&&(r=Xn.resolved,n(r))})).catch((t=>{clearTimeout(s),r=Xn.error,n(t)}))}))));return new Promise(((t,n)=>{Promise.all(e).then((e=>{const r=e.filter((t=>t!==Xn.resolved));r.length>0?n(r):t()})).catch((t=>n([t])))}))}shutdown(){return this.activeSpanProcessor.shutdown()}_getPropagator(t){var e;return null