@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
JavaScript
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t="object"==typeof globalThis?globalThis:"object"==typeof self?self:"object"==typeof window?window:"object"==typeof global?global:{},e="1.8.0",n=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;const r=function(t){const e=new Set([t]),r=new Set,s=t.match(n);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 r.add(t),!1}function u(t){return e.add(t),!0}return function(t){if(e.has(t))return!0;if(r.has(t))return!1;const s=t.match(n);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)}}(e),s=e.split(".")[0],i=Symbol.for(`opentelemetry.js.api.${s}`),o=t;function a(t,n,r,s=!1){var a;const c=o[i]=null!==(a=o[i])&&void 0!==a?a:{version:e};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!==e){const n=new Error(`@opentelemetry/api: Registration of version v${c.version} for ${t} does not match previously registered API v${e}`);return r.error(n.stack||n.message),!1}return c[t]=n,r.debug(`@opentelemetry/api: Registered a global for ${t} v${e}.`),!0}function c(t){var e,n;const s=null===(e=o[i])||void 0===e?void 0:e.version;if(s&&r(s))return null===(n=o[i])||void 0===n?void 0:n[t]}function u(t,n){n.debug(`@opentelemetry/api: Unregistering a global for ${t} v${e}.`);const r=o[i];r&&delete r[t]}class l{constructor(t){this._namespace=t.namespace||"DiagComponentLogger"}debug(...t){return d("debug",this._namespace,t)}error(...t){return d("error",this._namespace,t)}info(...t){return d("info",this._namespace,t)}warn(...t){return d("warn",this._namespace,t)}verbose(...t){return d("verbose",this._namespace,t)}}function d(t,e,n){const r=c("diag");if(r)return n.unshift(e),r[t](...n)}var h;!function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"}(h||(h={}));class _{constructor(){function t(t){return function(...e){const n=c("diag");if(n)return n[t](...e)}}const e=this;e.setLogger=(t,n={logLevel:h.INFO})=>{var r,s,i;if(t===e){const t=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return e.error(null!==(r=t.stack)&&void 0!==r?r:t.message),!1}"number"==typeof n&&(n={logLevel:n});const o=c("diag"),u=function(t,e){function n(n,r){const s=e[n];return"function"==typeof s&&t>=r?s.bind(e):function(){}}return t<h.NONE?t=h.NONE:t>h.ALL&&(t=h.ALL),e=e||{},{error:n("error",h.ERROR),warn:n("warn",h.WARN),info:n("info",h.INFO),debug:n("debug",h.DEBUG),verbose:n("verbose",h.VERBOSE)}}(null!==(s=n.logLevel)&&void 0!==s?s:h.INFO,t);if(o&&!n.suppressOverrideMessage){const t=null!==(i=(new Error).stack)&&void 0!==i?i:"<failed to generate stacktrace>";o.warn(`Current logger will be overwritten from ${t}`),u.warn(`Current logger will overwrite one already registered from ${t}`)}return a("diag",u,e,!0)},e.disable=()=>{u("diag",e)},e.createComponentLogger=t=>new l(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 _),this._instance}}class p{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 p(this._entries);return n._entries.set(t,e),n}removeEntry(t){const e=new p(this._entries);return e._entries.delete(t),e}removeEntries(...t){const e=new p(this._entries);for(const n of t)e._entries.delete(n);return e}clear(){return new p}}const m=Symbol("BaggageEntryMetadata"),E=_.instance();function T(t={}){return new p(new Map(Object.entries(t)))}function g(t){return"string"!=typeof t&&(E.error("Cannot create baggage metadata from unknown type: "+typeof t),t=""),{__TYPE__:m,toString:()=>t}}function f(t){return Symbol.for(t)}class v{constructor(t){const e=this;e._currentContext=t?new Map(t):new Map,e.getValue=t=>e._currentContext.get(t),e.setValue=(t,n)=>{const r=new v(e._currentContext);return r._currentContext.set(t,n),r},e.deleteValue=t=>{const n=new v(e._currentContext);return n._currentContext.delete(t),n}}}const S=new v,b=[{n:"error",c:"error"},{n:"warn",c:"warn"},{n:"info",c:"info"},{n:"debug",c:"debug"},{n:"verbose",c:"trace"}];class O{}class R{addCallback(t){}removeCallback(t){}}const L=new class{constructor(){}createHistogram(t,e){return w}createCounter(t,e){return A}createUpDownCounter(t,e){return y}createObservableGauge(t,e){return P}createObservableCounter(t,e){return N}createObservableUpDownCounter(t,e){return C}addBatchObservableCallback(t,e){}removeBatchObservableCallback(t){}},A=new class extends O{add(t,e){}},w=new class extends O{record(t,e){}},y=new class extends O{add(t,e){}},N=new class extends R{},P=new class extends R{},C=new class extends R{};var I;!function(t){t[t.INT=0]="INT",t[t.DOUBLE=1]="DOUBLE"}(I||(I={}));const x={get(t,e){if(null!=t)return t[e]},keys:t=>null==t?[]:Object.keys(t)},M={set(t,e,n){null!=t&&(t[e]=n)}};const U="context",D=new class{active(){return S}with(t,e,n,...r){return e.call(n,...r)}bind(t,e){return e}enable(){return this}disable(){return this}};class k{constructor(){}static getInstance(){return this._instance||(this._instance=new k),this._instance}setGlobalContextManager(t){return a(U,t,_.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 c(U)||D}disable(){this._getContextManager().disable(),u(U,_.instance())}}var B;!function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"}(B||(B={}));const H="0000000000000000",j="00000000000000000000000000000000",F={traceId:j,spanId:H,traceFlags:B.NONE};class V{constructor(t=F){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 G=f("OpenTelemetry Context Key SPAN");function $(t){return t.getValue(G)||void 0}function X(){return $(k.getInstance().active())}function z(t,e){return t.setValue(G,e)}function q(t){return t.deleteValue(G)}function W(t,e){return z(t,new V(e))}function K(t){var e;return null===(e=$(t))||void 0===e?void 0:e.spanContext()}const Y=/^([0-9a-f]{32})$/i,Q=/^[0-9a-f]{16}$/i;function Z(t){return Y.test(t)&&t!==j}function J(t){return Q.test(t)&&t!==H}function tt(t){return Z(t.traceId)&&J(t.spanId)}function et(t){return new V(t)}const nt=k.getInstance();class rt{startSpan(t,e,n=nt.active()){if(Boolean(null==e?void 0:e.root))return new V;const r=n&&K(n);return"object"==typeof(s=r)&&"string"==typeof s.spanId&&"string"==typeof s.traceId&&"number"==typeof s.traceFlags&&tt(r)?new V(r):new V;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:nt.active(),c=this.startSpan(t,s,a),u=z(a,c);return nt.with(u,o,void 0,c)}}const st=new rt;class it{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):st}}const ot=new class{getTracer(t,e,n){return new rt}};class at{getTracer(t,e,n){var r;return null!==(r=this.getDelegateTracer(t,e,n))&&void 0!==r?r:new it(this,t,e,n)}getDelegate(){var t;return null!==(t=this._delegate)&&void 0!==t?t:ot}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 ct,ut,lt;!function(t){t[t.NOT_RECORD=0]="NOT_RECORD",t[t.RECORD=1]="RECORD",t[t.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"}(ct||(ct={})),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"}(ut||(ut={})),function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"}(lt||(lt={}));const dt="[_0-9a-z-*/]",ht=new RegExp(`^(?:${`[a-z]${dt}{0,255}`}|${`[a-z0-9]${dt}{0,240}@[a-z]${dt}{0,13}`})$`),_t=/^[ -~]{0,255}[!-~]$/,pt=/,|=/;class mt{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 ht.test(t)})(s)&&function(t){return _t.test(t)&&!pt.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 mt;return t._internalState=new Map(this._internalState),t}}const Et=k.getInstance(),Tt=_.instance();const gt=new class{getMeter(t,e,n){return L}},ft="metrics";class vt{constructor(){}static getInstance(){return this._instance||(this._instance=new vt),this._instance}setGlobalMeterProvider(t){return a(ft,t,_.instance())}getMeterProvider(){return c(ft)||gt}getMeter(t,e,n){return this.getMeterProvider().getMeter(t,e,n)}disable(){u(ft,_.instance())}}const St=vt.getInstance();const bt=f("OpenTelemetry Baggage Key");function Ot(t){return t.getValue(bt)||void 0}function Rt(){return Ot(k.getInstance().active())}function Lt(t,e){return t.setValue(bt,e)}function At(t){return t.deleteValue(bt)}const wt="propagation",yt=new class{inject(t,e){}extract(t,e){return t}fields(){return[]}};class Nt{constructor(){this.createBaggage=T,this.getBaggage=Ot,this.getActiveBaggage=Rt,this.setBaggage=Lt,this.deleteBaggage=At}static getInstance(){return this._instance||(this._instance=new Nt),this._instance}setGlobalPropagator(t){return a(wt,t,_.instance())}inject(t,e,n=M){return this._getGlobalPropagator().inject(t,e,n)}extract(t,e,n=x){return this._getGlobalPropagator().extract(t,e,n)}fields(){return this._getGlobalPropagator().fields()}disable(){u(wt,_.instance())}_getGlobalPropagator(){return c(wt)||yt}}const Pt=Nt.getInstance(),Ct="trace";class It{constructor(){this._proxyTracerProvider=new at,this.wrapSpanContext=et,this.isSpanContextValid=tt,this.deleteSpan=q,this.getSpan=$,this.getActiveSpan=X,this.getSpanContext=K,this.setSpan=z,this.setSpanContext=W}static getInstance(){return this._instance||(this._instance=new It),this._instance}setGlobalTracerProvider(t){const e=a(Ct,this._proxyTracerProvider,_.instance());return e&&this._proxyTracerProvider.setDelegate(t),e}getTracerProvider(){return c(Ct)||this._proxyTracerProvider}getTracer(t,e){return this.getTracerProvider().getTracer(t,e)}disable(){u(Ct,_.instance()),this._proxyTracerProvider=new at}}const xt=It.getInstance();var Mt={context:Et,diag:Tt,metrics:St,propagation:Pt,trace:xt},Ut=Object.freeze({__proto__:null,context:Et,diag:Tt,metrics:St,propagation:Pt,trace:xt,default:Mt,baggageEntryMetadataFromString:g,createContextKey:f,ROOT_CONTEXT:S,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<b.length;e++)this[b[e].n]=t(b[e].c)}},get DiagLogLevel(){return h},createNoopMeter:function(){return L},get ValueType(){return I},defaultTextMapGetter:x,defaultTextMapSetter:M,ProxyTracer:it,ProxyTracerProvider:at,get SamplingDecision(){return ct},get SpanKind(){return ut},get SpanStatusCode(){return lt},get TraceFlags(){return B},createTraceState:function(t){return new mt(t)},isSpanContextValid:tt,isValidTraceId:Z,isValidSpanId:J,INVALID_SPANID:H,INVALID_TRACEID:j,INVALID_SPAN_CONTEXT:F});const Dt=f("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function kt(t){return!0===t.getValue(Dt)}const Bt="=",Ht=";",jt=",",Ft="baggage";function Vt(t){const e=t.split(Ht);if(e.length<=0)return;const n=e.shift();if(!n)return;const r=n.indexOf(Bt);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=g(e.join(Ht))),{key:s,value:i,metadata:o}}function Gt(t){return"string"!=typeof t||0===t.length?{}:t.split(jt).map((t=>Vt(t))).filter((t=>void 0!==t&&t.value.length>0)).reduce(((t,e)=>(t[e.key]=e.value,t)),{})}class $t{inject(t,e,n){const r=Pt.getBaggage(t);if(!r||kt(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+=Ht+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}),"")}(s);i.length>0&&n.set(e,Ft,i)}extract(t,e,n){const r=n.get(e,Ft),s=Array.isArray(r)?r.join(jt):r;if(!s)return t;const i={};if(0===s.length)return t;return s.split(jt).forEach((t=>{const e=Vt(t);if(e){const t={value:e.value};e.metadata&&(t.metadata=e.metadata),i[e.key]=t}})),0===Object.entries(i).length?t:Pt.setBaggage(t,Pt.createBaggage(i))}fields(){return[Ft]}}function Xt(t){const e={};if("object"!=typeof t||null==t)return e;for(const[n,r]of Object.entries(t))zt(n)?qt(r)?Array.isArray(r)?e[n]=r.slice():e[n]=r:Tt.warn(`Invalid attribute value set for key: ${n}`):Tt.warn(`Invalid attribute key: ${n}`);return e}function zt(t){return"string"==typeof t&&t.length>0}function qt(t){return null==t||(Array.isArray(t)?function(t){let e;for(const n of t)if(null!=n){if(!e){if(Wt(n)){e=typeof n;continue}return!1}if(typeof n!==e)return!1}return!0}(t):Wt(t))}function Wt(t){switch(typeof t){case"number":case"boolean":case"string":return!0}return!1}let Kt=t=>{Tt.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 Yt(t){try{Kt(t)}catch(t){}}var Qt;!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"}(Qt||(Qt={}));const Zt="object"==typeof globalThis?globalThis:"object"==typeof self?self:"object"==typeof window?window:"object"==typeof global?global:{},Jt=",",te=["OTEL_SDK_DISABLED"];function ee(t){return te.indexOf(t)>-1}const ne=["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 re(t){return ne.indexOf(t)>-1}const se=["OTEL_NO_PATCH_MODULES","OTEL_PROPAGATORS"];function ie(t){return se.indexOf(t)>-1}const oe=1/0,ae=128,ce={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:h.INFO,OTEL_NO_PATCH_MODULES:[],OTEL_PROPAGATORS:["tracecontext","baggage"],OTEL_RESOURCE_ATTRIBUTES:"",OTEL_SERVICE_NAME:"",OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT:oe,OTEL_ATTRIBUTE_COUNT_LIMIT:ae,OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT:oe,OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT:ae,OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT:oe,OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT:ae,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:Qt.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 ue(t,e,n){if(void 0===n[t])return;const r=String(n[t]);e[t]="true"===r.toLowerCase()}function le(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 de(t,e,n,r=Jt){const s=n[t];"string"==typeof s&&(e[t]=s.split(r).map((t=>t.trim())))}const he={ALL:h.ALL,VERBOSE:h.VERBOSE,DEBUG:h.DEBUG,INFO:h.INFO,WARN:h.WARN,ERROR:h.ERROR,NONE:h.NONE};function _e(t,e,n){const r=n[t];if("string"==typeof r){const n=he[r.toUpperCase()];null!=n&&(e[t]=n)}}function pe(t){const e={};for(const n in ce){const r=n;if("OTEL_LOG_LEVEL"===r)_e(r,e,t);else if(ee(r))ue(r,e,t);else if(re(r))le(r,e,t);else if(ie(r))de(r,e,t);else{const n=t[r];null!=n&&(e[r]=String(n))}}return e}function me(){const t=pe(Zt);return Object.assign({},ce,t)}function Ee(t){return t>=48&&t<=57?t-48:t>=97&&t<=102?t-87:t-55}function Te(t){const e=new Uint8Array(t.length/2);let n=0;for(let r=0;r<t.length;r+=2){const s=Ee(t.charCodeAt(r)),i=Ee(t.charCodeAt(r+1));e[n++]=s<<4|i}return e}const ge=Array(32);function fe(t){return function(){for(let e=0;e<2*t;e++)ge[e]=Math.floor(16*Math.random())+48,ge[e]>=58&&(ge[e]+=39);return String.fromCharCode.apply(null,ge.slice(0,2*t))}}const ve=performance;function Se(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 be=Se(["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"]),Oe=Se(["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"]),Re=Se(["cpp","dotnet","erlang","go","java","nodejs","php","python","ruby","webjs"]),Le={[Oe.TELEMETRY_SDK_NAME]:"opentelemetry",[Oe.PROCESS_RUNTIME_NAME]:"browser",[Oe.TELEMETRY_SDK_LANGUAGE]:Re.WEBJS,[Oe.TELEMETRY_SDK_VERSION]:"1.22.0"};const Ae=Math.pow(10,6),we=Math.pow(10,9);function ye(t){const e=t/1e3;return[Math.trunc(e),Math.round(t%1e3*Ae)]}function Ne(){let t=ve.timeOrigin;if("number"!=typeof t){const e=ve;t=e.timing&&e.timing.fetchStart}return t}function Pe(t){return De(ye(Ne()),ye("number"==typeof t?t:ve.now()))}function Ce(t){if(Me(t))return t;if("number"==typeof t)return t<Ne()?Pe(t):ye(t);if(t instanceof Date)return ye(t.getTime());throw TypeError("Invalid input type")}function Ie(t){return t[0]*we+t[1]}function xe(t){return 1e6*t[0]+t[1]/1e3}function Me(t){return Array.isArray(t)&&2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]}function Ue(t){return Me(t)||"number"==typeof t||t instanceof Date}function De(t,e){const n=[t[0]+e[0],t[1]+e[1]];return n[1]>=we&&(n[1]-=we,n[0]+=1),n}var ke;!function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"}(ke||(ke={}));class Be{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){Tt.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){Tt.warn(`Failed to inject with ${r.constructor.name}. Err: ${t.message}`)}return t}),t)}fields(){return this._fields.slice()}}const He="[_0-9a-z-*/]",je=new RegExp(`^(?:${`[a-z]${He}{0,255}`}|${`[a-z0-9]${He}{0,240}@[a-z]${He}{0,13}`})$`),Fe=/^[ -~]{0,255}[!-~]$/,Ve=/,|=/;class Ge{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 je.test(t)})(s)&&function(t){return Fe.test(t)&&!Ve.test(t)}(i)&&t.set(s,i)}return t}),new Map),this._internalState.size>32&&(this._internalState=new Map(Array.from(this._internalState.entries()).reverse().slice(0,32))))}_keys(){return Array.from(this._internalState.keys()).reverse()}_clone(){const t=new Ge;return t._internalState=new Map(this._internalState),t}}const $e="traceparent",Xe="tracestate",ze=new RegExp("^\\s?((?!ff)[\\da-f]{2})-((?![0]{32})[\\da-f]{32})-((?![0]{16})[\\da-f]{16})-([\\da-f]{2})(-.*)?\\s?$");class qe{inject(t,e,n){const r=xt.getSpanContext(t);if(!r||kt(t)||!tt(r))return;const s=`00-${r.traceId}-${r.spanId}-0${Number(r.traceFlags||B.NONE).toString(16)}`;n.set(e,$e,s),r.traceState&&n.set(e,Xe,r.traceState.serialize())}extract(t,e,n){const r=n.get(e,$e);if(!r)return t;const s=Array.isArray(r)?r[0]:r;if("string"!=typeof s)return t;const i=function(t){const e=ze.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,Xe);if(o){const t=Array.isArray(o)?o.join(","):o;i.traceState=new Ge("string"==typeof t?t:void 0)}return xt.setSpanContext(t,i)}fields(){return[$e,Xe]}}var We;!function(t){t.HTTP="http"}(We||(We={}));const Ke="[object Object]",Ye="[object Null]",Qe="[object Undefined]",Ze=Function.prototype.toString,Je=Ze.call(Object),tn=(en=Object.getPrototypeOf,nn=Object,function(t){return en(nn(t))});var en,nn;const rn=Object.prototype,sn=rn.hasOwnProperty,on=Symbol?Symbol.toStringTag:void 0,an=rn.toString;function cn(t){if(!function(t){return null!=t&&"object"==typeof t}(t)||function(t){if(null==t)return void 0===t?Qe:Ye;return on&&on in Object(t)?function(t){const e=sn.call(t,on),n=t[on];let r=!1;try{t[on]=void 0,r=!0}catch(t){}const s=an.call(t);r&&(e?t[on]=n:delete t[on]);return s}(t):function(t){return an.call(t)}(t)}(t)!==Ke)return!1;const e=tn(t);if(null===e)return!0;const n=sn.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Ze.call(n)===Je}const un=20;function ln(t){return _n(t)?t.slice():t}function dn(t,e,n=0,r){let s;if(!(n>un)){if(n++,En(t)||En(e)||pn(e))s=ln(e);else if(_n(t)){if(s=t.slice(),_n(e))for(let t=0,n=e.length;t<n;t++)s.push(ln(e[t]));else if(mn(e)){const t=Object.keys(e);for(let n=0,r=t.length;n<r;n++){const r=t[n];s[r]=ln(e[r])}}}else if(mn(t))if(mn(e)){if(!function(t,e){if(!cn(t)||!cn(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(En(c))void 0===c?delete s[a]:s[a]=c;else{const i=s[a],o=c;if(hn(t,a,r)||hn(e,a,r))delete s[a];else{if(mn(i)&&mn(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]=dn(s[a],c,n,r)}}}}else s=e;return s}}function hn(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 _n(t){return Array.isArray(t)}function pn(t){return"function"==typeof t}function mn(t){return!En(t)&&!_n(t)&&!pn(t)&&"object"==typeof t}function En(t){return"string"==typeof t||"number"==typeof t||"boolean"==typeof t||void 0===t||t instanceof Date||t instanceof RegExp||null===t}function Tn(t,e){return"string"==typeof e?t===e:!!t.match(e)}function gn(t,e){if(!e)return!1;for(const n of e)if(Tn(t,n))return!0;return!1}class fn{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 vn{constructor(t,e){this._callback=t,this._that=e,this._isCalled=!1,this._deferred=new fn}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 Sn{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:lt.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=ve.now(),this._performanceOffset=l-(this._performanceStartTime+Ne()),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?(Tt.warn(`Invalid attribute key: ${t}`),this):qt(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):(Tt.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 Tt.warn("No events allowed."),this._droppedEventsCount++,this;this.events.length>=this._spanLimits.eventCountLimit&&(0===this._droppedEventsCount&&Tt.debug("Dropping extra events."),this.events.shift(),this._droppedEventsCount++),Ue(e)&&(Ue(n)||(n=e),e=void 0);const r=Xt(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()?Tt.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+=we),[n,r]}(this.startTime,this.endTime),this._duration[0]<0&&(Tt.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&&Tt.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`),this._spanProcessor.onEnd(this))}_getTime(t){if("number"==typeof t&&t<ve.now())return Pe(t+this._performanceOffset);if("number"==typeof t)return ye(t);if(t instanceof Date)return ye(t.getTime());if(Me(t))return t;if(this._startTimeProvided)return ye(Date.now());const e=ve.now()-this._performanceStartTime;return De(this.startTime,ye(e))}isRecording(){return!1===this._ended}recordException(t,e){const n={};"string"==typeof t?n[be.EXCEPTION_MESSAGE]=t:t&&(t.code?n[be.EXCEPTION_TYPE]=t.code.toString():t.name&&(n[be.EXCEPTION_TYPE]=t.name),t.message&&(n[be.EXCEPTION_MESSAGE]=t.message),t.stack&&(n[be.EXCEPTION_STACKTRACE]=t.stack)),n[be.EXCEPTION_TYPE]||n[be.EXCEPTION_MESSAGE]?this.addEvent("exception",n,e):Tt.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&&Tt.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?(Tt.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 bn;!function(t){t[t.NOT_RECORD=0]="NOT_RECORD",t[t.RECORD=1]="RECORD",t[t.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"}(bn||(bn={}));class On{shouldSample(){return{decision:bn.NOT_RECORD}}toString(){return"AlwaysOffSampler"}}class Rn{shouldSample(){return{decision:bn.RECORD_AND_SAMPLED}}toString(){return"AlwaysOnSampler"}}class Ln{constructor(t){var e,n,r,s;this._root=t.root,this._root||(Yt(new Error("ParentBasedSampler must have a root sampler configured")),this._root=new Rn),this._remoteParentSampled=null!==(e=t.remoteParentSampled)&&void 0!==e?e:new Rn,this._remoteParentNotSampled=null!==(n=t.remoteParentNotSampled)&&void 0!==n?n:new On,this._localParentSampled=null!==(r=t.localParentSampled)&&void 0!==r?r:new Rn,this._localParentNotSampled=null!==(s=t.localParentNotSampled)&&void 0!==s?s:new On}shouldSample(t,e,n,r,s,i){const o=xt.getSpanContext(t);return o&&tt(o)?o.isRemote?o.traceFlags&B.SAMPLED?this._remoteParentSampled.shouldSample(t,e,n,r,s,i):this._remoteParentNotSampled.shouldSample(t,e,n,r,s,i):o.traceFlags&B.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 An{constructor(t=0){this._ratio=t,this._ratio=this._normalize(t),this._upperBound=Math.floor(4294967295*this._ratio)}shouldSample(t,e){return{decision:Z(e)&&this._accumulate(e)<this._upperBound?bn.RECORD_AND_SAMPLED:bn.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 wn=me(),yn=Qt.AlwaysOn,Nn=1;function Pn(){return{sampler:Cn(wn),forceFlushTimeoutMillis:3e4,generalLimits:{attributeValueLengthLimit:me().OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT,attributeCountLimit:me().OTEL_ATTRIBUTE_COUNT_LIMIT},spanLimits:{attributeValueLengthLimit:me().OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT,attributeCountLimit:me().OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT,linkCountLimit:me().OTEL_SPAN_LINK_COUNT_LIMIT,eventCountLimit:me().OTEL_SPAN_EVENT_COUNT_LIMIT,attributePerEventCountLimit:me().OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT,attributePerLinkCountLimit:me().OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT}}}function Cn(t=me()){switch(t.OTEL_TRACES_SAMPLER){case Qt.AlwaysOn:return new Rn;case Qt.AlwaysOff:return new On;case Qt.ParentBasedAlwaysOn:return new Ln({root:new Rn});case Qt.ParentBasedAlwaysOff:return new Ln({root:new On});case Qt.TraceIdRatio:return new An(In(t));case Qt.ParentBasedTraceIdRatio:return new Ln({root:new An(In(t))});default:return Tt.error(`OTEL_TRACES_SAMPLER value "${t.OTEL_TRACES_SAMPLER} invalid, defaulting to ${yn}".`),new Rn}}function In(t){if(void 0===t.OTEL_TRACES_SAMPLER_ARG||""===t.OTEL_TRACES_SAMPLER_ARG)return Tt.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${Nn}.`),Nn;const e=Number(t.OTEL_TRACES_SAMPLER_ARG);return isNaN(e)?(Tt.error(`OTEL_TRACES_SAMPLER_ARG=${t.OTEL_TRACES_SAMPLER_ARG} was given, but it is invalid, defaulting to ${Nn}.`),Nn):e<0||e>1?(Tt.error(`OTEL_TRACES_SAMPLER_ARG=${t.OTEL_TRACES_SAMPLER_ARG} was given, but it is out of range ([0..1]), defaulting to ${Nn}.`),Nn):e}function xn(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?pe(process.env):pe(Zt);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:ae,_.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:oe,Object.assign({},t,{spanLimits:_})}class Mn{constructor(t,e){this._exporter=t,this._isExporting=!1,this._finishedSpans=[],this._droppedSpansCount=0;const n=me();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 vn(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(Tt.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&B.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&&Tt.debug("maxQueueSize reached, dropping spans"),void this._droppedSpansCount++;this._droppedSpansCount>0&&(Tt.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);Et.with(function(t){return t.setValue(Dt,!0)}(Et.active()),(()=>{const r=this._finishedSpans.splice(0,this._maxExportBatchSize),s=()=>this._exporter.export(r,(r=>{var s;clearTimeout(n),r.code===ke.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=>{Yt(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,Yt(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 Un extends Mn{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 Dn{constructor(){this.generateTraceId=Bn(16),this.generateSpanId=Bn(8)}}const kn=Array(32);function Bn(t){return function(){for(let e=0;e<2*t;e++)kn[e]=Math.floor(16*Math.random())+48,kn[e]>=58&&(kn[e]+=39);return String.fromCharCode.apply(null,kn.slice(0,2*t))}}class Hn{constructor(t,e,n){this._tracerProvider=n;const r=function(t){const e={sampler:Cn()},n=Pn(),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 Dn,this.resource=n.resource,this.instrumentationLibrary=t}startSpan(t,e={},n=Et.active()){var r,s,i;e.root&&(n=xt.deleteSpan(n));const o=xt.getSpan(n);if(kt(n)){Tt.debug("Instrumentation suppressed, returning Noop Span");return xt.wrapSpanContext(F)}const a=null==o?void 0:o.spanContext(),c=this._idGenerator.generateSpanId();let u,l,d;a&&xt.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:ut.INTERNAL,_=(null!==(s=e.links)&&void 0!==s?s:[]).map((t=>({context:t.context,attributes:Xt(t.attributes)}))),p=Xt(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===ct.RECORD_AND_SAMPLED?B.SAMPLED:B.NONE,traceState:l};if(m.decision===ct.NOT_RECORD){Tt.debug("Recording is off, propagating context in a non-recording span");return xt.wrapSpanContext(E)}const T=Xt(Object.assign(p,m.attributes));return new Sn(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:Et.active(),c=this.startSpan(t,s,a),u=xt.setSpan(a,c);return Et.with(u,o,void 0,c)}getGeneralLimits(){return this._generalLimits}getSpanLimits(){return this._spanLimits}getActiveSpanProcessor(){return this._tracerProvider.getActiveSpanProcessor()}}function jn(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 Fn{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=>(Tt.debug("a resource's async attributes promise rejected: %s",t),this.asyncAttributesPending=!1,{})))}static empty(){return Fn.EMPTY}static default(){return new Fn({[Oe.SERVICE_NAME]:"unknown_service",[Oe.TELEMETRY_SDK_LANGUAGE]:Le[Oe.TELEMETRY_SDK_LANGUAGE],[Oe.TELEMETRY_SDK_NAME]:Le[Oe.TELEMETRY_SDK_NAME],[Oe.TELEMETRY_SDK_VERSION]:Le[Oe.TELEMETRY_SDK_VERSION]})}get attributes(){var t;return this.asyncAttributesPending&&Tt.error("Accessing resource attributes before async attributes settled"),null!==(t=this._attributes)&&void 0!==t?t:{}}waitForAsyncAttributes(){return jn(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 Fn(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 Fn(n,r)}}Fn.EMPTY=new Fn({});class Vn{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=>{Yt(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 Gn{onStart(t,e){}onEnd(t){}shutdown(){return Promise.resolve()}forceFlush(){return Promise.resolve()}}var $n,Xn;!function(t){t[t.resolved=0]="resolved",t[t.timeout=1]="timeout",t[t.error=2]="error",t[t.unresolved=3]="unresolved"}($n||($n={}));class zn{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=dn(e,t.shift(),0,n);return e}({},Pn(),xn(t));this.resource=null!==(e=n.resource)&&void 0!==e?e:Fn.empty(),this.resource=Fn.default().merge(this.resource),this._config=Object.assign({},n,{resource:this.resource});const r=this._buildExporterFromEnv();if(void 0!==r){const t=new Un(r);this.activeSpanProcessor=t}else this.activeSpanProcessor=new Gn}getTracer(t,e,n){const r=`${t}@${e||""}:${(null==n?void 0:n.schemaUrl)||""}`;return this._tracers.has(r)||this._tracers.set(r,new Hn({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=>Tt.error("Error while trying to shutdown current span processor",t))),this._registeredSpanProcessors.push(t),this.activeSpanProcessor=new Vn(this._registeredSpanProcessors)}getActiveSpanProcessor(){return this.activeSpanProcessor}register(t={}){xt.setGlobalTracerProvider(this),void 0===t.propagator&&(t.propagator=this._buildPropagatorFromEnv()),t.contextManager&&Et.setGlobalContextManager(t.contextManager),t.propagator&&Pt.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=$n.timeout}),t);e.forceFlush().then((()=>{clearTimeout(s),r!==$n.timeout&&(r=$n.resolved,n(r))})).catch((t=>{clearTimeout(s),r=$n.error,n(t)}))}))));return new Promise(((t,n)=>{Promise.all(e).then((e=>{const r=e.filter((t=>t!==$n.resolved));r.length>0?n(r):t()})).catch((t=>n([t])))}))}shutdown(){return this.activeSpanProcessor.shutdow