UNPKG

dd-trace

Version:

Datadog APM tracing client for JavaScript

1 lines 23.7 kB
(()=>{"use strict";var e,t,r,n,o,i,a,_,T,E={};E.d=(e,t)=>{for(var r in t)E.o(t,r)&&!E.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},E.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),E.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var u={};E.r(u),E.d(u,{baggageUtils:()=>e6,hrTime:()=>w,timeInputToHrTime:()=>X,W3CTraceContextPropagator:()=>eI,callWithTimeout:()=>eQ,AlwaysOnSampler:()=>eb,isTracingSuppressed:()=>O,AlwaysOffSampler:()=>eN,loggingErrorHandler:()=>C,DEFAULT_ATTRIBUTE_COUNT_LIMIT:()=>eo,deleteRPCMetadata:()=>ev,suppressTracing:()=>f,RPCType:()=>T,RandomIdGenerator:()=>Z,setRPCMetadata:()=>eA,unrefTimer:()=>ef,hrTimeToMilliseconds:()=>V,TRACE_PARENT_HEADER:()=>ey,unsuppressTracing:()=>s,globalErrorHandler:()=>U,_globalThis:()=>q,getEnvWithoutDefaults:()=>el,ParentBasedSampler:()=>eU,millisToHrTime:()=>D,isTimeInputHrTime:()=>F,otperformance:()=>M,internal:()=>e5,urlMatches:()=>eq,BindOnceFuture:()=>e8,DEFAULT_ENVIRONMENT:()=>e_,SDK_INFO:()=>$,isWrapped:()=>e1,isAttributeKey:()=>m,TraceState:()=>eP,hexToBase64:()=>ec,TRACE_STATE_HEADER:()=>ed,getEnv:()=>eu,getTimeOrigin:()=>B,TraceIdRatioBasedSampler:()=>eM,hrTimeDuration:()=>j,DEFAULT_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT:()=>ei,isTimeInput:()=>K,hexToBinary:()=>Y,DEFAULT_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT:()=>ea,parseTraceParent:()=>eh,isUrlIgnored:()=>e0,parseEnvironment:()=>eE,setGlobalErrorHandler:()=>b,DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT:()=>en,isAttributeValue:()=>A,CompositePropagator:()=>eO,hrTimeToMicroseconds:()=>H,AnchoredClock:()=>d,TracesSamplerValues:()=>_,ExportResultCode:()=>i,hrTimeToNanoseconds:()=>G,merge:()=>eH,TimeoutError:()=>eJ,W3CBaggagePropagator:()=>y,addHrTimes:()=>k,getRPCMetadata:()=>eC,sanitizeAttributes:()=>I,hrTimeToTimeStamp:()=>x,VERSION:()=>Q});let l=require("@opentelemetry/api");var c=(0,l.createContextKey)("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function f(e){return e.setValue(c,!0)}function s(e){return e.deleteValue(c)}function O(e){return!0===e.getValue(c)}var p="baggage",R=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a};function L(e){return e.reduce(function(e,t){var r=""+e+(""!==e?",":"")+t;return r.length>8192?e:r},"")}function S(e){return e.getAllEntries().map(function(e){var t=R(e,2),r=t[0],n=t[1],o=encodeURIComponent(r)+"="+encodeURIComponent(n.value);return void 0!==n.metadata&&(o+=";"+n.metadata.toString()),o})}function P(e){var t,r=e.split(";");if(!(r.length<=0)){var n=r.shift();if(n){var o=n.indexOf("=");if(!(o<=0)){var i=decodeURIComponent(n.substring(0,o).trim()),a=decodeURIComponent(n.substring(o+1).trim());return r.length>0&&(t=(0,l.baggageEntryMetadataFromString)(r.join(";"))),{key:i,value:a,metadata:t}}}}}var y=function(){function e(){}return e.prototype.inject=function(e,t,r){var n=l.propagation.getBaggage(e);if(!(!n||O(e))){var o=L(S(n).filter(function(e){return e.length<=4096}).slice(0,180));o.length>0&&r.set(t,p,o)}},e.prototype.extract=function(e,t,r){var n=r.get(t,p),o=Array.isArray(n)?n.join(","):n;if(!o)return e;var i={};return 0===o.length||(o.split(",").forEach(function(e){var t=P(e);if(t){var r={value:t.value};t.metadata&&(r.metadata=t.metadata),i[t.key]=r}}),0===Object.entries(i).length)?e:l.propagation.setBaggage(e,l.propagation.createBaggage(i))},e.prototype.fields=function(){return[p]},e}(),d=function(){function e(e,t){this._monotonicClock=t,this._epochMillis=e.now(),this._performanceMillis=t.now()}return e.prototype.now=function(){var e=this._monotonicClock.now()-this._performanceMillis;return this._epochMillis+e},e}(),g=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},h=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a};function I(e){var t,r,n={};if("object"!=typeof e||null==e)return n;try{for(var o=g(Object.entries(e)),i=o.next();!i.done;i=o.next()){var a=h(i.value,2),_=a[0],T=a[1];if(!m(_)){l.diag.warn("Invalid attribute key: "+_);continue}if(!A(T)){l.diag.warn("Invalid attribute value set for key: "+_);continue}Array.isArray(T)?n[_]=T.slice():n[_]=T}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return n}function m(e){return"string"==typeof e&&e.length>0}function A(e){return null==e||(Array.isArray(e)?function(e){try{for(var t,r,n,o=g(e),i=o.next();!i.done;i=o.next()){var a=i.value;if(null!=a){if(!n){if(v(a)){n=typeof a;continue}return!1}if(typeof a!==n)return!1}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return!0}(e):v(e))}function v(e){switch(typeof e){case"number":case"boolean":case"string":return!0}return!1}function C(){return function(e){var t;l.diag.error("string"==typeof(t=e)?t:JSON.stringify(function(e){for(var t={},r=e;null!==r;)Object.getOwnPropertyNames(r).forEach(function(e){if(!t[e]){var n=r[e];n&&(t[e]=String(n))}}),r=Object.getPrototypeOf(r);return t}(t)))}}var N=C();function b(e){N=e}function U(e){try{N(e)}catch(e){}}var M=require("perf_hooks").performance;function D(e){return[Math.trunc(e/1e3),Math.round(e%1e3*1e6)]}function B(){var e=M.timeOrigin;return"number"!=typeof e&&(e=M.timing&&M.timing.fetchStart),e}function w(e){return k(D(B()),D("number"==typeof e?e:M.now()))}function X(e){if(F(e))return e;if("number"==typeof e)if(e<B())return w(e);else return D(e);if(e instanceof Date)return D(e.getTime());throw TypeError("Invalid input type")}function j(e,t){var r=t[0]-e[0],n=t[1]-e[1];return n<0&&(r-=1,n+=1e9),[r,n]}function x(e){var t=""+"0".repeat(9)+e[1]+"Z",r=t.substring(t.length-9-1);return new Date(1e3*e[0]).toISOString().replace("000Z",r)}function G(e){return 1e9*e[0]+e[1]}function V(e){return 1e3*e[0]+e[1]/1e6}function H(e){return 1e6*e[0]+e[1]/1e3}function F(e){return Array.isArray(e)&&2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]}function K(e){return F(e)||"number"==typeof e||e instanceof Date}function k(e,t){var r=[e[0]+t[0],e[1]+t[1]];return r[1]>=1e9&&(r[1]-=1e9,r[0]+=1),r}function z(e){return e>=48&&e<=57?e-48:e>=97&&e<=102?e-87:e-55}function Y(e){for(var t=new Uint8Array(e.length/2),r=0,n=0;n<e.length;n+=2){var o=z(e.charCodeAt(n)),i=z(e.charCodeAt(n+1));t[r++]=o<<4|i}return t}(r=i||(i={}))[r.SUCCESS=0]="SUCCESS",r[r.FAILED=1]="FAILED";var Z=function(){this.generateTraceId=J(16),this.generateSpanId=J(8)},W=Buffer.allocUnsafe(16);function J(e){return function(){for(var t=0;t<e/4;t++)W.writeUInt32BE(0x100000000*Math.random()>>>0,4*t);for(var t=0;t<e;t++)if(W[t]>0)break;else t===e-1&&(W[e-1]=1);return W.toString("hex",0,e)}}var Q="1.30.1",$=((a={})["telemetry.sdk.name"]="opentelemetry",a["process.runtime.name"]="node",a["telemetry.sdk.language"]="nodejs",a["telemetry.sdk.version"]=Q,a),q="object"==typeof globalThis?globalThis:global;(n=_||(_={})).AlwaysOff="always_off",n.AlwaysOn="always_on",n.ParentBasedAlwaysOff="parentbased_always_off",n.ParentBasedAlwaysOn="parentbased_always_on",n.ParentBasedTraceIdRatio="parentbased_traceidratio",n.TraceIdRatio="traceidratio";var ee=["OTEL_SDK_DISABLED"],et=["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"],er=["OTEL_NO_PATCH_MODULES","OTEL_PROPAGATORS","OTEL_SEMCONV_STABILITY_OPT_IN"],en=1/0,eo=128,ei=128,ea=128,e_={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:l.DiagLogLevel.INFO,OTEL_NO_PATCH_MODULES:[],OTEL_PROPAGATORS:["tracecontext","baggage"],OTEL_RESOURCE_ATTRIBUTES:"",OTEL_SERVICE_NAME:"",OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT:en,OTEL_ATTRIBUTE_COUNT_LIMIT:eo,OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT:en,OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT:eo,OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT:en,OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT:eo,OTEL_SPAN_EVENT_COUNT_LIMIT:128,OTEL_SPAN_LINK_COUNT_LIMIT:128,OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT:ei,OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT:ea,OTEL_TRACES_EXPORTER:"",OTEL_TRACES_SAMPLER:_.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",OTEL_SEMCONV_STABILITY_OPT_IN:[]},eT={ALL:l.DiagLogLevel.ALL,VERBOSE:l.DiagLogLevel.VERBOSE,DEBUG:l.DiagLogLevel.DEBUG,INFO:l.DiagLogLevel.INFO,WARN:l.DiagLogLevel.WARN,ERROR:l.DiagLogLevel.ERROR,NONE:l.DiagLogLevel.NONE};function eE(e){var t={};for(var r in e_)if("OTEL_LOG_LEVEL"===r)!function(e,t,r){var n=r[e];if("string"==typeof n){var o=eT[n.toUpperCase()];null!=o&&(t[e]=o)}}(r,t,e);else if(ee.indexOf(r)>-1)!function(e,t,r){if(void 0!==r[e]){var n=String(r[e]);t[e]="true"===n.toLowerCase()}}(r,t,e);else if(et.indexOf(r)>-1)!function(e,t,r,n,o){if(void 0===n&&(n=-1/0),void 0===o&&(o=1/0),void 0!==r[e]){var i=Number(r[e]);isNaN(i)||(i<n?t[e]=n:i>o?t[e]=o:t[e]=i)}}(r,t,e);else if(er.indexOf(r)>-1)!function(e,t,r,n){void 0===n&&(n=",");var o=r[e];"string"==typeof o&&(t[e]=o.split(n).map(function(e){return e.trim()}))}(r,t,e);else{var n=e[r];null!=n&&(t[r]=String(n))}return t}function eu(){return Object.assign({},e_,eE(process.env))}function el(){return eE(process.env)}function ec(e){return Buffer.from(Y(e)).toString("base64")}function ef(e){e.unref()}var es=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},eO=function(){function e(e){var t;void 0===e&&(e={}),this._propagators=null!=(t=e.propagators)?t:[],this._fields=Array.from(new Set(this._propagators.map(function(e){return"function"==typeof e.fields?e.fields():[]}).reduce(function(e,t){return e.concat(t)},[])))}return e.prototype.inject=function(e,t,r){var n,o;try{for(var i=es(this._propagators),a=i.next();!a.done;a=i.next()){var _=a.value;try{_.inject(e,t,r)}catch(e){l.diag.warn("Failed to inject with "+_.constructor.name+". Err: "+e.message)}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(n)throw n.error}}},e.prototype.extract=function(e,t,r){return this._propagators.reduce(function(e,n){try{return n.extract(e,t,r)}catch(e){l.diag.warn("Failed to extract with "+n.constructor.name+". Err: "+e.message)}return e},e)},e.prototype.fields=function(){return this._fields.slice()},e}(),ep="[_0-9a-z-*/]",eR=RegExp("^(?:[a-z]"+ep+"{0,255}|"+("[a-z0-9]"+ep+"{0,240}@[a-z]")+ep+"{0,13})$"),eL=/^[ -~]{0,255}[!-~]$/,eS=/,|=/,eP=function(){function e(e){this._internalState=new Map,e&&this._parse(e)}return e.prototype.set=function(e,t){var r=this._clone();return r._internalState.has(e)&&r._internalState.delete(e),r._internalState.set(e,t),r},e.prototype.unset=function(e){var t=this._clone();return t._internalState.delete(e),t},e.prototype.get=function(e){return this._internalState.get(e)},e.prototype.serialize=function(){var e=this;return this._keys().reduce(function(t,r){return t.push(r+"="+e.get(r)),t},[]).join(",")},e.prototype._parse=function(e){!(e.length>512)&&(this._internalState=e.split(",").reverse().reduce(function(e,t){var r=t.trim(),n=r.indexOf("=");if(-1!==n){var o=r.slice(0,n),i=r.slice(n+1,t.length);eR.test(o)&&eL.test(i)&&!eS.test(i)&&e.set(o,i)}return e},new Map),this._internalState.size>32&&(this._internalState=new Map(Array.from(this._internalState.entries()).reverse().slice(0,32))))},e.prototype._keys=function(){return Array.from(this._internalState.keys()).reverse()},e.prototype._clone=function(){var t=new e;return t._internalState=new Map(this._internalState),t},e}(),ey="traceparent",ed="tracestate",eg=RegExp("^\\s?((?!ff)[\\da-f]{2})-((?![0]{32})[\\da-f]{32})-((?![0]{16})[\\da-f]{16})-([\\da-f]{2})(-.*)?\\s?$");function eh(e){var t=eg.exec(e);return!t||"00"===t[1]&&t[5]?null:{traceId:t[2],spanId:t[3],traceFlags:parseInt(t[4],16)}}var eI=function(){function e(){}return e.prototype.inject=function(e,t,r){var n=l.trace.getSpanContext(e);if(!(!n||O(e))&&(0,l.isSpanContextValid)(n)){var o="00-"+n.traceId+"-"+n.spanId+"-0"+Number(n.traceFlags||l.TraceFlags.NONE).toString(16);r.set(t,ey,o),n.traceState&&r.set(t,ed,n.traceState.serialize())}},e.prototype.extract=function(e,t,r){var n=r.get(t,ey);if(!n)return e;var o=Array.isArray(n)?n[0]:n;if("string"!=typeof o)return e;var i=eh(o);if(!i)return e;i.isRemote=!0;var a=r.get(t,ed);if(a){var _=Array.isArray(a)?a.join(","):a;i.traceState=new eP("string"==typeof _?_:void 0)}return l.trace.setSpanContext(e,i)},e.prototype.fields=function(){return[ey,ed]},e}(),em=(0,l.createContextKey)("OpenTelemetry SDK Context Key RPC_METADATA");function eA(e,t){return e.setValue(em,t)}function ev(e){return e.deleteValue(em)}function eC(e){return e.getValue(em)}(T||(T={})).HTTP="http";var eN=function(){function e(){}return e.prototype.shouldSample=function(){return{decision:l.SamplingDecision.NOT_RECORD}},e.prototype.toString=function(){return"AlwaysOffSampler"},e}(),eb=function(){function e(){}return e.prototype.shouldSample=function(){return{decision:l.SamplingDecision.RECORD_AND_SAMPLED}},e.prototype.toString=function(){return"AlwaysOnSampler"},e}(),eU=function(){function e(e){var t,r,n,o;this._root=e.root,this._root||(U(Error("ParentBasedSampler must have a root sampler configured")),this._root=new eb),this._remoteParentSampled=null!=(t=e.remoteParentSampled)?t:new eb,this._remoteParentNotSampled=null!=(r=e.remoteParentNotSampled)?r:new eN,this._localParentSampled=null!=(n=e.localParentSampled)?n:new eb,this._localParentNotSampled=null!=(o=e.localParentNotSampled)?o:new eN}return e.prototype.shouldSample=function(e,t,r,n,o,i){var a=l.trace.getSpanContext(e);return a&&(0,l.isSpanContextValid)(a)?a.isRemote?a.traceFlags&l.TraceFlags.SAMPLED?this._remoteParentSampled.shouldSample(e,t,r,n,o,i):this._remoteParentNotSampled.shouldSample(e,t,r,n,o,i):a.traceFlags&l.TraceFlags.SAMPLED?this._localParentSampled.shouldSample(e,t,r,n,o,i):this._localParentNotSampled.shouldSample(e,t,r,n,o,i):this._root.shouldSample(e,t,r,n,o,i)},e.prototype.toString=function(){return"ParentBased{root="+this._root.toString()+", remoteParentSampled="+this._remoteParentSampled.toString()+", remoteParentNotSampled="+this._remoteParentNotSampled.toString()+", localParentSampled="+this._localParentSampled.toString()+", localParentNotSampled="+this._localParentNotSampled.toString()+"}"},e}(),eM=function(){function e(e){void 0===e&&(e=0),this._ratio=e,this._ratio=this._normalize(e),this._upperBound=Math.floor(0xffffffff*this._ratio)}return e.prototype.shouldSample=function(e,t){return{decision:(0,l.isValidTraceId)(t)&&this._accumulate(t)<this._upperBound?l.SamplingDecision.RECORD_AND_SAMPLED:l.SamplingDecision.NOT_RECORD}},e.prototype.toString=function(){return"TraceIdRatioBased{"+this._ratio+"}"},e.prototype._normalize=function(e){return"number"!=typeof e||isNaN(e)?0:e>=1?1:e<=0?0:e},e.prototype._accumulate=function(e){for(var t=0,r=0;r<e.length/8;r++){var n=8*r;t=(t^parseInt(e.slice(n,n+8),16))>>>0}return t},e}(),eD=Function.prototype.toString,eB=eD.call(Object),ew=(e=Object.getPrototypeOf,t=Object,function(r){return e(t(r))}),eX=Object.prototype,ej=eX.hasOwnProperty,ex=Symbol?Symbol.toStringTag:void 0,eG=eX.toString;function eV(e){if(null==(t=e)||"object"!=typeof t||"[object Object]"!==(null==(r=e)?void 0===r?"[object Undefined]":"[object Null]":ex&&ex in Object(r)?function(e){var t=ej.call(e,ex),r=e[ex],n=!1;try{e[ex]=void 0,n=!0}catch(e){}var o=eG.call(e);return n&&(t?e[ex]=r:delete e[ex]),o}(r):(n=r,eG.call(n))))return!1;var t,r,n,o=ew(e);if(null===o)return!0;var i=ej.call(o,"constructor")&&o.constructor;return"function"==typeof i&&i instanceof i&&eD.call(i)===eB}function eH(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var r=e.shift(),n=new WeakMap;e.length>0;)r=function e(t,r,n,o){if(void 0===n&&(n=0),!(n>20)){if(n++,eZ(t)||eZ(r)||ez(r))_=eF(r);else if(ek(t)){if(_=t.slice(),ek(r))for(var i,a,_,T=0,E=r.length;T<E;T++)_.push(eF(r[T]));else if(eY(r))for(var u=Object.keys(r),T=0,E=u.length;T<E;T++){var l=u[T];_[l]=eF(r[l])}}else if(eY(t))if(eY(r)){if(i=t,a=r,!(eV(i)&&eV(a)))return r;_=Object.assign({},t);for(var u=Object.keys(r),T=0,E=u.length;T<E;T++){var l=u[T],c=r[l];if(eZ(c))void 0===c?delete _[l]:_[l]=c;else{var f=_[l];if(eK(t,l,o)||eK(r,l,o))delete _[l];else{if(eY(f)&&eY(c)){var s=o.get(f)||[],O=o.get(c)||[];s.push({obj:t,key:l}),O.push({obj:r,key:l}),o.set(f,s),o.set(c,O)}_[l]=e(_[l],c,n,o)}}}}else _=r;return _}}(r,e.shift(),0,n);return r}function eF(e){return ek(e)?e.slice():e}function eK(e,t,r){for(var n=r.get(e[t])||[],o=0,i=n.length;o<i;o++){var a=n[o];if(a.key===t&&a.obj===e)return!0}return!1}function ek(e){return Array.isArray(e)}function ez(e){return"function"==typeof e}function eY(e){return!eZ(e)&&!ek(e)&&!ez(e)&&"object"==typeof e}function eZ(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||void 0===e||e instanceof Date||e instanceof RegExp||null===e}var eW=(o=function(e,t){return(o=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),eJ=function(e){function t(r){var n=e.call(this,r)||this;return Object.setPrototypeOf(n,t.prototype),n}return eW(t,e),t}(Error);function eQ(e,t){var r;return Promise.race([e,new Promise(function(e,n){r=setTimeout(function(){n(new eJ("Operation timed out."))},t)})]).then(function(e){return clearTimeout(r),e},function(e){throw clearTimeout(r),e})}var e$=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function eq(e,t){return"string"==typeof t?e===t:!!e.match(t)}function e0(e,t){var r,n;if(!t)return!1;try{for(var o=e$(t),i=o.next();!i.done;i=o.next()){var a=i.value;if(eq(e,a))return!0}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return!1}function e1(e){return"function"==typeof e&&"function"==typeof e.__original&&"function"==typeof e.__unwrap&&!0===e.__wrapped}var e2=function(){function e(){var e=this;this._promise=new Promise(function(t,r){e._resolve=t,e._reject=r})}return Object.defineProperty(e.prototype,"promise",{get:function(){return this._promise},enumerable:!1,configurable:!0}),e.prototype.resolve=function(e){this._resolve(e)},e.prototype.reject=function(e){this._reject(e)},e}(),e3=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},e4=function(e,t,r){if(r||2==arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))},e8=function(){function e(e,t){this._callback=e,this._that=t,this._isCalled=!1,this._deferred=new e2}return Object.defineProperty(e.prototype,"isCalled",{get:function(){return this._isCalled},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"promise",{get:function(){return this._deferred.promise},enumerable:!1,configurable:!0}),e.prototype.call=function(){for(var e,t=this,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];if(!this._isCalled){this._isCalled=!0;try{Promise.resolve((e=this._callback).call.apply(e,e4([this._that],e3(r),!1))).then(function(e){return t._deferred.resolve(e)},function(e){return t._deferred.reject(e)})}catch(e){this._deferred.reject(e)}}return this._deferred.promise},e}(),e6={getKeyPairs:S,serializeKeyPairs:L,parseKeyPairsIntoRecord:function(e){return"string"!=typeof e||0===e.length?{}:e.split(",").map(function(e){return P(e)}).filter(function(e){return void 0!==e&&e.value.length>0}).reduce(function(e,t){return e[t.key]=t.value,e},{})},parsePairKeyValue:P},e5={_export:function(e,t){return new Promise(function(r){l.context.with(f(l.context.active()),function(){e.export(t,function(e){r(e)})})})}};module.exports=u})();