Comparing version 0.21.0 to 0.22.0
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Zipkin={})}(this,function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;e.length>n;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function o(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function a(t){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}var c={get type(){return"None"},get present(){return!1},map:function(){return this},ifPresent:function(){},flatMap:function(){return this},getOrElse:function(t){return t instanceof Function?t():t},equals:function(t){return t===this},toString:function(){return"None"}},h=function(){function t(e){n(this,t),this.value=e}return o(t,[{key:"map",value:function(e){return new t(e(this.value))}},{key:"ifPresent",value:function(t){t(this.value)}},{key:"flatMap",value:function(t){return t(this.value)}},{key:"getOrElse",value:function(){return this.value}},{key:"equals",value:function(e){return e instanceof t&&e.value===this.value}},{key:"toString",value:function(){return"Some(".concat(this.value,")")}},{key:"type",get:function(){return"Some"}},{key:"present",get:function(){return!0}}]),t}();function f(t){return t instanceof h||c.equals(t)}var p={Some:h,None:c,isOptional:f,verifyIsOptional:function(t){if(null==t)throw Error("Error: data is not Optional - it's null");if(!f(t))throw Error("Error: data (".concat(t,") is not an Option!"));if(f(t.value))throw Error("Error: data (".concat(t.value,") is wrapped in Option twice"))},verifyIsNotOptional:function(t){if(f(t))throw Error("Error: data (".concat(t,") is an Option!"))},fromNullable:function(t){return null==t?c:new h(t)}},l="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function d(){throw Error("setTimeout has not been defined")}function v(){throw Error("clearTimeout has not been defined")}var m=d,g=v;function y(t){if(m===setTimeout)return setTimeout(t,0);if((m===d||!m)&&setTimeout)return m=setTimeout,setTimeout(t,0);try{return m(t,0)}catch(e){try{return m.call(null,t,0)}catch(e){return m.call(this,t,0)}}}"function"==typeof l.setTimeout&&(m=setTimeout),"function"==typeof l.clearTimeout&&(g=clearTimeout);var w,E=[],I=!1,b=-1;function S(){I&&w&&(I=!1,w.length?E=w.concat(E):b=-1,E.length&&A())}function A(){if(!I){var t=y(S);I=!0;for(var e=E.length;e;){for(w=E,E=[];++b<e;)w&&w[b].run();b=-1,e=E.length}w=null,I=!1,function(t){if(g===clearTimeout)return clearTimeout(t);if((g===v||!g)&&clearTimeout)return g=clearTimeout,clearTimeout(t);try{g(t)}catch(e){try{return g.call(null,t)}catch(e){return g.call(this,t)}}}(t)}}function R(t,e){this.fun=t,this.array=e}R.prototype.run=function(){this.fun.apply(null,this.array)};function _(){}var k=_,T=_,O=_,C=_,P=_,N=_,U=_;var x=l.performance||{},B=x.now||x.mozNow||x.msNow||x.oNow||x.webkitNow||function(){return(new Date).getTime()};var L=new Date;var M,j={nextTick:function(t){var e=[];if(arguments.length>1)for(var n=1;arguments.length>n;n++)e[n-1]=arguments[n];E.push(new R(t,e)),1!==E.length||I||y(A)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:k,addListener:T,once:O,off:C,removeListener:P,removeAllListeners:N,emit:U,binding:function(t){throw Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(t){throw Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(t){var e=.001*B.call(x),n=Math.floor(e),r=Math.floor(e%1*1e9);return t&&(n-=t[0],0>(r-=t[1])&&(n--,r+=1e9)),[n,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-L)/1e3}};function D(){return"/tmp"}var Y={EOL:"\n",tmpdir:D,tmpDir:D,networkInterfaces:function(){},getNetworkInterfaces:function(){},release:function(){return void 0!==l.navigator?l.navigator.appVersion:""},type:function(){return"Browser"},cpus:function(){return[]},totalmem:function(){return Number.MAX_VALUE},freemem:function(){return Number.MAX_VALUE},uptime:function(){return 0},loadavg:function(){return[]},hostname:function(){return void 0!==l.location?l.location.hostname:""},endianness:function(){if(void 0===M){var t=new ArrayBuffer(2),e=new Uint8Array(t),n=new Uint16Array(t);if(e[0]=1,e[1]=2,258===n[0])M="BE";else{if(513!==n[0])throw Error("unable to figure out endianess");M="LE"}}return M}};function q(t,e){for(var n in t)for(var r=t[n].length-1;r>=0;r-=1){var o=t[n][r];if(!o.internal&&o.family===e&&("IPv4"===e||0===o.scopeid))return o.address}return"IPv4"===e?"127.0.0.1":"::1"}function F(t,e){var n={};for(var r in t)r===e&&(n[r]=t[r]);return n}function z(t){var e=Y.networkInterfaces();return t&&(e=F(e,t)),q(e,"IPv4")}z.ipv4=z,z.ipv6=function(t){var e=Y.networkInterfaces();return t&&(e=F(e,t)),q(e,"IPv6")};var K=z,H=function(){function t(e){n(this,t),this.addr=e}return o(t,[{key:"ipv4",value:function(){var t=this.toInt();if(t&&0!==t)return this.addr}},{key:"toInt",value:function(){var t=this.addr.split(".");return t[0]<<24|t[1]<<16|t[2]<<8|t[3]}},{key:"toString",value:function(){return"InetAddress(".concat(this.addr,")")}}]),t}();var V="object"===(void 0===j?"undefined":e(j))&&"function"==typeof j.on?new H(K.ipv4()):new H("127.0.0.1");H.getLocalAddress=function(){return V};var J=H,X=function(){function t(){n(this,t)}return o(t,[{key:"toString",value:function(){return"".concat(this.annotationType,"()")}}]),t}(),Z=function(t){function e(){return n(this,e),u(this,a(e).apply(this,arguments))}return i(e,X),e}(),$=function(t){function e(){return n(this,e),u(this,a(e).apply(this,arguments))}return i(e,X),e}(),G=function(t){function e(){return n(this,e),u(this,a(e).apply(this,arguments))}return i(e,X),e}(),Q=function(t){function e(){return n(this,e),u(this,a(e).apply(this,arguments))}return i(e,X),e}(),W=function(t){function e(){return n(this,e),u(this,a(e).apply(this,arguments))}return i(e,X),e}(),tt=function(t){function e(){return n(this,e),u(this,a(e).apply(this,arguments))}return i(e,X),e}(),et=function(t){function e(){return n(this,e),u(this,a(e).apply(this,arguments))}return i(e,X),e}(),nt=function(t){function e(){return n(this,e),u(this,a(e).apply(this,arguments))}return i(e,X),e}();function rt(t){this.name=t}rt.prototype.toString=function(){return'LocalOperationStart("'.concat(this.name,'")')};var ot=function(t){function e(){return n(this,e),u(this,a(e).apply(this,arguments))}return i(e,X),e}();function it(t){this.message=t}function at(t){this.serviceName=t}function st(t){this.name=t}function ut(t){var e=t.port;this.host=t.host,this.port=e}function ct(t){var e=t.host,n=t.port;this.serviceName=t.serviceName,this.host=e||void 0,this.port=n||0}function ht(t){var e=t.port;this.host=t.host||J.getLocalAddress(),this.port=e||0}function ft(t){var e=t.host,n=t.port;this.serviceName=t.serviceName,this.host=e,this.port=n}function pt(t,e){this.key=t,this.value=e}it.prototype.toString=function(){return'Message("'.concat(this.message,'")')},at.prototype.toString=function(){return'ServiceName("'.concat(this.serviceName,'")')},st.prototype.toString=function(){return'Rpc("'.concat(this.name,'")')},ut.prototype.toString=function(){return'ClientAddr(host="'.concat(this.host,'", port=').concat(this.port,")")},ct.prototype.toString=function(){return'ServerAddr(serviceName="'.concat(this.serviceName,'", host="').concat(this.host,'", port=').concat(this.port,")")},ht.prototype.toString=function(){return'LocalAddr(host="'.concat(""+this.host,'", port=').concat(this.port,")")},ft.prototype.toString=function(){return'MessageAddr(serviceName="'.concat(this.serviceName,'", host="').concat(this.host,'", port=').concat(this.port,")")},pt.prototype.toString=function(){return"BinaryAnnotation(".concat(this.key,'="').concat(this.value,'")')};var lt={ClientSend:Z,ClientRecv:$,ServerSend:G,ServerRecv:Q,ProducerStart:W,ProducerStop:tt,ConsumerStart:et,ConsumerStop:nt,MessageAddr:ft,Message:it,ServiceName:at,Rpc:st,ClientAddr:ut,ServerAddr:ct,LocalAddr:ht,BinaryAnnotation:pt,LocalOperationStart:rt,LocalOperationStop:ot};Object.keys(lt).forEach(function(t){lt[t].prototype.annotationType=t});var dt=lt,vt=function(t){return!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then};var mt=p.Some,gt=function(){function t(e){n(this,t),this.evaluator=e}return o(t,[{key:"shouldSample",value:function(t){var e=this,n=t.sampled.getOrElse(function(){return e.evaluator(t)});return new mt(n)}},{key:"toString",value:function(){return"Sampler(".concat(""+this.evaluator,")")}}]),t}();function yt(t){return!1}function wt(t){return!0}yt.toString=function(){return"never sample"},wt.toString=function(){return"always sample"};var Et={Sampler:gt,CountingSampler:function(t){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return n(this,e),u(this,a(e).call(this,function(t){if(t>0){if(1>t){var e=0,n=parseInt(1/t),r=function(t){var r=0==(e%=n);return e+=1,r};return r.toString=function(){return"countingSampler: sampleRate=".concat(t)},r}return wt}return yt}(1>t?t:1)))}return i(e,gt),e}(),neverSample:yt,alwaysSample:wt},It=function(){function t(e){var r=e.traceId,o=e.timestamp,i=e.annotation;n(this,t),this.traceId=r,this.timestamp=o,this.annotation=i}return o(t,[{key:"toString",value:function(){return"Record(traceId=".concat(""+this.traceId,", annotation=").concat(""+this.annotation,")")}}]),t}(),bt=p.None,St=p.verifyIsOptional,At=p.verifyIsNotOptional,Rt=p.isOptional,_t=new(0,p.Some)(!0),kt=function(){function t(e){n(this,t);var r=e.spanId,o=e.traceId,i=void 0===o?r:o,a=e.parentId,s=void 0===a?bt:a,u=e.flags,c=e.debug,h=void 0===c?1===(void 0===u?0:u):c,f=e.sampled,p=void 0===f?bt:f,l=e.shared,d=void 0!==l&&l;At(r),St(s),St(p),this._traceId=Rt(i)?i.getOrElse(r):null==i?r:i,this._parentId=s,this._spanId=r,this._sampled=h?_t:p,this._debug=h,this._shared=d}return o(t,[{key:"isDebug",value:function(){return this._debug}},{key:"isShared",value:function(){return this._shared}},{key:"toString",value:function(){return"TraceId(spanId=".concat(""+this.spanId)+", parentSpanId=".concat(""+this.parentSpanId)+", traceId=".concat(""+this.traceId,")")}},{key:"traceId",get:function(){return this._traceId}},{key:"parentSpanId",get:function(){return this._parentId}},{key:"parentId",get:function(){return this._parentId.getOrElse(this._spanId)}},{key:"spanId",get:function(){return this._spanId}},{key:"sampled",get:function(){return this._sampled}},{key:"flags",get:function(){return this._debug?1:0}}]),t}();var Tt=function(){for(var t="",e=0;16>e;e+=1)t+="0123456789abcdef"[Math.floor(16*Math.random())];return t},Ot=void 0!==j&&j.hrtime;var Ct={now:Ot?function(t,e){if(t&&e){var n=j.hrtime(e);return t+Math.floor(1e6*n[0]+n[1]/1e3)}return 1e3*Date.now()}:function(){return 1e3*Date.now()},hrtime:Ot?function(){return j.hrtime()}:function(){}};function Pt(t){var e=t.ipv4,n=t.port;this.setServiceName(t.serviceName),this.setIpv4(e),this.setPort(n)}function Nt(t,e){this.timestamp=t,this.value=""+e}function Ut(t){var e=this;this.traceId=t.traceId,t.parentSpanId.ifPresent(function(t){e.parentId=t}),this.id=t.spanId,this.name=void 0,this.kind=void 0,this.timestamp=void 0,this.duration=void 0,this.localEndpoint=void 0,this.remoteEndpoint=void 0,this.annotations=[],this.tags={},this.debug=t.isDebug(),this.shared=t.isShared()}Pt.prototype.setServiceName=function(t){this.serviceName=t?t.toLocaleLowerCase():void 0},Pt.prototype.setIpv4=function(t){this.ipv4=t},Pt.prototype.setPort=function(t){this.port=t||void 0},Pt.prototype.isEmpty=function(){return void 0===this.serviceName&&void 0===this.ipv4&&void 0===this.port},Nt.prototype.toString=function(){return'Annotation(value="'.concat(this.value,'")')},Ut.prototype.setName=function(t){this.name=t?t.toLocaleLowerCase():void 0},Ut.prototype.setKind=function(t){this.kind=t},Ut.prototype.setTimestamp=function(t){this.timestamp=t},Ut.prototype.setDuration=function(t){void 0!==t&&(this.duration=Math.max(t,1))},Ut.prototype.setLocalEndpoint=function(t){this.localEndpoint=t&&!t.isEmpty()?t:void 0},Ut.prototype.setRemoteEndpoint=function(t){this.remoteEndpoint=t&&!t.isEmpty()?t:void 0},Ut.prototype.addAnnotation=function(t,e){this.annotations.push(new Nt(t,e))},Ut.prototype.putTag=function(t,e){this.tags[t]=""+e},Ut.prototype.setDebug=function(t){this.debug=t},Ut.prototype.setShared=function(t){this.shared=t},Ut.prototype.toString=function(){var t=this.annotations.map(function(t){return""+t}).join(", ");return"Span(id=".concat(this.traceId,", annotations=[").concat(t,"])")};var xt={Endpoint:Pt,Span:Ut},Bt=p.None,Lt=p.Some,Mt=Et.Sampler,jt=Et.alwaysSample,Dt=Ct.now,Yt=Ct.hrtime,qt=xt.Endpoint;function Ft(t){throw Error("Tracer: Missing required argument ".concat(t,"."))}function zt(t){return null==t}var Kt=function(){function t(e){var r=e.ctxImpl,o=void 0===r?Ft("ctxImpl"):r,i=e.recorder,a=void 0===i?Ft("recorder"):i,s=e.sampler,u=void 0===s?new Mt(jt):s,c=e.traceId128Bit,h=void 0!==c&&c,f=e.supportsJoin,p=void 0===f||f,l=e.localServiceName,d=e.localEndpoint,v=e.log,m=void 0===v?console:v,g=e.defaultTags;n(this,t),this.log=m,this.recorder=a,this.sampler=u,this.traceId128Bit=h,this.supportsJoin=p,this._localEndpoint=d||new qt({serviceName:l||"unknown"}),this._ctxImpl=o,this._sentinelTraceId=this.createRootId(),this._startTimestamp=Dt(),this._startTick=Yt(),this.recorder.setDefaultTags&&this.recorder.setDefaultTags(g)}return o(t,[{key:"scoped",value:function(t){return this._ctxImpl.scoped(t)}},{key:"letId",value:function(t,e){return this._ctxImpl.letContext(t,e)}},{key:"createRootId",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Bt,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=Tt(),r=this.traceId128Bit?Tt()+n:n,o=new kt({traceId:r,parentId:Bt,spanId:n,sampled:t,flags:e?1:0});return t===Bt&&(o._sampled=this.sampler.shouldSample(o)),o}},{key:"createChildId",value:function(t){if(zt(t)&&(t=this._ctxImpl.getContext()),t===this._sentinelTraceId||zt(t))return this.createRootId();var e=new kt({traceId:t.traceId,parentId:new Lt(t.spanId),spanId:Tt(),debug:t.isDebug(),sampled:t.sampled});return!1===e.sampled.present&&(e._sampled=this.sampler.shouldSample(e)),e}},{key:"_explicitRecord",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Dt(this._startTimestamp,this._startTick);this.recorder.record(new It({traceId:t,timestamp:n,annotation:e}))}},{key:"local",value:function(t,e){var n=this;if("function"!=typeof e)throw Error("you must pass a function");return this.scoped(function(){var r,o=n.createChildId();n.setId(o),n.recordServiceName(n._localEndpoint.serviceName),n.recordAnnotation(new dt.LocalOperationStart(t));try{r=e()}catch(t){throw n.recordBinary("error",t.message?t.message:""+t),n.recordAnnotation(new dt.LocalOperationStop),t}return vt(r)?o.sampled.getOrElse(!1)?r.then(function(t){return n._explicitRecord(o,new dt.LocalOperationStop),t}).catch(function(t){throw n._explicitRecord(o,new dt.BinaryAnnotation("error",t.message?t.message:""+t)),n._explicitRecord(o,new dt.LocalOperationStop),t}):r:(n.recordAnnotation(new dt.LocalOperationStop),r)})}},{key:"join",value:function(t){if(zt(t))throw Error("traceId is a required arg");if(zt(t._spanId))throw Error("Must be valid TraceId instance");return this.supportsJoin?(t.sampled===Bt?t._sampled=this.sampler.shouldSample(t):t._shared=!0,t):this.createChildId(t)}},{key:"setId",value:function(t){this._ctxImpl.setContext(t)}},{key:"recordAnnotation",value:function(t,e){this.id.sampled.getOrElse(!1)&&this._explicitRecord(this.id,t,e)}},{key:"recordMessage",value:function(t){this.recordAnnotation(new dt.Message(t))}},{key:"recordServiceName",value:function(t){this.recordAnnotation(new dt.ServiceName(t))}},{key:"recordRpc",value:function(t){this.recordAnnotation(new dt.Rpc(t))}},{key:"recordClientAddr",value:function(t){this.recordAnnotation(new dt.ClientAddr(t))}},{key:"recordServerAddr",value:function(t){this.recordAnnotation(new dt.ServerAddr(t))}},{key:"recordLocalAddr",value:function(t){this.recordAnnotation(new dt.LocalAddr(t))}},{key:"recordBinary",value:function(t,e){this.recordAnnotation(new dt.BinaryAnnotation(t,e))}},{key:"writeIdToConsole",value:function(t){this.log.info("".concat(t,": ").concat(""+this.id))}},{key:"setTags",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&this.recordBinary(e,t[e])}},{key:"id",get:function(){return this._ctxImpl.getContext()||this._sentinelTraceId}},{key:"localEndpoint",get:function(){return this._localEndpoint}}]),t}(),Ht=function(){function t(){n(this,t),this.currentCtx=null}return o(t,[{key:"setContext",value:function(t){this.currentCtx=t}},{key:"getContext",value:function(){return this.currentCtx}},{key:"scoped",value:function(t){var e=this.getContext();try{return t()}finally{this.setContext(e)}}},{key:"letContext",value:function(t,e){var n=this;return this.scoped(function(){return n.setContext(t),e()})}}]),t}(),Vt={TraceId:"X-B3-TraceId",SpanId:"X-B3-SpanId",ParentSpanId:"X-B3-ParentSpanId",Sampled:"X-B3-Sampled",Flags:"X-B3-Flags"},Jt=Ct.now,Xt=xt.Span,Zt=xt.Endpoint,$t=Symbol("defaultTags");var Gt=function(){function t(e,r){n(this,t),this.traceId=e,this.timeoutTimestamp=r,this.delegate=new Xt(e),this.localEndpoint=new Zt({}),this.shouldFlush=!1}return o(t,[{key:"setDuration",value:function(t){if(!this.shouldFlush){this.shouldFlush=!0;var e=this.delegate.timestamp;void 0===e?this.delegate.addAnnotation(t,"finish"):this.delegate.setDuration(t-e)}}}]),t}(),Qt=6e7,Wt=function(){function t(e){var r=this,o=e.logger,i=e.timeout,a=void 0===i?Qt:i;n(this,t),this.logger=o,this.timeout=a,this.partialSpans=new Map,this[$t]={};var s=setInterval(function(){r.partialSpans.forEach(function(t,e){(function(t){return t.timeoutTimestamp<Jt()})(t)&&(t.delegate.addAnnotation(Jt(),"zipkin-js.flush"),r._writeSpan(e,t))})},1e3);s.unref&&s.unref()}return o(t,[{key:"_addDefaultTagsAndLocalEndpoint",value:function(t){var e=this[$t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.delegate.putTag(n,e[n]);t.delegate.setLocalEndpoint(t.localEndpoint)}},{key:"_writeSpan",value:function(t,e){if(arguments.length>2&&void 0!==arguments[2]&&arguments[2]||void 0!==this.partialSpans.get(t)){this.partialSpans.delete(t);var n=e.delegate;e.delegate.timestamp&&this._addDefaultTagsAndLocalEndpoint(e),this.logger.logSpan(n)}}},{key:"_updateSpanMap",value:function(t,e,n){var r,o=!1;this.partialSpans.has(t)?r=this.partialSpans.get(t):(o=!0,r=new Gt(t,e+this.timeout)),n(r),r.shouldFlush?this._writeSpan(t,r,o):this.partialSpans.set(t,r)}},{key:"flush",value:function(){var t=this;this.partialSpans.forEach(function(e,n){t._writeSpan(n,e)})}},{key:"record",value:function(t){var e=t.traceId;this._updateSpanMap(e,t.timestamp,function(n){switch(t.annotation.annotationType){case"ClientAddr":n.delegate.setKind("SERVER"),n.delegate.setRemoteEndpoint(new Zt({serviceName:t.annotation.serviceName,ipv4:t.annotation.host&&t.annotation.host.ipv4(),port:t.annotation.port}));break;case"ClientSend":n.delegate.setKind("CLIENT"),n.delegate.setTimestamp(t.timestamp);break;case"ClientRecv":n.delegate.setKind("CLIENT"),n.setDuration(t.timestamp);break;case"ServerSend":n.delegate.setKind("SERVER"),n.setDuration(t.timestamp);break;case"ServerRecv":n.delegate.setShared(e.isShared()),n.delegate.setKind("SERVER"),n.delegate.setTimestamp(t.timestamp);break;case"ProducerStart":n.delegate.setKind("PRODUCER"),n.delegate.setTimestamp(t.timestamp);break;case"ProducerStop":n.delegate.setKind("PRODUCER"),n.setDuration(t.timestamp);break;case"ConsumerStart":n.delegate.setKind("CONSUMER"),n.delegate.setTimestamp(t.timestamp);break;case"ConsumerStop":n.delegate.setKind("CONSUMER"),n.setDuration(t.timestamp);break;case"MessageAddr":n.delegate.setRemoteEndpoint(new Zt({serviceName:t.annotation.serviceName,ipv4:t.annotation.host&&t.annotation.host.ipv4(),port:t.annotation.port}));break;case"LocalOperationStart":n.delegate.setName(t.annotation.name),n.delegate.setTimestamp(t.timestamp);break;case"LocalOperationStop":n.setDuration(t.timestamp);break;case"Message":n.delegate.addAnnotation(t.timestamp,t.annotation.message);break;case"Rpc":n.delegate.setName(t.annotation.name);break;case"ServiceName":n.localEndpoint.setServiceName(t.annotation.serviceName);break;case"BinaryAnnotation":n.delegate.putTag(t.annotation.key,t.annotation.value);break;case"LocalAddr":n.localEndpoint.setIpv4(t.annotation.host&&t.annotation.host.ipv4()),n.localEndpoint.setPort(t.annotation.port);break;case"ServerAddr":n.delegate.setKind("CLIENT"),n.delegate.setRemoteEndpoint(new Zt({serviceName:t.annotation.serviceName,ipv4:t.annotation.host&&t.annotation.host.ipv4(),port:t.annotation.port}))}})}},{key:"setDefaultTags",value:function(t){this[$t]=t}},{key:"toString",value:function(){return"BatchRecorder()"}}]),t}(),te=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:console.log;n(this,t),this.logger=e}return o(t,[{key:"record",value:function(t){var e=t.traceId,n=e.spanId,r=e.parentId,o=e.traceId;this.logger("Record at (timestamp=".concat(t.timestamp,", spanId=").concat(n,", parentId=").concat(r,", ")+"traceId=".concat(o,"): ").concat(""+t.annotation))}},{key:"toString",value:function(){return"consoleTracer"}}]),t}(),ee=2147483647,ne=36,re=1,oe=26,ie=38,ae=700,se=72,ue=128,ce="-",he=/[^\x20-\x7E]/,fe=/[\x2E\u3002\uFF0E\uFF61]/g,pe={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},le=ne-re,de=Math.floor,ve=String.fromCharCode;function me(t){throw new RangeError(pe[t])}function ge(t,e){return t+22+75*(26>t)-((0!=e)<<5)}function ye(t,e,n){var r=0;for(t=n?de(t/ae):t>>1,t+=de(t/e);t>le*oe>>1;r+=ne)t=de(t/le);return de(r+(le+1)*t/(t+ie))}function we(t){return function(t,e){var n=t.split("@"),r="";n.length>1&&(r=n[0]+"@",t=n[1]);var o=function(t,e){for(var n=t.length,r=[];n--;)r[n]=e(t[n]);return r}((t=t.replace(fe,".")).split("."),e).join(".");return r+o}(t,function(t){return he.test(t)?"xn--"+function(t){var e,n,r,o,i,a,s,u,c,h,f,p,l,d,v,m=[];for(p=(t=function(t){for(var e,n,r=[],o=0,i=t.length;i>o;)55296>(e=t.charCodeAt(o++))||e>56319||o>=i?r.push(e):56320==(64512&(n=t.charCodeAt(o++)))?r.push(((1023&e)<<10)+(1023&n)+65536):(r.push(e),o--);return r}(t)).length,e=ue,n=0,i=se,a=0;p>a;++a)128>(f=t[a])&&m.push(ve(f));for(r=o=m.length,o&&m.push(ce);p>r;){for(s=ee,a=0;p>a;++a)(f=t[a])>=e&&s>f&&(s=f);for(s-e>de((ee-n)/(l=r+1))&&me("overflow"),n+=(s-e)*l,e=s,a=0;p>a;++a)if(e>(f=t[a])&&++n>ee&&me("overflow"),f==e){for(u=n,c=ne;(h=c>i?i+oe>c?c-i:oe:re)<=u;c+=ne)m.push(ve(ge(h+(v=u-h)%(d=ne-h),0))),u=de(v/d);m.push(ve(ge(u,0))),i=ye(n,l,r==o),n=0,++r}++n,++e}return m.join("")}(t):t})}var Ee=[],Ie=[],be="undefined"!=typeof Uint8Array?Uint8Array:Array,Se=!1;function Ae(){Se=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0;64>e;++e)Ee[e]=t[e],Ie[t.charCodeAt(e)]=e;Ie[45]=62,Ie[95]=63}function Re(t,e,n){for(var r,o=[],i=e;n>i;i+=3)o.push(Ee[(r=(t[i]<<16)+(t[i+1]<<8)+t[i+2])>>18&63]+Ee[r>>12&63]+Ee[r>>6&63]+Ee[63&r]);return o.join("")}function _e(t){var e;Se||Ae();for(var n=t.length,r=n%3,o="",i=[],a=0,s=n-r;s>a;a+=16383)i.push(Re(t,a,a+16383>s?s:a+16383));return 1===r?(o+=Ee[(e=t[n-1])>>2],o+=Ee[e<<4&63],o+="=="):2===r&&(o+=Ee[(e=(t[n-2]<<8)+t[n-1])>>10],o+=Ee[e>>4&63],o+=Ee[e<<2&63],o+="="),i.push(o),i.join("")}function ke(t,e,n,r,o){var i,a,s=8*o-r-1,u=(1<<s)-1,c=u>>1,h=-7,f=n?o-1:0,p=n?-1:1,l=t[e+f];for(f+=p,i=l&(1<<-h)-1,l>>=-h,h+=s;h>0;i=256*i+t[e+f],f+=p,h-=8);for(a=i&(1<<-h)-1,i>>=-h,h+=r;h>0;a=256*a+t[e+f],f+=p,h-=8);if(0===i)i=1-c;else{if(i===u)return a?NaN:1/0*(l?-1:1);a+=Math.pow(2,r),i-=c}return(l?-1:1)*a*Math.pow(2,i-r)}function Te(t,e,n,r,o,i){var a,s,u,c=8*i-o-1,h=(1<<c)-1,f=h>>1,p=23===o?5.960464477539062e-8:0,l=r?0:i-1,d=r?1:-1,v=0>e||0===e&&0>1/e?1:0;for(isNaN(e=Math.abs(e))||e===1/0?(s=isNaN(e)?1:0,a=h):(1>e*(u=Math.pow(2,-(a=Math.floor(Math.log(e)/Math.LN2))))&&(a--,u*=2),2>(e+=1>a+f?p*Math.pow(2,1-f):p/u)*u||(a++,u/=2),h>a+f?1>a+f?(s=e*Math.pow(2,f-1)*Math.pow(2,o),a=0):(s=(e*u-1)*Math.pow(2,o),a+=f):(s=0,a=h));o>=8;t[n+l]=255&s,l+=d,s/=256,o-=8);for(a=a<<o|s,c+=o;c>0;t[n+l]=255&a,l+=d,a/=256,c-=8);t[n+l-d]|=128*v}var Oe={}.toString,Ce=Array.isArray||function(t){return"[object Array]"==Oe.call(t)};function Pe(){return Ue.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Ne(t,e){if(Pe()<e)throw new RangeError("Invalid typed array length");return Ue.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=Ue.prototype:(null===t&&(t=new Ue(e)),t.length=e),t}function Ue(t,e,n){if(!(Ue.TYPED_ARRAY_SUPPORT||this instanceof Ue))return new Ue(t,e,n);if("number"==typeof t){if("string"==typeof e)throw Error("If encoding is specified then the first argument must be a string");return Le(this,t)}return xe(this,t,e,n)}function xe(t,e,n,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,n,r){if(0>n||n>e.byteLength)throw new RangeError("'offset' is out of bounds");if(n+(r||0)>e.byteLength)throw new RangeError("'length' is out of bounds");e=void 0===n&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,n):new Uint8Array(e,n,r);Ue.TYPED_ARRAY_SUPPORT?(t=e).__proto__=Ue.prototype:t=Me(t,e);return t}(t,e,n,r):"string"==typeof e?function(t,e,n){"string"==typeof n&&""!==n||(n="utf8");if(!Ue.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|Ye(e,n),o=(t=Ne(t,r)).write(e,n);o!==r&&(t=t.slice(0,o));return t}(t,e,n):function(t,e){if(De(e)){var n=0|je(e.length);return 0===(t=Ne(t,n)).length?t:(e.copy(t,0,0,n),t)}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(r=e.length)!=r?Ne(t,0):Me(t,e);if("Buffer"===e.type&&Ce(e.data))return Me(t,e.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function Be(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(0>t)throw new RangeError('"size" argument must not be negative')}function Le(t,e){if(Be(e),t=Ne(t,0>e?0:0|je(e)),!Ue.TYPED_ARRAY_SUPPORT)for(var n=0;e>n;++n)t[n]=0;return t}function Me(t,e){var n=0>e.length?0:0|je(e.length);t=Ne(t,n);for(var r=0;n>r;r+=1)t[r]=255&e[r];return t}function je(t){if(t>=Pe())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Pe().toString(16)+" bytes");return 0|t}function De(t){return!(null==t||!t._isBuffer)}function Ye(t,e){if(De(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return ln(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return dn(t).length;default:if(r)return ln(t).length;e=(""+e).toLowerCase(),r=!0}}function qe(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function Fe(t,e,n,r,o){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:-2147483648>n&&(n=-2147483648),isNaN(n=+n)&&(n=o?0:t.length-1),0>n&&(n=t.length+n),t.length>n){if(0>n){if(!o)return-1;n=0}}else{if(o)return-1;n=t.length-1}if("string"==typeof e&&(e=Ue.from(e,r)),De(e))return 0===e.length?-1:ze(t,e,n,r,o);if("number"==typeof e)return e&=255,Ue.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):ze(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function ze(t,e,n,r,o){var i,a=1,s=t.length,u=e.length;if(void 0!==r&&("ucs2"===(r=(r+"").toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(2>t.length||2>e.length)return-1;a=2,s/=2,u/=2,n/=2}function c(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var h=-1;for(i=n;s>i;i++)if(c(t,i)===c(e,-1===h?0:i-h)){if(-1===h&&(h=i),i-h+1===u)return h*a}else-1!==h&&(i-=i-h),h=-1}else for(n+u>s&&(n=s-u),i=n;i>=0;i--){for(var f=!0,p=0;u>p;p++)if(c(t,i+p)!==c(e,p)){f=!1;break}if(f)return i}return-1}function Ke(t,e,n,r){var o=t.length-(n=+n||0);r?(r=+r)>o&&(r=o):r=o;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var a=0;r>a;++a){var s=parseInt(e.substr(2*a,2),16);if(isNaN(s))return a;t[n+a]=s}return a}function He(t,e,n,r){return vn(ln(e,t.length-n),t,n,r)}function Ve(t,e,n,r){return vn(function(t){for(var e=[],n=0;t.length>n;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function Je(t,e,n,r){return Ve(t,e,n,r)}function Xe(t,e,n,r){return vn(dn(e),t,n,r)}function Ze(t,e,n,r){return vn(function(t,e){for(var n,r,o=[],i=0;t.length>i&&0<=(e-=2);++i)n=t.charCodeAt(i),r=n>>8,o.push(n%256),o.push(r);return o}(e,t.length-n),t,n,r)}function $e(t,e,n){return _e(0===e&&n===t.length?t:t.slice(e,n))}function Ge(t,e,n){n=Math.min(t.length,n);for(var r=[],o=e;n>o;){var i,a,s,u,c=t[o],h=null,f=c>239?4:c>223?3:c>191?2:1;if(n>=o+f)switch(f){case 1:128>c&&(h=c);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&c)<<6|63&i)>127&&(h=u);break;case 3:a=t[o+2],128==(192&(i=t[o+1]))&&128==(192&a)&&(u=(15&c)<<12|(63&i)<<6|63&a)>2047&&(55296>u||u>57343)&&(h=u);break;case 4:a=t[o+2],s=t[o+3],128==(192&(i=t[o+1]))&&128==(192&a)&&128==(192&s)&&(u=(15&c)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&1114112>u&&(h=u)}null===h?(h=65533,f=1):h>65535&&(r.push((h-=65536)>>>10&1023|55296),h=56320|1023&h),r.push(h),o+=f}return function(t){var e=t.length;if(Qe>=e)return String.fromCharCode.apply(String,t);var n="",r=0;for(;e>r;)n+=String.fromCharCode.apply(String,t.slice(r,r+=Qe));return n}(r)}Ue.TYPED_ARRAY_SUPPORT=void 0===l.TYPED_ARRAY_SUPPORT||l.TYPED_ARRAY_SUPPORT,Ue.poolSize=8192,Ue._augment=function(t){return t.__proto__=Ue.prototype,t},Ue.from=function(t,e,n){return xe(null,t,e,n)},Ue.TYPED_ARRAY_SUPPORT&&(Ue.prototype.__proto__=Uint8Array.prototype,Ue.__proto__=Uint8Array),Ue.alloc=function(t,e,n){return function(t,e,n,r){return Be(e),e>0&&void 0!==n?"string"==typeof r?Ne(t,e).fill(n,r):Ne(t,e).fill(n):Ne(t,e)}(null,t,e,n)},Ue.allocUnsafe=function(t){return Le(null,t)},Ue.allocUnsafeSlow=function(t){return Le(null,t)},Ue.isBuffer=function(t){return null!=t&&(!!t._isBuffer||mn(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&mn(t.slice(0,0))}(t))},Ue.compare=function(t,e){if(!De(t)||!De(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,r=e.length,o=0,i=Math.min(n,r);i>o;++o)if(t[o]!==e[o]){n=t[o],r=e[o];break}return r>n?-1:n>r?1:0},Ue.isEncoding=function(t){switch((t+"").toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Ue.concat=function(t,e){if(!Ce(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return Ue.alloc(0);var n;if(void 0===e)for(e=0,n=0;t.length>n;++n)e+=t[n].length;var r=Ue.allocUnsafe(e),o=0;for(n=0;t.length>n;++n){var i=t[n];if(!De(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,o),o+=i.length}return r},Ue.byteLength=Ye,Ue.prototype._isBuffer=!0,Ue.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;t>e;e+=2)qe(this,e,e+1);return this},Ue.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;t>e;e+=4)qe(this,e,e+3),qe(this,e+1,e+2);return this},Ue.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;t>e;e+=8)qe(this,e,e+7),qe(this,e+1,e+6),qe(this,e+2,e+5),qe(this,e+3,e+4);return this},Ue.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?Ge(this,0,t):function(t,e,n){var r=!1;if((void 0===e||0>e)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),0>=n)return"";if((e>>>=0)>=(n>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return en(this,e,n);case"utf8":case"utf-8":return Ge(this,e,n);case"ascii":return We(this,e,n);case"latin1":case"binary":return tn(this,e,n);case"base64":return $e(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return nn(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}.apply(this,arguments)},Ue.prototype.equals=function(t){if(!De(t))throw new TypeError("Argument must be a Buffer");return this===t||0===Ue.compare(this,t)},Ue.prototype.inspect=function(){var t="";return this.length>0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),"<Buffer "+t+">"},Ue.prototype.compare=function(t,e,n,r,o){if(!De(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),0>e||n>t.length||0>r||o>this.length)throw new RangeError("out of range index");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(r>>>=0),a=(n>>>=0)-(e>>>=0),s=Math.min(i,a),u=this.slice(r,o),c=t.slice(e,n),h=0;s>h;++h)if(u[h]!==c[h]){i=u[h],a=c[h];break}return a>i?-1:i>a?1:0},Ue.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},Ue.prototype.indexOf=function(t,e,n){return Fe(this,t,e,n,!0)},Ue.prototype.lastIndexOf=function(t,e,n){return Fe(this,t,e,n,!1)},Ue.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-e;if((void 0===n||n>o)&&(n=o),t.length>0&&(0>n||0>e)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return Ke(this,t,e,n);case"utf8":case"utf-8":return He(this,t,e,n);case"ascii":return Ve(this,t,e,n);case"latin1":case"binary":return Je(this,t,e,n);case"base64":return Xe(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ze(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},Ue.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Qe=4096;function We(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;n>o;++o)r+=String.fromCharCode(127&t[o]);return r}function tn(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;n>o;++o)r+=String.fromCharCode(t[o]);return r}function en(t,e,n){var r=t.length;e&&e>=0||(e=0),(!n||0>n||n>r)&&(n=r);for(var o="",i=e;n>i;++i)o+=pn(t[i]);return o}function nn(t,e,n){for(var r=t.slice(e,n),o="",i=0;r.length>i;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function rn(t,e,n){if(t%1!=0||0>t)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function on(t,e,n,r,o,i){if(!De(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||i>e)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function an(t,e,n,r){0>e&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-n,2);i>o;++o)t[n+o]=(e&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function sn(t,e,n,r){0>e&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-n,4);i>o;++o)t[n+o]=e>>>8*(r?o:3-o)&255}function un(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError("Index out of range");if(0>n)throw new RangeError("Index out of range")}function cn(t,e,n,r,o){return o||un(t,0,n,4),Te(t,e,n,r,23,4),n+4}function hn(t,e,n,r,o){return o||un(t,0,n,8),Te(t,e,n,r,52,8),n+8}Ue.prototype.slice=function(t,e){var n,r=this.length;if(0>(t=~~t)?0>(t+=r)&&(t=0):t>r&&(t=r),0>(e=void 0===e?r:~~e)?0>(e+=r)&&(e=0):e>r&&(e=r),t>e&&(e=t),Ue.TYPED_ARRAY_SUPPORT)(n=this.subarray(t,e)).__proto__=Ue.prototype;else{var o=e-t;n=new Ue(o,void 0);for(var i=0;o>i;++i)n[i]=this[i+t]}return n},Ue.prototype.readUIntLE=function(t,e,n){t|=0,e|=0,n||rn(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r},Ue.prototype.readUIntBE=function(t,e,n){t|=0,e|=0,n||rn(t,e,this.length);for(var r=this[t+--e],o=1;e>0&&(o*=256);)r+=this[t+--e]*o;return r},Ue.prototype.readUInt8=function(t,e){return e||rn(t,1,this.length),this[t]},Ue.prototype.readUInt16LE=function(t,e){return e||rn(t,2,this.length),this[t]|this[t+1]<<8},Ue.prototype.readUInt16BE=function(t,e){return e||rn(t,2,this.length),this[t]<<8|this[t+1]},Ue.prototype.readUInt32LE=function(t,e){return e||rn(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Ue.prototype.readUInt32BE=function(t,e){return e||rn(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Ue.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||rn(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return(o*=128)>r||(r-=Math.pow(2,8*e)),r},Ue.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||rn(t,e,this.length);for(var r=e,o=1,i=this[t+--r];r>0&&(o*=256);)i+=this[t+--r]*o;return(o*=128)>i||(i-=Math.pow(2,8*e)),i},Ue.prototype.readInt8=function(t,e){return e||rn(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Ue.prototype.readInt16LE=function(t,e){e||rn(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},Ue.prototype.readInt16BE=function(t,e){e||rn(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},Ue.prototype.readInt32LE=function(t,e){return e||rn(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Ue.prototype.readInt32BE=function(t,e){return e||rn(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Ue.prototype.readFloatLE=function(t,e){return e||rn(t,4,this.length),ke(this,t,!0,23,4)},Ue.prototype.readFloatBE=function(t,e){return e||rn(t,4,this.length),ke(this,t,!1,23,4)},Ue.prototype.readDoubleLE=function(t,e){return e||rn(t,8,this.length),ke(this,t,!0,52,8)},Ue.prototype.readDoubleBE=function(t,e){return e||rn(t,8,this.length),ke(this,t,!1,52,8)},Ue.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||on(this,t,e,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[e]=255&t;++i<n&&(o*=256);)this[e+i]=t/o&255;return e+n},Ue.prototype.writeUIntBE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||on(this,t,e,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+n},Ue.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||on(this,t,e,1,255,0),Ue.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},Ue.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||on(this,t,e,2,65535,0),Ue.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):an(this,t,e,!0),e+2},Ue.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||on(this,t,e,2,65535,0),Ue.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):an(this,t,e,!1),e+2},Ue.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||on(this,t,e,4,4294967295,0),Ue.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):sn(this,t,e,!0),e+4},Ue.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||on(this,t,e,4,4294967295,0),Ue.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):sn(this,t,e,!1),e+4},Ue.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var o=Math.pow(2,8*n-1);on(this,t,e,n,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i<n&&(a*=256);)0>t&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+n},Ue.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var o=Math.pow(2,8*n-1);on(this,t,e,n,o-1,-o)}var i=n-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)0>t&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+n},Ue.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||on(this,t,e,1,127,-128),Ue.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=255&t,e+1},Ue.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||on(this,t,e,2,32767,-32768),Ue.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):an(this,t,e,!0),e+2},Ue.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||on(this,t,e,2,32767,-32768),Ue.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):an(this,t,e,!1),e+2},Ue.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||on(this,t,e,4,2147483647,-2147483648),Ue.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):sn(this,t,e,!0),e+4},Ue.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||on(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),Ue.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):sn(this,t,e,!1),e+4},Ue.prototype.writeFloatLE=function(t,e,n){return cn(this,t,e,!0,n)},Ue.prototype.writeFloatBE=function(t,e,n){return cn(this,t,e,!1,n)},Ue.prototype.writeDoubleLE=function(t,e,n){return hn(this,t,e,!0,n)},Ue.prototype.writeDoubleBE=function(t,e,n){return hn(this,t,e,!1,n)},Ue.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),t.length>e||(e=t.length),e||(e=0),r>0&&n>r&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>n||n>=this.length)throw new RangeError("sourceStart out of bounds");if(0>r)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),r-n>t.length-e&&(r=t.length-e+n);var o,i=r-n;if(this===t&&e>n&&r>e)for(o=i-1;o>=0;--o)t[o+e]=this[o+n];else if(1e3>i||!Ue.TYPED_ARRAY_SUPPORT)for(o=0;i>o;++o)t[o+e]=this[o+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+i),e);return i},Ue.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===t.length){var o=t.charCodeAt(0);256>o&&(t=o)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!Ue.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof t&&(t&=255);if(0>e||e>this.length||n>this.length)throw new RangeError("Out of range index");if(e>=n)return this;var i;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(i=e;n>i;++i)this[i]=t;else{var a=De(t)?t:ln(""+new Ue(t,r)),s=a.length;for(i=0;n-e>i;++i)this[i+e]=a[i%s]}return this};var fn=/[^+\/0-9A-Za-z-_]/g;function pn(t){return 16>t?"0"+t.toString(16):t.toString(16)}function ln(t,e){var n;e=e||1/0;for(var r=t.length,o=null,i=[],a=0;r>a;++a){if((n=t.charCodeAt(a))>55295&&57344>n){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(56320>n){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,128>n){if(0>(e-=1))break;i.push(n)}else if(2048>n){if(0>(e-=2))break;i.push(n>>6|192,63&n|128)}else if(65536>n){if(0>(e-=3))break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(n>=1114112)throw Error("Invalid code point");if(0>(e-=4))break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function dn(t){return function(t){var e,n,r,o,i,a;Se||Ae();var s=t.length;if(s%4>0)throw Error("Invalid string. Length must be a multiple of 4");a=new be(3*s/4-(i="="===t[s-2]?2:"="===t[s-1]?1:0)),r=i>0?s-4:s;var u=0;for(e=0,n=0;r>e;e+=4,n+=3)o=Ie[t.charCodeAt(e)]<<18|Ie[t.charCodeAt(e+1)]<<12|Ie[t.charCodeAt(e+2)]<<6|Ie[t.charCodeAt(e+3)],a[u++]=o>>16&255,a[u++]=o>>8&255,a[u++]=255&o;return 2===i?(o=Ie[t.charCodeAt(e)]<<2|Ie[t.charCodeAt(e+1)]>>4,a[u++]=255&o):1===i&&(o=Ie[t.charCodeAt(e)]<<10|Ie[t.charCodeAt(e+1)]<<4|Ie[t.charCodeAt(e+2)]>>2,a[u++]=o>>8&255,a[u++]=255&o),a}(function(t){if(2>(t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(fn,"")).length)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function vn(t,e,n,r){for(var o=0;r>o&&(o+n<e.length&&o<t.length);++o)e[o+n]=t[o];return o}function mn(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}function gn(t){return null===t}function yn(t){return"string"==typeof t}function wn(t){return"object"==typeof t&&null!==t}function En(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var In=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function bn(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}}function Sn(t,e){if(t.map)return t.map(e);for(var n=[],r=0;t.length>r;r++)n.push(e(t[r],r));return n}var An=Object.keys||function(t){var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.push(n);return e};function Rn(t,e,n,r){n=n||"=";var o={};if("string"!=typeof t||0===t.length)return o;var i=/\+/g;t=t.split(e=e||"&");var a=1e3;r&&"number"==typeof r.maxKeys&&(a=r.maxKeys);var s=t.length;a>0&&s>a&&(s=a);for(var u=0;s>u;++u){var c,h,f,p,l=t[u].replace(i,"%20"),d=l.indexOf(n);0>d?(c=l,h=""):(c=l.substr(0,d),h=l.substr(d+1)),f=decodeURIComponent(c),p=decodeURIComponent(h),En(o,f)?In(o[f])?o[f].push(p):o[f]=[o[f],p]:o[f]=p}return o}var _n={parse:qn,resolve:function(t,e){return qn(t,!1,!0).resolve(e)},resolveObject:function(t,e){return t?qn(t,!1,!0).resolveObject(e):e},format:function(t){yn(t)&&(t=Fn({},t));return zn(t)},Url:kn};function kn(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var Tn=/^([a-z0-9.+-]+:)/i,On=/:[0-9]*$/,Cn=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Pn=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),Nn=["'"].concat(Pn),Un=["%","/","?",";","#"].concat(Nn),xn=["/","?","#"],Bn=255,Ln=/^[+a-z0-9A-Z_-]{0,63}$/,Mn=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,jn={javascript:!0,"javascript:":!0},Dn={javascript:!0,"javascript:":!0},Yn={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function qn(t,e,n){if(t&&wn(t)&&t instanceof kn)return t;var r=new kn;return r.parse(t,e,n),r}function Fn(t,e,n,r){if(!yn(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),i=-1!==o&&o<e.indexOf("#")?"?":"#",a=e.split(i);a[0]=a[0].replace(/\\/g,"/");var s=e=a.join(i);if(s=s.trim(),!r&&1===e.split("#").length){var u=Cn.exec(s);if(u)return t.path=s,t.href=s,t.pathname=u[1],u[2]?(t.search=u[2],t.query=n?Rn(t.search.substr(1)):t.search.substr(1)):n&&(t.search="",t.query={}),t}var c,h,f,p=Tn.exec(s);if(p){var l=(p=p[0]).toLowerCase();t.protocol=l,s=s.substr(p.length)}if(r||p||s.match(/^\/\/[^@\/]+@[^@\/]+/)){var d="//"===s.substr(0,2);!d||p&&Dn[p]||(s=s.substr(2),t.slashes=!0)}if(!Dn[p]&&(d||p&&!Yn[p])){var v,m,g=-1;for(c=0;xn.length>c;c++)-1===(h=s.indexOf(xn[c]))||-1!==g&&h>=g||(g=h);for(-1!==(m=-1===g?s.lastIndexOf("@"):s.lastIndexOf("@",g))&&(v=s.slice(0,m),s=s.slice(m+1),t.auth=decodeURIComponent(v)),g=-1,c=0;Un.length>c;c++)-1===(h=s.indexOf(Un[c]))||-1!==g&&h>=g||(g=h);-1===g&&(g=s.length),t.host=s.slice(0,g),s=s.slice(g),Kn(t),t.hostname=t.hostname||"";var y="["===t.hostname[0]&&"]"===t.hostname[t.hostname.length-1];if(!y){var w=t.hostname.split(/\./);for(c=0,f=w.length;f>c;c++){var E=w[c];if(E&&!E.match(Ln)){for(var I="",b=0,S=E.length;S>b;b++)E.charCodeAt(b)>127?I+="x":I+=E[b];if(!I.match(Ln)){var A=w.slice(0,c),R=w.slice(c+1),_=E.match(Mn);_&&(A.push(_[1]),R.unshift(_[2])),R.length&&(s="/"+R.join(".")+s),t.hostname=A.join(".");break}}}}t.hostname=t.hostname.length>Bn?"":t.hostname.toLowerCase(),y||(t.hostname=we(t.hostname)),t.host=(t.hostname||"")+(t.port?":"+t.port:""),t.href+=t.host,y&&(t.hostname=t.hostname.substr(1,t.hostname.length-2),"/"!==s[0]&&(s="/"+s))}if(!jn[l])for(c=0,f=Nn.length;f>c;c++){var k=Nn[c];if(-1!==s.indexOf(k)){var T=encodeURIComponent(k);T===k&&(T=escape(k)),s=s.split(k).join(T)}}var O=s.indexOf("#");-1!==O&&(t.hash=s.substr(O),s=s.slice(0,O));var C=s.indexOf("?");(-1!==C?(t.search=s.substr(C),t.query=s.substr(C+1),n&&(t.query=Rn(t.query)),s=s.slice(0,C)):n&&(t.search="",t.query={}),s&&(t.pathname=s),Yn[l]&&t.hostname&&!t.pathname&&(t.pathname="/"),t.pathname||t.search)&&(t.path=(t.pathname||"")+(t.search||""));return t.href=zn(t),t}function zn(t){var e=t.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var n,r,o,i,a=t.protocol||"",s=t.pathname||"",u=t.hash||"",c=!1,h="";t.host?c=e+t.host:t.hostname&&(c=e+(-1===t.hostname.indexOf(":")?t.hostname:"["+this.hostname+"]"),t.port&&(c+=":"+t.port)),t.query&&wn(t.query)&&Object.keys(t.query).length&&(r=r||"&",o=o||"=",null===(n=t.query)&&(n=void 0),h="object"==typeof n?Sn(An(n),function(t){var e=encodeURIComponent(bn(t))+o;return In(n[t])?Sn(n[t],function(t){return e+encodeURIComponent(bn(t))}).join(r):e+encodeURIComponent(bn(n[t]))}).join(r):i?encodeURIComponent(bn(i))+o+encodeURIComponent(bn(n)):"");var f=t.search||h&&"?"+h||"";return a&&":"!==a.substr(-1)&&(a+=":"),t.slashes||(!a||Yn[a])&&!1!==c?(c="//"+(c||""),s&&"/"!==s.charAt(0)&&(s="/"+s)):c||(c=""),u&&"#"!==u.charAt(0)&&(u="#"+u),f&&"?"!==f.charAt(0)&&(f="?"+f),a+c+(s=s.replace(/[?#]/g,function(t){return encodeURIComponent(t)}))+(f=f.replace("#","%23"))+u}function Kn(t){var e=t.host,n=On.exec(e);n&&(":"!==(n=n[0])&&(t.port=n.substr(1)),e=e.substr(0,e.length-n.length)),e&&(t.hostname=e)}kn.prototype.parse=function(t,e,n){return Fn(this,t,e,n)},kn.prototype.format=function(){return zn(this)},kn.prototype.resolve=function(t){return this.resolveObject(qn(t,!1,!0)).format()},kn.prototype.resolveObject=function(t){if(yn(t)){var e=new kn;e.parse(t,!1,!0),t=e}for(var n,r=new kn,o=Object.keys(this),i=0;o.length>i;i++){var a=o[i];r[a]=this[a]}if(r.hash=t.hash,""===t.href)return r.href=r.format(),r;if(t.slashes&&!t.protocol){for(var s=Object.keys(t),u=0;s.length>u;u++){var c=s[u];"protocol"!==c&&(r[c]=t[c])}return Yn[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r}if(t.protocol&&t.protocol!==r.protocol){if(!Yn[t.protocol]){for(var h=Object.keys(t),f=0;h.length>f;f++){var p=h[f];r[p]=t[p]}return r.href=r.format(),r}if(r.protocol=t.protocol,t.host||Dn[t.protocol])r.pathname=t.pathname;else{for(n=(t.pathname||"").split("/");n.length&&!(t.host=n.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==n[0]&&n.unshift(""),2>n.length&&n.unshift(""),r.pathname=n.join("/")}if(r.search=t.search,r.query=t.query,r.host=t.host||"",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search)r.path=(r.pathname||"")+(r.search||"");return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var l,d=r.pathname&&"/"===r.pathname.charAt(0),v=t.host||t.pathname&&"/"===t.pathname.charAt(0),m=v||d||r.host&&t.pathname,g=m,y=r.pathname&&r.pathname.split("/")||[],w=r.protocol&&!Yn[r.protocol];if(n=t.pathname&&t.pathname.split("/")||[],w&&(r.hostname="",r.port=null,r.host&&(""===y[0]?y[0]=r.host:y.unshift(r.host)),r.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===n[0]?n[0]=t.host:n.unshift(t.host)),t.host=null),m=m&&(""===n[0]||""===y[0])),v)r.host=t.host||""===t.host?t.host:r.host,r.hostname=t.hostname||""===t.hostname?t.hostname:r.hostname,r.search=t.search,r.query=t.query,y=n;else if(n.length)y||(y=[]),y.pop(),y=y.concat(n),r.search=t.search,r.query=t.query;else if(null!=t.search)return w&&(r.hostname=r.host=y.shift(),(l=!(!r.host||0>=r.host.indexOf("@"))&&r.host.split("@"))&&(r.auth=l.shift(),r.host=r.hostname=l.shift())),r.search=t.search,r.query=t.query,gn(r.pathname)&&gn(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r;if(!y.length)return r.pathname=null,r.path=r.search?"/"+r.search:null,r.href=r.format(),r;for(var E=y.slice(-1)[0],I=(r.host||t.host||y.length>1)&&("."===E||".."===E)||""===E,b=0,S=y.length;S>=0;S--)"."===(E=y[S])?y.splice(S,1):".."===E?(y.splice(S,1),b++):b&&(y.splice(S,1),b--);if(!m&&!g)for(;b--;b)y.unshift("..");!m||""===y[0]||y[0]&&"/"===y[0].charAt(0)||y.unshift(""),I&&"/"!==y.join("/").substr(-1)&&y.push("");var A=""===y[0]||y[0]&&"/"===y[0].charAt(0);return w&&(r.hostname=r.host=A?"":y.length?y.shift():"",(l=!(!r.host||0>=r.host.indexOf("@"))&&r.host.split("@"))&&(r.auth=l.shift(),r.host=r.hostname=l.shift())),(m=m||r.host&&y.length)&&!A&&y.unshift(""),y.length?r.pathname=y.join("/"):(r.pathname=null,r.path=null),gn(r.pathname)&&gn(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},kn.prototype.parseHost=function(){return Kn(this)};var Hn=function(t){var e=_n.parse(t);return{host:e.hostname,path:e.pathname}},Vn=p.Some,Jn=p.None;function Xn(t){return"1"===t||"true"===t}function Zn(t){try{return new Vn(parseInt(t))}catch(t){return Jn}}function $n(t){throw Error("HttpServerInstrumentation: Missing required argument ".concat(t,"."))}var Gn={addZipkinHeaders:function(t,e){var n=function(t,e){var n=t.headers||{};return n[Vt.TraceId]=e.traceId,n[Vt.SpanId]=e.spanId,e.parentSpanId.ifPresent(function(t){n[Vt.ParentSpanId]=t}),e.sampled.ifPresent(function(t){n[Vt.Sampled]=t?"1":"0"}),e.isDebug()&&(n[Vt.Flags]="1"),n}(t,e);return Object.assign({},t,{headers:n})}};var Qn={HttpServer:function(){function t(e){var r=e.tracer,o=void 0===r?$n("tracer"):r,i=e.serviceName,a=void 0===i?o.localEndpoint.serviceName:i,s=e.host,u=e.port,c=void 0===u?$n("port"):u;n(this,t),this.tracer=o,this.serviceName=a,this.host=s&&new J(s),this.port=c}return o(t,[{key:"_createIdFromHeaders",value:function(t){if(function(t){return t(Vt.TraceId)!==Jn&&t(Vt.SpanId)!==Jn}(t)){var e=t(Vt.SpanId).map(function(e){var n=t(Vt.TraceId),r=t(Vt.ParentSpanId),o=t(Vt.Sampled),i=t(Vt.Flags).flatMap(Zn).getOrElse(0);return new kt({traceId:n.getOrElse(),parentId:r,spanId:e,debug:1===i,sampled:o.map(Xn)})});return new Vn(this.tracer.join(e.getOrElse()))}if(t(Vt.Flags)!==Jn||t(Vt.Sampled)!==Jn){var n=t(Vt.Sampled)===Jn?Jn:t(Vt.Sampled).map(Xn),r=t(Vt.Flags).flatMap(Zn).getOrElse(0);return new Vn(this.tracer.createRootId(n,1===r))}return new Vn(this.tracer.createRootId())}},{key:"spanNameFromRoute",value:function(t,e,n){return n>299&&400>n?"".concat(t," redirected"):404===n?"".concat(t," not_found"):e&&""!==e?"".concat(t," ").concat(e):t}},{key:"recordRequest",value:function(t,e,n){var r=this;this._createIdFromHeaders(n).ifPresent(function(t){return r.tracer.setId(t)});var o=this.tracer.id,i=Hn(e).path;return this.tracer.recordServiceName(this.serviceName),this.tracer.recordRpc(t.toUpperCase()),this.tracer.recordBinary("http.path",i),this.tracer.recordAnnotation(new dt.ServerRecv),this.tracer.recordAnnotation(new dt.LocalAddr({host:this.host,port:this.port})),o}},{key:"recordResponse",value:function(t,e,n){this.tracer.setId(t),this.tracer.recordBinary("http.status_code",""+e),n?this.tracer.recordBinary("error",""+n):(200>e||e>399)&&this.tracer.recordBinary("error",""+e),this.tracer.recordAnnotation(new dt.ServerSend)}}]),t}(),HttpClient:function(){function t(e){var r=e.tracer,o=void 0===r?function(t){throw Error("HttpClientInstrumentation: Missing required argument ".concat(t,"."))}("tracer"):r,i=e.serviceName,a=void 0===i?o.localEndpoint.serviceName:i,s=e.remoteServiceName;n(this,t),this.tracer=o,this.serviceName=a,this.remoteServiceName=s}return o(t,[{key:"recordRequest",value:function(t,e,n){this.tracer.setId(this.tracer.createChildId());var r=this.tracer.id,o=Hn(e).path;return this.tracer.recordServiceName(this.serviceName),this.tracer.recordRpc(n.toUpperCase()),this.tracer.recordBinary("http.path",o),this.tracer.recordAnnotation(new dt.ClientSend),this.remoteServiceName&&this.tracer.recordAnnotation(new dt.ServerAddr({serviceName:this.remoteServiceName})),Gn.addZipkinHeaders(t,r)}},{key:"recordResponse",value:function(t,e){this.tracer.setId(t),this.tracer.recordBinary("http.status_code",""+e),(200>e||e>399)&&this.tracer.recordBinary("error",""+e),this.tracer.recordAnnotation(new dt.ClientRecv)}},{key:"recordError",value:function(t,e){this.tracer.setId(t),this.tracer.recordBinary("error",""+e),this.tracer.recordAnnotation(new dt.ClientRecv)}}]),t}()};function Wn(t){if(void 0!==t){var e={serviceName:t.serviceName||""};return t.ipv4&&(e.ipv4=t.ipv4),t.port&&(e.port=t.port),e}}var tr={JSON_V1:{encode:function(t){return function(t){var e={traceId:t.traceId};t.parentId&&(e.parentId=t.parentId),e.id=t.id,e.name=t.name||"",t.shared||(e.timestamp=t.timestamp,e.duration=t.duration);var n,r,o,i=Wn(t.localEndpoint);switch(t.kind){case"CLIENT":n=t.timestamp?"cs":void 0,r="cr",o="sa";break;case"SERVER":n=t.timestamp?"sr":void 0,r="ss",o="ca";break;case"PRODUCER":n=t.timestamp?"ms":void 0,r="ws",o="ma";break;case"CONSUMER":t.timestamp&&t.duration?(n="wr",r="mr"):t.timestamp&&(n="mr"),o="ma"}(t.annotations.length>0||n)&&(e.annotations=t.annotations.map(function(t){return function(t,e){return{value:t.value,timestamp:t.timestamp,endpoint:e}}(t,i)})),n&&(e.annotations.push({value:n,timestamp:t.timestamp,endpoint:i}),t.duration&&e.annotations.push({value:r,timestamp:t.timestamp+t.duration,endpoint:i}));var a=Object.keys(t.tags);if((a.length>0||t.remoteEndpoint)&&(e.binaryAnnotations=a.map(function(e){return{key:e,value:t.tags[e],endpoint:i}})),t.remoteEndpoint){var s={key:o,value:!0,endpoint:Wn(t.remoteEndpoint)};e.binaryAnnotations.push(s)}return t.debug&&(e.debug=!0),JSON.stringify(e)}(t)}},JSON_V2:{encode:function(t){return function(t){var e={traceId:t.traceId};return t.parentId&&(e.parentId=t.parentId),e.id=t.id,t.name&&(e.name=t.name),t.kind&&(e.kind=t.kind),t.timestamp&&(e.timestamp=t.timestamp),t.duration&&(e.duration=t.duration),t.localEndpoint&&(e.localEndpoint=t.localEndpoint),t.remoteEndpoint&&(e.remoteEndpoint=t.remoteEndpoint),t.annotations.length>0&&(e.annotations=t.annotations),Object.keys(t.tags).length>0&&(e.tags=t.tags),t.debug&&(e.debug=!0),t.shared&&(e.shared=!0),JSON.stringify(e)}(t)}}};t.option=p,t.Annotation=dt,t.Tracer=Kt,t.createNoopTracer=function(){var t=new Ht;return new Kt({recorder:{record:function(){}},ctxImpl:t})},t.randomTraceId=Tt,t.sampler=Et,t.TraceId=kt,t.HttpHeaders=Vt,t.InetAddress=J,t.BatchRecorder=Wt,t.ConsoleRecorder=te,t.ExplicitContext=Ht,t.Instrumentation=Qn,t.Request=Gn,t.jsonEncoder=tr,t.model=xt,t.parseRequestUrl=Hn,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Zipkin={})}(this,function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;e.length>n;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function o(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function a(t){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function c(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}();return function(){var n,r=a(t);if(e){var o=a(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return u(this,n)}}var h={get type(){return"None"},get present(){return!1},map:function(){return this},ifPresent:function(){},flatMap:function(){return this},getOrElse:function(t){return t instanceof Function?t():t},equals:function(t){return t===this},toString:function(){return"None"}},f=function(){function t(e){n(this,t),this.value=e}return o(t,[{key:"map",value:function(e){return new t(e(this.value))}},{key:"ifPresent",value:function(t){t(this.value)}},{key:"flatMap",value:function(t){return t(this.value)}},{key:"getOrElse",value:function(){return this.value}},{key:"equals",value:function(e){return e instanceof t&&e.value===this.value}},{key:"toString",value:function(){return"Some(".concat(this.value,")")}},{key:"type",get:function(){return"Some"}},{key:"present",get:function(){return!0}}]),t}();function p(t){return t instanceof f||h.equals(t)}var l={Some:f,None:h,isOptional:p,verifyIsOptional:function(t){if(null==t)throw Error("Error: data is not Optional - it's null");if(!p(t))throw Error("Error: data (".concat(t,") is not an Option!"));if(p(t.value))throw Error("Error: data (".concat(t.value,") is wrapped in Option twice"))},verifyIsNotOptional:function(t){if(p(t))throw Error("Error: data (".concat(t,") is an Option!"))},fromNullable:function(t){return null==t?h:new f(t)}},d="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function v(){throw Error("setTimeout has not been defined")}function m(){throw Error("clearTimeout has not been defined")}var g=v,y=m;function w(t){if(g===setTimeout)return setTimeout(t,0);if((g===v||!g)&&setTimeout)return g=setTimeout,setTimeout(t,0);try{return g(t,0)}catch(e){try{return g.call(null,t,0)}catch(e){return g.call(this,t,0)}}}"function"==typeof d.setTimeout&&(g=setTimeout),"function"==typeof d.clearTimeout&&(y=clearTimeout);var E,I=[],b=!1,S=-1;function A(){b&&E&&(b=!1,E.length?I=E.concat(I):S=-1,I.length&&R())}function R(){if(!b){var t=w(A);b=!0;for(var e=I.length;e;){for(E=I,I=[];++S<e;)E&&E[S].run();S=-1,e=I.length}E=null,b=!1,function(t){if(y===clearTimeout)return clearTimeout(t);if((y===m||!y)&&clearTimeout)return y=clearTimeout,clearTimeout(t);try{y(t)}catch(e){try{return y.call(null,t)}catch(e){return y.call(this,t)}}}(t)}}function _(t,e){this.fun=t,this.array=e}_.prototype.run=function(){this.fun.apply(null,this.array)};function k(){}var T=k,O=k,P=k,C=k,N=k,U=k,x=k;var B=d.performance||{},L=B.now||B.mozNow||B.msNow||B.oNow||B.webkitNow||function(){return(new Date).getTime()};var M=new Date;var j,D={nextTick:function(t){var e=[];if(arguments.length>1)for(var n=1;arguments.length>n;n++)e[n-1]=arguments[n];I.push(new _(t,e)),1!==I.length||b||w(R)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:T,addListener:O,once:P,off:C,removeListener:N,removeAllListeners:U,emit:x,binding:function(t){throw Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(t){throw Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(t){var e=.001*L.call(B),n=Math.floor(e),r=Math.floor(e%1*1e9);return t&&(n-=t[0],0>(r-=t[1])&&(n--,r+=1e9)),[n,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-M)/1e3}};function Y(){return"/tmp"}var q={EOL:"\n",tmpdir:Y,tmpDir:Y,networkInterfaces:function(){},getNetworkInterfaces:function(){},release:function(){return void 0!==d.navigator?d.navigator.appVersion:""},type:function(){return"Browser"},cpus:function(){return[]},totalmem:function(){return Number.MAX_VALUE},freemem:function(){return Number.MAX_VALUE},uptime:function(){return 0},loadavg:function(){return[]},hostname:function(){return void 0!==d.location?d.location.hostname:""},endianness:function(){if(void 0===j){var t=new ArrayBuffer(2),e=new Uint8Array(t),n=new Uint16Array(t);if(e[0]=1,e[1]=2,258===n[0])j="BE";else{if(513!==n[0])throw Error("unable to figure out endianess");j="LE"}}return j}};function F(t,e){for(var n in t)for(var r=t[n].length-1;r>=0;r-=1){var o=t[n][r];if(!o.internal&&o.family===e&&("IPv4"===e||0===o.scopeid))return o.address}return"IPv4"===e?"127.0.0.1":"::1"}function z(t,e){var n={};for(var r in t)r===e&&(n[r]=t[r]);return n}function K(t){var e=q.networkInterfaces();return t&&(e=z(e,t)),F(e,"IPv4")}K.ipv4=K,K.ipv6=function(t){var e=q.networkInterfaces();return t&&(e=z(e,t)),F(e,"IPv6")};var H=K,V=function(){function t(e){n(this,t),this.addr=e}return o(t,[{key:"ipv4",value:function(){var t=this.toInt();if(t&&0!==t)return this.addr}},{key:"toInt",value:function(){var t=this.addr.split(".");return t[0]<<24|t[1]<<16|t[2]<<8|t[3]}},{key:"toString",value:function(){return"InetAddress(".concat(this.addr,")")}}]),t}();var J="object"===(void 0===D?"undefined":e(D))&&"function"==typeof D.on?new V(H.ipv4()):new V("127.0.0.1");V.getLocalAddress=function(){return J};var X=V,Z=function(){function t(){n(this,t)}return o(t,[{key:"toString",value:function(){return"".concat(this.annotationType,"()")}}]),t}(),$=function(t){i(r,Z);var e=c(r);function r(){return n(this,r),e.apply(this,arguments)}return r}(),G=function(t){i(r,Z);var e=c(r);function r(){return n(this,r),e.apply(this,arguments)}return r}(),Q=function(t){i(r,Z);var e=c(r);function r(){return n(this,r),e.apply(this,arguments)}return r}(),W=function(t){i(r,Z);var e=c(r);function r(){return n(this,r),e.apply(this,arguments)}return r}(),tt=function(t){i(r,Z);var e=c(r);function r(){return n(this,r),e.apply(this,arguments)}return r}(),et=function(t){i(r,Z);var e=c(r);function r(){return n(this,r),e.apply(this,arguments)}return r}(),nt=function(t){i(r,Z);var e=c(r);function r(){return n(this,r),e.apply(this,arguments)}return r}(),rt=function(t){i(r,Z);var e=c(r);function r(){return n(this,r),e.apply(this,arguments)}return r}();function ot(t){this.name=t}ot.prototype.toString=function(){return'LocalOperationStart("'.concat(this.name,'")')};var it=function(t){i(r,Z);var e=c(r);function r(){return n(this,r),e.apply(this,arguments)}return r}();function at(t){this.message=t}function st(t){this.serviceName=t}function ut(t){this.name=t}function ct(t){var e=t.port;this.host=t.host,this.port=e}function ht(t){var e=t.host,n=t.port;this.serviceName=t.serviceName,this.host=e||void 0,this.port=n||0}function ft(t){var e=t.port;this.host=t.host||X.getLocalAddress(),this.port=e||0}function pt(t){var e=t.host,n=t.port;this.serviceName=t.serviceName,this.host=e,this.port=n}function lt(t,e){this.key=t,this.value=e}at.prototype.toString=function(){return'Message("'.concat(this.message,'")')},st.prototype.toString=function(){return'ServiceName("'.concat(this.serviceName,'")')},ut.prototype.toString=function(){return'Rpc("'.concat(this.name,'")')},ct.prototype.toString=function(){return'ClientAddr(host="'.concat(this.host,'", port=').concat(this.port,")")},ht.prototype.toString=function(){return'ServerAddr(serviceName="'.concat(this.serviceName,'", host="').concat(this.host,'", port=').concat(this.port,")")},ft.prototype.toString=function(){return'LocalAddr(host="'.concat(""+this.host,'", port=').concat(this.port,")")},pt.prototype.toString=function(){return'MessageAddr(serviceName="'.concat(this.serviceName,'", host="').concat(this.host,'", port=').concat(this.port,")")},lt.prototype.toString=function(){return"BinaryAnnotation(".concat(this.key,'="').concat(this.value,'")')};var dt={ClientSend:$,ClientRecv:G,ServerSend:Q,ServerRecv:W,ProducerStart:tt,ProducerStop:et,ConsumerStart:nt,ConsumerStop:rt,MessageAddr:pt,Message:at,ServiceName:st,Rpc:ut,ClientAddr:ct,ServerAddr:ht,LocalAddr:ft,BinaryAnnotation:lt,LocalOperationStart:ot,LocalOperationStop:it};Object.keys(dt).forEach(function(t){dt[t].prototype.annotationType=t});var vt=dt,mt=gt;function gt(t){return!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then}mt.default=gt;var yt=l.Some,wt=function(){function t(e){n(this,t),this.evaluator=e}return o(t,[{key:"shouldSample",value:function(t){var e=this,n=t.sampled.getOrElse(function(){return e.evaluator(t)});return new yt(n)}},{key:"toString",value:function(){return"Sampler(".concat(""+this.evaluator,")")}}]),t}();function Et(t){return!1}function It(t){return!0}Et.toString=function(){return"never sample"},It.toString=function(){return"always sample"};var bt={Sampler:wt,CountingSampler:function(t){i(r,wt);var e=c(r);function r(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return n(this,r),e.call(this,function(t){if(t>0){if(1>t){var e=0,n=parseInt(1/t),r=function(t){var r=0==(e%=n);return e+=1,r};return r.toString=function(){return"countingSampler: sampleRate=".concat(t)},r}return It}return Et}(1>t?t:1))}return r}(),neverSample:Et,alwaysSample:It},St=function(){function t(e){var r=e.traceId,o=e.timestamp,i=e.annotation;n(this,t),this.traceId=r,this.timestamp=o,this.annotation=i}return o(t,[{key:"toString",value:function(){return"Record(traceId=".concat(""+this.traceId,", annotation=").concat(""+this.annotation,")")}}]),t}(),At=l.None,Rt=l.verifyIsOptional,_t=l.verifyIsNotOptional,kt=l.isOptional,Tt=new(0,l.Some)(!0),Ot=function(){function t(e){n(this,t);var r=e.spanId,o=e.traceId,i=void 0===o?r:o,a=e.parentId,s=void 0===a?At:a,u=e.flags,c=e.debug,h=void 0===c?1===(void 0===u?0:u):c,f=e.sampled,p=void 0===f?At:f,l=e.shared,d=void 0!==l&&l;_t(r),Rt(s),Rt(p),this._traceId=kt(i)?i.getOrElse(r):null==i?r:i,this._parentId=s,this._spanId=r,this._sampled=h?Tt:p,this._debug=h,this._shared=d}return o(t,[{key:"isDebug",value:function(){return this._debug}},{key:"isShared",value:function(){return this._shared}},{key:"toString",value:function(){return"TraceId(spanId=".concat(""+this.spanId)+", parentSpanId=".concat(""+this.parentSpanId)+", traceId=".concat(""+this.traceId,")")}},{key:"traceId",get:function(){return this._traceId}},{key:"parentSpanId",get:function(){return this._parentId}},{key:"parentId",get:function(){return this._parentId.getOrElse(this._spanId)}},{key:"spanId",get:function(){return this._spanId}},{key:"sampled",get:function(){return this._sampled}},{key:"flags",get:function(){return this._debug?1:0}}]),t}();var Pt=function(){for(var t="",e=0;16>e;e+=1)t+="0123456789abcdef"[Math.floor(16*Math.random())];return t},Ct=void 0!==D&&D.hrtime;var Nt={now:Ct?function(t,e){if(t&&e){var n=D.hrtime(e);return t+Math.floor(1e6*n[0]+n[1]/1e3)}return 1e3*Date.now()}:function(){return 1e3*Date.now()},hrtime:Ct?function(){return D.hrtime()}:function(){}};function Ut(t){var e=t.ipv4,n=t.port;this.setServiceName(t.serviceName),this.setIpv4(e),this.setPort(n)}function xt(t,e){this.timestamp=t,this.value=""+e}function Bt(t){var e=this;this.traceId=t.traceId,t.parentSpanId.ifPresent(function(t){e.parentId=t}),this.id=t.spanId,this.name=void 0,this.kind=void 0,this.timestamp=void 0,this.duration=void 0,this.localEndpoint=void 0,this.remoteEndpoint=void 0,this.annotations=[],this.tags={},this.debug=t.isDebug(),this.shared=t.isShared()}Ut.prototype.setServiceName=function(t){this.serviceName=t?t.toLocaleLowerCase():void 0},Ut.prototype.setIpv4=function(t){this.ipv4=t},Ut.prototype.setPort=function(t){this.port=t||void 0},Ut.prototype.isEmpty=function(){return void 0===this.serviceName&&void 0===this.ipv4&&void 0===this.port},xt.prototype.toString=function(){return'Annotation(value="'.concat(this.value,'")')},Bt.prototype.setName=function(t){this.name=t?t.toLocaleLowerCase():void 0},Bt.prototype.setKind=function(t){this.kind=t},Bt.prototype.setTimestamp=function(t){this.timestamp=t},Bt.prototype.setDuration=function(t){void 0!==t&&(this.duration=Math.max(t,1))},Bt.prototype.setLocalEndpoint=function(t){this.localEndpoint=t&&!t.isEmpty()?t:void 0},Bt.prototype.setRemoteEndpoint=function(t){this.remoteEndpoint=t&&!t.isEmpty()?t:void 0},Bt.prototype.addAnnotation=function(t,e){this.annotations.push(new xt(t,e))},Bt.prototype.putTag=function(t,e){this.tags[t]=""+e},Bt.prototype.setDebug=function(t){this.debug=t},Bt.prototype.setShared=function(t){this.shared=t},Bt.prototype.toString=function(){var t=this.annotations.map(function(t){return""+t}).join(", ");return"Span(id=".concat(this.traceId,", annotations=[").concat(t,"])")};var Lt={Endpoint:Ut,Span:Bt},Mt=l.None,jt=l.Some,Dt=bt.Sampler,Yt=bt.alwaysSample,qt=Nt.now,Ft=Nt.hrtime,zt=Lt.Endpoint;function Kt(t){throw Error("Tracer: Missing required argument ".concat(t,"."))}function Ht(t){return null==t}var Vt=function(){function t(e){var r=e.ctxImpl,o=void 0===r?Kt("ctxImpl"):r,i=e.recorder,a=void 0===i?Kt("recorder"):i,s=e.sampler,u=void 0===s?new Dt(Yt):s,c=e.traceId128Bit,h=void 0!==c&&c,f=e.supportsJoin,p=void 0===f||f,l=e.localServiceName,d=e.localEndpoint,v=e.log,m=void 0===v?console:v,g=e.defaultTags;n(this,t),this.log=m,this.recorder=a,this.sampler=u,this.traceId128Bit=h,this.supportsJoin=p,this._localEndpoint=d||new zt({serviceName:l||"unknown"}),this._ctxImpl=o,this._sentinelTraceId=this.createRootId(),this._startTimestamp=qt(),this._startTick=Ft(),this.recorder.setDefaultTags&&this.recorder.setDefaultTags(g)}return o(t,[{key:"scoped",value:function(t){return this._ctxImpl.scoped(t)}},{key:"letId",value:function(t,e){return this._ctxImpl.letContext(t,e)}},{key:"createRootId",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Mt,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=Pt(),r=this.traceId128Bit?Pt()+n:n,o=new Ot({traceId:r,parentId:Mt,spanId:n,sampled:t,flags:e?1:0});return t===Mt&&(o._sampled=this.sampler.shouldSample(o)),o}},{key:"createChildId",value:function(t){if(Ht(t)&&(t=this._ctxImpl.getContext()),t===this._sentinelTraceId||Ht(t))return this.createRootId();var e=new Ot({traceId:t.traceId,parentId:new jt(t.spanId),spanId:Pt(),debug:t.isDebug(),sampled:t.sampled});return!1===e.sampled.present&&(e._sampled=this.sampler.shouldSample(e)),e}},{key:"_explicitRecord",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:qt(this._startTimestamp,this._startTick);this.recorder.record(new St({traceId:t,timestamp:n,annotation:e}))}},{key:"local",value:function(t,e){var n=this;if("function"!=typeof e)throw Error("you must pass a function");return this.scoped(function(){var r,o=n.createChildId();n.setId(o),n.recordServiceName(n._localEndpoint.serviceName),n.recordAnnotation(new vt.LocalOperationStart(t));try{r=e()}catch(t){throw n.recordBinary("error",t.message?t.message:""+t),n.recordAnnotation(new vt.LocalOperationStop),t}return mt(r)?o.sampled.getOrElse(!1)?r.then(function(t){return n._explicitRecord(o,new vt.LocalOperationStop),t}).catch(function(t){throw n._explicitRecord(o,new vt.BinaryAnnotation("error",t.message?t.message:""+t)),n._explicitRecord(o,new vt.LocalOperationStop),t}):r:(n.recordAnnotation(new vt.LocalOperationStop),r)})}},{key:"join",value:function(t){if(Ht(t))throw Error("traceId is a required arg");if(Ht(t._spanId))throw Error("Must be valid TraceId instance");return this.supportsJoin?(t.sampled===Mt?t._sampled=this.sampler.shouldSample(t):t._shared=!0,t):this.createChildId(t)}},{key:"setId",value:function(t){this._ctxImpl.setContext(t)}},{key:"recordAnnotation",value:function(t,e){this.id.sampled.getOrElse(!1)&&this._explicitRecord(this.id,t,e)}},{key:"recordMessage",value:function(t){this.recordAnnotation(new vt.Message(t))}},{key:"recordServiceName",value:function(t){this.recordAnnotation(new vt.ServiceName(t))}},{key:"recordRpc",value:function(t){this.recordAnnotation(new vt.Rpc(t))}},{key:"recordClientAddr",value:function(t){this.recordAnnotation(new vt.ClientAddr(t))}},{key:"recordServerAddr",value:function(t){this.recordAnnotation(new vt.ServerAddr(t))}},{key:"recordLocalAddr",value:function(t){this.recordAnnotation(new vt.LocalAddr(t))}},{key:"recordBinary",value:function(t,e){this.recordAnnotation(new vt.BinaryAnnotation(t,e))}},{key:"writeIdToConsole",value:function(t){this.log.info("".concat(t,": ").concat(""+this.id))}},{key:"setTags",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&this.recordBinary(e,t[e])}},{key:"id",get:function(){return this._ctxImpl.getContext()||this._sentinelTraceId}},{key:"localEndpoint",get:function(){return this._localEndpoint}}]),t}(),Jt=function(){function t(){n(this,t),this.currentCtx=null}return o(t,[{key:"setContext",value:function(t){this.currentCtx=t}},{key:"getContext",value:function(){return this.currentCtx}},{key:"scoped",value:function(t){var e=this.getContext();try{return t()}finally{this.setContext(e)}}},{key:"letContext",value:function(t,e){var n=this;return this.scoped(function(){return n.setContext(t),e()})}}]),t}(),Xt={TraceId:"X-B3-TraceId",SpanId:"X-B3-SpanId",ParentSpanId:"X-B3-ParentSpanId",Sampled:"X-B3-Sampled",Flags:"X-B3-Flags"},Zt=Nt.now,$t=Lt.Span,Gt=Lt.Endpoint,Qt=Symbol("defaultTags");var Wt=function(){function t(e,r){n(this,t),this.traceId=e,this.timeoutTimestamp=r,this.delegate=new $t(e),this.localEndpoint=new Gt({}),this.shouldFlush=!1}return o(t,[{key:"setDuration",value:function(t){if(!this.shouldFlush){this.shouldFlush=!0;var e=this.delegate.timestamp;void 0===e?this.delegate.addAnnotation(t,"finish"):this.delegate.setDuration(t-e)}}}]),t}(),te=6e7,ee=function(){function t(e){var r=this,o=e.logger,i=e.timeout,a=void 0===i?te:i;n(this,t),this.logger=o,this.timeout=a,this.partialSpans=new Map,this[Qt]={};var s=setInterval(function(){r.partialSpans.forEach(function(t,e){(function(t){return t.timeoutTimestamp<Zt()})(t)&&(t.delegate.addAnnotation(Zt(),"zipkin-js.flush"),r._writeSpan(e,t))})},1e3);s.unref&&s.unref()}return o(t,[{key:"_addDefaultTagsAndLocalEndpoint",value:function(t){var e=this[Qt];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.delegate.putTag(n,e[n]);t.delegate.setLocalEndpoint(t.localEndpoint)}},{key:"_writeSpan",value:function(t,e){if(arguments.length>2&&void 0!==arguments[2]&&arguments[2]||void 0!==this.partialSpans.get(t)){this.partialSpans.delete(t);var n=e.delegate;e.delegate.timestamp&&this._addDefaultTagsAndLocalEndpoint(e),this.logger.logSpan(n)}}},{key:"_updateSpanMap",value:function(t,e,n){var r,o=!1;this.partialSpans.has(t)?r=this.partialSpans.get(t):(o=!0,r=new Wt(t,e+this.timeout)),n(r),r.shouldFlush?this._writeSpan(t,r,o):this.partialSpans.set(t,r)}},{key:"flush",value:function(){var t=this;this.partialSpans.forEach(function(e,n){t._writeSpan(n,e)})}},{key:"record",value:function(t){var e=t.traceId;this._updateSpanMap(e,t.timestamp,function(n){switch(t.annotation.annotationType){case"ClientAddr":n.delegate.setKind("SERVER"),n.delegate.setRemoteEndpoint(new Gt({serviceName:t.annotation.serviceName,ipv4:t.annotation.host&&t.annotation.host.ipv4(),port:t.annotation.port}));break;case"ClientSend":n.delegate.setKind("CLIENT"),n.delegate.setTimestamp(t.timestamp);break;case"ClientRecv":n.delegate.setKind("CLIENT"),n.setDuration(t.timestamp);break;case"ServerSend":n.delegate.setKind("SERVER"),n.setDuration(t.timestamp);break;case"ServerRecv":n.delegate.setShared(e.isShared()),n.delegate.setKind("SERVER"),n.delegate.setTimestamp(t.timestamp);break;case"ProducerStart":n.delegate.setKind("PRODUCER"),n.delegate.setTimestamp(t.timestamp);break;case"ProducerStop":n.delegate.setKind("PRODUCER"),n.setDuration(t.timestamp);break;case"ConsumerStart":n.delegate.setKind("CONSUMER"),n.delegate.setTimestamp(t.timestamp);break;case"ConsumerStop":n.delegate.setKind("CONSUMER"),n.setDuration(t.timestamp);break;case"MessageAddr":n.delegate.setRemoteEndpoint(new Gt({serviceName:t.annotation.serviceName,ipv4:t.annotation.host&&t.annotation.host.ipv4(),port:t.annotation.port}));break;case"LocalOperationStart":n.delegate.setName(t.annotation.name),n.delegate.setTimestamp(t.timestamp);break;case"LocalOperationStop":n.setDuration(t.timestamp);break;case"Message":n.delegate.addAnnotation(t.timestamp,t.annotation.message);break;case"Rpc":n.delegate.setName(t.annotation.name);break;case"ServiceName":n.localEndpoint.setServiceName(t.annotation.serviceName);break;case"BinaryAnnotation":n.delegate.putTag(t.annotation.key,t.annotation.value);break;case"LocalAddr":n.localEndpoint.setIpv4(t.annotation.host&&t.annotation.host.ipv4()),n.localEndpoint.setPort(t.annotation.port);break;case"ServerAddr":n.delegate.setKind("CLIENT"),n.delegate.setRemoteEndpoint(new Gt({serviceName:t.annotation.serviceName,ipv4:t.annotation.host&&t.annotation.host.ipv4(),port:t.annotation.port}))}})}},{key:"setDefaultTags",value:function(t){this[Qt]=t}},{key:"toString",value:function(){return"BatchRecorder()"}}]),t}(),ne=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:console.log;n(this,t),this.logger=e}return o(t,[{key:"record",value:function(t){var e=t.traceId,n=e.spanId,r=e.parentId,o=e.traceId;this.logger("Record at (timestamp=".concat(t.timestamp,", spanId=").concat(n,", parentId=").concat(r,", ")+"traceId=".concat(o,"): ").concat(""+t.annotation))}},{key:"toString",value:function(){return"consoleTracer"}}]),t}(),re=2147483647,oe=36,ie=1,ae=26,se=38,ue=700,ce=72,he=128,fe="-",pe=/[^\x20-\x7E]/,le=/[\x2E\u3002\uFF0E\uFF61]/g,de={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},ve=oe-ie,me=Math.floor,ge=String.fromCharCode;function ye(t){throw new RangeError(de[t])}function we(t,e){return t+22+75*(26>t)-((0!=e)<<5)}function Ee(t,e,n){var r=0;for(t=n?me(t/ue):t>>1,t+=me(t/e);t>ve*ae>>1;r+=oe)t=me(t/ve);return me(r+(ve+1)*t/(t+se))}function Ie(t){return function(t,e){var n=t.split("@"),r="";n.length>1&&(r=n[0]+"@",t=n[1]);var o=function(t,e){for(var n=t.length,r=[];n--;)r[n]=e(t[n]);return r}((t=t.replace(le,".")).split("."),e).join(".");return r+o}(t,function(t){return pe.test(t)?"xn--"+function(t){var e,n,r,o,i,a,s,u,c,h,f,p,l,d,v,m=[];for(p=(t=function(t){for(var e,n,r=[],o=0,i=t.length;i>o;)55296>(e=t.charCodeAt(o++))||e>56319||o>=i?r.push(e):56320==(64512&(n=t.charCodeAt(o++)))?r.push(((1023&e)<<10)+(1023&n)+65536):(r.push(e),o--);return r}(t)).length,e=he,n=0,i=ce,a=0;p>a;++a)128>(f=t[a])&&m.push(ge(f));for(r=o=m.length,o&&m.push(fe);p>r;){for(s=re,a=0;p>a;++a)(f=t[a])>=e&&s>f&&(s=f);for(s-e>me((re-n)/(l=r+1))&&ye("overflow"),n+=(s-e)*l,e=s,a=0;p>a;++a)if(e>(f=t[a])&&++n>re&&ye("overflow"),f==e){for(u=n,c=oe;(h=c>i?i+ae>c?c-i:ae:ie)<=u;c+=oe)m.push(ge(we(h+(v=u-h)%(d=oe-h),0))),u=me(v/d);m.push(ge(we(u,0))),i=Ee(n,l,r==o),n=0,++r}++n,++e}return m.join("")}(t):t})}var be=[],Se=[],Ae="undefined"!=typeof Uint8Array?Uint8Array:Array,Re=!1;function _e(){Re=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0;64>e;++e)be[e]=t[e],Se[t.charCodeAt(e)]=e;Se[45]=62,Se[95]=63}function ke(t,e,n){for(var r,o=[],i=e;n>i;i+=3)o.push(be[(r=(t[i]<<16)+(t[i+1]<<8)+t[i+2])>>18&63]+be[r>>12&63]+be[r>>6&63]+be[63&r]);return o.join("")}function Te(t){var e;Re||_e();for(var n=t.length,r=n%3,o="",i=[],a=0,s=n-r;s>a;a+=16383)i.push(ke(t,a,a+16383>s?s:a+16383));return 1===r?(o+=be[(e=t[n-1])>>2],o+=be[e<<4&63],o+="=="):2===r&&(o+=be[(e=(t[n-2]<<8)+t[n-1])>>10],o+=be[e>>4&63],o+=be[e<<2&63],o+="="),i.push(o),i.join("")}function Oe(t,e,n,r,o){var i,a,s=8*o-r-1,u=(1<<s)-1,c=u>>1,h=-7,f=n?o-1:0,p=n?-1:1,l=t[e+f];for(f+=p,i=l&(1<<-h)-1,l>>=-h,h+=s;h>0;i=256*i+t[e+f],f+=p,h-=8);for(a=i&(1<<-h)-1,i>>=-h,h+=r;h>0;a=256*a+t[e+f],f+=p,h-=8);if(0===i)i=1-c;else{if(i===u)return a?NaN:1/0*(l?-1:1);a+=Math.pow(2,r),i-=c}return(l?-1:1)*a*Math.pow(2,i-r)}function Pe(t,e,n,r,o,i){var a,s,u,c=8*i-o-1,h=(1<<c)-1,f=h>>1,p=23===o?5.960464477539062e-8:0,l=r?0:i-1,d=r?1:-1,v=0>e||0===e&&0>1/e?1:0;for(isNaN(e=Math.abs(e))||e===1/0?(s=isNaN(e)?1:0,a=h):(1>e*(u=Math.pow(2,-(a=Math.floor(Math.log(e)/Math.LN2))))&&(a--,u*=2),2>(e+=1>a+f?p*Math.pow(2,1-f):p/u)*u||(a++,u/=2),h>a+f?1>a+f?(s=e*Math.pow(2,f-1)*Math.pow(2,o),a=0):(s=(e*u-1)*Math.pow(2,o),a+=f):(s=0,a=h));o>=8;t[n+l]=255&s,l+=d,s/=256,o-=8);for(a=a<<o|s,c+=o;c>0;t[n+l]=255&a,l+=d,a/=256,c-=8);t[n+l-d]|=128*v}var Ce={}.toString,Ne=Array.isArray||function(t){return"[object Array]"==Ce.call(t)};function Ue(){return Be.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function xe(t,e){if(Ue()<e)throw new RangeError("Invalid typed array length");return Be.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=Be.prototype:(null===t&&(t=new Be(e)),t.length=e),t}function Be(t,e,n){if(!(Be.TYPED_ARRAY_SUPPORT||this instanceof Be))return new Be(t,e,n);if("number"==typeof t){if("string"==typeof e)throw Error("If encoding is specified then the first argument must be a string");return je(this,t)}return Le(this,t,e,n)}function Le(t,e,n,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,n,r){if(0>n||n>e.byteLength)throw new RangeError("'offset' is out of bounds");if(n+(r||0)>e.byteLength)throw new RangeError("'length' is out of bounds");e=void 0===n&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,n):new Uint8Array(e,n,r);Be.TYPED_ARRAY_SUPPORT?(t=e).__proto__=Be.prototype:t=De(t,e);return t}(t,e,n,r):"string"==typeof e?function(t,e,n){"string"==typeof n&&""!==n||(n="utf8");if(!Be.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|Fe(e,n),o=(t=xe(t,r)).write(e,n);o!==r&&(t=t.slice(0,o));return t}(t,e,n):function(t,e){if(qe(e)){var n=0|Ye(e.length);return 0===(t=xe(t,n)).length?t:(e.copy(t,0,0,n),t)}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(r=e.length)!=r?xe(t,0):De(t,e);if("Buffer"===e.type&&Ne(e.data))return De(t,e.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function Me(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(0>t)throw new RangeError('"size" argument must not be negative')}function je(t,e){if(Me(e),t=xe(t,0>e?0:0|Ye(e)),!Be.TYPED_ARRAY_SUPPORT)for(var n=0;e>n;++n)t[n]=0;return t}function De(t,e){var n=0>e.length?0:0|Ye(e.length);t=xe(t,n);for(var r=0;n>r;r+=1)t[r]=255&e[r];return t}function Ye(t){if(t>=Ue())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ue().toString(16)+" bytes");return 0|t}function qe(t){return!(null==t||!t._isBuffer)}function Fe(t,e){if(qe(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return vn(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return mn(t).length;default:if(r)return vn(t).length;e=(""+e).toLowerCase(),r=!0}}function ze(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function Ke(t,e,n,r,o){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:-2147483648>n&&(n=-2147483648),isNaN(n=+n)&&(n=o?0:t.length-1),0>n&&(n=t.length+n),t.length>n){if(0>n){if(!o)return-1;n=0}}else{if(o)return-1;n=t.length-1}if("string"==typeof e&&(e=Be.from(e,r)),qe(e))return 0===e.length?-1:He(t,e,n,r,o);if("number"==typeof e)return e&=255,Be.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):He(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function He(t,e,n,r,o){var i,a=1,s=t.length,u=e.length;if(void 0!==r&&("ucs2"===(r=(r+"").toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(2>t.length||2>e.length)return-1;a=2,s/=2,u/=2,n/=2}function c(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var h=-1;for(i=n;s>i;i++)if(c(t,i)===c(e,-1===h?0:i-h)){if(-1===h&&(h=i),i-h+1===u)return h*a}else-1!==h&&(i-=i-h),h=-1}else for(n+u>s&&(n=s-u),i=n;i>=0;i--){for(var f=!0,p=0;u>p;p++)if(c(t,i+p)!==c(e,p)){f=!1;break}if(f)return i}return-1}function Ve(t,e,n,r){var o=t.length-(n=+n||0);r?(r=+r)>o&&(r=o):r=o;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var a=0;r>a;++a){var s=parseInt(e.substr(2*a,2),16);if(isNaN(s))return a;t[n+a]=s}return a}function Je(t,e,n,r){return gn(vn(e,t.length-n),t,n,r)}function Xe(t,e,n,r){return gn(function(t){for(var e=[],n=0;t.length>n;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function Ze(t,e,n,r){return Xe(t,e,n,r)}function $e(t,e,n,r){return gn(mn(e),t,n,r)}function Ge(t,e,n,r){return gn(function(t,e){for(var n,r,o=[],i=0;t.length>i&&0<=(e-=2);++i)n=t.charCodeAt(i),r=n>>8,o.push(n%256),o.push(r);return o}(e,t.length-n),t,n,r)}function Qe(t,e,n){return Te(0===e&&n===t.length?t:t.slice(e,n))}function We(t,e,n){n=Math.min(t.length,n);for(var r=[],o=e;n>o;){var i,a,s,u,c=t[o],h=null,f=c>239?4:c>223?3:c>191?2:1;if(n>=o+f)switch(f){case 1:128>c&&(h=c);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&c)<<6|63&i)>127&&(h=u);break;case 3:a=t[o+2],128==(192&(i=t[o+1]))&&128==(192&a)&&(u=(15&c)<<12|(63&i)<<6|63&a)>2047&&(55296>u||u>57343)&&(h=u);break;case 4:a=t[o+2],s=t[o+3],128==(192&(i=t[o+1]))&&128==(192&a)&&128==(192&s)&&(u=(15&c)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&1114112>u&&(h=u)}null===h?(h=65533,f=1):h>65535&&(r.push((h-=65536)>>>10&1023|55296),h=56320|1023&h),r.push(h),o+=f}return function(t){var e=t.length;if(tn>=e)return String.fromCharCode.apply(String,t);var n="",r=0;for(;e>r;)n+=String.fromCharCode.apply(String,t.slice(r,r+=tn));return n}(r)}Be.TYPED_ARRAY_SUPPORT=void 0===d.TYPED_ARRAY_SUPPORT||d.TYPED_ARRAY_SUPPORT,Be.poolSize=8192,Be._augment=function(t){return t.__proto__=Be.prototype,t},Be.from=function(t,e,n){return Le(null,t,e,n)},Be.TYPED_ARRAY_SUPPORT&&(Be.prototype.__proto__=Uint8Array.prototype,Be.__proto__=Uint8Array),Be.alloc=function(t,e,n){return function(t,e,n,r){return Me(e),e>0&&void 0!==n?"string"==typeof r?xe(t,e).fill(n,r):xe(t,e).fill(n):xe(t,e)}(null,t,e,n)},Be.allocUnsafe=function(t){return je(null,t)},Be.allocUnsafeSlow=function(t){return je(null,t)},Be.isBuffer=function(t){return null!=t&&(!!t._isBuffer||yn(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&yn(t.slice(0,0))}(t))},Be.compare=function(t,e){if(!qe(t)||!qe(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,r=e.length,o=0,i=Math.min(n,r);i>o;++o)if(t[o]!==e[o]){n=t[o],r=e[o];break}return r>n?-1:n>r?1:0},Be.isEncoding=function(t){switch((t+"").toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Be.concat=function(t,e){if(!Ne(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return Be.alloc(0);var n;if(void 0===e)for(e=0,n=0;t.length>n;++n)e+=t[n].length;var r=Be.allocUnsafe(e),o=0;for(n=0;t.length>n;++n){var i=t[n];if(!qe(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,o),o+=i.length}return r},Be.byteLength=Fe,Be.prototype._isBuffer=!0,Be.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;t>e;e+=2)ze(this,e,e+1);return this},Be.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;t>e;e+=4)ze(this,e,e+3),ze(this,e+1,e+2);return this},Be.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;t>e;e+=8)ze(this,e,e+7),ze(this,e+1,e+6),ze(this,e+2,e+5),ze(this,e+3,e+4);return this},Be.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?We(this,0,t):function(t,e,n){var r=!1;if((void 0===e||0>e)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),0>=n)return"";if((e>>>=0)>=(n>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return rn(this,e,n);case"utf8":case"utf-8":return We(this,e,n);case"ascii":return en(this,e,n);case"latin1":case"binary":return nn(this,e,n);case"base64":return Qe(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return on(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}.apply(this,arguments)},Be.prototype.equals=function(t){if(!qe(t))throw new TypeError("Argument must be a Buffer");return this===t||0===Be.compare(this,t)},Be.prototype.inspect=function(){var t="";return this.length>0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),"<Buffer "+t+">"},Be.prototype.compare=function(t,e,n,r,o){if(!qe(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),0>e||n>t.length||0>r||o>this.length)throw new RangeError("out of range index");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(r>>>=0),a=(n>>>=0)-(e>>>=0),s=Math.min(i,a),u=this.slice(r,o),c=t.slice(e,n),h=0;s>h;++h)if(u[h]!==c[h]){i=u[h],a=c[h];break}return a>i?-1:i>a?1:0},Be.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},Be.prototype.indexOf=function(t,e,n){return Ke(this,t,e,n,!0)},Be.prototype.lastIndexOf=function(t,e,n){return Ke(this,t,e,n,!1)},Be.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-e;if((void 0===n||n>o)&&(n=o),t.length>0&&(0>n||0>e)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return Ve(this,t,e,n);case"utf8":case"utf-8":return Je(this,t,e,n);case"ascii":return Xe(this,t,e,n);case"latin1":case"binary":return Ze(this,t,e,n);case"base64":return $e(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ge(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},Be.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var tn=4096;function en(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;n>o;++o)r+=String.fromCharCode(127&t[o]);return r}function nn(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;n>o;++o)r+=String.fromCharCode(t[o]);return r}function rn(t,e,n){var r=t.length;e&&e>=0||(e=0),(!n||0>n||n>r)&&(n=r);for(var o="",i=e;n>i;++i)o+=dn(t[i]);return o}function on(t,e,n){for(var r=t.slice(e,n),o="",i=0;r.length>i;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function an(t,e,n){if(t%1!=0||0>t)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function sn(t,e,n,r,o,i){if(!qe(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||i>e)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function un(t,e,n,r){0>e&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-n,2);i>o;++o)t[n+o]=(e&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function cn(t,e,n,r){0>e&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-n,4);i>o;++o)t[n+o]=e>>>8*(r?o:3-o)&255}function hn(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError("Index out of range");if(0>n)throw new RangeError("Index out of range")}function fn(t,e,n,r,o){return o||hn(t,0,n,4),Pe(t,e,n,r,23,4),n+4}function pn(t,e,n,r,o){return o||hn(t,0,n,8),Pe(t,e,n,r,52,8),n+8}Be.prototype.slice=function(t,e){var n,r=this.length;if(0>(t=~~t)?0>(t+=r)&&(t=0):t>r&&(t=r),0>(e=void 0===e?r:~~e)?0>(e+=r)&&(e=0):e>r&&(e=r),t>e&&(e=t),Be.TYPED_ARRAY_SUPPORT)(n=this.subarray(t,e)).__proto__=Be.prototype;else{var o=e-t;n=new Be(o,void 0);for(var i=0;o>i;++i)n[i]=this[i+t]}return n},Be.prototype.readUIntLE=function(t,e,n){t|=0,e|=0,n||an(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r},Be.prototype.readUIntBE=function(t,e,n){t|=0,e|=0,n||an(t,e,this.length);for(var r=this[t+--e],o=1;e>0&&(o*=256);)r+=this[t+--e]*o;return r},Be.prototype.readUInt8=function(t,e){return e||an(t,1,this.length),this[t]},Be.prototype.readUInt16LE=function(t,e){return e||an(t,2,this.length),this[t]|this[t+1]<<8},Be.prototype.readUInt16BE=function(t,e){return e||an(t,2,this.length),this[t]<<8|this[t+1]},Be.prototype.readUInt32LE=function(t,e){return e||an(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Be.prototype.readUInt32BE=function(t,e){return e||an(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Be.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||an(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return(o*=128)>r||(r-=Math.pow(2,8*e)),r},Be.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||an(t,e,this.length);for(var r=e,o=1,i=this[t+--r];r>0&&(o*=256);)i+=this[t+--r]*o;return(o*=128)>i||(i-=Math.pow(2,8*e)),i},Be.prototype.readInt8=function(t,e){return e||an(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Be.prototype.readInt16LE=function(t,e){e||an(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},Be.prototype.readInt16BE=function(t,e){e||an(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},Be.prototype.readInt32LE=function(t,e){return e||an(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Be.prototype.readInt32BE=function(t,e){return e||an(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Be.prototype.readFloatLE=function(t,e){return e||an(t,4,this.length),Oe(this,t,!0,23,4)},Be.prototype.readFloatBE=function(t,e){return e||an(t,4,this.length),Oe(this,t,!1,23,4)},Be.prototype.readDoubleLE=function(t,e){return e||an(t,8,this.length),Oe(this,t,!0,52,8)},Be.prototype.readDoubleBE=function(t,e){return e||an(t,8,this.length),Oe(this,t,!1,52,8)},Be.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||sn(this,t,e,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[e]=255&t;++i<n&&(o*=256);)this[e+i]=t/o&255;return e+n},Be.prototype.writeUIntBE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||sn(this,t,e,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+n},Be.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||sn(this,t,e,1,255,0),Be.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},Be.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||sn(this,t,e,2,65535,0),Be.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):un(this,t,e,!0),e+2},Be.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||sn(this,t,e,2,65535,0),Be.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):un(this,t,e,!1),e+2},Be.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||sn(this,t,e,4,4294967295,0),Be.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):cn(this,t,e,!0),e+4},Be.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||sn(this,t,e,4,4294967295,0),Be.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):cn(this,t,e,!1),e+4},Be.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var o=Math.pow(2,8*n-1);sn(this,t,e,n,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i<n&&(a*=256);)0>t&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+n},Be.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var o=Math.pow(2,8*n-1);sn(this,t,e,n,o-1,-o)}var i=n-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)0>t&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+n},Be.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||sn(this,t,e,1,127,-128),Be.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=255&t,e+1},Be.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||sn(this,t,e,2,32767,-32768),Be.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):un(this,t,e,!0),e+2},Be.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||sn(this,t,e,2,32767,-32768),Be.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):un(this,t,e,!1),e+2},Be.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||sn(this,t,e,4,2147483647,-2147483648),Be.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):cn(this,t,e,!0),e+4},Be.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||sn(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),Be.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):cn(this,t,e,!1),e+4},Be.prototype.writeFloatLE=function(t,e,n){return fn(this,t,e,!0,n)},Be.prototype.writeFloatBE=function(t,e,n){return fn(this,t,e,!1,n)},Be.prototype.writeDoubleLE=function(t,e,n){return pn(this,t,e,!0,n)},Be.prototype.writeDoubleBE=function(t,e,n){return pn(this,t,e,!1,n)},Be.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),t.length>e||(e=t.length),e||(e=0),r>0&&n>r&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>n||n>=this.length)throw new RangeError("sourceStart out of bounds");if(0>r)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),r-n>t.length-e&&(r=t.length-e+n);var o,i=r-n;if(this===t&&e>n&&r>e)for(o=i-1;o>=0;--o)t[o+e]=this[o+n];else if(1e3>i||!Be.TYPED_ARRAY_SUPPORT)for(o=0;i>o;++o)t[o+e]=this[o+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+i),e);return i},Be.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===t.length){var o=t.charCodeAt(0);256>o&&(t=o)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!Be.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof t&&(t&=255);if(0>e||e>this.length||n>this.length)throw new RangeError("Out of range index");if(e>=n)return this;var i;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(i=e;n>i;++i)this[i]=t;else{var a=qe(t)?t:vn(""+new Be(t,r)),s=a.length;for(i=0;n-e>i;++i)this[i+e]=a[i%s]}return this};var ln=/[^+\/0-9A-Za-z-_]/g;function dn(t){return 16>t?"0"+t.toString(16):t.toString(16)}function vn(t,e){var n;e=e||1/0;for(var r=t.length,o=null,i=[],a=0;r>a;++a){if((n=t.charCodeAt(a))>55295&&57344>n){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(56320>n){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,128>n){if(0>(e-=1))break;i.push(n)}else if(2048>n){if(0>(e-=2))break;i.push(n>>6|192,63&n|128)}else if(65536>n){if(0>(e-=3))break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(n>=1114112)throw Error("Invalid code point");if(0>(e-=4))break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function mn(t){return function(t){var e,n,r,o,i,a;Re||_e();var s=t.length;if(s%4>0)throw Error("Invalid string. Length must be a multiple of 4");a=new Ae(3*s/4-(i="="===t[s-2]?2:"="===t[s-1]?1:0)),r=i>0?s-4:s;var u=0;for(e=0,n=0;r>e;e+=4,n+=3)o=Se[t.charCodeAt(e)]<<18|Se[t.charCodeAt(e+1)]<<12|Se[t.charCodeAt(e+2)]<<6|Se[t.charCodeAt(e+3)],a[u++]=o>>16&255,a[u++]=o>>8&255,a[u++]=255&o;return 2===i?(o=Se[t.charCodeAt(e)]<<2|Se[t.charCodeAt(e+1)]>>4,a[u++]=255&o):1===i&&(o=Se[t.charCodeAt(e)]<<10|Se[t.charCodeAt(e+1)]<<4|Se[t.charCodeAt(e+2)]>>2,a[u++]=o>>8&255,a[u++]=255&o),a}(function(t){if(2>(t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(ln,"")).length)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function gn(t,e,n,r){for(var o=0;r>o&&(o+n<e.length&&o<t.length);++o)e[o+n]=t[o];return o}function yn(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}function wn(t){return null===t}function En(t){return"string"==typeof t}function In(t){return"object"==typeof t&&null!==t}function bn(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var Sn=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function An(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}}function Rn(t,e){if(t.map)return t.map(e);for(var n=[],r=0;t.length>r;r++)n.push(e(t[r],r));return n}var _n=Object.keys||function(t){var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.push(n);return e};function kn(t,e,n,r){n=n||"=";var o={};if("string"!=typeof t||0===t.length)return o;var i=/\+/g;t=t.split(e=e||"&");var a=1e3;r&&"number"==typeof r.maxKeys&&(a=r.maxKeys);var s=t.length;a>0&&s>a&&(s=a);for(var u=0;s>u;++u){var c,h,f,p,l=t[u].replace(i,"%20"),d=l.indexOf(n);0>d?(c=l,h=""):(c=l.substr(0,d),h=l.substr(d+1)),f=decodeURIComponent(c),p=decodeURIComponent(h),bn(o,f)?Sn(o[f])?o[f].push(p):o[f]=[o[f],p]:o[f]=p}return o}var Tn={parse:zn,resolve:function(t,e){return zn(t,!1,!0).resolve(e)},resolveObject:function(t,e){return t?zn(t,!1,!0).resolveObject(e):e},format:function(t){En(t)&&(t=Kn({},t));return Hn(t)},Url:On};function On(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var Pn=/^([a-z0-9.+-]+:)/i,Cn=/:[0-9]*$/,Nn=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Un=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),xn=["'"].concat(Un),Bn=["%","/","?",";","#"].concat(xn),Ln=["/","?","#"],Mn=255,jn=/^[+a-z0-9A-Z_-]{0,63}$/,Dn=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Yn={javascript:!0,"javascript:":!0},qn={javascript:!0,"javascript:":!0},Fn={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function zn(t,e,n){if(t&&In(t)&&t instanceof On)return t;var r=new On;return r.parse(t,e,n),r}function Kn(t,e,n,r){if(!En(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),i=-1!==o&&o<e.indexOf("#")?"?":"#",a=e.split(i);a[0]=a[0].replace(/\\/g,"/");var s=e=a.join(i);if(s=s.trim(),!r&&1===e.split("#").length){var u=Nn.exec(s);if(u)return t.path=s,t.href=s,t.pathname=u[1],u[2]?(t.search=u[2],t.query=n?kn(t.search.substr(1)):t.search.substr(1)):n&&(t.search="",t.query={}),t}var c,h,f,p=Pn.exec(s);if(p){var l=(p=p[0]).toLowerCase();t.protocol=l,s=s.substr(p.length)}if(r||p||s.match(/^\/\/[^@\/]+@[^@\/]+/)){var d="//"===s.substr(0,2);!d||p&&qn[p]||(s=s.substr(2),t.slashes=!0)}if(!qn[p]&&(d||p&&!Fn[p])){var v,m,g=-1;for(c=0;Ln.length>c;c++)-1===(h=s.indexOf(Ln[c]))||-1!==g&&h>=g||(g=h);for(-1!==(m=-1===g?s.lastIndexOf("@"):s.lastIndexOf("@",g))&&(v=s.slice(0,m),s=s.slice(m+1),t.auth=decodeURIComponent(v)),g=-1,c=0;Bn.length>c;c++)-1===(h=s.indexOf(Bn[c]))||-1!==g&&h>=g||(g=h);-1===g&&(g=s.length),t.host=s.slice(0,g),s=s.slice(g),Vn(t),t.hostname=t.hostname||"";var y="["===t.hostname[0]&&"]"===t.hostname[t.hostname.length-1];if(!y){var w=t.hostname.split(/\./);for(c=0,f=w.length;f>c;c++){var E=w[c];if(E&&!E.match(jn)){for(var I="",b=0,S=E.length;S>b;b++)E.charCodeAt(b)>127?I+="x":I+=E[b];if(!I.match(jn)){var A=w.slice(0,c),R=w.slice(c+1),_=E.match(Dn);_&&(A.push(_[1]),R.unshift(_[2])),R.length&&(s="/"+R.join(".")+s),t.hostname=A.join(".");break}}}}t.hostname=t.hostname.length>Mn?"":t.hostname.toLowerCase(),y||(t.hostname=Ie(t.hostname)),t.host=(t.hostname||"")+(t.port?":"+t.port:""),t.href+=t.host,y&&(t.hostname=t.hostname.substr(1,t.hostname.length-2),"/"!==s[0]&&(s="/"+s))}if(!Yn[l])for(c=0,f=xn.length;f>c;c++){var k=xn[c];if(-1!==s.indexOf(k)){var T=encodeURIComponent(k);T===k&&(T=escape(k)),s=s.split(k).join(T)}}var O=s.indexOf("#");-1!==O&&(t.hash=s.substr(O),s=s.slice(0,O));var P=s.indexOf("?");(-1!==P?(t.search=s.substr(P),t.query=s.substr(P+1),n&&(t.query=kn(t.query)),s=s.slice(0,P)):n&&(t.search="",t.query={}),s&&(t.pathname=s),Fn[l]&&t.hostname&&!t.pathname&&(t.pathname="/"),t.pathname||t.search)&&(t.path=(t.pathname||"")+(t.search||""));return t.href=Hn(t),t}function Hn(t){var e=t.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var n,r,o,i,a=t.protocol||"",s=t.pathname||"",u=t.hash||"",c=!1,h="";t.host?c=e+t.host:t.hostname&&(c=e+(-1===t.hostname.indexOf(":")?t.hostname:"["+this.hostname+"]"),t.port&&(c+=":"+t.port)),t.query&&In(t.query)&&Object.keys(t.query).length&&(r=r||"&",o=o||"=",null===(n=t.query)&&(n=void 0),h="object"==typeof n?Rn(_n(n),function(t){var e=encodeURIComponent(An(t))+o;return Sn(n[t])?Rn(n[t],function(t){return e+encodeURIComponent(An(t))}).join(r):e+encodeURIComponent(An(n[t]))}).join(r):i?encodeURIComponent(An(i))+o+encodeURIComponent(An(n)):"");var f=t.search||h&&"?"+h||"";return a&&":"!==a.substr(-1)&&(a+=":"),t.slashes||(!a||Fn[a])&&!1!==c?(c="//"+(c||""),s&&"/"!==s.charAt(0)&&(s="/"+s)):c||(c=""),u&&"#"!==u.charAt(0)&&(u="#"+u),f&&"?"!==f.charAt(0)&&(f="?"+f),a+c+(s=s.replace(/[?#]/g,function(t){return encodeURIComponent(t)}))+(f=f.replace("#","%23"))+u}function Vn(t){var e=t.host,n=Cn.exec(e);n&&(":"!==(n=n[0])&&(t.port=n.substr(1)),e=e.substr(0,e.length-n.length)),e&&(t.hostname=e)}On.prototype.parse=function(t,e,n){return Kn(this,t,e,n)},On.prototype.format=function(){return Hn(this)},On.prototype.resolve=function(t){return this.resolveObject(zn(t,!1,!0)).format()},On.prototype.resolveObject=function(t){if(En(t)){var e=new On;e.parse(t,!1,!0),t=e}for(var n,r=new On,o=Object.keys(this),i=0;o.length>i;i++){var a=o[i];r[a]=this[a]}if(r.hash=t.hash,""===t.href)return r.href=r.format(),r;if(t.slashes&&!t.protocol){for(var s=Object.keys(t),u=0;s.length>u;u++){var c=s[u];"protocol"!==c&&(r[c]=t[c])}return Fn[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r}if(t.protocol&&t.protocol!==r.protocol){if(!Fn[t.protocol]){for(var h=Object.keys(t),f=0;h.length>f;f++){var p=h[f];r[p]=t[p]}return r.href=r.format(),r}if(r.protocol=t.protocol,t.host||qn[t.protocol])r.pathname=t.pathname;else{for(n=(t.pathname||"").split("/");n.length&&!(t.host=n.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==n[0]&&n.unshift(""),2>n.length&&n.unshift(""),r.pathname=n.join("/")}if(r.search=t.search,r.query=t.query,r.host=t.host||"",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search)r.path=(r.pathname||"")+(r.search||"");return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var l,d=r.pathname&&"/"===r.pathname.charAt(0),v=t.host||t.pathname&&"/"===t.pathname.charAt(0),m=v||d||r.host&&t.pathname,g=m,y=r.pathname&&r.pathname.split("/")||[],w=r.protocol&&!Fn[r.protocol];if(n=t.pathname&&t.pathname.split("/")||[],w&&(r.hostname="",r.port=null,r.host&&(""===y[0]?y[0]=r.host:y.unshift(r.host)),r.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===n[0]?n[0]=t.host:n.unshift(t.host)),t.host=null),m=m&&(""===n[0]||""===y[0])),v)r.host=t.host||""===t.host?t.host:r.host,r.hostname=t.hostname||""===t.hostname?t.hostname:r.hostname,r.search=t.search,r.query=t.query,y=n;else if(n.length)y||(y=[]),y.pop(),y=y.concat(n),r.search=t.search,r.query=t.query;else if(null!=t.search)return w&&(r.hostname=r.host=y.shift(),(l=!(!r.host||0>=r.host.indexOf("@"))&&r.host.split("@"))&&(r.auth=l.shift(),r.host=r.hostname=l.shift())),r.search=t.search,r.query=t.query,wn(r.pathname)&&wn(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r;if(!y.length)return r.pathname=null,r.path=r.search?"/"+r.search:null,r.href=r.format(),r;for(var E=y.slice(-1)[0],I=(r.host||t.host||y.length>1)&&("."===E||".."===E)||""===E,b=0,S=y.length;S>=0;S--)"."===(E=y[S])?y.splice(S,1):".."===E?(y.splice(S,1),b++):b&&(y.splice(S,1),b--);if(!m&&!g)for(;b--;b)y.unshift("..");!m||""===y[0]||y[0]&&"/"===y[0].charAt(0)||y.unshift(""),I&&"/"!==y.join("/").substr(-1)&&y.push("");var A=""===y[0]||y[0]&&"/"===y[0].charAt(0);return w&&(r.hostname=r.host=A?"":y.length?y.shift():"",(l=!(!r.host||0>=r.host.indexOf("@"))&&r.host.split("@"))&&(r.auth=l.shift(),r.host=r.hostname=l.shift())),(m=m||r.host&&y.length)&&!A&&y.unshift(""),y.length?r.pathname=y.join("/"):(r.pathname=null,r.path=null),wn(r.pathname)&&wn(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},On.prototype.parseHost=function(){return Vn(this)};var Jn=function(t){var e=Tn.parse(t);return{host:e.hostname,path:e.pathname}},Xn=l.Some,Zn=l.None;function $n(t){return"1"===t||"true"===t}function Gn(t){try{return new Xn(parseInt(t))}catch(t){return Zn}}function Qn(t){throw Error("HttpServerInstrumentation: Missing required argument ".concat(t,"."))}var Wn={addZipkinHeaders:function(t,e){var n=function(t,e){var n=t.headers||{};return n[Xt.TraceId]=e.traceId,n[Xt.SpanId]=e.spanId,e.parentSpanId.ifPresent(function(t){n[Xt.ParentSpanId]=t}),e.sampled.ifPresent(function(t){n[Xt.Sampled]=t?"1":"0"}),e.isDebug()&&(n[Xt.Flags]="1"),n}(t,e);return Object.assign({},t,{headers:n})}};var tr={HttpServer:function(){function t(e){var r=e.tracer,o=void 0===r?Qn("tracer"):r,i=e.serviceName,a=void 0===i?o.localEndpoint.serviceName:i,s=e.host,u=e.port,c=void 0===u?Qn("port"):u;n(this,t),this.tracer=o,this.serviceName=a,this.host=s&&new X(s),this.port=c}return o(t,[{key:"_createIdFromHeaders",value:function(t){if(function(t){return t(Xt.TraceId)!==Zn&&t(Xt.SpanId)!==Zn}(t)){var e=t(Xt.SpanId).map(function(e){var n=t(Xt.TraceId),r=t(Xt.ParentSpanId),o=t(Xt.Sampled),i=t(Xt.Flags).flatMap(Gn).getOrElse(0);return new Ot({traceId:n.getOrElse(),parentId:r,spanId:e,debug:1===i,sampled:o.map($n)})});return new Xn(this.tracer.join(e.getOrElse()))}if(t(Xt.Flags)!==Zn||t(Xt.Sampled)!==Zn){var n=t(Xt.Sampled)===Zn?Zn:t(Xt.Sampled).map($n),r=t(Xt.Flags).flatMap(Gn).getOrElse(0);return new Xn(this.tracer.createRootId(n,1===r))}return new Xn(this.tracer.createRootId())}},{key:"spanNameFromRoute",value:function(t,e,n){return n>299&&400>n?"".concat(t," redirected"):404===n?"".concat(t," not_found"):e&&""!==e?"".concat(t," ").concat(e):t}},{key:"recordRequest",value:function(t,e,n){var r=this;this._createIdFromHeaders(n).ifPresent(function(t){return r.tracer.setId(t)});var o=this.tracer.id,i=Jn(e).path;return this.tracer.recordServiceName(this.serviceName),this.tracer.recordRpc(t.toUpperCase()),this.tracer.recordBinary("http.path",i),this.tracer.recordAnnotation(new vt.ServerRecv),this.tracer.recordAnnotation(new vt.LocalAddr({host:this.host,port:this.port})),o}},{key:"recordResponse",value:function(t,e,n){this.tracer.setId(t),this.tracer.recordBinary("http.status_code",""+e),n?this.tracer.recordBinary("error",""+n):(200>e||e>399)&&this.tracer.recordBinary("error",""+e),this.tracer.recordAnnotation(new vt.ServerSend)}}]),t}(),HttpClient:function(){function t(e){var r=e.tracer,o=void 0===r?function(t){throw Error("HttpClientInstrumentation: Missing required argument ".concat(t,"."))}("tracer"):r,i=e.serviceName,a=void 0===i?o.localEndpoint.serviceName:i,s=e.remoteServiceName;n(this,t),this.tracer=o,this.serviceName=a,this.remoteServiceName=s}return o(t,[{key:"recordRequest",value:function(t,e,n){this.tracer.setId(this.tracer.createChildId());var r=this.tracer.id,o=Jn(e).path;return this.tracer.recordServiceName(this.serviceName),this.tracer.recordRpc(n.toUpperCase()),this.tracer.recordBinary("http.path",o),this.tracer.recordAnnotation(new vt.ClientSend),this.remoteServiceName&&this.tracer.recordAnnotation(new vt.ServerAddr({serviceName:this.remoteServiceName})),Wn.addZipkinHeaders(t,r)}},{key:"recordResponse",value:function(t,e){this.tracer.setId(t),this.tracer.recordBinary("http.status_code",""+e),(200>e||e>399)&&this.tracer.recordBinary("error",""+e),this.tracer.recordAnnotation(new vt.ClientRecv)}},{key:"recordError",value:function(t,e){this.tracer.setId(t),this.tracer.recordBinary("error",""+e),this.tracer.recordAnnotation(new vt.ClientRecv)}}]),t}()};function er(t){if(void 0!==t){var e={serviceName:t.serviceName||""};return t.ipv4&&(e.ipv4=t.ipv4),t.port&&(e.port=t.port),e}}var nr={JSON_V1:{encode:function(t){return function(t){var e={traceId:t.traceId};t.parentId&&(e.parentId=t.parentId),e.id=t.id,e.name=t.name||"",t.shared||(e.timestamp=t.timestamp,e.duration=t.duration);var n,r,o,i=er(t.localEndpoint);switch(t.kind){case"CLIENT":n=t.timestamp?"cs":void 0,r="cr",o="sa";break;case"SERVER":n=t.timestamp?"sr":void 0,r="ss",o="ca";break;case"PRODUCER":n=t.timestamp?"ms":void 0,r="ws",o="ma";break;case"CONSUMER":t.timestamp&&t.duration?(n="wr",r="mr"):t.timestamp&&(n="mr"),o="ma"}(t.annotations.length>0||n)&&(e.annotations=t.annotations.map(function(t){return function(t,e){return{value:t.value,timestamp:t.timestamp,endpoint:e}}(t,i)})),n&&(e.annotations.push({value:n,timestamp:t.timestamp,endpoint:i}),t.duration&&e.annotations.push({value:r,timestamp:t.timestamp+t.duration,endpoint:i}));var a=Object.keys(t.tags);if((a.length>0||t.remoteEndpoint)&&(e.binaryAnnotations=a.map(function(e){return{key:e,value:t.tags[e],endpoint:i}})),t.remoteEndpoint){var s={key:o,value:!0,endpoint:er(t.remoteEndpoint)};e.binaryAnnotations.push(s)}return t.debug&&(e.debug=!0),JSON.stringify(e)}(t)}},JSON_V2:{encode:function(t){return function(t){var e={traceId:t.traceId};return t.parentId&&(e.parentId=t.parentId),e.id=t.id,t.name&&(e.name=t.name),t.kind&&(e.kind=t.kind),t.timestamp&&(e.timestamp=t.timestamp),t.duration&&(e.duration=t.duration),t.localEndpoint&&(e.localEndpoint=t.localEndpoint),t.remoteEndpoint&&(e.remoteEndpoint=t.remoteEndpoint),t.annotations.length>0&&(e.annotations=t.annotations),Object.keys(t.tags).length>0&&(e.tags=t.tags),t.debug&&(e.debug=!0),t.shared&&(e.shared=!0),JSON.stringify(e)}(t)}}};t.option=l,t.Annotation=vt,t.Tracer=Vt,t.createNoopTracer=function(){var t=new Jt;return new Vt({recorder:{record:function(){}},ctxImpl:t})},t.randomTraceId=Pt,t.sampler=bt,t.TraceId=Ot,t.HttpHeaders=Xt,t.InetAddress=X,t.BatchRecorder=ee,t.ConsoleRecorder=ne,t.ExplicitContext=Jt,t.Instrumentation=tr,t.Request=Wn,t.jsonEncoder=nr,t.model=Lt,t.parseRequestUrl=Jn,Object.defineProperty(t,"__esModule",{value:!0})}); |
166
es/index.js
@@ -73,2 +73,15 @@ import os from 'os'; | ||
function _isNativeReflectConstruct() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
function _assertThisInitialized(self) { | ||
@@ -90,2 +103,21 @@ if (self === void 0) { | ||
function _createSuper(Derived) { | ||
var hasNativeReflectConstruct = _isNativeReflectConstruct(); | ||
return function () { | ||
var Super = _getPrototypeOf(Derived), | ||
result; | ||
if (hasNativeReflectConstruct) { | ||
var NewTarget = _getPrototypeOf(this).constructor; | ||
result = Reflect.construct(Super, arguments, NewTarget); | ||
} else { | ||
result = Super.apply(this, arguments); | ||
} | ||
return _possibleConstructorReturn(this, result); | ||
}; | ||
} | ||
var None = { | ||
@@ -118,5 +150,3 @@ get type() { | ||
var Some = | ||
/*#__PURE__*/ | ||
function () { | ||
var Some = /*#__PURE__*/function () { | ||
function Some(value) { | ||
@@ -261,5 +291,3 @@ _classCallCheck(this, Some); | ||
var InetAddress = | ||
/*#__PURE__*/ | ||
function () { | ||
var InetAddress = /*#__PURE__*/function () { | ||
function InetAddress(addr) { | ||
@@ -330,5 +358,3 @@ _classCallCheck(this, InetAddress); | ||
var SimpleAnnotation = | ||
/*#__PURE__*/ | ||
function () { | ||
var SimpleAnnotation = /*#__PURE__*/function () { | ||
function SimpleAnnotation() { | ||
@@ -348,11 +374,11 @@ _classCallCheck(this, SimpleAnnotation); | ||
var ClientSend = | ||
/*#__PURE__*/ | ||
function (_SimpleAnnotation) { | ||
var ClientSend = /*#__PURE__*/function (_SimpleAnnotation) { | ||
_inherits(ClientSend, _SimpleAnnotation); | ||
var _super = _createSuper(ClientSend); | ||
function ClientSend() { | ||
_classCallCheck(this, ClientSend); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(ClientSend).apply(this, arguments)); | ||
return _super.apply(this, arguments); | ||
} | ||
@@ -363,11 +389,11 @@ | ||
var ClientRecv = | ||
/*#__PURE__*/ | ||
function (_SimpleAnnotation2) { | ||
var ClientRecv = /*#__PURE__*/function (_SimpleAnnotation2) { | ||
_inherits(ClientRecv, _SimpleAnnotation2); | ||
var _super2 = _createSuper(ClientRecv); | ||
function ClientRecv() { | ||
_classCallCheck(this, ClientRecv); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(ClientRecv).apply(this, arguments)); | ||
return _super2.apply(this, arguments); | ||
} | ||
@@ -378,11 +404,11 @@ | ||
var ServerSend = | ||
/*#__PURE__*/ | ||
function (_SimpleAnnotation3) { | ||
var ServerSend = /*#__PURE__*/function (_SimpleAnnotation3) { | ||
_inherits(ServerSend, _SimpleAnnotation3); | ||
var _super3 = _createSuper(ServerSend); | ||
function ServerSend() { | ||
_classCallCheck(this, ServerSend); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(ServerSend).apply(this, arguments)); | ||
return _super3.apply(this, arguments); | ||
} | ||
@@ -393,11 +419,11 @@ | ||
var ServerRecv = | ||
/*#__PURE__*/ | ||
function (_SimpleAnnotation4) { | ||
var ServerRecv = /*#__PURE__*/function (_SimpleAnnotation4) { | ||
_inherits(ServerRecv, _SimpleAnnotation4); | ||
var _super4 = _createSuper(ServerRecv); | ||
function ServerRecv() { | ||
_classCallCheck(this, ServerRecv); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(ServerRecv).apply(this, arguments)); | ||
return _super4.apply(this, arguments); | ||
} | ||
@@ -408,11 +434,11 @@ | ||
var ProducerStart = | ||
/*#__PURE__*/ | ||
function (_SimpleAnnotation5) { | ||
var ProducerStart = /*#__PURE__*/function (_SimpleAnnotation5) { | ||
_inherits(ProducerStart, _SimpleAnnotation5); | ||
var _super5 = _createSuper(ProducerStart); | ||
function ProducerStart() { | ||
_classCallCheck(this, ProducerStart); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(ProducerStart).apply(this, arguments)); | ||
return _super5.apply(this, arguments); | ||
} | ||
@@ -423,11 +449,11 @@ | ||
var ProducerStop = | ||
/*#__PURE__*/ | ||
function (_SimpleAnnotation6) { | ||
var ProducerStop = /*#__PURE__*/function (_SimpleAnnotation6) { | ||
_inherits(ProducerStop, _SimpleAnnotation6); | ||
var _super6 = _createSuper(ProducerStop); | ||
function ProducerStop() { | ||
_classCallCheck(this, ProducerStop); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(ProducerStop).apply(this, arguments)); | ||
return _super6.apply(this, arguments); | ||
} | ||
@@ -438,11 +464,11 @@ | ||
var ConsumerStart = | ||
/*#__PURE__*/ | ||
function (_SimpleAnnotation7) { | ||
var ConsumerStart = /*#__PURE__*/function (_SimpleAnnotation7) { | ||
_inherits(ConsumerStart, _SimpleAnnotation7); | ||
var _super7 = _createSuper(ConsumerStart); | ||
function ConsumerStart() { | ||
_classCallCheck(this, ConsumerStart); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(ConsumerStart).apply(this, arguments)); | ||
return _super7.apply(this, arguments); | ||
} | ||
@@ -453,11 +479,11 @@ | ||
var ConsumerStop = | ||
/*#__PURE__*/ | ||
function (_SimpleAnnotation8) { | ||
var ConsumerStop = /*#__PURE__*/function (_SimpleAnnotation8) { | ||
_inherits(ConsumerStop, _SimpleAnnotation8); | ||
var _super8 = _createSuper(ConsumerStop); | ||
function ConsumerStop() { | ||
_classCallCheck(this, ConsumerStop); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(ConsumerStop).apply(this, arguments)); | ||
return _super8.apply(this, arguments); | ||
} | ||
@@ -476,11 +502,11 @@ | ||
var LocalOperationStop = | ||
/*#__PURE__*/ | ||
function (_SimpleAnnotation9) { | ||
var LocalOperationStop = /*#__PURE__*/function (_SimpleAnnotation9) { | ||
_inherits(LocalOperationStop, _SimpleAnnotation9); | ||
var _super9 = _createSuper(LocalOperationStop); | ||
function LocalOperationStop() { | ||
_classCallCheck(this, LocalOperationStop); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(LocalOperationStop).apply(this, arguments)); | ||
return _super9.apply(this, arguments); | ||
} | ||
@@ -598,2 +624,3 @@ | ||
var isPromise_1 = isPromise; | ||
var default_1 = isPromise; | ||
@@ -603,2 +630,3 @@ function isPromise(obj) { | ||
} | ||
isPromise_1.default = default_1; | ||
@@ -611,5 +639,3 @@ var Some$1 = option.Some; // Determines whether or not a traceId should be sampled. | ||
var Sampler = | ||
/*#__PURE__*/ | ||
function () { | ||
var Sampler = /*#__PURE__*/function () { | ||
function Sampler(evaluator) { | ||
@@ -684,7 +710,7 @@ _classCallCheck(this, Sampler); | ||
var CountingSampler = | ||
/*#__PURE__*/ | ||
function (_Sampler) { | ||
var CountingSampler = /*#__PURE__*/function (_Sampler) { | ||
_inherits(CountingSampler, _Sampler); | ||
var _super = _createSuper(CountingSampler); | ||
function CountingSampler() { | ||
@@ -695,3 +721,3 @@ var sampleRate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; | ||
return _possibleConstructorReturn(this, _getPrototypeOf(CountingSampler).call(this, makeCountingEvaluator(sampleRate < 1 ? sampleRate : 1))); | ||
return _super.call(this, makeCountingEvaluator(sampleRate < 1 ? sampleRate : 1)); | ||
} | ||
@@ -709,5 +735,3 @@ | ||
var Record = | ||
/*#__PURE__*/ | ||
function () { | ||
var Record = /*#__PURE__*/function () { | ||
function Record(_ref) { | ||
@@ -744,5 +768,3 @@ var traceId = _ref.traceId, | ||
var TraceId = | ||
/*#__PURE__*/ | ||
function () { | ||
var TraceId = /*#__PURE__*/function () { | ||
function TraceId(params) { | ||
@@ -1034,5 +1056,3 @@ _classCallCheck(this, TraceId); | ||
var Tracer = | ||
/*#__PURE__*/ | ||
function () { | ||
var Tracer = /*#__PURE__*/function () { | ||
function Tracer(_ref) { | ||
@@ -1320,5 +1340,3 @@ var _ref$ctxImpl = _ref.ctxImpl, | ||
var explicitContext = | ||
/*#__PURE__*/ | ||
function () { | ||
var explicitContext = /*#__PURE__*/function () { | ||
function ExplicitContext() { | ||
@@ -1404,5 +1422,3 @@ _classCallCheck(this, ExplicitContext); | ||
var PartialSpan = | ||
/*#__PURE__*/ | ||
function () { | ||
var PartialSpan = /*#__PURE__*/function () { | ||
/** | ||
@@ -1464,5 +1480,3 @@ * @constructor | ||
var BatchRecorder = | ||
/*#__PURE__*/ | ||
function () { | ||
var BatchRecorder = /*#__PURE__*/function () { | ||
/** | ||
@@ -1719,5 +1733,3 @@ * @constructor | ||
*/ | ||
var ConsoleRecorder = | ||
/*#__PURE__*/ | ||
function () { | ||
var ConsoleRecorder = /*#__PURE__*/function () { | ||
/* eslint-disable no-console */ | ||
@@ -1787,5 +1799,3 @@ function ConsoleRecorder() { | ||
var HttpServerInstrumentation = | ||
/*#__PURE__*/ | ||
function () { | ||
var HttpServerInstrumentation = /*#__PURE__*/function () { | ||
function HttpServerInstrumentation(_ref) { | ||
@@ -1922,5 +1932,3 @@ var _ref$tracer = _ref.tracer, | ||
var HttpClientInstrumentation = | ||
/*#__PURE__*/ | ||
function () { | ||
var HttpClientInstrumentation = /*#__PURE__*/function () { | ||
function HttpClientInstrumentation(_ref) { | ||
@@ -1927,0 +1935,0 @@ var _ref$tracer = _ref.tracer, |
166
lib/index.js
@@ -79,2 +79,15 @@ 'use strict'; | ||
function _isNativeReflectConstruct() { | ||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (Reflect.construct.sham) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
function _assertThisInitialized(self) { | ||
@@ -96,2 +109,21 @@ if (self === void 0) { | ||
function _createSuper(Derived) { | ||
var hasNativeReflectConstruct = _isNativeReflectConstruct(); | ||
return function () { | ||
var Super = _getPrototypeOf(Derived), | ||
result; | ||
if (hasNativeReflectConstruct) { | ||
var NewTarget = _getPrototypeOf(this).constructor; | ||
result = Reflect.construct(Super, arguments, NewTarget); | ||
} else { | ||
result = Super.apply(this, arguments); | ||
} | ||
return _possibleConstructorReturn(this, result); | ||
}; | ||
} | ||
var None = { | ||
@@ -124,5 +156,3 @@ get type() { | ||
var Some = | ||
/*#__PURE__*/ | ||
function () { | ||
var Some = /*#__PURE__*/function () { | ||
function Some(value) { | ||
@@ -267,5 +297,3 @@ _classCallCheck(this, Some); | ||
var InetAddress = | ||
/*#__PURE__*/ | ||
function () { | ||
var InetAddress = /*#__PURE__*/function () { | ||
function InetAddress(addr) { | ||
@@ -336,5 +364,3 @@ _classCallCheck(this, InetAddress); | ||
var SimpleAnnotation = | ||
/*#__PURE__*/ | ||
function () { | ||
var SimpleAnnotation = /*#__PURE__*/function () { | ||
function SimpleAnnotation() { | ||
@@ -354,11 +380,11 @@ _classCallCheck(this, SimpleAnnotation); | ||
var ClientSend = | ||
/*#__PURE__*/ | ||
function (_SimpleAnnotation) { | ||
var ClientSend = /*#__PURE__*/function (_SimpleAnnotation) { | ||
_inherits(ClientSend, _SimpleAnnotation); | ||
var _super = _createSuper(ClientSend); | ||
function ClientSend() { | ||
_classCallCheck(this, ClientSend); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(ClientSend).apply(this, arguments)); | ||
return _super.apply(this, arguments); | ||
} | ||
@@ -369,11 +395,11 @@ | ||
var ClientRecv = | ||
/*#__PURE__*/ | ||
function (_SimpleAnnotation2) { | ||
var ClientRecv = /*#__PURE__*/function (_SimpleAnnotation2) { | ||
_inherits(ClientRecv, _SimpleAnnotation2); | ||
var _super2 = _createSuper(ClientRecv); | ||
function ClientRecv() { | ||
_classCallCheck(this, ClientRecv); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(ClientRecv).apply(this, arguments)); | ||
return _super2.apply(this, arguments); | ||
} | ||
@@ -384,11 +410,11 @@ | ||
var ServerSend = | ||
/*#__PURE__*/ | ||
function (_SimpleAnnotation3) { | ||
var ServerSend = /*#__PURE__*/function (_SimpleAnnotation3) { | ||
_inherits(ServerSend, _SimpleAnnotation3); | ||
var _super3 = _createSuper(ServerSend); | ||
function ServerSend() { | ||
_classCallCheck(this, ServerSend); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(ServerSend).apply(this, arguments)); | ||
return _super3.apply(this, arguments); | ||
} | ||
@@ -399,11 +425,11 @@ | ||
var ServerRecv = | ||
/*#__PURE__*/ | ||
function (_SimpleAnnotation4) { | ||
var ServerRecv = /*#__PURE__*/function (_SimpleAnnotation4) { | ||
_inherits(ServerRecv, _SimpleAnnotation4); | ||
var _super4 = _createSuper(ServerRecv); | ||
function ServerRecv() { | ||
_classCallCheck(this, ServerRecv); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(ServerRecv).apply(this, arguments)); | ||
return _super4.apply(this, arguments); | ||
} | ||
@@ -414,11 +440,11 @@ | ||
var ProducerStart = | ||
/*#__PURE__*/ | ||
function (_SimpleAnnotation5) { | ||
var ProducerStart = /*#__PURE__*/function (_SimpleAnnotation5) { | ||
_inherits(ProducerStart, _SimpleAnnotation5); | ||
var _super5 = _createSuper(ProducerStart); | ||
function ProducerStart() { | ||
_classCallCheck(this, ProducerStart); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(ProducerStart).apply(this, arguments)); | ||
return _super5.apply(this, arguments); | ||
} | ||
@@ -429,11 +455,11 @@ | ||
var ProducerStop = | ||
/*#__PURE__*/ | ||
function (_SimpleAnnotation6) { | ||
var ProducerStop = /*#__PURE__*/function (_SimpleAnnotation6) { | ||
_inherits(ProducerStop, _SimpleAnnotation6); | ||
var _super6 = _createSuper(ProducerStop); | ||
function ProducerStop() { | ||
_classCallCheck(this, ProducerStop); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(ProducerStop).apply(this, arguments)); | ||
return _super6.apply(this, arguments); | ||
} | ||
@@ -444,11 +470,11 @@ | ||
var ConsumerStart = | ||
/*#__PURE__*/ | ||
function (_SimpleAnnotation7) { | ||
var ConsumerStart = /*#__PURE__*/function (_SimpleAnnotation7) { | ||
_inherits(ConsumerStart, _SimpleAnnotation7); | ||
var _super7 = _createSuper(ConsumerStart); | ||
function ConsumerStart() { | ||
_classCallCheck(this, ConsumerStart); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(ConsumerStart).apply(this, arguments)); | ||
return _super7.apply(this, arguments); | ||
} | ||
@@ -459,11 +485,11 @@ | ||
var ConsumerStop = | ||
/*#__PURE__*/ | ||
function (_SimpleAnnotation8) { | ||
var ConsumerStop = /*#__PURE__*/function (_SimpleAnnotation8) { | ||
_inherits(ConsumerStop, _SimpleAnnotation8); | ||
var _super8 = _createSuper(ConsumerStop); | ||
function ConsumerStop() { | ||
_classCallCheck(this, ConsumerStop); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(ConsumerStop).apply(this, arguments)); | ||
return _super8.apply(this, arguments); | ||
} | ||
@@ -482,11 +508,11 @@ | ||
var LocalOperationStop = | ||
/*#__PURE__*/ | ||
function (_SimpleAnnotation9) { | ||
var LocalOperationStop = /*#__PURE__*/function (_SimpleAnnotation9) { | ||
_inherits(LocalOperationStop, _SimpleAnnotation9); | ||
var _super9 = _createSuper(LocalOperationStop); | ||
function LocalOperationStop() { | ||
_classCallCheck(this, LocalOperationStop); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(LocalOperationStop).apply(this, arguments)); | ||
return _super9.apply(this, arguments); | ||
} | ||
@@ -604,2 +630,3 @@ | ||
var isPromise_1 = isPromise; | ||
var default_1 = isPromise; | ||
@@ -609,2 +636,3 @@ function isPromise(obj) { | ||
} | ||
isPromise_1.default = default_1; | ||
@@ -617,5 +645,3 @@ var Some$1 = option.Some; // Determines whether or not a traceId should be sampled. | ||
var Sampler = | ||
/*#__PURE__*/ | ||
function () { | ||
var Sampler = /*#__PURE__*/function () { | ||
function Sampler(evaluator) { | ||
@@ -690,7 +716,7 @@ _classCallCheck(this, Sampler); | ||
var CountingSampler = | ||
/*#__PURE__*/ | ||
function (_Sampler) { | ||
var CountingSampler = /*#__PURE__*/function (_Sampler) { | ||
_inherits(CountingSampler, _Sampler); | ||
var _super = _createSuper(CountingSampler); | ||
function CountingSampler() { | ||
@@ -701,3 +727,3 @@ var sampleRate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; | ||
return _possibleConstructorReturn(this, _getPrototypeOf(CountingSampler).call(this, makeCountingEvaluator(sampleRate < 1 ? sampleRate : 1))); | ||
return _super.call(this, makeCountingEvaluator(sampleRate < 1 ? sampleRate : 1)); | ||
} | ||
@@ -715,5 +741,3 @@ | ||
var Record = | ||
/*#__PURE__*/ | ||
function () { | ||
var Record = /*#__PURE__*/function () { | ||
function Record(_ref) { | ||
@@ -750,5 +774,3 @@ var traceId = _ref.traceId, | ||
var TraceId = | ||
/*#__PURE__*/ | ||
function () { | ||
var TraceId = /*#__PURE__*/function () { | ||
function TraceId(params) { | ||
@@ -1040,5 +1062,3 @@ _classCallCheck(this, TraceId); | ||
var Tracer = | ||
/*#__PURE__*/ | ||
function () { | ||
var Tracer = /*#__PURE__*/function () { | ||
function Tracer(_ref) { | ||
@@ -1326,5 +1346,3 @@ var _ref$ctxImpl = _ref.ctxImpl, | ||
var explicitContext = | ||
/*#__PURE__*/ | ||
function () { | ||
var explicitContext = /*#__PURE__*/function () { | ||
function ExplicitContext() { | ||
@@ -1410,5 +1428,3 @@ _classCallCheck(this, ExplicitContext); | ||
var PartialSpan = | ||
/*#__PURE__*/ | ||
function () { | ||
var PartialSpan = /*#__PURE__*/function () { | ||
/** | ||
@@ -1470,5 +1486,3 @@ * @constructor | ||
var BatchRecorder = | ||
/*#__PURE__*/ | ||
function () { | ||
var BatchRecorder = /*#__PURE__*/function () { | ||
/** | ||
@@ -1725,5 +1739,3 @@ * @constructor | ||
*/ | ||
var ConsoleRecorder = | ||
/*#__PURE__*/ | ||
function () { | ||
var ConsoleRecorder = /*#__PURE__*/function () { | ||
/* eslint-disable no-console */ | ||
@@ -1793,5 +1805,3 @@ function ConsoleRecorder() { | ||
var HttpServerInstrumentation = | ||
/*#__PURE__*/ | ||
function () { | ||
var HttpServerInstrumentation = /*#__PURE__*/function () { | ||
function HttpServerInstrumentation(_ref) { | ||
@@ -1928,5 +1938,3 @@ var _ref$tracer = _ref.tracer, | ||
var HttpClientInstrumentation = | ||
/*#__PURE__*/ | ||
function () { | ||
var HttpClientInstrumentation = /*#__PURE__*/function () { | ||
function HttpClientInstrumentation(_ref) { | ||
@@ -1933,0 +1941,0 @@ var _ref$tracer = _ref.tracer, |
{ | ||
"name": "zipkin", | ||
"version": "0.21.0", | ||
"version": "0.22.0", | ||
"description": "The core tracer for Zipkin JS", | ||
@@ -23,3 +23,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "324702a96c7e378143be861c8eafcc6cea7f00ac" | ||
"gitHead": "bc590b2957b4c1e0c434de3c6fb7b4feeb406f8b" | ||
} |
@@ -24,4 +24,4 @@ # zipkin | ||
const tracer = new zipkin.Tracer({ | ||
ctxImpl, | ||
recorder: new zipkin.ConsoleRecorder(), // For easy debugging. You probably want to use an actual implementation, like Kafka or Scribe. | ||
ctxImpl, // the in-process context | ||
recorder: new zipkin.ConsoleRecorder(), // For easy debugging. You probably want to use an actual implementation, like Kafka or AWS SQS. | ||
sampler: new zipkin.sampler.CountingSampler(0.01), // sample rate 0.01 will sample 1 % of all incoming requests | ||
@@ -33,3 +33,13 @@ traceId128Bit: true, // to generate 128-bit trace IDs. 64-bit (false) is default | ||
### In-process context (node only) | ||
The event loop is what allows Node.js to perform non-blocking I/O operations, hence | ||
several operations are happening at the same time and we need a way to correlate different operations that happen at the same time to a specific trace. There are two options for this: explicit and implicit context. | ||
In the **explicit context**, we pass around an object `ctx` from the top layer of the application down to those operations we want to trace. For example, a `ctx` will be handed from the HTTP handler down to the application layer and finally to a HTTP call that queries external resources. | ||
In the **implicit context**, we don't need to pass anything, the in-process context is transparent for the user (see [zipkin-context-cls](pakcages/zipkin-context-cls)). | ||
### Local tracing | ||
Sometimes you have activity that precedes a remote request that you want to | ||
@@ -41,2 +51,3 @@ capture in a trace. `tracer.local` can time an operation, placing a | ||
Here's an example tracing a synchronous function: | ||
```javascript | ||
@@ -50,2 +61,3 @@ // A span representing checkout completes before result is returned | ||
Here's an example tracing a function that returns a promise: | ||
```javascript | ||
@@ -52,0 +64,0 @@ // A span is in progress and completes when the promise is resolved. |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
489745
65
12353