Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zipkin

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zipkin - npm Package Compare versions

Comparing version 0.20.0-alpha.1 to 0.20.0

LICENSE

2

dist/zipkin.min.js

@@ -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}();H.getLocalAddress=function(){return"object"===(void 0===j?"undefined":e(j))&&"function"==typeof j.on?new H(K.ipv4()):new H("127.0.0.1")};var V=H,J=function(){function t(){n(this,t)}return o(t,[{key:"toString",value:function(){return"".concat(this.annotationType,"()")}}]),t}(),X=function(t){function e(){return n(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),Z=function(t){function e(){return n(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),$=function(t){function e(){return n(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),G=function(t){function e(){return n(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),Q=function(t){function e(){return n(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),W=function(t){function e(){return n(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),tt=function(t){function e(){return n(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),et=function(t){function e(){return n(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}();function nt(t){this.name=t}nt.prototype.toString=function(){return'LocalOperationStart("'.concat(this.name,'")')};var rt=function(t){function e(){return n(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}();function ot(t){this.message=t}function it(t){this.serviceName=t}function at(t){this.name=t}function st(t){var e=t.port;this.host=t.host,this.port=e}function ut(t){var e=t.host,n=t.port;this.serviceName=t.serviceName,this.host=e||void 0,this.port=n||0}function ct(t){var e=t.port;this.host=t.host||V.getLocalAddress(),this.port=e||0}function ht(t){var e=t.host,n=t.port;this.serviceName=t.serviceName,this.host=e,this.port=n}function ft(t,e){this.key=t,this.value=e}ot.prototype.toString=function(){return'Message("'.concat(this.message,'")')},it.prototype.toString=function(){return'ServiceName("'.concat(this.serviceName,'")')},at.prototype.toString=function(){return'Rpc("'.concat(this.name,'")')},st.prototype.toString=function(){return'ClientAddr(host="'.concat(this.host,'", port=').concat(this.port,")")},ut.prototype.toString=function(){return'ServerAddr(serviceName="'.concat(this.serviceName,'", host="').concat(this.host,'", port=').concat(this.port,")")},ct.prototype.toString=function(){return'LocalAddr(host="'.concat(""+this.host,'", port=').concat(this.port,")")},ht.prototype.toString=function(){return'MessageAddr(serviceName="'.concat(this.serviceName,'", host="').concat(this.host,'", port=').concat(this.port,")")},ft.prototype.toString=function(){return"BinaryAnnotation(".concat(this.key,'="').concat(this.value,'")')};var pt={ClientSend:X,ClientRecv:Z,ServerSend:$,ServerRecv:G,ProducerStart:Q,ProducerStop:W,ConsumerStart:tt,ConsumerStop:et,MessageAddr:ht,Message:ot,ServiceName:it,Rpc:at,ClientAddr:st,ServerAddr:ut,LocalAddr:ct,BinaryAnnotation:ft,LocalOperationStart:nt,LocalOperationStop:rt};Object.keys(pt).forEach(function(t){pt[t].prototype.annotationType=t});var lt=pt,dt=function(t){return!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then};var vt=p.Some,mt=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 vt(n)}},{key:"toString",value:function(){return"Sampler(".concat(""+this.evaluator,")")}}]),t}();function gt(t){return!1}function yt(t){return!0}gt.toString=function(){return"never sample"},yt.toString=function(){return"always sample"};var wt={Sampler:mt,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 yt}return gt}(1>t?t:1)))}return i(e,mt),e}(),neverSample:gt,alwaysSample:yt},Et=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}(),It=p.None,bt=p.verifyIsOptional,St=p.verifyIsNotOptional,At=p.isOptional,Rt=new(0,p.Some)(!0),_t=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?It: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?It:f,l=e.shared,d=void 0!==l&&l;St(r),bt(s),bt(p),this._traceId=At(i)?i.getOrElse(r):null==i?r:i,this._parentId=s,this._spanId=r,this._sampled=h?Rt: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 kt=function(){for(var t="",e=0;16>e;e+=1)t+="0123456789abcdef"[Math.floor(16*Math.random())];return t},Tt=void 0!==j&&j.hrtime;var Ot={now:Tt?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:Tt?function(){return j.hrtime()}:function(){}};function Ct(t){var e=t.ipv4,n=t.port;this.setServiceName(t.serviceName),this.setIpv4(e),this.setPort(n)}function Pt(t,e){this.timestamp=t,this.value=""+e}function Nt(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()}Ct.prototype.setServiceName=function(t){this.serviceName=t?t.toLocaleLowerCase():void 0},Ct.prototype.setIpv4=function(t){this.ipv4=t},Ct.prototype.setPort=function(t){this.port=t||void 0},Ct.prototype.isEmpty=function(){return void 0===this.serviceName&&void 0===this.ipv4&&void 0===this.port},Pt.prototype.toString=function(){return'Annotation(value="'.concat(this.value,'")')},Nt.prototype.setName=function(t){this.name=t?t.toLocaleLowerCase():void 0},Nt.prototype.setKind=function(t){this.kind=t},Nt.prototype.setTimestamp=function(t){this.timestamp=t},Nt.prototype.setDuration=function(t){void 0!==t&&(this.duration=Math.max(t,1))},Nt.prototype.setLocalEndpoint=function(t){this.localEndpoint=t&&!t.isEmpty()?t:void 0},Nt.prototype.setRemoteEndpoint=function(t){this.remoteEndpoint=t&&!t.isEmpty()?t:void 0},Nt.prototype.addAnnotation=function(t,e){this.annotations.push(new Pt(t,e))},Nt.prototype.putTag=function(t,e){this.tags[t]=""+e},Nt.prototype.setDebug=function(t){this.debug=t},Nt.prototype.setShared=function(t){this.shared=t},Nt.prototype.toString=function(){var t=this.annotations.map(function(t){return""+t}).join(", ");return"Span(id=".concat(this.traceId,", annotations=[").concat(t,"])")};var Ut={Endpoint:Ct,Span:Nt},xt=p.None,Bt=p.Some,Lt=wt.Sampler,Mt=wt.alwaysSample,jt=Ot.now,Dt=Ot.hrtime,Yt=Ut.Endpoint;function qt(t){throw Error("Tracer: Missing required argument ".concat(t,"."))}function Ft(t){return null==t}var zt=function(){function t(e){var r=e.ctxImpl,o=void 0===r?qt("ctxImpl"):r,i=e.recorder,a=void 0===i?qt("recorder"):i,s=e.sampler,u=void 0===s?new Lt(Mt):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 Yt({serviceName:l||"unknown"}),this._ctxImpl=o,this._sentinelTraceId=this.createRootId(),this._startTimestamp=jt(),this._startTick=Dt(),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]:xt,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=kt(),r=this.traceId128Bit?kt()+n:n,o=new _t({traceId:r,parentId:xt,spanId:n,sampled:t,flags:e?1:0});return t===xt&&(o._sampled=this.sampler.shouldSample(o)),o}},{key:"createChildId",value:function(t){if(Ft(t)&&(t=this._ctxImpl.getContext()),t===this._sentinelTraceId||Ft(t))return this.createRootId();var e=new _t({traceId:t.traceId,parentId:new Bt(t.spanId),spanId:kt(),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]:jt(this._startTimestamp,this._startTick);this.recorder.record(new Et({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 lt.LocalOperationStart(t));try{r=e()}catch(t){throw n.recordBinary("error",t.message?t.message:""+t),n.recordAnnotation(new lt.LocalOperationStop),t}return dt(r)?o.sampled.getOrElse(!1)?r.then(function(t){return n._explicitRecord(o,new lt.LocalOperationStop),t}).catch(function(t){throw n._explicitRecord(o,new lt.BinaryAnnotation("error",t.message?t.message:""+t)),n._explicitRecord(o,new lt.LocalOperationStop),t}):r:(n.recordAnnotation(new lt.LocalOperationStop),r)})}},{key:"join",value:function(t){if(Ft(t))throw Error("traceId is a required arg");if(Ft(t._spanId))throw Error("Must be valid TraceId instance");return this.supportsJoin?(t.sampled===xt?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 lt.Message(t))}},{key:"recordServiceName",value:function(t){this.recordAnnotation(new lt.ServiceName(t))}},{key:"recordRpc",value:function(t){this.recordAnnotation(new lt.Rpc(t))}},{key:"recordClientAddr",value:function(t){this.recordAnnotation(new lt.ClientAddr(t))}},{key:"recordServerAddr",value:function(t){this.recordAnnotation(new lt.ServerAddr(t))}},{key:"recordLocalAddr",value:function(t){this.recordAnnotation(new lt.LocalAddr(t))}},{key:"recordBinary",value:function(t,e){this.recordAnnotation(new lt.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}(),Kt=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}(),Ht={TraceId:"X-B3-TraceId",SpanId:"X-B3-SpanId",ParentSpanId:"X-B3-ParentSpanId",Sampled:"X-B3-Sampled",Flags:"X-B3-Flags"},Vt=Ot.now,Jt=Ut.Span,Xt=Ut.Endpoint,Zt=6e7,$t=Symbol("defaultTags");var Gt=function(){function t(e,r){n(this,t),this.traceId=e,this.timeoutTimestamp=r,this.delegate=new Jt(e),this.localEndpoint=new Xt({}),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=function(){function t(e){var r=this,o=e.logger,i=e.timeout,a=void 0===i?Zt: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<Vt()})(t)&&(t.delegate.addAnnotation(Vt(),"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]||"undefined"!==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 Xt({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 Xt({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 Xt({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}(),Wt=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}(),te=2147483647,ee=36,ne=1,re=26,oe=38,ie=700,ae=72,se=128,ue="-",ce=/[^\x20-\x7E]/,he=/[\x2E\u3002\uFF0E\uFF61]/g,fe={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},pe=ee-ne,le=Math.floor,de=String.fromCharCode;function ve(t){throw new RangeError(fe[t])}function me(t,e){return t+22+75*(26>t)-((0!=e)<<5)}function ge(t,e,n){var r=0;for(t=n?le(t/ie):t>>1,t+=le(t/e);t>pe*re>>1;r+=ee)t=le(t/pe);return le(r+(pe+1)*t/(t+oe))}function ye(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(he,".")).split("."),e).join(".");return r+o}(t,function(t){return ce.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=se,n=0,i=ae,a=0;p>a;++a)128>(f=t[a])&&m.push(de(f));for(r=o=m.length,o&&m.push(ue);p>r;){for(s=te,a=0;p>a;++a)(f=t[a])>=e&&s>f&&(s=f);for(s-e>le((te-n)/(l=r+1))&&ve("overflow"),n+=(s-e)*l,e=s,a=0;p>a;++a)if(e>(f=t[a])&&++n>te&&ve("overflow"),f==e){for(u=n,c=ee;(h=c>i?i+re>c?c-i:re:ne)<=u;c+=ee)m.push(de(me(h+(v=u-h)%(d=ee-h),0))),u=le(v/d);m.push(de(me(u,0))),i=ge(n,l,r==o),n=0,++r}++n,++e}return m.join("")}(t):t})}var we=[],Ee=[],Ie="undefined"!=typeof Uint8Array?Uint8Array:Array,be=!1;function Se(){be=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0;64>e;++e)we[e]=t[e],Ee[t.charCodeAt(e)]=e;Ee[45]=62,Ee[95]=63}function Ae(t,e,n){for(var r,o=[],i=e;n>i;i+=3)o.push(we[(r=(t[i]<<16)+(t[i+1]<<8)+t[i+2])>>18&63]+we[r>>12&63]+we[r>>6&63]+we[63&r]);return o.join("")}function Re(t){var e;be||Se();for(var n=t.length,r=n%3,o="",i=[],a=0,s=n-r;s>a;a+=16383)i.push(Ae(t,a,a+16383>s?s:a+16383));return 1===r?(o+=we[(e=t[n-1])>>2],o+=we[e<<4&63],o+="=="):2===r&&(o+=we[(e=(t[n-2]<<8)+t[n-1])>>10],o+=we[e>>4&63],o+=we[e<<2&63],o+="="),i.push(o),i.join("")}function _e(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 ke(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 Te={}.toString,Oe=Array.isArray||function(t){return"[object Array]"==Te.call(t)};function Ce(){return Ne.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Pe(t,e){if(Ce()<e)throw new RangeError("Invalid typed array length");return Ne.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=Ne.prototype:(null===t&&(t=new Ne(e)),t.length=e),t}function Ne(t,e,n){if(!(Ne.TYPED_ARRAY_SUPPORT||this instanceof Ne))return new Ne(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 Be(this,t)}return Ue(this,t,e,n)}function Ue(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);Ne.TYPED_ARRAY_SUPPORT?(t=e).__proto__=Ne.prototype:t=Le(t,e);return t}(t,e,n,r):"string"==typeof e?function(t,e,n){"string"==typeof n&&""!==n||(n="utf8");if(!Ne.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|De(e,n),o=(t=Pe(t,r)).write(e,n);o!==r&&(t=t.slice(0,o));return t}(t,e,n):function(t,e){if(je(e)){var n=0|Me(e.length);return 0===(t=Pe(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?Pe(t,0):Le(t,e);if("Buffer"===e.type&&Oe(e.data))return Le(t,e.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function xe(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 Be(t,e){if(xe(e),t=Pe(t,0>e?0:0|Me(e)),!Ne.TYPED_ARRAY_SUPPORT)for(var n=0;e>n;++n)t[n]=0;return t}function Le(t,e){var n=0>e.length?0:0|Me(e.length);t=Pe(t,n);for(var r=0;n>r;r+=1)t[r]=255&e[r];return t}function Me(t){if(t>=Ce())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ce().toString(16)+" bytes");return 0|t}function je(t){return!(null==t||!t._isBuffer)}function De(t,e){if(je(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 pn(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return ln(t).length;default:if(r)return pn(t).length;e=(""+e).toLowerCase(),r=!0}}function Ye(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function qe(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=Ne.from(e,r)),je(e))return 0===e.length?-1:Fe(t,e,n,r,o);if("number"==typeof e)return e&=255,Ne.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):Fe(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function Fe(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 ze(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 Ke(t,e,n,r){return dn(pn(e,t.length-n),t,n,r)}function He(t,e,n,r){return dn(function(t){for(var e=[],n=0;t.length>n;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function Ve(t,e,n,r){return He(t,e,n,r)}function Je(t,e,n,r){return dn(ln(e),t,n,r)}function Xe(t,e,n,r){return dn(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 Ze(t,e,n){return Re(0===e&&n===t.length?t:t.slice(e,n))}function $e(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(Ge>=e)return String.fromCharCode.apply(String,t);var n="",r=0;for(;e>r;)n+=String.fromCharCode.apply(String,t.slice(r,r+=Ge));return n}(r)}Ne.TYPED_ARRAY_SUPPORT=void 0===l.TYPED_ARRAY_SUPPORT||l.TYPED_ARRAY_SUPPORT,Ne.poolSize=8192,Ne._augment=function(t){return t.__proto__=Ne.prototype,t},Ne.from=function(t,e,n){return Ue(null,t,e,n)},Ne.TYPED_ARRAY_SUPPORT&&(Ne.prototype.__proto__=Uint8Array.prototype,Ne.__proto__=Uint8Array),Ne.alloc=function(t,e,n){return function(t,e,n,r){return xe(e),e>0&&void 0!==n?"string"==typeof r?Pe(t,e).fill(n,r):Pe(t,e).fill(n):Pe(t,e)}(null,t,e,n)},Ne.allocUnsafe=function(t){return Be(null,t)},Ne.allocUnsafeSlow=function(t){return Be(null,t)},Ne.isBuffer=function(t){return null!=t&&(!!t._isBuffer||vn(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&vn(t.slice(0,0))}(t))},Ne.compare=function(t,e){if(!je(t)||!je(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},Ne.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}},Ne.concat=function(t,e){if(!Oe(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return Ne.alloc(0);var n;if(void 0===e)for(e=0,n=0;t.length>n;++n)e+=t[n].length;var r=Ne.allocUnsafe(e),o=0;for(n=0;t.length>n;++n){var i=t[n];if(!je(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,o),o+=i.length}return r},Ne.byteLength=De,Ne.prototype._isBuffer=!0,Ne.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)Ye(this,e,e+1);return this},Ne.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)Ye(this,e,e+3),Ye(this,e+1,e+2);return this},Ne.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)Ye(this,e,e+7),Ye(this,e+1,e+6),Ye(this,e+2,e+5),Ye(this,e+3,e+4);return this},Ne.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?$e(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 tn(this,e,n);case"utf8":case"utf-8":return $e(this,e,n);case"ascii":return Qe(this,e,n);case"latin1":case"binary":return We(this,e,n);case"base64":return Ze(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return en(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}.apply(this,arguments)},Ne.prototype.equals=function(t){if(!je(t))throw new TypeError("Argument must be a Buffer");return this===t||0===Ne.compare(this,t)},Ne.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+">"},Ne.prototype.compare=function(t,e,n,r,o){if(!je(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},Ne.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},Ne.prototype.indexOf=function(t,e,n){return qe(this,t,e,n,!0)},Ne.prototype.lastIndexOf=function(t,e,n){return qe(this,t,e,n,!1)},Ne.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 ze(this,t,e,n);case"utf8":case"utf-8":return Ke(this,t,e,n);case"ascii":return He(this,t,e,n);case"latin1":case"binary":return Ve(this,t,e,n);case"base64":return Je(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Xe(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},Ne.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Ge=4096;function Qe(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 We(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 tn(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+=fn(t[i]);return o}function en(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 nn(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 rn(t,e,n,r,o,i){if(!je(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 on(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 an(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 sn(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 un(t,e,n,r,o){return o||sn(t,0,n,4),ke(t,e,n,r,23,4),n+4}function cn(t,e,n,r,o){return o||sn(t,0,n,8),ke(t,e,n,r,52,8),n+8}Ne.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),Ne.TYPED_ARRAY_SUPPORT)(n=this.subarray(t,e)).__proto__=Ne.prototype;else{var o=e-t;n=new Ne(o,void 0);for(var i=0;o>i;++i)n[i]=this[i+t]}return n},Ne.prototype.readUIntLE=function(t,e,n){t|=0,e|=0,n||nn(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r},Ne.prototype.readUIntBE=function(t,e,n){t|=0,e|=0,n||nn(t,e,this.length);for(var r=this[t+--e],o=1;e>0&&(o*=256);)r+=this[t+--e]*o;return r},Ne.prototype.readUInt8=function(t,e){return e||nn(t,1,this.length),this[t]},Ne.prototype.readUInt16LE=function(t,e){return e||nn(t,2,this.length),this[t]|this[t+1]<<8},Ne.prototype.readUInt16BE=function(t,e){return e||nn(t,2,this.length),this[t]<<8|this[t+1]},Ne.prototype.readUInt32LE=function(t,e){return e||nn(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Ne.prototype.readUInt32BE=function(t,e){return e||nn(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Ne.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||nn(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},Ne.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||nn(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},Ne.prototype.readInt8=function(t,e){return e||nn(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Ne.prototype.readInt16LE=function(t,e){e||nn(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},Ne.prototype.readInt16BE=function(t,e){e||nn(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},Ne.prototype.readInt32LE=function(t,e){return e||nn(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Ne.prototype.readInt32BE=function(t,e){return e||nn(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Ne.prototype.readFloatLE=function(t,e){return e||nn(t,4,this.length),_e(this,t,!0,23,4)},Ne.prototype.readFloatBE=function(t,e){return e||nn(t,4,this.length),_e(this,t,!1,23,4)},Ne.prototype.readDoubleLE=function(t,e){return e||nn(t,8,this.length),_e(this,t,!0,52,8)},Ne.prototype.readDoubleBE=function(t,e){return e||nn(t,8,this.length),_e(this,t,!1,52,8)},Ne.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||rn(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},Ne.prototype.writeUIntBE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||rn(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},Ne.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||rn(this,t,e,1,255,0),Ne.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},Ne.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||rn(this,t,e,2,65535,0),Ne.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):on(this,t,e,!0),e+2},Ne.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||rn(this,t,e,2,65535,0),Ne.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):on(this,t,e,!1),e+2},Ne.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||rn(this,t,e,4,4294967295,0),Ne.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):an(this,t,e,!0),e+4},Ne.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||rn(this,t,e,4,4294967295,0),Ne.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):an(this,t,e,!1),e+4},Ne.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var o=Math.pow(2,8*n-1);rn(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},Ne.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var o=Math.pow(2,8*n-1);rn(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},Ne.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||rn(this,t,e,1,127,-128),Ne.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=255&t,e+1},Ne.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||rn(this,t,e,2,32767,-32768),Ne.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):on(this,t,e,!0),e+2},Ne.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||rn(this,t,e,2,32767,-32768),Ne.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):on(this,t,e,!1),e+2},Ne.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||rn(this,t,e,4,2147483647,-2147483648),Ne.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):an(this,t,e,!0),e+4},Ne.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||rn(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),Ne.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):an(this,t,e,!1),e+4},Ne.prototype.writeFloatLE=function(t,e,n){return un(this,t,e,!0,n)},Ne.prototype.writeFloatBE=function(t,e,n){return un(this,t,e,!1,n)},Ne.prototype.writeDoubleLE=function(t,e,n){return cn(this,t,e,!0,n)},Ne.prototype.writeDoubleBE=function(t,e,n){return cn(this,t,e,!1,n)},Ne.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||!Ne.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},Ne.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&&!Ne.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=je(t)?t:pn(""+new Ne(t,r)),s=a.length;for(i=0;n-e>i;++i)this[i+e]=a[i%s]}return this};var hn=/[^+\/0-9A-Za-z-_]/g;function fn(t){return 16>t?"0"+t.toString(16):t.toString(16)}function pn(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 ln(t){return function(t){var e,n,r,o,i,a;be||Se();var s=t.length;if(s%4>0)throw Error("Invalid string. Length must be a multiple of 4");a=new Ie(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=Ee[t.charCodeAt(e)]<<18|Ee[t.charCodeAt(e+1)]<<12|Ee[t.charCodeAt(e+2)]<<6|Ee[t.charCodeAt(e+3)],a[u++]=o>>16&255,a[u++]=o>>8&255,a[u++]=255&o;return 2===i?(o=Ee[t.charCodeAt(e)]<<2|Ee[t.charCodeAt(e+1)]>>4,a[u++]=255&o):1===i&&(o=Ee[t.charCodeAt(e)]<<10|Ee[t.charCodeAt(e+1)]<<4|Ee[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(hn,"")).length)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function dn(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 vn(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}function mn(t){return null===t}function gn(t){return"string"==typeof t}function yn(t){return"object"==typeof t&&null!==t}function wn(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var En=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function In(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}}function bn(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 Sn=Object.keys||function(t){var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.push(n);return e};function An(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),wn(o,f)?En(o[f])?o[f].push(p):o[f]=[o[f],p]:o[f]=p}return o}var Rn={parse:Yn,resolve:function(t,e){return Yn(t,!1,!0).resolve(e)},resolveObject:function(t,e){return t?Yn(t,!1,!0).resolveObject(e):e},format:function(t){gn(t)&&(t=qn({},t));return Fn(t)},Url:_n};function _n(){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 kn=/^([a-z0-9.+-]+:)/i,Tn=/:[0-9]*$/,On=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Cn=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),Pn=["'"].concat(Cn),Nn=["%","/","?",";","#"].concat(Pn),Un=["/","?","#"],xn=255,Bn=/^[+a-z0-9A-Z_-]{0,63}$/,Ln=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Mn={javascript:!0,"javascript:":!0},jn={javascript:!0,"javascript:":!0},Dn={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function Yn(t,e,n){if(t&&yn(t)&&t instanceof _n)return t;var r=new _n;return r.parse(t,e,n),r}function qn(t,e,n,r){if(!gn(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=On.exec(s);if(u)return t.path=s,t.href=s,t.pathname=u[1],u[2]?(t.search=u[2],t.query=n?An(t.search.substr(1)):t.search.substr(1)):n&&(t.search="",t.query={}),t}var c,h,f,p=kn.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&&jn[p]||(s=s.substr(2),t.slashes=!0)}if(!jn[p]&&(d||p&&!Dn[p])){var v,m,g=-1;for(c=0;Un.length>c;c++)-1===(h=s.indexOf(Un[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;Nn.length>c;c++)-1===(h=s.indexOf(Nn[c]))||-1!==g&&h>=g||(g=h);-1===g&&(g=s.length),t.host=s.slice(0,g),s=s.slice(g),zn(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(Bn)){for(var I="",b=0,S=E.length;S>b;b++)E.charCodeAt(b)>127?I+="x":I+=E[b];if(!I.match(Bn)){var A=w.slice(0,c),R=w.slice(c+1),_=E.match(Ln);_&&(A.push(_[1]),R.unshift(_[2])),R.length&&(s="/"+R.join(".")+s),t.hostname=A.join(".");break}}}}t.hostname=t.hostname.length>xn?"":t.hostname.toLowerCase(),y||(t.hostname=ye(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(!Mn[l])for(c=0,f=Pn.length;f>c;c++){var k=Pn[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=An(t.query)),s=s.slice(0,C)):n&&(t.search="",t.query={}),s&&(t.pathname=s),Dn[l]&&t.hostname&&!t.pathname&&(t.pathname="/"),t.pathname||t.search)&&(t.path=(t.pathname||"")+(t.search||""));return t.href=Fn(t),t}function Fn(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&&yn(t.query)&&Object.keys(t.query).length&&(r=r||"&",o=o||"=",null===(n=t.query)&&(n=void 0),h="object"==typeof n?bn(Sn(n),function(t){var e=encodeURIComponent(In(t))+o;return En(n[t])?bn(n[t],function(t){return e+encodeURIComponent(In(t))}).join(r):e+encodeURIComponent(In(n[t]))}).join(r):i?encodeURIComponent(In(i))+o+encodeURIComponent(In(n)):"");var f=t.search||h&&"?"+h||"";return a&&":"!==a.substr(-1)&&(a+=":"),t.slashes||(!a||Dn[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 zn(t){var e=t.host,n=Tn.exec(e);n&&(":"!==(n=n[0])&&(t.port=n.substr(1)),e=e.substr(0,e.length-n.length)),e&&(t.hostname=e)}_n.prototype.parse=function(t,e,n){return qn(this,t,e,n)},_n.prototype.format=function(){return Fn(this)},_n.prototype.resolve=function(t){return this.resolveObject(Yn(t,!1,!0)).format()},_n.prototype.resolveObject=function(t){if(gn(t)){var e=new _n;e.parse(t,!1,!0),t=e}for(var n,r=new _n,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 Dn[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r}if(t.protocol&&t.protocol!==r.protocol){if(!Dn[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||jn[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&&!Dn[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,mn(r.pathname)&&mn(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),mn(r.pathname)&&mn(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},_n.prototype.parseHost=function(){return zn(this)};var Kn=function(t){var e=Rn.parse(t);return{host:e.hostname,path:e.pathname}},Hn=p.Some,Vn=p.None;function Jn(t){return"1"===t||"true"===t}function Xn(t){try{return new Hn(parseInt(t))}catch(t){return Vn}}function Zn(t){throw Error("HttpServerInstrumentation: Missing required argument ".concat(t,"."))}var $n={addZipkinHeaders:function(t,e){var n=function(t,e){var n=t.headers||{};return n[Ht.TraceId]=e.traceId,n[Ht.SpanId]=e.spanId,e.parentSpanId.ifPresent(function(t){n[Ht.ParentSpanId]=t}),e.sampled.ifPresent(function(t){n[Ht.Sampled]=t?"1":"0"}),e.isDebug()&&(n[Ht.Flags]="1"),n}(t,e);return Object.assign({},t,{headers:n})}};var Gn={HttpServer:function(){function t(e){var r=e.tracer,o=void 0===r?Zn("tracer"):r,i=e.serviceName,a=void 0===i?o.localEndpoint.serviceName:i,s=e.host,u=e.port,c=void 0===u?Zn("port"):u;n(this,t),this.tracer=o,this.serviceName=a,this.host=s&&new V(s),this.port=c}return o(t,[{key:"_createIdFromHeaders",value:function(t){if(function(t){return t(Ht.TraceId)!==Vn&&t(Ht.SpanId)!==Vn}(t)){var e=t(Ht.SpanId).map(function(e){var n=t(Ht.TraceId),r=t(Ht.ParentSpanId),o=t(Ht.Sampled),i=t(Ht.Flags).flatMap(Xn).getOrElse(0);return new _t({traceId:n.getOrElse(),parentId:r,spanId:e,debug:1===i,sampled:o.map(Jn)})});return new Hn(this.tracer.join(e.getOrElse()))}if(t(Ht.Flags)!==Vn||t(Ht.Sampled)!==Vn){var n=t(Ht.Sampled)===Vn?Vn:t(Ht.Sampled).map(Jn),r=t(Ht.Flags).flatMap(Xn).getOrElse(0);return new Hn(this.tracer.createRootId(n,1===r))}return new Hn(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=Kn(e).path;return this.tracer.recordServiceName(this.serviceName),this.tracer.recordRpc(t.toUpperCase()),this.tracer.recordBinary("http.path",i),this.tracer.recordAnnotation(new lt.ServerRecv),this.tracer.recordAnnotation(new lt.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 lt.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=Kn(e).path;return this.tracer.recordServiceName(this.serviceName),this.tracer.recordRpc(n.toUpperCase()),this.tracer.recordBinary("http.path",o),this.tracer.recordAnnotation(new lt.ClientSend),this.remoteServiceName&&this.tracer.recordAnnotation(new lt.ServerAddr({serviceName:this.remoteServiceName})),$n.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 lt.ClientRecv)}},{key:"recordError",value:function(t,e){this.tracer.setId(t),this.tracer.recordBinary("error",""+e),this.tracer.recordAnnotation(new lt.ClientRecv)}}]),t}()};function Qn(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 Wn={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=Qn(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:Qn(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=lt,t.Tracer=zt,t.createNoopTracer=function(){var t=new Kt;return new zt({recorder:{record:function(){}},ctxImpl:t})},t.randomTraceId=kt,t.sampler=wt,t.TraceId=_t,t.HttpHeaders=Ht,t.InetAddress=V,t.BatchRecorder=Qt,t.ConsoleRecorder=Wt,t.ExplicitContext=Kt,t.Instrumentation=Gn,t.Request=$n,t.jsonEncoder=Wn,t.model=Ut,t.parseRequestUrl=Kn,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}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})});

@@ -5,2 +5,4 @@ import os from 'os';

function _typeof(obj) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {

@@ -303,3 +305,3 @@ _typeof = function (obj) {

InetAddress.getLocalAddress = function getLocalAddress() {
function getLocalAddress() {
var isNode = (typeof process === "undefined" ? "undefined" : _typeof(process)) === 'object' && typeof process.on === 'function';

@@ -314,2 +316,10 @@

return new InetAddress(networkAddress.ipv4());
} // Cache this value at import time so as to avoid network interface
// lookup on every call
var cachedLocalAddress = getLocalAddress();
InetAddress.getLocalAddress = function () {
return cachedLocalAddress;
};

@@ -781,4 +791,3 @@

/**
* Please use parentSpanId instead as this can return confusing results
* (the span ID when absent).
* Please use parentSpanId instead as this can return confusing results (the span ID when absent).
*

@@ -1362,8 +1371,2 @@ * @deprecated since version v0.19

/**
* default timeout = 60 seconds (in microseconds)
* @type {number}
*/
var defaultTimeout = 60 * 1000000;
/**
* defaultTags property name

@@ -1389,3 +1392,4 @@ * @type {symbol}

* @param {TraceId} traceId
* @param {timeoutTimestamp} after this moment, data should be forcibly flushed
* @param {number} timeoutTimestamp (epoch in microseconds) after this moment, data
* should be forcibly flushed
*/

@@ -1404,3 +1408,3 @@ function PartialSpan(traceId, timeoutTimestamp) {

*
* @param {finishTimestamp} time to calculate the duration from
* @param {number} finishTimestamp (epoch in microseconds) to calculate the duration from
*/

@@ -1412,3 +1416,6 @@

value: function setDuration(finishTimestamp) {
if (this.shouldFlush) return;
if (this.shouldFlush) {
return;
}
this.shouldFlush = true; // even if we can't derive duration, we should report on finish

@@ -1431,6 +1438,12 @@

/**
* default timeout = 60 seconds (in microseconds)
* @type {number}
*/
var defaultTimeout = 60 * 1000000;
/**
* @class BatchRecorder
*/
var BatchRecorder =

@@ -1442,4 +1455,7 @@ /*#__PURE__*/

* @param {Object} options
* @property {Logger} logger logs the data to zipkin server
* @property {number} timeout timeout for span in microseconds
* @param {Logger} options.logger logs the data to zipkin server
* @param {number} options.timeout timeout after which an unfinished span
* is flushed to zipkin in **microseconds**. Passing this value has
* implications in the reported data of the span so we discourage users
* to pass a value for it unless there is a good reason for.
*/

@@ -1457,2 +1473,6 @@ function BatchRecorder(_ref) {

this.timeout = timeout;
/**
* @type Map<string, PartialSpan>
*/
this.partialSpans = new Map();

@@ -1473,3 +1493,3 @@ this[defaultTagsSymbol] = {}; // read through the partials spans regularly

});
}, 1000);
}, 1000); // every second, this will flush to zipkin any spans that have timed out

@@ -1497,8 +1517,10 @@ if (timer.unref) {

key: "_writeSpan",
value: function _writeSpan(id, span) {
value: function _writeSpan(id,
/** @type PartialSpan */
span) {
var isNew = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
// TODO(adriancole) refactor so this responsibility isn't in writeSpan
if (!isNew && this.partialSpans.get(id) === 'undefined') {
// Span not found. Could have been expired.
if (!isNew && typeof this.partialSpans.get(id) === 'undefined') {
// Span not found. Could have been expired.
return;

@@ -1558,3 +1580,5 @@ } // ready for garbage collection

this._updateSpanMap(id, rec.timestamp, function (span) {
this._updateSpanMap(id, rec.timestamp, function (
/** @type PartialSpan */
span) {
switch (rec.annotation.annotationType) {

@@ -1561,0 +1585,0 @@ case 'ClientAddr':

@@ -294,2 +294,11 @@ // TypeScript type definitions

class BatchRecorder implements Recorder {
/**
* @constructor
* @param {Object} args
* @param {Logger} args.logger logs the data to zipkin server
* @param {number} args.timeout timeout after which an unfinished span is
* flushed to zipkin in **microseconds**. Passing this value has
* implications in the reported data of the span so we discourage users
* to pass a value for it unless there is a good reason for.
*/
constructor(args: { logger: Logger, timeout?: number });

@@ -296,0 +305,0 @@ record: (rec: Record) => void;

@@ -11,2 +11,4 @@ 'use strict';

function _typeof(obj) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {

@@ -309,3 +311,3 @@ _typeof = function (obj) {

InetAddress.getLocalAddress = function getLocalAddress() {
function getLocalAddress() {
var isNode = (typeof process === "undefined" ? "undefined" : _typeof(process)) === 'object' && typeof process.on === 'function';

@@ -320,2 +322,10 @@

return new InetAddress(networkAddress.ipv4());
} // Cache this value at import time so as to avoid network interface
// lookup on every call
var cachedLocalAddress = getLocalAddress();
InetAddress.getLocalAddress = function () {
return cachedLocalAddress;
};

@@ -787,4 +797,3 @@

/**
* Please use parentSpanId instead as this can return confusing results
* (the span ID when absent).
* Please use parentSpanId instead as this can return confusing results (the span ID when absent).
*

@@ -1368,8 +1377,2 @@ * @deprecated since version v0.19

/**
* default timeout = 60 seconds (in microseconds)
* @type {number}
*/
var defaultTimeout = 60 * 1000000;
/**
* defaultTags property name

@@ -1395,3 +1398,4 @@ * @type {symbol}

* @param {TraceId} traceId
* @param {timeoutTimestamp} after this moment, data should be forcibly flushed
* @param {number} timeoutTimestamp (epoch in microseconds) after this moment, data
* should be forcibly flushed
*/

@@ -1410,3 +1414,3 @@ function PartialSpan(traceId, timeoutTimestamp) {

*
* @param {finishTimestamp} time to calculate the duration from
* @param {number} finishTimestamp (epoch in microseconds) to calculate the duration from
*/

@@ -1418,3 +1422,6 @@

value: function setDuration(finishTimestamp) {
if (this.shouldFlush) return;
if (this.shouldFlush) {
return;
}
this.shouldFlush = true; // even if we can't derive duration, we should report on finish

@@ -1437,6 +1444,12 @@

/**
* default timeout = 60 seconds (in microseconds)
* @type {number}
*/
var defaultTimeout = 60 * 1000000;
/**
* @class BatchRecorder
*/
var BatchRecorder =

@@ -1448,4 +1461,7 @@ /*#__PURE__*/

* @param {Object} options
* @property {Logger} logger logs the data to zipkin server
* @property {number} timeout timeout for span in microseconds
* @param {Logger} options.logger logs the data to zipkin server
* @param {number} options.timeout timeout after which an unfinished span
* is flushed to zipkin in **microseconds**. Passing this value has
* implications in the reported data of the span so we discourage users
* to pass a value for it unless there is a good reason for.
*/

@@ -1463,2 +1479,6 @@ function BatchRecorder(_ref) {

this.timeout = timeout;
/**
* @type Map<string, PartialSpan>
*/
this.partialSpans = new Map();

@@ -1479,3 +1499,3 @@ this[defaultTagsSymbol] = {}; // read through the partials spans regularly

});
}, 1000);
}, 1000); // every second, this will flush to zipkin any spans that have timed out

@@ -1503,8 +1523,10 @@ if (timer.unref) {

key: "_writeSpan",
value: function _writeSpan(id, span) {
value: function _writeSpan(id,
/** @type PartialSpan */
span) {
var isNew = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
// TODO(adriancole) refactor so this responsibility isn't in writeSpan
if (!isNew && this.partialSpans.get(id) === 'undefined') {
// Span not found. Could have been expired.
if (!isNew && typeof this.partialSpans.get(id) === 'undefined') {
// Span not found. Could have been expired.
return;

@@ -1564,3 +1586,5 @@ } // ready for garbage collection

this._updateSpanMap(id, rec.timestamp, function (span) {
this._updateSpanMap(id, rec.timestamp, function (
/** @type PartialSpan */
span) {
switch (rec.annotation.annotationType) {

@@ -1567,0 +1591,0 @@ case 'ClientAddr':

{
"name": "zipkin",
"version": "0.20.0-alpha.1+b49a1b4",
"version": "0.20.0",
"description": "The core tracer for Zipkin JS",

@@ -11,3 +11,3 @@ "main": "lib/index.js",

"build": "rollup -c",
"test": "tsc index.d.ts && mocha --require ../../test/helper.js --require @babel/register && karma start --single-run --browsers ChromeHeadless,FirefoxHeadless ../../karma.conf.js",
"test": "tsc --lib es6 index.d.ts && mocha --require ../../test/helper.js --require @babel/register && karma start --single-run --browsers ChromeHeadless,FirefoxHeadless ../../karma.conf.js",
"test-debug": "mocha --inspect-brk --require ../../test/helper.js",

@@ -24,3 +24,3 @@ "test-browser": "tsc index.d.ts && karma start --single-run --browsers ChromeHeadless ../../karma.conf.js",

},
"gitHead": "b49a1b4d310f92dad1e99fb5d65bd6800ecca853"
"gitHead": "2aca37be1edca1b1e0bd62bcdb9ac20d1717c457"
}

@@ -8,3 +8,2 @@ import babel from 'rollup-plugin-babel';

import builtins from 'rollup-plugin-node-builtins';
import del from 'rollup-plugin-delete';

@@ -27,3 +26,3 @@ const basePlugins = [

output: {file: 'lib/index.js', format: 'cjs'},
plugins: basePlugins.concat([del({targets: 'lib/*'})]),
plugins: basePlugins,
external,

@@ -36,3 +35,3 @@ },

output: {file: 'es/index.js', format: 'es'},
plugins: basePlugins.concat([del({targets: 'es/*'})]),
plugins: basePlugins,
external,

@@ -55,3 +54,2 @@ },

builtins(),
del({targets: 'dist/*'})
]),

@@ -58,0 +56,0 @@ },

@@ -5,8 +5,2 @@ const {now} = require('./time');

/**
* default timeout = 60 seconds (in microseconds)
* @type {number}
*/
const defaultTimeout = 60 * 1000000;
/**
* defaultTags property name

@@ -28,3 +22,4 @@ * @type {symbol}

* @param {TraceId} traceId
* @param {timeoutTimestamp} after this moment, data should be forcibly flushed
* @param {number} timeoutTimestamp (epoch in microseconds) after this moment, data
* should be forcibly flushed
*/

@@ -42,6 +37,9 @@ constructor(traceId, timeoutTimestamp) {

*
* @param {finishTimestamp} time to calculate the duration from
* @param {number} finishTimestamp (epoch in microseconds) to calculate the duration from
*/
setDuration(finishTimestamp) {
if (this.shouldFlush) return;
if (this.shouldFlush) {
return;
}
this.shouldFlush = true; // even if we can't derive duration, we should report on finish

@@ -61,2 +59,8 @@

/**
* default timeout = 60 seconds (in microseconds)
* @type {number}
*/
const defaultTimeout = 60 * 1000000;
/**
* @class BatchRecorder

@@ -68,4 +72,7 @@ */

* @param {Object} options
* @property {Logger} logger logs the data to zipkin server
* @property {number} timeout timeout for span in microseconds
* @param {Logger} options.logger logs the data to zipkin server
* @param {number} options.timeout timeout after which an unfinished span
* is flushed to zipkin in **microseconds**. Passing this value has
* implications in the reported data of the span so we discourage users
* to pass a value for it unless there is a good reason for.
*/

@@ -75,2 +82,5 @@ constructor({logger, timeout = defaultTimeout}) {

this.timeout = timeout;
/**
* @type Map<string, PartialSpan>
*/
this.partialSpans = new Map();

@@ -91,3 +101,3 @@ this[defaultTagsSymbol] = {};

});
}, 1000);
}, 1000); // every second, this will flush to zipkin any spans that have timed out
if (timer.unref) { // unref might not be available in browsers

@@ -110,6 +120,6 @@ timer.unref(); // Allows Node to terminate instead of blocking on timer

_writeSpan(id, span, isNew = false) {
_writeSpan(id, /** @type PartialSpan */ span, isNew = false) {
// TODO(adriancole) refactor so this responsibility isn't in writeSpan
if (!isNew && this.partialSpans.get(id) === 'undefined') {
// Span not found. Could have been expired.
if (!isNew && typeof this.partialSpans.get(id) === 'undefined') {
// Span not found. Could have been expired.
return;

@@ -160,3 +170,3 @@ }

this._updateSpanMap(id, rec.timestamp, (span) => {
this._updateSpanMap(id, rec.timestamp, (/** @type PartialSpan */ span) => {
switch (rec.annotation.annotationType) {

@@ -163,0 +173,0 @@ case 'ClientAddr':

@@ -34,3 +34,3 @@ class InetAddress {

// In non-node environments we fallback to 127.0.0.1
InetAddress.getLocalAddress = function getLocalAddress() {
function getLocalAddress() {
const isNode = typeof process === 'object' && typeof process.on === 'function';

@@ -44,4 +44,9 @@ if (!isNode) {

return new InetAddress(networkAddress.ipv4());
};
}
// Cache this value at import time so as to avoid network interface
// lookup on every call
const cachedLocalAddress = getLocalAddress();
InetAddress.getLocalAddress = () => cachedLocalAddress;
module.exports = InetAddress;

@@ -51,4 +51,3 @@ const {

/**
* Please use parentSpanId instead as this can return confusing results
* (the span ID when absent).
* Please use parentSpanId instead as this can return confusing results (the span ID when absent).
*

@@ -55,0 +54,0 @@ * @deprecated since version v0.19

@@ -16,2 +16,6 @@ const {expect} = require('chai');

let spans;
/**
* @type {BatchRecorder}
*/
let recorder;

@@ -490,2 +494,13 @@

});
it('should not log span that is not in partial spans list', () => {
const span = {
delegate: {
timestamp: 1,
setLocalEndpoint: () => {}
}
};
recorder._writeSpan(rootId, span);
expect(spans).to.be.empty; // eslint-disable-line no-unused-expressions
});
});

@@ -8,2 +8,6 @@ const InetAddress = require('../src/InetAddress');

it('should return the same object reference for multiple calls (cached)', () => {
expect(InetAddress.getLocalAddress()).to.equal(InetAddress.getLocalAddress());
});
it('should convert an IP address to integer representation', () => {

@@ -10,0 +14,0 @@ const addr = new InetAddress('80.91.37.133');

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc