Comparing version 0.18.2 to 0.18.3
@@ -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 r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var r=0;e.length>r;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function o(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),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){r(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,I=[],E=!1,b=-1;function S(){E&&w&&(E=!1,w.length?I=w.concat(I):b=-1,I.length&&A())}function A(){if(!E){var t=y(S);E=!0;for(var e=I.length;e;){for(w=I,I=[];++b<e;)w&&w[b].run();b=-1,e=I.length}w=null,E=!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 T(){}var _=T,k=T,O=T,P=T,C=T,N=T,U=T;var B=l.performance||{},x=B.now||B.mozNow||B.msNow||B.oNow||B.webkitNow||function(){return(new Date).getTime()};var L=new Date;var M,j={nextTick:function(t){var e=Array(arguments.length-1);if(arguments.length>1)for(var r=1;arguments.length>r;r++)e[r-1]=arguments[r];I.push(new R(t,e)),1!==I.length||E||y(A)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:_,addListener:k,once:O,off:P,removeListener:C,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*x.call(B),r=Math.floor(e),n=Math.floor(e%1*1e9);return t&&(r-=t[0],0>(n-=t[1])&&(r--,n+=1e9)),[r,n]},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),r=new Uint16Array(t);if(e[0]=1,e[1]=2,258===r[0])M="BE";else{if(513!==r[0])throw Error("unable to figure out endianess");M="LE"}}return M}};function q(t,e){for(var r in t)for(var n=t[r].length-1;n>=0;n--){var o=t[r][n];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 r={};for(var n in t)n===e&&(r[n]=t[n]);return r}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){r(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(){r(this,t)}return o(t,[{key:"toString",value:function(){return"".concat(this.annotationType,"()")}}]),t}(),X=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),Z=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),$=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),G=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),Q=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),W=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),tt=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),et=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}();function rt(t){this.name=t}rt.prototype.toString=function(){return'LocalOperationStart("'.concat(this.name,'")')};var nt=function(t){function e(){return r(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,r=t.port;this.serviceName=t.serviceName,this.host=e||void 0,this.port=r||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,r=t.port;this.serviceName=t.serviceName,this.host=e,this.port=r}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:rt,LocalOperationStop:nt};Object.keys(pt).forEach(function(t){pt[t].prototype.annotationType=t});var lt=pt,dt=p.Some,vt=function(){function t(e){r(this,t),this.evaluator=e}return o(t,[{key:"shouldSample",value:function(t){var e=this,r=t.sampled.getOrElse(function(){return e.evaluator(t)});return new dt(r)}},{key:"toString",value:function(){return"Sampler(".concat(""+this.evaluator,")")}}]),t}();function mt(t){return!1}function gt(t){return!0}mt.toString=function(){return"never sample"},gt.toString=function(){return"always sample"};var yt={Sampler:vt,CountingSampler:function(t){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return r(this,e),u(this,a(e).call(this,function(t){if(t>0){if(1>t){var e=0,r=parseInt(1/t),n=function(t){var n=0==(e%=r);return e++,n};return n.toString=function(){return"countingSampler: sampleRate=".concat(t)},n}return gt}return mt}(1>t?t:1)))}return i(e,vt),e}(),neverSample:mt,alwaysSample:gt},wt=function(){function t(e){var n=e.traceId,o=e.timestamp,i=e.annotation;r(this,t),this.traceId=n,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.Some,Et=p.None,bt=p.verifyIsOptional,St=p.verifyIsNotOptional,At=function(){function t(e){r(this,t);var n=e.traceId,o=void 0===n?Et:n,i=e.parentId,a=void 0===i?Et:i,s=e.spanId,u=e.sampled,c=void 0===u?Et:u,h=e.flags,f=void 0===h?0:h;bt(o),bt(a),St(s),bt(c),this._traceId=o,this._parentId=a,this._spanId=s,this._sampled=c,this._flags=f}return o(t,[{key:"isDebug",value:function(){return 1==(1&this._flags)}},{key:"toString",value:function(){return"TraceId(spanId=".concat(""+this.spanId)+", parentId=".concat(""+this.parentId)+", traceId=".concat(""+this.traceId,")")}},{key:"spanId",get:function(){return this._spanId}},{key:"parentId",get:function(){return this._parentId.getOrElse(this.spanId)}},{key:"traceId",get:function(){return this._traceId.getOrElse(this.parentId)}},{key:"sampled",get:function(){return this.isDebug()?new It(!0):this._sampled}},{key:"flags",get:function(){return this._flags}}]),t}();var Rt=function(){for(var t="",e=0;16>e;e++)t+="0123456789abcdef"[Math.floor(16*Math.random())];return t},Tt=void 0!==j&&j.hrtime;var _t={now:Tt?function(t,e){if(t&&e){var r=j.hrtime(e);return t+Math.floor(1e6*r[0]+r[1]/1e3)}return 1e3*Date.now()}:function(){return 1e3*Date.now()},hrtime:Tt?function(){return j.hrtime()}:function(){}};function kt(t){var e=t.ipv4,r=t.port;this.setServiceName(t.serviceName),this.setIpv4(e),this.setPort(r)}function Ot(t,e){this.timestamp=t,this.value=""+e}function Pt(t){var e=this;this.traceId=t.traceId,t._parentId.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=!1}kt.prototype.setServiceName=function(t){this.serviceName=t?t.toLocaleLowerCase():void 0},kt.prototype.setIpv4=function(t){this.ipv4=t},kt.prototype.setPort=function(t){this.port=t||void 0},kt.prototype.isEmpty=function(){return void 0===this.serviceName&&void 0===this.ipv4&&void 0===this.port},Ot.prototype.toString=function(){return'Annotation(value="'.concat(this.value,'")')},Pt.prototype.setName=function(t){this.name=t?t.toLocaleLowerCase():void 0},Pt.prototype.setKind=function(t){this.kind=t},Pt.prototype.setTimestamp=function(t){this.timestamp=t},Pt.prototype.setDuration=function(t){void 0!==t&&(this.duration=Math.max(t,1))},Pt.prototype.setLocalEndpoint=function(t){this.localEndpoint=t&&!t.isEmpty()?t:void 0},Pt.prototype.setRemoteEndpoint=function(t){this.remoteEndpoint=t&&!t.isEmpty()?t:void 0},Pt.prototype.addAnnotation=function(t,e){this.annotations.push(new Ot(t,e))},Pt.prototype.putTag=function(t,e){this.tags[t]=""+e},Pt.prototype.setDebug=function(t){this.debug=t},Pt.prototype.setShared=function(t){this.shared=t},Pt.prototype.toString=function(){var t=this.annotations.map(function(t){return""+t}).join(", ");return"Span(id=".concat(this.traceId,", annotations=[").concat(t,"])")};var Ct={Endpoint:kt,Span:Pt},Nt=function(t){return!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then};var Ut=p.None,Bt=p.Some,xt=p.fromNullable,Lt=yt.Sampler,Mt=yt.alwaysSample,jt=_t.now,Dt=_t.hrtime,Yt=Ct.Endpoint;function qt(t){throw Error("Tracer: Missing required argument ".concat(t,"."))}var Ft=function(){function t(e){var n=e.ctxImpl,o=void 0===n?qt("ctxImpl"):n,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;r(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._defaultTraceId=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]:Ut,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=Rt(),n=this.traceId128Bit?new Bt(Rt()+r):Ut,o=new At({traceId:n,parentId:Ut,spanId:r,sampled:t,flags:e?1:0});return t===Ut&&(o._sampled=this.sampler.shouldSample(o)),o}},{key:"createChildId",value:function(){var t=xt(this._ctxImpl.getContext()),e=new At({traceId:t.map(function(t){return t.traceId}),parentId:t.map(function(t){return t.spanId}),spanId:Rt(),sampled:t.flatMap(function(t){return t.sampled}),flags:t.map(function(t){return t.flags}).getOrElse(0)});return!1===e.sampled.present&&(e._sampled=this.sampler.shouldSample(e)),e}},{key:"local",value:function(t,e){var r=this;if("function"!=typeof e)throw Error("you must pass a function");return this.scoped(function(){var n,o=r.createChildId();r.setId(o),r.recordServiceName(r._localEndpoint.serviceName),r.recordAnnotation(new lt.LocalOperationStart(t));try{n=e()}catch(t){throw r.recordBinary("error",t.message?t.message:""+t),r.recordAnnotation(new lt.LocalOperationStop),t}if(!Nt(n))return r.recordAnnotation(new lt.LocalOperationStop),n;if(!o.sampled.getOrElse(!1))return n;var i=function(t){return r.recorder.record(new wt({traceId:o,timestamp:jt(r._startTimestamp,r._startTick),annotation:t}))};return n.then(function(t){return i(new lt.LocalOperationStop),t}).catch(function(t){throw i(new lt.BinaryAnnotation("error",t.message?t.message:""+t)),i(new lt.LocalOperationStop),t})})}},{key:"join",value:function(t){var e=this;if(!(t instanceof At))throw Error("Must be valid TraceId instance");return t._sampled===Ut&&(t._sampled=this.sampler.shouldSample(t)),this.supportsJoin?t:this.letId(t,function(){return e.createChildId()})}},{key:"setId",value:function(t){this._ctxImpl.setContext(t)}},{key:"recordAnnotation",value:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:jt(this._startTimestamp,this._startTick);this.id.sampled.ifPresent(function(n){n&&e.recorder.record(new wt({traceId:e.id,timestamp:r,annotation:t}))})}},{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)t.hasOwnProperty(e)&&this.recordBinary(e,t[e])}},{key:"id",get:function(){return this._ctxImpl.getContext()||this._defaultTraceId}},{key:"localEndpoint",get:function(){return this._localEndpoint}}]),t}(),zt=function(){function t(){r(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.currentCtx,r=t();return this.currentCtx=e,r}},{key:"letContext",value:function(t,e){var r=this;return this.scoped(function(){return r.setContext(t),e()})}}]),t}(),Kt={TraceId:"X-B3-TraceId",SpanId:"X-B3-SpanId",ParentSpanId:"X-B3-ParentSpanId",Sampled:"X-B3-Sampled",Flags:"X-B3-Flags"},Ht=_t.now,Vt=_t.hrtime,Jt=Ct.Span,Xt=Ct.Endpoint,Zt=6e7,$t=Symbol("defaultTags"),Gt=function(){function t(e){r(this,t),this.traceId=e,this.startTimestamp=Ht(),this.startTick=Vt(),this.delegate=new Jt(e),this.localEndpoint=new Xt({})}return o(t,[{key:"finish",value:function(){this.endTimestamp||(this.endTimestamp=Ht(this.startTimestamp,this.startTick))}}],[{key:"create",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new t(e);for(var o in r)r.hasOwnProperty(o)&&n.delegate.putTag(o,r[o]);return n}}]),t}(),Qt=function(){function t(e){var n=this,o=e.logger,i=e.timeout,a=void 0===i?Zt:i;r(this,t),this.logger=o,this.timeout=a,this.partialSpans=new Map,this[$t]={};var s=setInterval(function(){n.partialSpans.forEach(function(t,e){n._timedOut(t)&&n._writeSpan(e)})},1e3);s.unref&&s.unref()}return o(t,[{key:"_writeSpan",value:function(t){var e=this.partialSpans.get(t);if(void 0!==e){this.partialSpans.delete(t);var r=e.delegate;r.setLocalEndpoint(e.localEndpoint),e.endTimestamp&&(r.setTimestamp(e.startTimestamp),r.setDuration(e.endTimestamp-e.startTimestamp)),this.logger.logSpan(r)}}},{key:"_updateSpanMap",value:function(t,e){var r;e(r=this.partialSpans.has(t)?this.partialSpans.get(t):Gt.create(t,this[$t])),r.endTimestamp?this._writeSpan(t):this.partialSpans.set(t,r)}},{key:"_timedOut",value:function(t){return t.startTimestamp+this.timeout<Ht()}},{key:"record",value:function(t){var e=t.traceId;this._updateSpanMap(e,function(r){switch(t.annotation.annotationType){case"ClientSend":r.delegate.setKind("CLIENT");break;case"ClientRecv":r.finish(),r.delegate.setKind("CLIENT");break;case"ServerSend":r.finish(),r.delegate.setKind("SERVER");break;case"ServerRecv":r.delegate.setShared(e.parentId!==e.spanId),r.delegate.setKind("CLIENT");break;case"ProducerStart":r.delegate.setKind("PRODUCER");break;case"ProducerStop":r.finish(),r.delegate.setKind("PRODUCER");break;case"ConsumerStart":r.delegate.setKind("CONSUMER");break;case"ConsumerStop":r.finish(),r.delegate.setKind("CONSUMER");break;case"MessageAddr":r.delegate.setRemoteEndpoint(new Xt({serviceName:t.annotation.serviceName,ipv4:t.annotation.host&&t.annotation.host.ipv4(),port:t.annotation.port}));break;case"LocalOperationStart":r.delegate.setName(t.annotation.name);break;case"LocalOperationStop":r.finish();break;case"Message":r.delegate.addAnnotation(t.timestamp,t.annotation.message);break;case"Rpc":r.delegate.setName(t.annotation.name);break;case"ServiceName":r.localEndpoint.setServiceName(t.annotation.serviceName);break;case"BinaryAnnotation":r.delegate.putTag(t.annotation.key,t.annotation.value);break;case"LocalAddr":r.localEndpoint.setIpv4(t.annotation.host&&t.annotation.host.ipv4()),r.localEndpoint.setPort(t.annotation.port);break;case"ServerAddr":r.delegate.setKind("CLIENT"),r.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;r(this,t),this.logger=e}return o(t,[{key:"record",value:function(t){var e=t.traceId,r=e.spanId,n=e.parentId,o=e.traceId;this.logger("Record at (timestamp=".concat(t.timestamp,", spanId=").concat(r,", parentId=").concat(n,", ")+"traceId=".concat(o,"): ").concat(""+t.annotation))}},{key:"toString",value:function(){return"consoleTracer"}}]),t}(),te=2147483647,ee=36,re=1,ne=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-re,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,r){var n=0;for(t=r?le(t/ie):t>>1,t+=le(t/e);t>pe*ne>>1;n+=ee)t=le(t/pe);return le(n+(pe+1)*t/(t+oe))}function ye(t){return function(t,e){var r=t.split("@"),n="";r.length>1&&(n=r[0]+"@",t=r[1]);var o=function(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}((t=t.replace(he,".")).split("."),e).join(".");return n+o}(t,function(t){return ce.test(t)?"xn--"+function(t){var e,r,n,o,i,a,s,u,c,h,f,p,l,d,v,m=[];for(p=(t=function(t){for(var e,r,n=[],o=0,i=t.length;i>o;)55296>(e=t.charCodeAt(o++))||e>56319||o>=i?n.push(e):56320==(64512&(r=t.charCodeAt(o++)))?n.push(((1023&e)<<10)+(1023&r)+65536):(n.push(e),o--);return n}(t)).length,e=se,r=0,i=ae,a=0;p>a;++a)128>(f=t[a])&&m.push(de(f));for(n=o=m.length,o&&m.push(ue);p>n;){for(s=te,a=0;p>a;++a)(f=t[a])>=e&&s>f&&(s=f);for(s-e>le((te-r)/(l=n+1))&&ve("overflow"),r+=(s-e)*l,e=s,a=0;p>a;++a)if(e>(f=t[a])&&++r>te&&ve("overflow"),f==e){for(u=r,c=ee;(h=c>i?i+ne>c?c-i:ne:re)<=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(r,l,n==o),r=0,++n}++r,++e}return m.join("")}(t):t})}var we=[],Ie=[],Ee="undefined"!=typeof Uint8Array?Uint8Array:Array,be=!1;function Se(){be=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0;64>e;++e)we[e]=t[e],Ie[t.charCodeAt(e)]=e;Ie[45]=62,Ie[95]=63}function Ae(t,e,r){for(var n,o=[],i=e;r>i;i+=3)o.push(we[(n=(t[i]<<16)+(t[i+1]<<8)+t[i+2])>>18&63]+we[n>>12&63]+we[n>>6&63]+we[63&n]);return o.join("")}function Re(t){var e;be||Se();for(var r=t.length,n=r%3,o="",i=[],a=0,s=r-n;s>a;a+=16383)i.push(Ae(t,a,a+16383>s?s:a+16383));return 1===n?(o+=we[(e=t[r-1])>>2],o+=we[e<<4&63],o+="=="):2===n&&(o+=we[(e=(t[r-2]<<8)+t[r-1])>>10],o+=we[e>>4&63],o+=we[e<<2&63],o+="="),i.push(o),i.join("")}function Te(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<<s)-1,c=u>>1,h=-7,f=r?o-1:0,p=r?-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+=n;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,n),i-=c}return(l?-1:1)*a*Math.pow(2,i-n)}function _e(t,e,r,n,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=n?0:i-1,d=n?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[r+l]=255&s,l+=d,s/=256,o-=8);for(a=a<<o|s,c+=o;c>0;t[r+l]=255&a,l+=d,a/=256,c-=8);t[r+l-d]|=128*v}var ke={}.toString,Oe=Array.isArray||function(t){return"[object Array]"==ke.call(t)};function Pe(){return Ne.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Ce(t,e){if(Pe()<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,r){if(!(Ne.TYPED_ARRAY_SUPPORT||this instanceof Ne))return new Ne(t,e,r);if("number"==typeof t){if("string"==typeof e)throw Error("If encoding is specified then the first argument must be a string");return xe(this,t)}return Ue(this,t,e,r)}function Ue(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(0>r||r>e.byteLength)throw new RangeError("'offset' is out of bounds");if(r+(n||0)>e.byteLength)throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);Ne.TYPED_ARRAY_SUPPORT?(t=e).__proto__=Ne.prototype:t=Le(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!Ne.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|De(e,r),o=(t=Ce(t,n)).write(e,r);o!==n&&(t=t.slice(0,o));return t}(t,e,r):function(t,e){if(je(e)){var r=0|Me(e.length);return 0===(t=Ce(t,r)).length?t:(e.copy(t,0,0,r),t)}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?Ce(t,0):Le(t,e);if("Buffer"===e.type&&Oe(e.data))return Le(t,e.data)}var n;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 xe(t,e){if(Be(e),t=Ce(t,0>e?0:0|Me(e)),!Ne.TYPED_ARRAY_SUPPORT)for(var r=0;e>r;++r)t[r]=0;return t}function Le(t,e){var r=0>e.length?0:0|Me(e.length);t=Ce(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function Me(t){if(t>=Pe())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Pe().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 r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return fr(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return pr(t).length;default:if(n)return fr(t).length;e=(""+e).toLowerCase(),n=!0}}function Ye(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function qe(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:-2147483648>r&&(r=-2147483648),isNaN(r=+r)&&(r=o?0:t.length-1),0>r&&(r=t.length+r),t.length>r){if(0>r){if(!o)return-1;r=0}}else{if(o)return-1;r=t.length-1}if("string"==typeof e&&(e=Ne.from(e,n)),je(e))return 0===e.length?-1:Fe(t,e,r,n,o);if("number"==typeof e)return e&=255,Ne.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):Fe(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function Fe(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=(n+"").toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(2>t.length||2>e.length)return-1;a=2,s/=2,u/=2,r/=2}function c(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var h=-1;for(i=r;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(r+u>s&&(r=s-u),i=r;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,r,n){var o=t.length-(r=+r||0);n?(n=+n)>o&&(n=o):n=o;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var a=0;n>a;++a){var s=parseInt(e.substr(2*a,2),16);if(isNaN(s))return a;t[r+a]=s}return a}function Ke(t,e,r,n){return lr(fr(e,t.length-r),t,r,n)}function He(t,e,r,n){return lr(function(t){for(var e=[],r=0;t.length>r;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function Ve(t,e,r,n){return He(t,e,r,n)}function Je(t,e,r,n){return lr(pr(e),t,r,n)}function Xe(t,e,r,n){return lr(function(t,e){for(var r,n,o=[],i=0;t.length>i&&0<=(e-=2);++i)r=t.charCodeAt(i),n=r>>8,o.push(r%256),o.push(n);return o}(e,t.length-r),t,r,n)}function Ze(t,e,r){return Re(0===e&&r===t.length?t:t.slice(e,r))}function $e(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;r>o;){var i,a,s,u,c=t[o],h=null,f=c>239?4:c>223?3:c>191?2:1;if(r>=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&&(n.push((h-=65536)>>>10&1023|55296),h=56320|1023&h),n.push(h),o+=f}return function(t){var e=t.length;if(Ge>=e)return String.fromCharCode.apply(String,t);var r="",n=0;for(;e>n;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Ge));return r}(n)}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,r){return Ue(null,t,e,r)},Ne.TYPED_ARRAY_SUPPORT&&(Ne.prototype.__proto__=Uint8Array.prototype,Ne.__proto__=Uint8Array),Ne.alloc=function(t,e,r){return function(t,e,r,n){return Be(e),e>0&&void 0!==r?"string"==typeof n?Ce(t,e).fill(r,n):Ce(t,e).fill(r):Ce(t,e)}(null,t,e,r)},Ne.allocUnsafe=function(t){return xe(null,t)},Ne.allocUnsafeSlow=function(t){return xe(null,t)},Ne.isBuffer=function(t){return null!=t&&(!!t._isBuffer||dr(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&dr(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 r=t.length,n=e.length,o=0,i=Math.min(r,n);i>o;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return n>r?-1:r>n?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 r;if(void 0===e)for(e=0,r=0;t.length>r;++r)e+=t[r].length;var n=Ne.allocUnsafe(e),o=0;for(r=0;t.length>r;++r){var i=t[r];if(!je(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o),o+=i.length}return n},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,r){var n=!1;if((void 0===e||0>e)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),0>=r)return"";if((e>>>=0)>=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return tr(this,e,r);case"utf8":case"utf-8":return $e(this,e,r);case"ascii":return Qe(this,e,r);case"latin1":case"binary":return We(this,e,r);case"base64":return Ze(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return er(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!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,r,n,o){if(!je(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),0>e||r>t.length||0>n||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(i,a),u=this.slice(n,o),c=t.slice(e,r),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,r){return-1!==this.indexOf(t,e,r)},Ne.prototype.indexOf=function(t,e,r){return qe(this,t,e,r,!0)},Ne.prototype.lastIndexOf=function(t,e,r){return qe(this,t,e,r,!1)},Ne.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(0>r||0>e)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return ze(this,t,e,r);case"utf8":case"utf-8":return Ke(this,t,e,r);case"ascii":return He(this,t,e,r);case"latin1":case"binary":return Ve(this,t,e,r);case"base64":return Je(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Xe(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).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,r){var n="";r=Math.min(t.length,r);for(var o=e;r>o;++o)n+=String.fromCharCode(127&t[o]);return n}function We(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;r>o;++o)n+=String.fromCharCode(t[o]);return n}function tr(t,e,r){var n=t.length;e&&e>=0||(e=0),(!r||0>r||r>n)&&(r=n);for(var o="",i=e;r>i;++i)o+=hr(t[i]);return o}function er(t,e,r){for(var n=t.slice(e,r),o="",i=0;n.length>i;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function rr(t,e,r){if(t%1!=0||0>t)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function nr(t,e,r,n,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(r+n>t.length)throw new RangeError("Index out of range")}function or(t,e,r,n){0>e&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-r,2);i>o;++o)t[r+o]=(e&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function ir(t,e,r,n){0>e&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-r,4);i>o;++o)t[r+o]=e>>>8*(n?o:3-o)&255}function ar(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(0>r)throw new RangeError("Index out of range")}function sr(t,e,r,n,o){return o||ar(t,0,r,4),_e(t,e,r,n,23,4),r+4}function ur(t,e,r,n,o){return o||ar(t,0,r,8),_e(t,e,r,n,52,8),r+8}Ne.prototype.slice=function(t,e){var r,n=this.length;if(0>(t=~~t)?0>(t+=n)&&(t=0):t>n&&(t=n),0>(e=void 0===e?n:~~e)?0>(e+=n)&&(e=0):e>n&&(e=n),t>e&&(e=t),Ne.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=Ne.prototype;else{var o=e-t;r=new Ne(o,void 0);for(var i=0;o>i;++i)r[i]=this[i+t]}return r},Ne.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||rr(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},Ne.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||rr(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},Ne.prototype.readUInt8=function(t,e){return e||rr(t,1,this.length),this[t]},Ne.prototype.readUInt16LE=function(t,e){return e||rr(t,2,this.length),this[t]|this[t+1]<<8},Ne.prototype.readUInt16BE=function(t,e){return e||rr(t,2,this.length),this[t]<<8|this[t+1]},Ne.prototype.readUInt32LE=function(t,e){return e||rr(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||rr(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Ne.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||rr(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return(o*=128)>n||(n-=Math.pow(2,8*e)),n},Ne.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||rr(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return(o*=128)>i||(i-=Math.pow(2,8*e)),i},Ne.prototype.readInt8=function(t,e){return e||rr(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Ne.prototype.readInt16LE=function(t,e){e||rr(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},Ne.prototype.readInt16BE=function(t,e){e||rr(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},Ne.prototype.readInt32LE=function(t,e){return e||rr(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||rr(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||rr(t,4,this.length),Te(this,t,!0,23,4)},Ne.prototype.readFloatBE=function(t,e){return e||rr(t,4,this.length),Te(this,t,!1,23,4)},Ne.prototype.readDoubleLE=function(t,e){return e||rr(t,8,this.length),Te(this,t,!0,52,8)},Ne.prototype.readDoubleBE=function(t,e){return e||rr(t,8,this.length),Te(this,t,!1,52,8)},Ne.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||nr(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},Ne.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||nr(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},Ne.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||nr(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,r){return t=+t,e|=0,r||nr(this,t,e,2,65535,0),Ne.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):or(this,t,e,!0),e+2},Ne.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,2,65535,0),Ne.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):or(this,t,e,!1),e+2},Ne.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||nr(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):ir(this,t,e,!0),e+4},Ne.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||nr(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):ir(this,t,e,!1),e+4},Ne.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);nr(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i<r&&(a*=256);)0>t&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},Ne.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);nr(this,t,e,r,o-1,-o)}var i=r-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+r},Ne.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||nr(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,r){return t=+t,e|=0,r||nr(this,t,e,2,32767,-32768),Ne.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):or(this,t,e,!0),e+2},Ne.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,2,32767,-32768),Ne.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):or(this,t,e,!1),e+2},Ne.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||nr(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):ir(this,t,e,!0),e+4},Ne.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||nr(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):ir(this,t,e,!1),e+4},Ne.prototype.writeFloatLE=function(t,e,r){return sr(this,t,e,!0,r)},Ne.prototype.writeFloatBE=function(t,e,r){return sr(this,t,e,!1,r)},Ne.prototype.writeDoubleLE=function(t,e,r){return ur(this,t,e,!0,r)},Ne.prototype.writeDoubleBE=function(t,e,r){return ur(this,t,e,!1,r)},Ne.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),t.length>e||(e=t.length),e||(e=0),n>0&&r>n&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>n)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),n-r>t.length-e&&(n=t.length-e+r);var o,i=n-r;if(this===t&&e>r&&n>e)for(o=i-1;o>=0;--o)t[o+e]=this[o+r];else if(1e3>i||!Ne.TYPED_ARRAY_SUPPORT)for(o=0;i>o;++o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+i),e);return i},Ne.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var o=t.charCodeAt(0);256>o&&(t=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Ne.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(0>e||e>this.length||r>this.length)throw new RangeError("Out of range index");if(e>=r)return this;var i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;r>i;++i)this[i]=t;else{var a=je(t)?t:fr(""+new Ne(t,n)),s=a.length;for(i=0;r-e>i;++i)this[i+e]=a[i%s]}return this};var cr=/[^+\/0-9A-Za-z-_]/g;function hr(t){return 16>t?"0"+t.toString(16):t.toString(16)}function fr(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],a=0;n>a;++a){if((r=t.charCodeAt(a))>55295&&57344>r){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(56320>r){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,128>r){if(0>(e-=1))break;i.push(r)}else if(2048>r){if(0>(e-=2))break;i.push(r>>6|192,63&r|128)}else if(65536>r){if(0>(e-=3))break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(r>=1114112)throw Error("Invalid code point");if(0>(e-=4))break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function pr(t){return function(t){var e,r,n,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 Ee(3*s/4-(i="="===t[s-2]?2:"="===t[s-1]?1:0)),n=i>0?s-4:s;var u=0;for(e=0,r=0;n>e;e+=4,r+=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(cr,"")).length)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function lr(t,e,r,n){for(var o=0;n>o&&(o+r<e.length&&o<t.length);++o)e[o+r]=t[o];return o}function dr(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}function vr(t){return null===t}function mr(t){return"string"==typeof t}function gr(t){return"object"==typeof t&&null!==t}function yr(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var wr=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function Ir(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}}function Er(t,e){if(t.map)return t.map(e);for(var r=[],n=0;t.length>n;n++)r.push(e(t[n],n));return r}var br=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return e};function Sr(t,e,r,n){r=r||"=";var o={};if("string"!=typeof t||0===t.length)return o;var i=/\+/g;t=t.split(e=e||"&");var a=1e3;n&&"number"==typeof n.maxKeys&&(a=n.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(r);0>d?(c=l,h=""):(c=l.substr(0,d),h=l.substr(d+1)),f=decodeURIComponent(c),p=decodeURIComponent(h),yr(o,f)?wr(o[f])?o[f].push(p):o[f]=[o[f],p]:o[f]=p}return o}var Ar={parse:Dr,resolve:function(t,e){return Dr(t,!1,!0).resolve(e)},resolveObject:function(t,e){return t?Dr(t,!1,!0).resolveObject(e):e},format:function(t){mr(t)&&(t=Yr({},t));return qr(t)},Url:Rr};function Rr(){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 Tr=/^([a-z0-9.+-]+:)/i,_r=/:[0-9]*$/,kr=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Or=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),Pr=["'"].concat(Or),Cr=["%","/","?",";","#"].concat(Pr),Nr=["/","?","#"],Ur=255,Br=/^[+a-z0-9A-Z_-]{0,63}$/,xr=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Lr={javascript:!0,"javascript:":!0},Mr={javascript:!0,"javascript:":!0},jr={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function Dr(t,e,r){if(t&&gr(t)&&t instanceof Rr)return t;var n=new Rr;return n.parse(t,e,r),n}function Yr(t,e,r,n){if(!mr(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(),!n&&1===e.split("#").length){var u=kr.exec(s);if(u)return t.path=s,t.href=s,t.pathname=u[1],u[2]?(t.search=u[2],t.query=r?Sr(t.search.substr(1)):t.search.substr(1)):r&&(t.search="",t.query={}),t}var c,h,f,p=Tr.exec(s);if(p){var l=(p=p[0]).toLowerCase();t.protocol=l,s=s.substr(p.length)}if(n||p||s.match(/^\/\/[^@\/]+@[^@\/]+/)){var d="//"===s.substr(0,2);!d||p&&Mr[p]||(s=s.substr(2),t.slashes=!0)}if(!Mr[p]&&(d||p&&!jr[p])){var v,m,g=-1;for(c=0;Nr.length>c;c++)-1===(h=s.indexOf(Nr[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;Cr.length>c;c++)-1===(h=s.indexOf(Cr[c]))||-1!==g&&h>=g||(g=h);-1===g&&(g=s.length),t.host=s.slice(0,g),s=s.slice(g),Fr(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 I=w[c];if(I&&!I.match(Br)){for(var E="",b=0,S=I.length;S>b;b++)I.charCodeAt(b)>127?E+="x":E+=I[b];if(!E.match(Br)){var A=w.slice(0,c),R=w.slice(c+1),T=I.match(xr);T&&(A.push(T[1]),R.unshift(T[2])),R.length&&(s="/"+R.join(".")+s),t.hostname=A.join(".");break}}}}t.hostname=t.hostname.length>Ur?"":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(!Lr[l])for(c=0,f=Pr.length;f>c;c++){var _=Pr[c];if(-1!==s.indexOf(_)){var k=encodeURIComponent(_);k===_&&(k=escape(_)),s=s.split(_).join(k)}}var O=s.indexOf("#");-1!==O&&(t.hash=s.substr(O),s=s.slice(0,O));var P=s.indexOf("?");(-1!==P?(t.search=s.substr(P),t.query=s.substr(P+1),r&&(t.query=Sr(t.query)),s=s.slice(0,P)):r&&(t.search="",t.query={}),s&&(t.pathname=s),jr[l]&&t.hostname&&!t.pathname&&(t.pathname="/"),t.pathname||t.search)&&(t.path=(t.pathname||"")+(t.search||""));return t.href=qr(t),t}function qr(t){var e=t.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var r,n,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&&gr(t.query)&&Object.keys(t.query).length&&(n=n||"&",o=o||"=",null===(r=t.query)&&(r=void 0),h="object"==typeof r?Er(br(r),function(t){var e=encodeURIComponent(Ir(t))+o;return wr(r[t])?Er(r[t],function(t){return e+encodeURIComponent(Ir(t))}).join(n):e+encodeURIComponent(Ir(r[t]))}).join(n):i?encodeURIComponent(Ir(i))+o+encodeURIComponent(Ir(r)):"");var f=t.search||h&&"?"+h||"";return a&&":"!==a.substr(-1)&&(a+=":"),t.slashes||(!a||jr[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 Fr(t){var e=t.host,r=_r.exec(e);r&&(":"!==(r=r[0])&&(t.port=r.substr(1)),e=e.substr(0,e.length-r.length)),e&&(t.hostname=e)}Rr.prototype.parse=function(t,e,r){return Yr(this,t,e,r)},Rr.prototype.format=function(){return qr(this)},Rr.prototype.resolve=function(t){return this.resolveObject(Dr(t,!1,!0)).format()},Rr.prototype.resolveObject=function(t){if(mr(t)){var e=new Rr;e.parse(t,!1,!0),t=e}for(var r,n=new Rr,o=Object.keys(this),i=0;o.length>i;i++){var a=o[i];n[a]=this[a]}if(n.hash=t.hash,""===t.href)return n.href=n.format(),n;if(t.slashes&&!t.protocol){for(var s=Object.keys(t),u=0;s.length>u;u++){var c=s[u];"protocol"!==c&&(n[c]=t[c])}return jr[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(t.protocol&&t.protocol!==n.protocol){if(!jr[t.protocol]){for(var h=Object.keys(t),f=0;h.length>f;f++){var p=h[f];n[p]=t[p]}return n.href=n.format(),n}if(n.protocol=t.protocol,t.host||Mr[t.protocol])n.pathname=t.pathname;else{for(r=(t.pathname||"").split("/");r.length&&!(t.host=r.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==r[0]&&r.unshift(""),2>r.length&&r.unshift(""),n.pathname=r.join("/")}if(n.search=t.search,n.query=t.query,n.host=t.host||"",n.auth=t.auth,n.hostname=t.hostname||t.host,n.port=t.port,n.pathname||n.search)n.path=(n.pathname||"")+(n.search||"");return n.slashes=n.slashes||t.slashes,n.href=n.format(),n}var l,d=n.pathname&&"/"===n.pathname.charAt(0),v=t.host||t.pathname&&"/"===t.pathname.charAt(0),m=v||d||n.host&&t.pathname,g=m,y=n.pathname&&n.pathname.split("/")||[],w=n.protocol&&!jr[n.protocol];if(r=t.pathname&&t.pathname.split("/")||[],w&&(n.hostname="",n.port=null,n.host&&(""===y[0]?y[0]=n.host:y.unshift(n.host)),n.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===r[0]?r[0]=t.host:r.unshift(t.host)),t.host=null),m=m&&(""===r[0]||""===y[0])),v)n.host=t.host||""===t.host?t.host:n.host,n.hostname=t.hostname||""===t.hostname?t.hostname:n.hostname,n.search=t.search,n.query=t.query,y=r;else if(r.length)y||(y=[]),y.pop(),y=y.concat(r),n.search=t.search,n.query=t.query;else if(null!=t.search)return w&&(n.hostname=n.host=y.shift(),(l=!(!n.host||0>=n.host.indexOf("@"))&&n.host.split("@"))&&(n.auth=l.shift(),n.host=n.hostname=l.shift())),n.search=t.search,n.query=t.query,vr(n.pathname)&&vr(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!y.length)return n.pathname=null,n.path=n.search?"/"+n.search:null,n.href=n.format(),n;for(var I=y.slice(-1)[0],E=(n.host||t.host||y.length>1)&&("."===I||".."===I)||""===I,b=0,S=y.length;S>=0;S--)"."===(I=y[S])?y.splice(S,1):".."===I?(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(""),E&&"/"!==y.join("/").substr(-1)&&y.push("");var A=""===y[0]||y[0]&&"/"===y[0].charAt(0);return w&&(n.hostname=n.host=A?"":y.length?y.shift():"",(l=!(!n.host||0>=n.host.indexOf("@"))&&n.host.split("@"))&&(n.auth=l.shift(),n.host=n.hostname=l.shift())),(m=m||n.host&&y.length)&&!A&&y.unshift(""),y.length?n.pathname=y.join("/"):(n.pathname=null,n.path=null),vr(n.pathname)&&vr(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=t.auth||n.auth,n.slashes=n.slashes||t.slashes,n.href=n.format(),n},Rr.prototype.parseHost=function(){return Fr(this)};var zr=function(t){var e=Ar.parse(t);return{host:e.hostname,path:e.pathname}},Kr=p.Some,Hr=p.None;function Vr(t){return"1"===t||"true"===t}function Jr(t){try{return new Kr(parseInt(t))}catch(t){return Hr}}function Xr(t){throw Error("HttpServerInstrumentation: Missing required argument ".concat(t,"."))}var Zr={addZipkinHeaders:function(t,e){var r=function(t,e){var r=t.headers||{};return r[Kt.TraceId]=e.traceId,r[Kt.SpanId]=e.spanId,e._parentId.ifPresent(function(t){r[Kt.ParentSpanId]=t}),e.sampled.ifPresent(function(t){r[Kt.Sampled]=t?"1":"0"}),e.isDebug()&&(r[Kt.Flags]="1"),r}(t,e);return Object.assign({},t,{headers:r})}};var $r={HttpServer:function(){function t(e){var n=e.tracer,o=void 0===n?Xr("tracer"):n,i=e.serviceName,a=void 0===i?o.localEndpoint.serviceName:i,s=e.host,u=e.port,c=void 0===u?Xr("port"):u;r(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(Kt.TraceId)!==Hr&&t(Kt.SpanId)!==Hr}(t)){var e=t(Kt.SpanId).map(function(e){var r=t(Kt.TraceId),n=t(Kt.ParentSpanId),o=t(Kt.Sampled),i=t(Kt.Flags).flatMap(Jr).getOrElse(0);return new At({traceId:r,parentId:n,spanId:e,sampled:o.map(Vr),flags:i})});return new Kr(this.tracer.join(e.getOrElse()))}if(t(Kt.Flags)!==Hr||t(Kt.Sampled)!==Hr){var r=t(Kt.Sampled)===Hr?Hr:t(Kt.Sampled).map(Vr),n=t(Kt.Flags).flatMap(Jr).getOrElse(0);return new Kr(this.tracer.createRootId(r,1===n))}return new Kr(this.tracer.createRootId())}},{key:"recordRequest",value:function(t,e,r){var n=this;this._createIdFromHeaders(r).ifPresent(function(t){return n.tracer.setId(t)});var o=this.tracer.id,i=zr(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,r){this.tracer.setId(t),this.tracer.recordBinary("http.status_code",""+e),r?this.tracer.recordBinary("error",""+r):(200>e||e>399)&&this.tracer.recordBinary("error",""+e),this.tracer.recordAnnotation(new lt.ServerSend)}}]),t}(),HttpClient:function(){function t(e){var n=e.tracer,o=void 0===n?function(t){throw Error("HttpClientInstrumentation: Missing required argument ".concat(t,"."))}("tracer"):n,i=e.serviceName,a=void 0===i?o.localEndpoint.serviceName:i,s=e.remoteServiceName;r(this,t),this.tracer=o,this.serviceName=a,this.remoteServiceName=s}return o(t,[{key:"recordRequest",value:function(t,e,r){this.tracer.setId(this.tracer.createChildId());var n=this.tracer.id,o=zr(e).path;return this.tracer.recordServiceName(this.serviceName),this.tracer.recordRpc(r.toUpperCase()),this.tracer.recordBinary("http.path",o),this.tracer.recordAnnotation(new lt.ClientSend),this.remoteServiceName&&this.tracer.recordAnnotation(new lt.ServerAddr({serviceName:this.remoteServiceName})),Zr.addZipkinHeaders(t,n)}},{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 Gr(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 Qr={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 r,n,o,i=Gr(t.localEndpoint);switch(t.kind){case"CLIENT":r=t.timestamp?"cs":void 0,n="cr",o="sa";break;case"SERVER":r=t.timestamp?"sr":void 0,n="ss",o="ca";break;case"PRODUCER":r=t.timestamp?"ms":void 0,n="ws",o="ma";break;case"CONSUMER":t.timestamp&&t.duration?(r="wr",n="mr"):t.timestamp&&(r="mr"),o="ma"}(t.annotations.length>0||r)&&(e.annotations=t.annotations.map(function(t){return function(t,e){return{value:t.value,timestamp:t.timestamp,endpoint:e}}(t,i)})),r&&(e.annotations.push({value:r,timestamp:t.timestamp,endpoint:i}),t.duration&&e.annotations.push({value:n,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:Gr(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=Ft,t.createNoopTracer=function(){var t=new zt;return new Ft({recorder:{record:function(){}},ctxImpl:t})},t.randomTraceId=Rt,t.sampler=yt,t.TraceId=At,t.HttpHeaders=Kt,t.InetAddress=V,t.BatchRecorder=Qt,t.ConsoleRecorder=Wt,t.ExplicitContext=zt,t.Instrumentation=$r,t.Request=Zr,t.jsonEncoder=Qr,t.model=Ct,t.parseRequestUrl=zr,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 r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var r=0;e.length>r;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function o(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),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){r(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,I=[],b=!1,E=-1;function S(){b&&w&&(b=!1,w.length?I=w.concat(I):E=-1,I.length&&A())}function A(){if(!b){var t=y(S);b=!0;for(var e=I.length;e;){for(w=I,I=[];++E<e;)w&&w[E].run();E=-1,e=I.length}w=null,b=!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 T=_,k=_,O=_,P=_,C=_,N=_,U=_;var B=l.performance||{},x=B.now||B.mozNow||B.msNow||B.oNow||B.webkitNow||function(){return(new Date).getTime()};var L=new Date;var M,j={nextTick:function(t){var e=Array(arguments.length-1);if(arguments.length>1)for(var r=1;arguments.length>r;r++)e[r-1]=arguments[r];I.push(new R(t,e)),1!==I.length||b||y(A)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:T,addListener:k,once:O,off:P,removeListener:C,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*x.call(B),r=Math.floor(e),n=Math.floor(e%1*1e9);return t&&(r-=t[0],0>(n-=t[1])&&(r--,n+=1e9)),[r,n]},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),r=new Uint16Array(t);if(e[0]=1,e[1]=2,258===r[0])M="BE";else{if(513!==r[0])throw Error("unable to figure out endianess");M="LE"}}return M}};function q(t,e){for(var r in t)for(var n=t[r].length-1;n>=0;n--){var o=t[r][n];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 r={};for(var n in t)n===e&&(r[n]=t[n]);return r}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){r(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(){r(this,t)}return o(t,[{key:"toString",value:function(){return"".concat(this.annotationType,"()")}}]),t}(),X=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),Z=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),$=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),G=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),Q=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),W=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),tt=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}(),et=function(t){function e(){return r(this,e),u(this,a(e).apply(this,arguments))}return i(e,J),e}();function rt(t){this.name=t}rt.prototype.toString=function(){return'LocalOperationStart("'.concat(this.name,'")')};var nt=function(t){function e(){return r(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,r=t.port;this.serviceName=t.serviceName,this.host=e||void 0,this.port=r||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,r=t.port;this.serviceName=t.serviceName,this.host=e,this.port=r}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:rt,LocalOperationStop:nt};Object.keys(pt).forEach(function(t){pt[t].prototype.annotationType=t});var lt=pt,dt=p.Some,vt=function(){function t(e){r(this,t),this.evaluator=e}return o(t,[{key:"shouldSample",value:function(t){var e=this,r=t.sampled.getOrElse(function(){return e.evaluator(t)});return new dt(r)}},{key:"toString",value:function(){return"Sampler(".concat(""+this.evaluator,")")}}]),t}();function mt(t){return!1}function gt(t){return!0}mt.toString=function(){return"never sample"},gt.toString=function(){return"always sample"};var yt={Sampler:vt,CountingSampler:function(t){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return r(this,e),u(this,a(e).call(this,function(t){if(t>0){if(1>t){var e=0,r=parseInt(1/t),n=function(t){var n=0==(e%=r);return e++,n};return n.toString=function(){return"countingSampler: sampleRate=".concat(t)},n}return gt}return mt}(1>t?t:1)))}return i(e,vt),e}(),neverSample:mt,alwaysSample:gt},wt=function(){function t(e){var n=e.traceId,o=e.timestamp,i=e.annotation;r(this,t),this.traceId=n,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,Et=p.verifyIsNotOptional,St=p.isOptional,At=new(0,p.Some)(!0),Rt=function(){function t(e){r(this,t);var n=e.spanId,o=e.traceId,i=void 0===o?n: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;Et(n),bt(s),bt(p),this._traceId=St(i)?i.getOrElse(n):null==i?n:i,this._parentId=s,this._spanId=n,this._sampled=h?At: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 _t=function(){for(var t="",e=0;16>e;e++)t+="0123456789abcdef"[Math.floor(16*Math.random())];return t},Tt=void 0!==j&&j.hrtime;var kt={now:Tt?function(t,e){if(t&&e){var r=j.hrtime(e);return t+Math.floor(1e6*r[0]+r[1]/1e3)}return 1e3*Date.now()}:function(){return 1e3*Date.now()},hrtime:Tt?function(){return j.hrtime()}:function(){}};function Ot(t){var e=t.ipv4,r=t.port;this.setServiceName(t.serviceName),this.setIpv4(e),this.setPort(r)}function Pt(t,e){this.timestamp=t,this.value=""+e}function Ct(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()}Ot.prototype.setServiceName=function(t){this.serviceName=t?t.toLocaleLowerCase():void 0},Ot.prototype.setIpv4=function(t){this.ipv4=t},Ot.prototype.setPort=function(t){this.port=t||void 0},Ot.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,'")')},Ct.prototype.setName=function(t){this.name=t?t.toLocaleLowerCase():void 0},Ct.prototype.setKind=function(t){this.kind=t},Ct.prototype.setTimestamp=function(t){this.timestamp=t},Ct.prototype.setDuration=function(t){void 0!==t&&(this.duration=Math.max(t,1))},Ct.prototype.setLocalEndpoint=function(t){this.localEndpoint=t&&!t.isEmpty()?t:void 0},Ct.prototype.setRemoteEndpoint=function(t){this.remoteEndpoint=t&&!t.isEmpty()?t:void 0},Ct.prototype.addAnnotation=function(t,e){this.annotations.push(new Pt(t,e))},Ct.prototype.putTag=function(t,e){this.tags[t]=""+e},Ct.prototype.setDebug=function(t){this.debug=t},Ct.prototype.setShared=function(t){this.shared=t},Ct.prototype.toString=function(){var t=this.annotations.map(function(t){return""+t}).join(", ");return"Span(id=".concat(this.traceId,", annotations=[").concat(t,"])")};var Nt={Endpoint:Ot,Span:Ct},Ut=function(t){return!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then};var Bt=p.None,xt=p.Some,Lt=yt.Sampler,Mt=yt.alwaysSample,jt=kt.now,Dt=kt.hrtime,Yt=Nt.Endpoint;function qt(t){throw Error("Tracer: Missing required argument ".concat(t,"."))}var Ft=function(){function t(e){var n=e.ctxImpl,o=void 0===n?qt("ctxImpl"):n,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;r(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._defaultTraceId=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]:Bt,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=_t(),n=this.traceId128Bit?_t()+r:r,o=new Rt({traceId:n,parentId:Bt,spanId:r,sampled:t,flags:e?1:0});return t===Bt&&(o._sampled=this.sampler.shouldSample(o)),o}},{key:"isUndefinedOrNull",value:function(t){return null==t}},{key:"createChildId",value:function(t){if(this.isUndefinedOrNull(t)&&(t=this._ctxImpl.getContext()),this.isUndefinedOrNull(t))return this.createRootId();var e=new Rt({traceId:t.traceId,parentId:new xt(t.spanId),spanId:_t(),debug:t.isDebug(),sampled:t.sampled});return!1===e.sampled.present&&(e._sampled=this.sampler.shouldSample(e)),e}},{key:"local",value:function(t,e){var r=this;if("function"!=typeof e)throw Error("you must pass a function");return this.scoped(function(){var n,o=r.createChildId();r.setId(o),r.recordServiceName(r._localEndpoint.serviceName),r.recordAnnotation(new lt.LocalOperationStart(t));try{n=e()}catch(t){throw r.recordBinary("error",t.message?t.message:""+t),r.recordAnnotation(new lt.LocalOperationStop),t}if(!Ut(n))return r.recordAnnotation(new lt.LocalOperationStop),n;if(!o.sampled.getOrElse(!1))return n;var i=function(t){return r.recorder.record(new wt({traceId:o,timestamp:jt(r._startTimestamp,r._startTick),annotation:t}))};return n.then(function(t){return i(new lt.LocalOperationStop),t}).catch(function(t){throw i(new lt.BinaryAnnotation("error",t.message?t.message:""+t)),i(new lt.LocalOperationStop),t})})}},{key:"join",value:function(t){if(!(t instanceof Rt))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){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:jt(this._startTimestamp,this._startTick);this.id.sampled.ifPresent(function(n){n&&e.recorder.record(new wt({traceId:e.id,timestamp:r,annotation:t}))})}},{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)t.hasOwnProperty(e)&&this.recordBinary(e,t[e])}},{key:"id",get:function(){return this._ctxImpl.getContext()||this._defaultTraceId}},{key:"localEndpoint",get:function(){return this._localEndpoint}}]),t}(),zt=function(){function t(){r(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.currentCtx,r=t();return this.currentCtx=e,r}},{key:"letContext",value:function(t,e){var r=this;return this.scoped(function(){return r.setContext(t),e()})}}]),t}(),Kt={TraceId:"X-B3-TraceId",SpanId:"X-B3-SpanId",ParentSpanId:"X-B3-ParentSpanId",Sampled:"X-B3-Sampled",Flags:"X-B3-Flags"},Ht=kt.now,Vt=kt.hrtime,Jt=Nt.Span,Xt=Nt.Endpoint,Zt=6e7,$t=Symbol("defaultTags"),Gt=function(){function t(e){r(this,t),this.traceId=e,this.startTimestamp=Ht(),this.startTick=Vt(),this.delegate=new Jt(e),this.localEndpoint=new Xt({})}return o(t,[{key:"finish",value:function(){this.endTimestamp||(this.endTimestamp=Ht(this.startTimestamp,this.startTick))}}],[{key:"create",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new t(e);for(var o in r)r.hasOwnProperty(o)&&n.delegate.putTag(o,r[o]);return n}}]),t}(),Qt=function(){function t(e){var n=this,o=e.logger,i=e.timeout,a=void 0===i?Zt:i;r(this,t),this.logger=o,this.timeout=a,this.partialSpans=new Map,this[$t]={};var s=setInterval(function(){n.partialSpans.forEach(function(t,e){n._timedOut(t)&&n._writeSpan(e)})},1e3);s.unref&&s.unref()}return o(t,[{key:"_writeSpan",value:function(t){var e=this.partialSpans.get(t);if(void 0!==e){this.partialSpans.delete(t);var r=e.delegate;r.setLocalEndpoint(e.localEndpoint),e.endTimestamp&&(r.setTimestamp(e.startTimestamp),r.setDuration(e.endTimestamp-e.startTimestamp)),this.logger.logSpan(r)}}},{key:"_updateSpanMap",value:function(t,e){var r;e(r=this.partialSpans.has(t)?this.partialSpans.get(t):Gt.create(t,this[$t])),r.endTimestamp?this._writeSpan(t):this.partialSpans.set(t,r)}},{key:"_timedOut",value:function(t){return t.startTimestamp+this.timeout<Ht()}},{key:"record",value:function(t){var e=t.traceId;this._updateSpanMap(e,function(r){switch(t.annotation.annotationType){case"ClientSend":r.delegate.setKind("CLIENT");break;case"ClientRecv":r.finish(),r.delegate.setKind("CLIENT");break;case"ServerSend":r.finish(),r.delegate.setKind("SERVER");break;case"ServerRecv":r.delegate.setShared(e.isShared()),r.delegate.setKind("CLIENT");break;case"ProducerStart":r.delegate.setKind("PRODUCER");break;case"ProducerStop":r.finish(),r.delegate.setKind("PRODUCER");break;case"ConsumerStart":r.delegate.setKind("CONSUMER");break;case"ConsumerStop":r.finish(),r.delegate.setKind("CONSUMER");break;case"MessageAddr":r.delegate.setRemoteEndpoint(new Xt({serviceName:t.annotation.serviceName,ipv4:t.annotation.host&&t.annotation.host.ipv4(),port:t.annotation.port}));break;case"LocalOperationStart":r.delegate.setName(t.annotation.name);break;case"LocalOperationStop":r.finish();break;case"Message":r.delegate.addAnnotation(t.timestamp,t.annotation.message);break;case"Rpc":r.delegate.setName(t.annotation.name);break;case"ServiceName":r.localEndpoint.setServiceName(t.annotation.serviceName);break;case"BinaryAnnotation":r.delegate.putTag(t.annotation.key,t.annotation.value);break;case"LocalAddr":r.localEndpoint.setIpv4(t.annotation.host&&t.annotation.host.ipv4()),r.localEndpoint.setPort(t.annotation.port);break;case"ServerAddr":r.delegate.setKind("CLIENT"),r.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;r(this,t),this.logger=e}return o(t,[{key:"record",value:function(t){var e=t.traceId,r=e.spanId,n=e.parentId,o=e.traceId;this.logger("Record at (timestamp=".concat(t.timestamp,", spanId=").concat(r,", parentId=").concat(n,", ")+"traceId=".concat(o,"): ").concat(""+t.annotation))}},{key:"toString",value:function(){return"consoleTracer"}}]),t}(),te=2147483647,ee=36,re=1,ne=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-re,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,r){var n=0;for(t=r?le(t/ie):t>>1,t+=le(t/e);t>pe*ne>>1;n+=ee)t=le(t/pe);return le(n+(pe+1)*t/(t+oe))}function ye(t){return function(t,e){var r=t.split("@"),n="";r.length>1&&(n=r[0]+"@",t=r[1]);var o=function(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}((t=t.replace(he,".")).split("."),e).join(".");return n+o}(t,function(t){return ce.test(t)?"xn--"+function(t){var e,r,n,o,i,a,s,u,c,h,f,p,l,d,v,m=[];for(p=(t=function(t){for(var e,r,n=[],o=0,i=t.length;i>o;)55296>(e=t.charCodeAt(o++))||e>56319||o>=i?n.push(e):56320==(64512&(r=t.charCodeAt(o++)))?n.push(((1023&e)<<10)+(1023&r)+65536):(n.push(e),o--);return n}(t)).length,e=se,r=0,i=ae,a=0;p>a;++a)128>(f=t[a])&&m.push(de(f));for(n=o=m.length,o&&m.push(ue);p>n;){for(s=te,a=0;p>a;++a)(f=t[a])>=e&&s>f&&(s=f);for(s-e>le((te-r)/(l=n+1))&&ve("overflow"),r+=(s-e)*l,e=s,a=0;p>a;++a)if(e>(f=t[a])&&++r>te&&ve("overflow"),f==e){for(u=r,c=ee;(h=c>i?i+ne>c?c-i:ne:re)<=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(r,l,n==o),r=0,++n}++r,++e}return m.join("")}(t):t})}var we=[],Ie=[],be="undefined"!=typeof Uint8Array?Uint8Array:Array,Ee=!1;function Se(){Ee=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0;64>e;++e)we[e]=t[e],Ie[t.charCodeAt(e)]=e;Ie[45]=62,Ie[95]=63}function Ae(t,e,r){for(var n,o=[],i=e;r>i;i+=3)o.push(we[(n=(t[i]<<16)+(t[i+1]<<8)+t[i+2])>>18&63]+we[n>>12&63]+we[n>>6&63]+we[63&n]);return o.join("")}function Re(t){var e;Ee||Se();for(var r=t.length,n=r%3,o="",i=[],a=0,s=r-n;s>a;a+=16383)i.push(Ae(t,a,a+16383>s?s:a+16383));return 1===n?(o+=we[(e=t[r-1])>>2],o+=we[e<<4&63],o+="=="):2===n&&(o+=we[(e=(t[r-2]<<8)+t[r-1])>>10],o+=we[e>>4&63],o+=we[e<<2&63],o+="="),i.push(o),i.join("")}function _e(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<<s)-1,c=u>>1,h=-7,f=r?o-1:0,p=r?-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+=n;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,n),i-=c}return(l?-1:1)*a*Math.pow(2,i-n)}function Te(t,e,r,n,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=n?0:i-1,d=n?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[r+l]=255&s,l+=d,s/=256,o-=8);for(a=a<<o|s,c+=o;c>0;t[r+l]=255&a,l+=d,a/=256,c-=8);t[r+l-d]|=128*v}var ke={}.toString,Oe=Array.isArray||function(t){return"[object Array]"==ke.call(t)};function Pe(){return Ne.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Ce(t,e){if(Pe()<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,r){if(!(Ne.TYPED_ARRAY_SUPPORT||this instanceof Ne))return new Ne(t,e,r);if("number"==typeof t){if("string"==typeof e)throw Error("If encoding is specified then the first argument must be a string");return xe(this,t)}return Ue(this,t,e,r)}function Ue(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(0>r||r>e.byteLength)throw new RangeError("'offset' is out of bounds");if(r+(n||0)>e.byteLength)throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);Ne.TYPED_ARRAY_SUPPORT?(t=e).__proto__=Ne.prototype:t=Le(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!Ne.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|De(e,r),o=(t=Ce(t,n)).write(e,r);o!==n&&(t=t.slice(0,o));return t}(t,e,r):function(t,e){if(je(e)){var r=0|Me(e.length);return 0===(t=Ce(t,r)).length?t:(e.copy(t,0,0,r),t)}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?Ce(t,0):Le(t,e);if("Buffer"===e.type&&Oe(e.data))return Le(t,e.data)}var n;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 xe(t,e){if(Be(e),t=Ce(t,0>e?0:0|Me(e)),!Ne.TYPED_ARRAY_SUPPORT)for(var r=0;e>r;++r)t[r]=0;return t}function Le(t,e){var r=0>e.length?0:0|Me(e.length);t=Ce(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function Me(t){if(t>=Pe())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Pe().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 r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return fr(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return pr(t).length;default:if(n)return fr(t).length;e=(""+e).toLowerCase(),n=!0}}function Ye(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function qe(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:-2147483648>r&&(r=-2147483648),isNaN(r=+r)&&(r=o?0:t.length-1),0>r&&(r=t.length+r),t.length>r){if(0>r){if(!o)return-1;r=0}}else{if(o)return-1;r=t.length-1}if("string"==typeof e&&(e=Ne.from(e,n)),je(e))return 0===e.length?-1:Fe(t,e,r,n,o);if("number"==typeof e)return e&=255,Ne.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):Fe(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function Fe(t,e,r,n,o){var i,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=(n+"").toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(2>t.length||2>e.length)return-1;a=2,s/=2,u/=2,r/=2}function c(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var h=-1;for(i=r;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(r+u>s&&(r=s-u),i=r;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,r,n){var o=t.length-(r=+r||0);n?(n=+n)>o&&(n=o):n=o;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var a=0;n>a;++a){var s=parseInt(e.substr(2*a,2),16);if(isNaN(s))return a;t[r+a]=s}return a}function Ke(t,e,r,n){return lr(fr(e,t.length-r),t,r,n)}function He(t,e,r,n){return lr(function(t){for(var e=[],r=0;t.length>r;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function Ve(t,e,r,n){return He(t,e,r,n)}function Je(t,e,r,n){return lr(pr(e),t,r,n)}function Xe(t,e,r,n){return lr(function(t,e){for(var r,n,o=[],i=0;t.length>i&&0<=(e-=2);++i)r=t.charCodeAt(i),n=r>>8,o.push(r%256),o.push(n);return o}(e,t.length-r),t,r,n)}function Ze(t,e,r){return Re(0===e&&r===t.length?t:t.slice(e,r))}function $e(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;r>o;){var i,a,s,u,c=t[o],h=null,f=c>239?4:c>223?3:c>191?2:1;if(r>=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&&(n.push((h-=65536)>>>10&1023|55296),h=56320|1023&h),n.push(h),o+=f}return function(t){var e=t.length;if(Ge>=e)return String.fromCharCode.apply(String,t);var r="",n=0;for(;e>n;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Ge));return r}(n)}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,r){return Ue(null,t,e,r)},Ne.TYPED_ARRAY_SUPPORT&&(Ne.prototype.__proto__=Uint8Array.prototype,Ne.__proto__=Uint8Array),Ne.alloc=function(t,e,r){return function(t,e,r,n){return Be(e),e>0&&void 0!==r?"string"==typeof n?Ce(t,e).fill(r,n):Ce(t,e).fill(r):Ce(t,e)}(null,t,e,r)},Ne.allocUnsafe=function(t){return xe(null,t)},Ne.allocUnsafeSlow=function(t){return xe(null,t)},Ne.isBuffer=function(t){return null!=t&&(!!t._isBuffer||dr(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&dr(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 r=t.length,n=e.length,o=0,i=Math.min(r,n);i>o;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return n>r?-1:r>n?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 r;if(void 0===e)for(e=0,r=0;t.length>r;++r)e+=t[r].length;var n=Ne.allocUnsafe(e),o=0;for(r=0;t.length>r;++r){var i=t[r];if(!je(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o),o+=i.length}return n},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,r){var n=!1;if((void 0===e||0>e)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),0>=r)return"";if((e>>>=0)>=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return tr(this,e,r);case"utf8":case"utf-8":return $e(this,e,r);case"ascii":return Qe(this,e,r);case"latin1":case"binary":return We(this,e,r);case"base64":return Ze(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return er(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!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,r,n,o){if(!je(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),0>e||r>t.length||0>n||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(i,a),u=this.slice(n,o),c=t.slice(e,r),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,r){return-1!==this.indexOf(t,e,r)},Ne.prototype.indexOf=function(t,e,r){return qe(this,t,e,r,!0)},Ne.prototype.lastIndexOf=function(t,e,r){return qe(this,t,e,r,!1)},Ne.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(0>r||0>e)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return ze(this,t,e,r);case"utf8":case"utf-8":return Ke(this,t,e,r);case"ascii":return He(this,t,e,r);case"latin1":case"binary":return Ve(this,t,e,r);case"base64":return Je(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Xe(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).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,r){var n="";r=Math.min(t.length,r);for(var o=e;r>o;++o)n+=String.fromCharCode(127&t[o]);return n}function We(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;r>o;++o)n+=String.fromCharCode(t[o]);return n}function tr(t,e,r){var n=t.length;e&&e>=0||(e=0),(!r||0>r||r>n)&&(r=n);for(var o="",i=e;r>i;++i)o+=hr(t[i]);return o}function er(t,e,r){for(var n=t.slice(e,r),o="",i=0;n.length>i;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function rr(t,e,r){if(t%1!=0||0>t)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function nr(t,e,r,n,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(r+n>t.length)throw new RangeError("Index out of range")}function or(t,e,r,n){0>e&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-r,2);i>o;++o)t[r+o]=(e&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function ir(t,e,r,n){0>e&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-r,4);i>o;++o)t[r+o]=e>>>8*(n?o:3-o)&255}function ar(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(0>r)throw new RangeError("Index out of range")}function sr(t,e,r,n,o){return o||ar(t,0,r,4),Te(t,e,r,n,23,4),r+4}function ur(t,e,r,n,o){return o||ar(t,0,r,8),Te(t,e,r,n,52,8),r+8}Ne.prototype.slice=function(t,e){var r,n=this.length;if(0>(t=~~t)?0>(t+=n)&&(t=0):t>n&&(t=n),0>(e=void 0===e?n:~~e)?0>(e+=n)&&(e=0):e>n&&(e=n),t>e&&(e=t),Ne.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=Ne.prototype;else{var o=e-t;r=new Ne(o,void 0);for(var i=0;o>i;++i)r[i]=this[i+t]}return r},Ne.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||rr(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},Ne.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||rr(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},Ne.prototype.readUInt8=function(t,e){return e||rr(t,1,this.length),this[t]},Ne.prototype.readUInt16LE=function(t,e){return e||rr(t,2,this.length),this[t]|this[t+1]<<8},Ne.prototype.readUInt16BE=function(t,e){return e||rr(t,2,this.length),this[t]<<8|this[t+1]},Ne.prototype.readUInt32LE=function(t,e){return e||rr(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||rr(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Ne.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||rr(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return(o*=128)>n||(n-=Math.pow(2,8*e)),n},Ne.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||rr(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return(o*=128)>i||(i-=Math.pow(2,8*e)),i},Ne.prototype.readInt8=function(t,e){return e||rr(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Ne.prototype.readInt16LE=function(t,e){e||rr(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},Ne.prototype.readInt16BE=function(t,e){e||rr(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},Ne.prototype.readInt32LE=function(t,e){return e||rr(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||rr(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||rr(t,4,this.length),_e(this,t,!0,23,4)},Ne.prototype.readFloatBE=function(t,e){return e||rr(t,4,this.length),_e(this,t,!1,23,4)},Ne.prototype.readDoubleLE=function(t,e){return e||rr(t,8,this.length),_e(this,t,!0,52,8)},Ne.prototype.readDoubleBE=function(t,e){return e||rr(t,8,this.length),_e(this,t,!1,52,8)},Ne.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||nr(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},Ne.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||nr(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},Ne.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||nr(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,r){return t=+t,e|=0,r||nr(this,t,e,2,65535,0),Ne.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):or(this,t,e,!0),e+2},Ne.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,2,65535,0),Ne.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):or(this,t,e,!1),e+2},Ne.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||nr(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):ir(this,t,e,!0),e+4},Ne.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||nr(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):ir(this,t,e,!1),e+4},Ne.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);nr(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i<r&&(a*=256);)0>t&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/a>>0)-s&255;return e+r},Ne.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);nr(this,t,e,r,o-1,-o)}var i=r-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+r},Ne.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||nr(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,r){return t=+t,e|=0,r||nr(this,t,e,2,32767,-32768),Ne.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):or(this,t,e,!0),e+2},Ne.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||nr(this,t,e,2,32767,-32768),Ne.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):or(this,t,e,!1),e+2},Ne.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||nr(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):ir(this,t,e,!0),e+4},Ne.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||nr(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):ir(this,t,e,!1),e+4},Ne.prototype.writeFloatLE=function(t,e,r){return sr(this,t,e,!0,r)},Ne.prototype.writeFloatBE=function(t,e,r){return sr(this,t,e,!1,r)},Ne.prototype.writeDoubleLE=function(t,e,r){return ur(this,t,e,!0,r)},Ne.prototype.writeDoubleBE=function(t,e,r){return ur(this,t,e,!1,r)},Ne.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),t.length>e||(e=t.length),e||(e=0),n>0&&r>n&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>n)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),n-r>t.length-e&&(n=t.length-e+r);var o,i=n-r;if(this===t&&e>r&&n>e)for(o=i-1;o>=0;--o)t[o+e]=this[o+r];else if(1e3>i||!Ne.TYPED_ARRAY_SUPPORT)for(o=0;i>o;++o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+i),e);return i},Ne.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var o=t.charCodeAt(0);256>o&&(t=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Ne.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(0>e||e>this.length||r>this.length)throw new RangeError("Out of range index");if(e>=r)return this;var i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;r>i;++i)this[i]=t;else{var a=je(t)?t:fr(""+new Ne(t,n)),s=a.length;for(i=0;r-e>i;++i)this[i+e]=a[i%s]}return this};var cr=/[^+\/0-9A-Za-z-_]/g;function hr(t){return 16>t?"0"+t.toString(16):t.toString(16)}function fr(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],a=0;n>a;++a){if((r=t.charCodeAt(a))>55295&&57344>r){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(56320>r){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,128>r){if(0>(e-=1))break;i.push(r)}else if(2048>r){if(0>(e-=2))break;i.push(r>>6|192,63&r|128)}else if(65536>r){if(0>(e-=3))break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(r>=1114112)throw Error("Invalid code point");if(0>(e-=4))break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function pr(t){return function(t){var e,r,n,o,i,a;Ee||Se();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)),n=i>0?s-4:s;var u=0;for(e=0,r=0;n>e;e+=4,r+=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(cr,"")).length)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function lr(t,e,r,n){for(var o=0;n>o&&(o+r<e.length&&o<t.length);++o)e[o+r]=t[o];return o}function dr(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}function vr(t){return null===t}function mr(t){return"string"==typeof t}function gr(t){return"object"==typeof t&&null!==t}function yr(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var wr=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function Ir(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}}function br(t,e){if(t.map)return t.map(e);for(var r=[],n=0;t.length>n;n++)r.push(e(t[n],n));return r}var Er=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return e};function Sr(t,e,r,n){r=r||"=";var o={};if("string"!=typeof t||0===t.length)return o;var i=/\+/g;t=t.split(e=e||"&");var a=1e3;n&&"number"==typeof n.maxKeys&&(a=n.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(r);0>d?(c=l,h=""):(c=l.substr(0,d),h=l.substr(d+1)),f=decodeURIComponent(c),p=decodeURIComponent(h),yr(o,f)?wr(o[f])?o[f].push(p):o[f]=[o[f],p]:o[f]=p}return o}var Ar={parse:Dr,resolve:function(t,e){return Dr(t,!1,!0).resolve(e)},resolveObject:function(t,e){return t?Dr(t,!1,!0).resolveObject(e):e},format:function(t){mr(t)&&(t=Yr({},t));return qr(t)},Url:Rr};function Rr(){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 _r=/^([a-z0-9.+-]+:)/i,Tr=/:[0-9]*$/,kr=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Or=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),Pr=["'"].concat(Or),Cr=["%","/","?",";","#"].concat(Pr),Nr=["/","?","#"],Ur=255,Br=/^[+a-z0-9A-Z_-]{0,63}$/,xr=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Lr={javascript:!0,"javascript:":!0},Mr={javascript:!0,"javascript:":!0},jr={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function Dr(t,e,r){if(t&&gr(t)&&t instanceof Rr)return t;var n=new Rr;return n.parse(t,e,r),n}function Yr(t,e,r,n){if(!mr(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(),!n&&1===e.split("#").length){var u=kr.exec(s);if(u)return t.path=s,t.href=s,t.pathname=u[1],u[2]?(t.search=u[2],t.query=r?Sr(t.search.substr(1)):t.search.substr(1)):r&&(t.search="",t.query={}),t}var c,h,f,p=_r.exec(s);if(p){var l=(p=p[0]).toLowerCase();t.protocol=l,s=s.substr(p.length)}if(n||p||s.match(/^\/\/[^@\/]+@[^@\/]+/)){var d="//"===s.substr(0,2);!d||p&&Mr[p]||(s=s.substr(2),t.slashes=!0)}if(!Mr[p]&&(d||p&&!jr[p])){var v,m,g=-1;for(c=0;Nr.length>c;c++)-1===(h=s.indexOf(Nr[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;Cr.length>c;c++)-1===(h=s.indexOf(Cr[c]))||-1!==g&&h>=g||(g=h);-1===g&&(g=s.length),t.host=s.slice(0,g),s=s.slice(g),Fr(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 I=w[c];if(I&&!I.match(Br)){for(var b="",E=0,S=I.length;S>E;E++)I.charCodeAt(E)>127?b+="x":b+=I[E];if(!b.match(Br)){var A=w.slice(0,c),R=w.slice(c+1),_=I.match(xr);_&&(A.push(_[1]),R.unshift(_[2])),R.length&&(s="/"+R.join(".")+s),t.hostname=A.join(".");break}}}}t.hostname=t.hostname.length>Ur?"":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(!Lr[l])for(c=0,f=Pr.length;f>c;c++){var T=Pr[c];if(-1!==s.indexOf(T)){var k=encodeURIComponent(T);k===T&&(k=escape(T)),s=s.split(T).join(k)}}var O=s.indexOf("#");-1!==O&&(t.hash=s.substr(O),s=s.slice(0,O));var P=s.indexOf("?");(-1!==P?(t.search=s.substr(P),t.query=s.substr(P+1),r&&(t.query=Sr(t.query)),s=s.slice(0,P)):r&&(t.search="",t.query={}),s&&(t.pathname=s),jr[l]&&t.hostname&&!t.pathname&&(t.pathname="/"),t.pathname||t.search)&&(t.path=(t.pathname||"")+(t.search||""));return t.href=qr(t),t}function qr(t){var e=t.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var r,n,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&&gr(t.query)&&Object.keys(t.query).length&&(n=n||"&",o=o||"=",null===(r=t.query)&&(r=void 0),h="object"==typeof r?br(Er(r),function(t){var e=encodeURIComponent(Ir(t))+o;return wr(r[t])?br(r[t],function(t){return e+encodeURIComponent(Ir(t))}).join(n):e+encodeURIComponent(Ir(r[t]))}).join(n):i?encodeURIComponent(Ir(i))+o+encodeURIComponent(Ir(r)):"");var f=t.search||h&&"?"+h||"";return a&&":"!==a.substr(-1)&&(a+=":"),t.slashes||(!a||jr[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 Fr(t){var e=t.host,r=Tr.exec(e);r&&(":"!==(r=r[0])&&(t.port=r.substr(1)),e=e.substr(0,e.length-r.length)),e&&(t.hostname=e)}Rr.prototype.parse=function(t,e,r){return Yr(this,t,e,r)},Rr.prototype.format=function(){return qr(this)},Rr.prototype.resolve=function(t){return this.resolveObject(Dr(t,!1,!0)).format()},Rr.prototype.resolveObject=function(t){if(mr(t)){var e=new Rr;e.parse(t,!1,!0),t=e}for(var r,n=new Rr,o=Object.keys(this),i=0;o.length>i;i++){var a=o[i];n[a]=this[a]}if(n.hash=t.hash,""===t.href)return n.href=n.format(),n;if(t.slashes&&!t.protocol){for(var s=Object.keys(t),u=0;s.length>u;u++){var c=s[u];"protocol"!==c&&(n[c]=t[c])}return jr[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(t.protocol&&t.protocol!==n.protocol){if(!jr[t.protocol]){for(var h=Object.keys(t),f=0;h.length>f;f++){var p=h[f];n[p]=t[p]}return n.href=n.format(),n}if(n.protocol=t.protocol,t.host||Mr[t.protocol])n.pathname=t.pathname;else{for(r=(t.pathname||"").split("/");r.length&&!(t.host=r.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==r[0]&&r.unshift(""),2>r.length&&r.unshift(""),n.pathname=r.join("/")}if(n.search=t.search,n.query=t.query,n.host=t.host||"",n.auth=t.auth,n.hostname=t.hostname||t.host,n.port=t.port,n.pathname||n.search)n.path=(n.pathname||"")+(n.search||"");return n.slashes=n.slashes||t.slashes,n.href=n.format(),n}var l,d=n.pathname&&"/"===n.pathname.charAt(0),v=t.host||t.pathname&&"/"===t.pathname.charAt(0),m=v||d||n.host&&t.pathname,g=m,y=n.pathname&&n.pathname.split("/")||[],w=n.protocol&&!jr[n.protocol];if(r=t.pathname&&t.pathname.split("/")||[],w&&(n.hostname="",n.port=null,n.host&&(""===y[0]?y[0]=n.host:y.unshift(n.host)),n.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===r[0]?r[0]=t.host:r.unshift(t.host)),t.host=null),m=m&&(""===r[0]||""===y[0])),v)n.host=t.host||""===t.host?t.host:n.host,n.hostname=t.hostname||""===t.hostname?t.hostname:n.hostname,n.search=t.search,n.query=t.query,y=r;else if(r.length)y||(y=[]),y.pop(),y=y.concat(r),n.search=t.search,n.query=t.query;else if(null!=t.search)return w&&(n.hostname=n.host=y.shift(),(l=!(!n.host||0>=n.host.indexOf("@"))&&n.host.split("@"))&&(n.auth=l.shift(),n.host=n.hostname=l.shift())),n.search=t.search,n.query=t.query,vr(n.pathname)&&vr(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!y.length)return n.pathname=null,n.path=n.search?"/"+n.search:null,n.href=n.format(),n;for(var I=y.slice(-1)[0],b=(n.host||t.host||y.length>1)&&("."===I||".."===I)||""===I,E=0,S=y.length;S>=0;S--)"."===(I=y[S])?y.splice(S,1):".."===I?(y.splice(S,1),E++):E&&(y.splice(S,1),E--);if(!m&&!g)for(;E--;E)y.unshift("..");!m||""===y[0]||y[0]&&"/"===y[0].charAt(0)||y.unshift(""),b&&"/"!==y.join("/").substr(-1)&&y.push("");var A=""===y[0]||y[0]&&"/"===y[0].charAt(0);return w&&(n.hostname=n.host=A?"":y.length?y.shift():"",(l=!(!n.host||0>=n.host.indexOf("@"))&&n.host.split("@"))&&(n.auth=l.shift(),n.host=n.hostname=l.shift())),(m=m||n.host&&y.length)&&!A&&y.unshift(""),y.length?n.pathname=y.join("/"):(n.pathname=null,n.path=null),vr(n.pathname)&&vr(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=t.auth||n.auth,n.slashes=n.slashes||t.slashes,n.href=n.format(),n},Rr.prototype.parseHost=function(){return Fr(this)};var zr=function(t){var e=Ar.parse(t);return{host:e.hostname,path:e.pathname}},Kr=p.Some,Hr=p.None;function Vr(t){return"1"===t||"true"===t}function Jr(t){try{return new Kr(parseInt(t))}catch(t){return Hr}}function Xr(t){throw Error("HttpServerInstrumentation: Missing required argument ".concat(t,"."))}var Zr={addZipkinHeaders:function(t,e){var r=function(t,e){var r=t.headers||{};return r[Kt.TraceId]=e.traceId,r[Kt.SpanId]=e.spanId,e.parentSpanId.ifPresent(function(t){r[Kt.ParentSpanId]=t}),e.sampled.ifPresent(function(t){r[Kt.Sampled]=t?"1":"0"}),e.isDebug()&&(r[Kt.Flags]="1"),r}(t,e);return Object.assign({},t,{headers:r})}};var $r={HttpServer:function(){function t(e){var n=e.tracer,o=void 0===n?Xr("tracer"):n,i=e.serviceName,a=void 0===i?o.localEndpoint.serviceName:i,s=e.host,u=e.port,c=void 0===u?Xr("port"):u;r(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(Kt.TraceId)!==Hr&&t(Kt.SpanId)!==Hr}(t)){var e=t(Kt.SpanId).map(function(e){var r=t(Kt.TraceId),n=t(Kt.ParentSpanId),o=t(Kt.Sampled),i=t(Kt.Flags).flatMap(Jr).getOrElse(0);return new Rt({traceId:r.getOrElse(),parentId:n,spanId:e,debug:1===i,sampled:o.map(Vr)})});return new Kr(this.tracer.join(e.getOrElse()))}if(t(Kt.Flags)!==Hr||t(Kt.Sampled)!==Hr){var r=t(Kt.Sampled)===Hr?Hr:t(Kt.Sampled).map(Vr),n=t(Kt.Flags).flatMap(Jr).getOrElse(0);return new Kr(this.tracer.createRootId(r,1===n))}return new Kr(this.tracer.createRootId())}},{key:"recordRequest",value:function(t,e,r){var n=this;this._createIdFromHeaders(r).ifPresent(function(t){return n.tracer.setId(t)});var o=this.tracer.id,i=zr(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,r){this.tracer.setId(t),this.tracer.recordBinary("http.status_code",""+e),r?this.tracer.recordBinary("error",""+r):(200>e||e>399)&&this.tracer.recordBinary("error",""+e),this.tracer.recordAnnotation(new lt.ServerSend)}}]),t}(),HttpClient:function(){function t(e){var n=e.tracer,o=void 0===n?function(t){throw Error("HttpClientInstrumentation: Missing required argument ".concat(t,"."))}("tracer"):n,i=e.serviceName,a=void 0===i?o.localEndpoint.serviceName:i,s=e.remoteServiceName;r(this,t),this.tracer=o,this.serviceName=a,this.remoteServiceName=s}return o(t,[{key:"recordRequest",value:function(t,e,r){this.tracer.setId(this.tracer.createChildId());var n=this.tracer.id,o=zr(e).path;return this.tracer.recordServiceName(this.serviceName),this.tracer.recordRpc(r.toUpperCase()),this.tracer.recordBinary("http.path",o),this.tracer.recordAnnotation(new lt.ClientSend),this.remoteServiceName&&this.tracer.recordAnnotation(new lt.ServerAddr({serviceName:this.remoteServiceName})),Zr.addZipkinHeaders(t,n)}},{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 Gr(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 Qr={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 r,n,o,i=Gr(t.localEndpoint);switch(t.kind){case"CLIENT":r=t.timestamp?"cs":void 0,n="cr",o="sa";break;case"SERVER":r=t.timestamp?"sr":void 0,n="ss",o="ca";break;case"PRODUCER":r=t.timestamp?"ms":void 0,n="ws",o="ma";break;case"CONSUMER":t.timestamp&&t.duration?(r="wr",n="mr"):t.timestamp&&(r="mr"),o="ma"}(t.annotations.length>0||r)&&(e.annotations=t.annotations.map(function(t){return function(t,e){return{value:t.value,timestamp:t.timestamp,endpoint:e}}(t,i)})),r&&(e.annotations.push({value:r,timestamp:t.timestamp,endpoint:i}),t.duration&&e.annotations.push({value:n,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:Gr(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=Ft,t.createNoopTracer=function(){var t=new zt;return new Ft({recorder:{record:function(){}},ctxImpl:t})},t.randomTraceId=_t,t.sampler=yt,t.TraceId=Rt,t.HttpHeaders=Kt,t.InetAddress=V,t.BatchRecorder=Qt,t.ConsoleRecorder=Wt,t.ExplicitContext=zt,t.Instrumentation=$r,t.Request=Zr,t.jsonEncoder=Qr,t.model=Nt,t.parseRequestUrl=zr,Object.defineProperty(t,"__esModule",{value:!0})}); |
159
es/index.js
@@ -701,3 +701,5 @@ import os from 'os'; | ||
verifyIsOptional$1 = option.verifyIsOptional, | ||
verifyIsNotOptional$1 = option.verifyIsNotOptional; | ||
verifyIsNotOptional$1 = option.verifyIsNotOptional, | ||
isOptional$1 = option.isOptional; | ||
var T = new Some$2(true); | ||
@@ -710,20 +712,32 @@ var TraceId = | ||
var _params$traceId = params.traceId, | ||
traceId = _params$traceId === void 0 ? None$1 : _params$traceId, | ||
var spanId = params.spanId, | ||
_params$traceId = params.traceId, | ||
traceId = _params$traceId === void 0 ? spanId : _params$traceId, | ||
_params$parentId = params.parentId, | ||
parentId = _params$parentId === void 0 ? None$1 : _params$parentId, | ||
spanId = params.spanId, | ||
_params$flags = params.flags, | ||
flags = _params$flags === void 0 ? 0 : _params$flags, | ||
_params$debug = params.debug, | ||
debug = _params$debug === void 0 ? flags === 1 : _params$debug, | ||
_params$sampled = params.sampled, | ||
sampled = _params$sampled === void 0 ? None$1 : _params$sampled, | ||
_params$flags = params.flags, | ||
flags = _params$flags === void 0 ? 0 : _params$flags; | ||
verifyIsOptional$1(traceId); | ||
_params$shared = params.shared, | ||
shared = _params$shared === void 0 ? false : _params$shared; | ||
verifyIsNotOptional$1(spanId); | ||
verifyIsOptional$1(parentId); | ||
verifyIsNotOptional$1(spanId); | ||
verifyIsOptional$1(sampled); | ||
this._traceId = traceId; | ||
verifyIsOptional$1(sampled); // support old signatures which allowed traceId to be optional | ||
if (isOptional$1(traceId)) { | ||
this._traceId = traceId.getOrElse(spanId); | ||
} else if (typeof traceId === 'undefined' || traceId === null) { | ||
this._traceId = spanId; | ||
} else { | ||
this._traceId = traceId; | ||
} | ||
this._parentId = parentId; | ||
this._spanId = spanId; | ||
this._sampled = sampled; | ||
this._flags = flags; | ||
this._sampled = debug ? T : sampled; | ||
this._debug = debug; | ||
this._shared = shared; | ||
} | ||
@@ -734,26 +748,39 @@ | ||
value: function isDebug() { | ||
// The jshint tool always complains about using bitwise operators, | ||
// but in this case it's actually intentional, so we disable the warning: | ||
// jshint bitwise: false | ||
return (this._flags & 1) === 1; | ||
return this._debug; | ||
} | ||
}, { | ||
key: "isShared", | ||
value: function isShared() { | ||
return this._shared; | ||
} | ||
}, { | ||
key: "toString", | ||
value: function toString() { | ||
return "TraceId(spanId=".concat(this.spanId.toString()) + ", parentId=".concat(this.parentId.toString()) + ", traceId=".concat(this.traceId.toString(), ")"); | ||
return "TraceId(spanId=".concat(this.spanId.toString()) + ", parentSpanId=".concat(this.parentSpanId.toString()) + ", traceId=".concat(this.traceId.toString(), ")"); | ||
} | ||
}, { | ||
key: "spanId", | ||
key: "traceId", | ||
get: function get() { | ||
return this._spanId; | ||
return this._traceId; | ||
} | ||
}, { | ||
key: "parentSpanId", | ||
get: function get() { | ||
return this._parentId; | ||
} | ||
/** | ||
* Please use parentSpanId instead as this can return confusing results (the span ID when absent). | ||
* | ||
* @deprecated since version v0.19 | ||
*/ | ||
}, { | ||
key: "parentId", | ||
get: function get() { | ||
return this._parentId.getOrElse(this.spanId); | ||
return this._parentId.getOrElse(this._spanId); | ||
} | ||
}, { | ||
key: "traceId", | ||
key: "spanId", | ||
get: function get() { | ||
return this._traceId.getOrElse(this.parentId); | ||
return this._spanId; | ||
} | ||
@@ -763,8 +790,14 @@ }, { | ||
get: function get() { | ||
return this.isDebug() ? new Some$2(true) : this._sampled; | ||
return this._sampled; | ||
} | ||
/** | ||
* Please use isDebug instead. | ||
* | ||
* @deprecated since version v0.19 | ||
*/ | ||
}, { | ||
key: "flags", | ||
get: function get() { | ||
return this._flags; | ||
return this._debug ? 1 : 0; | ||
} | ||
@@ -863,7 +896,5 @@ }]); | ||
this.traceId = traceId.traceId; | ||
traceId._parentId.ifPresent(function (id) { | ||
traceId.parentSpanId.ifPresent(function (id) { | ||
_this.parentId = id; | ||
}); | ||
this.id = traceId.spanId; | ||
@@ -883,3 +914,3 @@ this.name = undefined; // no default | ||
this.debug = traceId.isDebug(); | ||
this.shared = false; | ||
this.shared = traceId.isShared(); | ||
} | ||
@@ -960,4 +991,3 @@ | ||
var None$2 = option.None, | ||
Some$3 = option.Some, | ||
fromNullable$1 = option.fromNullable; | ||
Some$3 = option.Some; | ||
var Sampler$1 = sampler.Sampler, | ||
@@ -1035,3 +1065,3 @@ alwaysSample$1 = sampler.alwaysSample; | ||
var rootSpanId = randomTraceId_1(); | ||
var traceId = this.traceId128Bit ? new Some$3(randomTraceId_1() + rootSpanId) : None$2; | ||
var traceId = this.traceId128Bit ? randomTraceId_1() + rootSpanId : rootSpanId; | ||
var id = new TraceId_1({ | ||
@@ -1052,19 +1082,24 @@ traceId: traceId, | ||
}, { | ||
key: "isUndefinedOrNull", | ||
value: function isUndefinedOrNull(obj) { | ||
return typeof obj === 'undefined' || obj === null; | ||
} | ||
}, { | ||
key: "createChildId", | ||
value: function createChildId() { | ||
var currentId = fromNullable$1(this._ctxImpl.getContext()); | ||
value: function createChildId(parentId) { | ||
if (this.isUndefinedOrNull(parentId)) { | ||
/* eslint-disable no-param-reassign */ | ||
parentId = this._ctxImpl.getContext(); | ||
} | ||
if (this.isUndefinedOrNull(parentId)) { | ||
return this.createRootId(); | ||
} | ||
var childId = new TraceId_1({ | ||
traceId: currentId.map(function (id) { | ||
return id.traceId; | ||
}), | ||
parentId: currentId.map(function (id) { | ||
return id.spanId; | ||
}), | ||
traceId: parentId.traceId, | ||
parentId: new Some$3(parentId.spanId), | ||
spanId: randomTraceId_1(), | ||
sampled: currentId.flatMap(function (id) { | ||
return id.sampled; | ||
}), | ||
flags: currentId.map(function (id) { | ||
return id.flags; | ||
}).getOrElse(0) | ||
debug: parentId.isDebug(), | ||
sampled: parentId.sampled | ||
}); | ||
@@ -1145,4 +1180,2 @@ | ||
value: function join(traceId) { | ||
var _this2 = this; | ||
if (!(traceId instanceof TraceId_1)) { | ||
@@ -1152,10 +1185,15 @@ throw new Error('Must be valid TraceId instance'); | ||
if (traceId._sampled === None$2) { | ||
if (!this.supportsJoin) { | ||
return this.createChildId(traceId); | ||
} | ||
if (traceId.sampled === None$2) { | ||
/* eslint-disable no-param-reassign */ | ||
traceId._sampled = this.sampler.shouldSample(traceId); | ||
} else { | ||
/* eslint-disable no-param-reassign */ | ||
traceId._shared = true; | ||
} | ||
return !this.supportsJoin ? this.letId(traceId, function () { | ||
return _this2.createChildId(); | ||
}) : traceId; | ||
return traceId; | ||
} | ||
@@ -1170,3 +1208,3 @@ }, { | ||
value: function recordAnnotation(annotation) { | ||
var _this3 = this; | ||
var _this2 = this; | ||
@@ -1177,4 +1215,4 @@ var timestamp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : now$1(this._startTimestamp, this._startTick); | ||
_this3.recorder.record(new record({ | ||
traceId: _this3.id, | ||
_this2.recorder.record(new record({ | ||
traceId: _this2.id, | ||
timestamp: timestamp, | ||
@@ -1504,4 +1542,3 @@ annotation: annotation | ||
case 'ServerRecv': | ||
// TODO: only set this to false when we know we in an existing trace | ||
span.delegate.setShared(id.parentId !== id.spanId); | ||
span.delegate.setShared(id.isShared()); | ||
span.delegate.setKind('CLIENT'); | ||
@@ -1696,7 +1733,7 @@ break; | ||
return new TraceId_1({ | ||
traceId: traceId, | ||
traceId: traceId.getOrElse(), | ||
parentId: parentSpanId, | ||
spanId: sid, | ||
sampled: sampled.map(stringToBoolean), | ||
flags: flags | ||
debug: flags === 1, | ||
sampled: sampled.map(stringToBoolean) | ||
}); | ||
@@ -1764,7 +1801,5 @@ }); | ||
headers[httpHeaders.SpanId] = traceId.spanId; | ||
traceId._parentId.ifPresent(function (psid) { | ||
traceId.parentSpanId.ifPresent(function (psid) { | ||
headers[httpHeaders.ParentSpanId] = psid; | ||
}); | ||
traceId.sampled.ifPresent(function (sampled) { | ||
@@ -1771,0 +1806,0 @@ headers[httpHeaders.Sampled] = sampled ? '1' : '0'; |
@@ -65,15 +65,16 @@ // TypeScript type definitions | ||
readonly traceId: string; | ||
readonly parentId: string; | ||
readonly parentSpanId: option.IOption<string>; | ||
readonly spanId: string; | ||
readonly sampled: option.IOption<boolean>; | ||
readonly flags: number; | ||
isDebug(): boolean; | ||
isShared(): boolean; | ||
constructor(args?: { | ||
traceId?: option.IOption<string>, | ||
traceId?: string, | ||
parentId?: option.IOption<string>, | ||
spanId?: string, | ||
sampled?: option.IOption<boolean>, | ||
flags?: number | ||
debug?: boolean, | ||
shared?: boolean | ||
}); | ||
@@ -80,0 +81,0 @@ |
159
lib/index.js
@@ -707,3 +707,5 @@ 'use strict'; | ||
verifyIsOptional$1 = option.verifyIsOptional, | ||
verifyIsNotOptional$1 = option.verifyIsNotOptional; | ||
verifyIsNotOptional$1 = option.verifyIsNotOptional, | ||
isOptional$1 = option.isOptional; | ||
var T = new Some$2(true); | ||
@@ -716,20 +718,32 @@ var TraceId = | ||
var _params$traceId = params.traceId, | ||
traceId = _params$traceId === void 0 ? None$1 : _params$traceId, | ||
var spanId = params.spanId, | ||
_params$traceId = params.traceId, | ||
traceId = _params$traceId === void 0 ? spanId : _params$traceId, | ||
_params$parentId = params.parentId, | ||
parentId = _params$parentId === void 0 ? None$1 : _params$parentId, | ||
spanId = params.spanId, | ||
_params$flags = params.flags, | ||
flags = _params$flags === void 0 ? 0 : _params$flags, | ||
_params$debug = params.debug, | ||
debug = _params$debug === void 0 ? flags === 1 : _params$debug, | ||
_params$sampled = params.sampled, | ||
sampled = _params$sampled === void 0 ? None$1 : _params$sampled, | ||
_params$flags = params.flags, | ||
flags = _params$flags === void 0 ? 0 : _params$flags; | ||
verifyIsOptional$1(traceId); | ||
_params$shared = params.shared, | ||
shared = _params$shared === void 0 ? false : _params$shared; | ||
verifyIsNotOptional$1(spanId); | ||
verifyIsOptional$1(parentId); | ||
verifyIsNotOptional$1(spanId); | ||
verifyIsOptional$1(sampled); | ||
this._traceId = traceId; | ||
verifyIsOptional$1(sampled); // support old signatures which allowed traceId to be optional | ||
if (isOptional$1(traceId)) { | ||
this._traceId = traceId.getOrElse(spanId); | ||
} else if (typeof traceId === 'undefined' || traceId === null) { | ||
this._traceId = spanId; | ||
} else { | ||
this._traceId = traceId; | ||
} | ||
this._parentId = parentId; | ||
this._spanId = spanId; | ||
this._sampled = sampled; | ||
this._flags = flags; | ||
this._sampled = debug ? T : sampled; | ||
this._debug = debug; | ||
this._shared = shared; | ||
} | ||
@@ -740,26 +754,39 @@ | ||
value: function isDebug() { | ||
// The jshint tool always complains about using bitwise operators, | ||
// but in this case it's actually intentional, so we disable the warning: | ||
// jshint bitwise: false | ||
return (this._flags & 1) === 1; | ||
return this._debug; | ||
} | ||
}, { | ||
key: "isShared", | ||
value: function isShared() { | ||
return this._shared; | ||
} | ||
}, { | ||
key: "toString", | ||
value: function toString() { | ||
return "TraceId(spanId=".concat(this.spanId.toString()) + ", parentId=".concat(this.parentId.toString()) + ", traceId=".concat(this.traceId.toString(), ")"); | ||
return "TraceId(spanId=".concat(this.spanId.toString()) + ", parentSpanId=".concat(this.parentSpanId.toString()) + ", traceId=".concat(this.traceId.toString(), ")"); | ||
} | ||
}, { | ||
key: "spanId", | ||
key: "traceId", | ||
get: function get() { | ||
return this._spanId; | ||
return this._traceId; | ||
} | ||
}, { | ||
key: "parentSpanId", | ||
get: function get() { | ||
return this._parentId; | ||
} | ||
/** | ||
* Please use parentSpanId instead as this can return confusing results (the span ID when absent). | ||
* | ||
* @deprecated since version v0.19 | ||
*/ | ||
}, { | ||
key: "parentId", | ||
get: function get() { | ||
return this._parentId.getOrElse(this.spanId); | ||
return this._parentId.getOrElse(this._spanId); | ||
} | ||
}, { | ||
key: "traceId", | ||
key: "spanId", | ||
get: function get() { | ||
return this._traceId.getOrElse(this.parentId); | ||
return this._spanId; | ||
} | ||
@@ -769,8 +796,14 @@ }, { | ||
get: function get() { | ||
return this.isDebug() ? new Some$2(true) : this._sampled; | ||
return this._sampled; | ||
} | ||
/** | ||
* Please use isDebug instead. | ||
* | ||
* @deprecated since version v0.19 | ||
*/ | ||
}, { | ||
key: "flags", | ||
get: function get() { | ||
return this._flags; | ||
return this._debug ? 1 : 0; | ||
} | ||
@@ -869,7 +902,5 @@ }]); | ||
this.traceId = traceId.traceId; | ||
traceId._parentId.ifPresent(function (id) { | ||
traceId.parentSpanId.ifPresent(function (id) { | ||
_this.parentId = id; | ||
}); | ||
this.id = traceId.spanId; | ||
@@ -889,3 +920,3 @@ this.name = undefined; // no default | ||
this.debug = traceId.isDebug(); | ||
this.shared = false; | ||
this.shared = traceId.isShared(); | ||
} | ||
@@ -966,4 +997,3 @@ | ||
var None$2 = option.None, | ||
Some$3 = option.Some, | ||
fromNullable$1 = option.fromNullable; | ||
Some$3 = option.Some; | ||
var Sampler$1 = sampler.Sampler, | ||
@@ -1041,3 +1071,3 @@ alwaysSample$1 = sampler.alwaysSample; | ||
var rootSpanId = randomTraceId_1(); | ||
var traceId = this.traceId128Bit ? new Some$3(randomTraceId_1() + rootSpanId) : None$2; | ||
var traceId = this.traceId128Bit ? randomTraceId_1() + rootSpanId : rootSpanId; | ||
var id = new TraceId_1({ | ||
@@ -1058,19 +1088,24 @@ traceId: traceId, | ||
}, { | ||
key: "isUndefinedOrNull", | ||
value: function isUndefinedOrNull(obj) { | ||
return typeof obj === 'undefined' || obj === null; | ||
} | ||
}, { | ||
key: "createChildId", | ||
value: function createChildId() { | ||
var currentId = fromNullable$1(this._ctxImpl.getContext()); | ||
value: function createChildId(parentId) { | ||
if (this.isUndefinedOrNull(parentId)) { | ||
/* eslint-disable no-param-reassign */ | ||
parentId = this._ctxImpl.getContext(); | ||
} | ||
if (this.isUndefinedOrNull(parentId)) { | ||
return this.createRootId(); | ||
} | ||
var childId = new TraceId_1({ | ||
traceId: currentId.map(function (id) { | ||
return id.traceId; | ||
}), | ||
parentId: currentId.map(function (id) { | ||
return id.spanId; | ||
}), | ||
traceId: parentId.traceId, | ||
parentId: new Some$3(parentId.spanId), | ||
spanId: randomTraceId_1(), | ||
sampled: currentId.flatMap(function (id) { | ||
return id.sampled; | ||
}), | ||
flags: currentId.map(function (id) { | ||
return id.flags; | ||
}).getOrElse(0) | ||
debug: parentId.isDebug(), | ||
sampled: parentId.sampled | ||
}); | ||
@@ -1151,4 +1186,2 @@ | ||
value: function join(traceId) { | ||
var _this2 = this; | ||
if (!(traceId instanceof TraceId_1)) { | ||
@@ -1158,10 +1191,15 @@ throw new Error('Must be valid TraceId instance'); | ||
if (traceId._sampled === None$2) { | ||
if (!this.supportsJoin) { | ||
return this.createChildId(traceId); | ||
} | ||
if (traceId.sampled === None$2) { | ||
/* eslint-disable no-param-reassign */ | ||
traceId._sampled = this.sampler.shouldSample(traceId); | ||
} else { | ||
/* eslint-disable no-param-reassign */ | ||
traceId._shared = true; | ||
} | ||
return !this.supportsJoin ? this.letId(traceId, function () { | ||
return _this2.createChildId(); | ||
}) : traceId; | ||
return traceId; | ||
} | ||
@@ -1176,3 +1214,3 @@ }, { | ||
value: function recordAnnotation(annotation) { | ||
var _this3 = this; | ||
var _this2 = this; | ||
@@ -1183,4 +1221,4 @@ var timestamp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : now$1(this._startTimestamp, this._startTick); | ||
_this3.recorder.record(new record({ | ||
traceId: _this3.id, | ||
_this2.recorder.record(new record({ | ||
traceId: _this2.id, | ||
timestamp: timestamp, | ||
@@ -1510,4 +1548,3 @@ annotation: annotation | ||
case 'ServerRecv': | ||
// TODO: only set this to false when we know we in an existing trace | ||
span.delegate.setShared(id.parentId !== id.spanId); | ||
span.delegate.setShared(id.isShared()); | ||
span.delegate.setKind('CLIENT'); | ||
@@ -1702,7 +1739,7 @@ break; | ||
return new TraceId_1({ | ||
traceId: traceId, | ||
traceId: traceId.getOrElse(), | ||
parentId: parentSpanId, | ||
spanId: sid, | ||
sampled: sampled.map(stringToBoolean), | ||
flags: flags | ||
debug: flags === 1, | ||
sampled: sampled.map(stringToBoolean) | ||
}); | ||
@@ -1770,7 +1807,5 @@ }); | ||
headers[httpHeaders.SpanId] = traceId.spanId; | ||
traceId._parentId.ifPresent(function (psid) { | ||
traceId.parentSpanId.ifPresent(function (psid) { | ||
headers[httpHeaders.ParentSpanId] = psid; | ||
}); | ||
traceId.sampled.ifPresent(function (sampled) { | ||
@@ -1777,0 +1812,0 @@ headers[httpHeaders.Sampled] = sampled ? '1' : '0'; |
{ | ||
"name": "zipkin", | ||
"version": "0.18.2", | ||
"version": "0.18.3", | ||
"description": "The core tracer for Zipkin JS", | ||
@@ -39,3 +39,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "3183c863d94a6b8c054182c968ede9d997d59dc5" | ||
"gitHead": "ee17b9fc76796f4ce340cbac7a43a29a2970ac3a" | ||
} |
@@ -151,4 +151,3 @@ const {now, hrtime} = require('./time'); | ||
case 'ServerRecv': | ||
// TODO: only set this to false when we know we in an existing trace | ||
span.delegate.setShared(id.parentId !== id.spanId); | ||
span.delegate.setShared(id.isShared()); | ||
span.delegate.setKind('CLIENT'); | ||
@@ -155,0 +154,0 @@ break; |
@@ -50,7 +50,7 @@ const Annotation = require('../annotation'); | ||
return new TraceId({ | ||
traceId, | ||
traceId: traceId.getOrElse(), | ||
parentId: parentSpanId, | ||
spanId: sid, | ||
debug: flags === 1, | ||
sampled: sampled.map(stringToBoolean), | ||
flags | ||
}); | ||
@@ -57,0 +57,0 @@ }); |
@@ -31,3 +31,3 @@ function Endpoint({serviceName, ipv4, port}) { | ||
this.traceId = traceId.traceId; | ||
traceId._parentId.ifPresent((id) => { | ||
traceId.parentSpanId.ifPresent((id) => { | ||
this.parentId = id; | ||
@@ -45,3 +45,3 @@ }); | ||
this.debug = traceId.isDebug(); | ||
this.shared = false; | ||
this.shared = traceId.isShared(); | ||
} | ||
@@ -48,0 +48,0 @@ |
@@ -8,3 +8,3 @@ const HttpHeaders = require('./httpHeaders'); | ||
traceId._parentId.ifPresent(psid => { | ||
traceId.parentSpanId.ifPresent(psid => { | ||
headers[HttpHeaders.ParentSpanId] = psid; | ||
@@ -11,0 +11,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
const {None, Some, fromNullable} = require('../option'); | ||
const {None, Some} = require('../option'); | ||
const {Sampler, alwaysSample} = require('./sampler'); | ||
@@ -71,4 +71,4 @@ | ||
const traceId = this.traceId128Bit | ||
? new Some(randomTraceId() + rootSpanId) | ||
: None; | ||
? randomTraceId() + rootSpanId | ||
: rootSpanId; | ||
const id = new TraceId({ | ||
@@ -89,13 +89,22 @@ traceId, | ||
createChildId() { | ||
const currentId = fromNullable( | ||
this._ctxImpl.getContext() | ||
); | ||
isUndefinedOrNull(obj) { | ||
return typeof obj === 'undefined' || obj === null; | ||
} | ||
createChildId(parentId) { | ||
if (this.isUndefinedOrNull(parentId)) { | ||
/* eslint-disable no-param-reassign */ | ||
parentId = this._ctxImpl.getContext(); | ||
} | ||
if (this.isUndefinedOrNull(parentId)) { | ||
return this.createRootId(); | ||
} | ||
const childId = new TraceId({ | ||
traceId: currentId.map(id => id.traceId), | ||
parentId: currentId.map(id => id.spanId), | ||
traceId: parentId.traceId, | ||
parentId: new Some(parentId.spanId), | ||
spanId: randomTraceId(), | ||
sampled: currentId.flatMap(id => id.sampled), | ||
flags: currentId.map(id => id.flags).getOrElse(0) | ||
debug: parentId.isDebug(), | ||
sampled: parentId.sampled, | ||
}); | ||
@@ -166,12 +175,14 @@ if (childId.sampled.present === false) { | ||
if (traceId._sampled === None) { | ||
if (!this.supportsJoin) { | ||
return this.createChildId(traceId); | ||
} | ||
if (traceId.sampled === None) { | ||
/* eslint-disable no-param-reassign */ | ||
traceId._sampled = this.sampler.shouldSample(traceId); | ||
} else { | ||
/* eslint-disable no-param-reassign */ | ||
traceId._shared = true; | ||
} | ||
return !this.supportsJoin | ||
? this.letId(traceId, () => | ||
this.createChildId() | ||
) | ||
: traceId; | ||
return traceId; | ||
} | ||
@@ -178,0 +189,0 @@ |
@@ -1,47 +0,86 @@ | ||
const {Some, None, verifyIsOptional, verifyIsNotOptional} = require('../option'); | ||
const { | ||
Some, | ||
None, | ||
verifyIsOptional, | ||
verifyIsNotOptional, | ||
isOptional | ||
} = require('../option'); | ||
const T = new Some(true); | ||
class TraceId { | ||
constructor(params) { | ||
const {traceId = None, parentId = None, spanId, sampled = None, flags = 0} = params; | ||
verifyIsOptional(traceId); | ||
const { | ||
spanId, | ||
traceId = spanId, | ||
parentId = None, | ||
flags = 0, // deprecated | ||
debug = flags === 1, | ||
sampled = None, | ||
shared = false | ||
} = params; | ||
verifyIsNotOptional(spanId); | ||
verifyIsOptional(parentId); | ||
verifyIsNotOptional(spanId); | ||
verifyIsOptional(sampled); | ||
this._traceId = traceId; | ||
// support old signatures which allowed traceId to be optional | ||
if (isOptional(traceId)) { | ||
this._traceId = traceId.getOrElse(spanId); | ||
} else if (typeof traceId === 'undefined' || traceId === null) { | ||
this._traceId = spanId; | ||
} else { | ||
this._traceId = traceId; | ||
} | ||
this._parentId = parentId; | ||
this._spanId = spanId; | ||
this._sampled = sampled; | ||
this._flags = flags; | ||
this._sampled = debug ? T : sampled; | ||
this._debug = debug; | ||
this._shared = shared; | ||
} | ||
get spanId() { | ||
return this._spanId; | ||
get traceId() { | ||
return this._traceId; | ||
} | ||
get parentSpanId() { | ||
return this._parentId; | ||
} | ||
/** | ||
* Please use parentSpanId instead as this can return confusing results (the span ID when absent). | ||
* | ||
* @deprecated since version v0.19 | ||
*/ | ||
get parentId() { | ||
return this._parentId.getOrElse(this.spanId); | ||
return this._parentId.getOrElse(this._spanId); | ||
} | ||
get traceId() { | ||
return this._traceId.getOrElse(this.parentId); | ||
get spanId() { | ||
return this._spanId; | ||
} | ||
get sampled() { | ||
return this.isDebug() ? new Some(true) : this._sampled; | ||
return this._sampled; | ||
} | ||
/** | ||
* Please use isDebug instead. | ||
* | ||
* @deprecated since version v0.19 | ||
*/ | ||
get flags() { | ||
return this._flags; | ||
return this._debug ? 1 : 0; | ||
} | ||
isDebug() { | ||
// The jshint tool always complains about using bitwise operators, | ||
// but in this case it's actually intentional, so we disable the warning: | ||
// jshint bitwise: false | ||
return (this._flags & 1) === 1; | ||
return this._debug; | ||
} | ||
isShared() { | ||
return this._shared; | ||
} | ||
toString() { | ||
return `TraceId(spanId=${this.spanId.toString()}` + | ||
`, parentId=${this.parentId.toString()}` + | ||
`, parentSpanId=${this.parentSpanId.toString()}` + | ||
`, traceId=${this.traceId.toString()})`; | ||
@@ -48,0 +87,0 @@ } |
@@ -9,3 +9,3 @@ import { expect } from 'chai'; | ||
const span: model.Span = new model.Span(new TraceId({ traceId: new option.Some('xyz')})); | ||
const span: model.Span = new model.Span(new TraceId({ spanId: 'xyz' })); | ||
@@ -12,0 +12,0 @@ expect(v1.encode(span)).to.be.a('string'); |
@@ -19,3 +19,3 @@ import {expect} from 'chai'; | ||
const span: model.Span = new model.Span(new TraceId({ | ||
traceId: new option.Some('a'), | ||
traceId: 'a', | ||
spanId: 'b' | ||
@@ -22,0 +22,0 @@ })); |
import { expect } from 'chai'; | ||
import {option, Request, RequestZipkinHeaders, TraceId} from 'zipkin'; | ||
import Some = option.Some; | ||
@@ -9,3 +8,3 @@ describe('Request', () => { | ||
const traceId = new TraceId({ | ||
traceId: new Some('863ac35c9f6413ad48485a3953bb6124'), | ||
traceId: '863ac35c9f6413ad48485a3953bb6124', | ||
spanId: '48485a3953bb6124' | ||
@@ -25,3 +24,3 @@ }); | ||
const traceId = new TraceId({ | ||
traceId: new Some('863ac35c9f6413ad48485a3953bb6124'), | ||
traceId: '863ac35c9f6413ad48485a3953bb6124', | ||
spanId: '48485a3953bb6124' | ||
@@ -28,0 +27,0 @@ }); |
@@ -7,10 +7,16 @@ import { expect } from 'chai'; | ||
const traceId: TraceId = new TraceId({ | ||
traceId: new option.Some('48485a3953bb6124'), | ||
spanId: '48485a3953bb6124' | ||
traceId: '1', | ||
parentId: new option.Some('1'), | ||
spanId: '2' | ||
}); | ||
expect(traceId.isShared()).to.equal(false); | ||
const sampled: option.IOption<boolean> = traceId.sampled; | ||
expect(sampled.map).to.be.a('function'); | ||
expect(sampled).to.equal(option.None); | ||
expect(sampled.map).to.be.a('function'); | ||
const parentId: option.IOption<string> = traceId.parentSpanId; | ||
expect(parentId.map).to.be.a('function'); | ||
}); | ||
}); |
@@ -8,3 +8,3 @@ const sinon = require('sinon'); | ||
const InetAddress = require('../src/InetAddress'); | ||
const {Some, None} = require('../src/option'); | ||
const {Some} = require('../src/option'); | ||
const ExplicitContext = require('../src/explicit-context'); | ||
@@ -23,3 +23,3 @@ | ||
trace.setId(new TraceId({ | ||
traceId: None, | ||
traceId: 'a', | ||
parentId: new Some('a'), | ||
@@ -69,3 +69,3 @@ spanId: 'c', | ||
trace.setId(new TraceId({ | ||
traceId: None, | ||
traceId: 'a', | ||
parentId: new Some('a'), | ||
@@ -91,4 +91,3 @@ spanId: 'c', | ||
// TODO: handle this when headers are extracted instead of guessing | ||
it('should set non-root server span as shared', () => { | ||
it('should copy shared flag from trace id', () => { | ||
const logSpan = sinon.spy(); | ||
@@ -103,6 +102,7 @@ | ||
trace.setId(new TraceId({ | ||
traceId: None, | ||
traceId: 'a', | ||
parentId: new Some('a'), | ||
spanId: 'c', | ||
sampled: new Some(true) | ||
sampled: new Some(true), | ||
shared: true | ||
})); | ||
@@ -132,3 +132,3 @@ | ||
trace.setId(new TraceId({ | ||
traceId: new Some('a'), | ||
traceId: 'a', | ||
spanId: 'c', | ||
@@ -167,3 +167,3 @@ sampled: new Some(true) | ||
trace.setId(new TraceId({ | ||
traceId: new Some('a'), | ||
traceId: 'a', | ||
spanId: 'c', | ||
@@ -195,3 +195,3 @@ sampled: new Some(true) | ||
const traceId = new TraceId({ | ||
traceId: None, | ||
traceId: 'a', | ||
parentId: new Some('a'), | ||
@@ -236,3 +236,3 @@ spanId: 'c', | ||
trace.setId(new TraceId({ | ||
traceId: None, | ||
traceId: 'a', | ||
parentId: new Some('a'), | ||
@@ -269,3 +269,3 @@ spanId: 'c', | ||
trace.setId(new TraceId({ | ||
traceId: None, | ||
traceId: 'a', | ||
parentId: new Some('a'), | ||
@@ -321,3 +321,3 @@ spanId: 'c', | ||
trace.setId(new TraceId({ | ||
traceId: None, | ||
traceId: 'a', | ||
parentId: new Some('a'), | ||
@@ -324,0 +324,0 @@ spanId: 'c', |
@@ -36,2 +36,3 @@ const sinon = require('sinon'); | ||
.to.have.lengthOf(16)); | ||
annotations.forEach(ann => expect(ann.traceId.isShared()).to.equal(false)); | ||
@@ -38,0 +39,0 @@ expect(annotations[0].annotation.annotationType).to.equal('ServiceName'); |
@@ -46,2 +46,3 @@ const sinon = require('sinon'); | ||
.to.equal(originalSpanId)); | ||
annotations.forEach(ann => expect(ann.traceId.isShared()).to.equal(false)); | ||
@@ -106,2 +107,3 @@ expect(annotations[0].annotation.annotationType).to.equal('ServiceName'); | ||
annotations.forEach(ann => expect(ann.traceId.spanId).to.equal('bbb')); | ||
annotations.forEach(ann => expect(ann.traceId.isShared()).to.equal(true)); | ||
@@ -157,4 +159,5 @@ expect(annotations[0].annotation.annotationType).to.equal('ServiceName'); | ||
annotations.forEach(ann => expect(ann.traceId.traceId).to.equal('aaa')); | ||
annotations.forEach(ann => expect(ann.traceId.parentId).to.equal('bbb')); | ||
annotations.forEach(ann => expect(ann.traceId.parentSpanId.getOrElse()).to.equal('bbb')); | ||
annotations.forEach(ann => expect(ann.traceId.spanId).to.not.equal('bbb')); | ||
annotations.forEach(ann => expect(ann.traceId.isShared()).to.equal(false)); | ||
@@ -238,2 +241,3 @@ expect(annotations[0].annotation.annotationType).to.equal('ServiceName'); | ||
annotations.forEach(ann => expect(ann.traceId.spanId).to.not.be.empty); | ||
annotations.forEach(ann => expect(ann.traceId.isShared()).to.equal(false)); | ||
@@ -240,0 +244,0 @@ expect(annotations[0].annotation.annotationType).to.equal('ServiceName'); |
const TraceId = require('../src/tracer/TraceId'); | ||
const {Span, Endpoint} = require('../src/model'); | ||
const {JSON_V1} = require('../src/jsonEncoder'); | ||
const {Some, None} = require('../src/option'); | ||
const {Some} = require('../src/option'); | ||
@@ -10,5 +10,3 @@ describe('JSON v1 Formatting', () => { | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('000000000000162e'), | ||
spanId: '000000000000162e', | ||
sampled: None | ||
spanId: '000000000000162e' | ||
})); | ||
@@ -23,6 +21,5 @@ | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('000000000000162e'), | ||
traceId: '000000000000162e', | ||
parentId: new Some('000000000000abcd'), | ||
spanId: '000000000000efgh', | ||
sampled: None | ||
spanId: '000000000000efgh' | ||
})); | ||
@@ -37,3 +34,3 @@ | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('00000000000004d2000000000000162e'), | ||
traceId: '00000000000004d2000000000000162e', | ||
spanId: '000000000000162e' | ||
@@ -49,5 +46,5 @@ })); | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('00000000000004d2000000000000162e'), | ||
traceId: '00000000000004d2000000000000162e', | ||
spanId: '000000000000162e', | ||
flags: 1 | ||
debug: true | ||
})); | ||
@@ -60,6 +57,5 @@ | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('a'), | ||
traceId: 'a', | ||
parentId: new Some('b'), | ||
spanId: 'c', | ||
sampled: None | ||
spanId: 'c' | ||
})); | ||
@@ -127,6 +123,5 @@ span.setName('GET'); | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('a'), | ||
traceId: 'a', | ||
parentId: new Some('b'), | ||
spanId: 'c', | ||
sampled: None | ||
spanId: 'c' | ||
})); | ||
@@ -147,6 +142,5 @@ span.setName('GET'); | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('a'), | ||
traceId: 'a', | ||
parentId: new Some('b'), | ||
spanId: 'c', | ||
sampled: None | ||
spanId: 'c' | ||
})); | ||
@@ -163,6 +157,5 @@ span.setName('GET'); | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('a'), | ||
traceId: 'a', | ||
parentId: new Some('b'), | ||
spanId: 'c', | ||
sampled: None | ||
spanId: 'c' | ||
})); | ||
@@ -186,6 +179,5 @@ span.setName('GET'); | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('a'), | ||
traceId: 'a', | ||
parentId: new Some('b'), | ||
spanId: 'c', | ||
sampled: None | ||
spanId: 'c' | ||
})); | ||
@@ -192,0 +184,0 @@ span.setName('GET'); |
const TraceId = require('../src/tracer/TraceId'); | ||
const {Span, Endpoint} = require('../src/model'); | ||
const {JSON_V2} = require('../src/jsonEncoder'); | ||
const {Some, None} = require('../src/option'); | ||
const {Some} = require('../src/option'); | ||
@@ -9,5 +9,3 @@ describe('JSON v2 Formatting', () => { | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('000000000000162e'), | ||
spanId: '000000000000162e', | ||
sampled: None | ||
spanId: '000000000000162e' | ||
})); | ||
@@ -22,6 +20,5 @@ | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('000000000000162e'), | ||
traceId: '000000000000162e', | ||
parentId: new Some('000000000000abcd'), | ||
spanId: '000000000000efgh', | ||
sampled: None | ||
spanId: '000000000000efgh' | ||
})); | ||
@@ -36,3 +33,3 @@ | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('00000000000004d2000000000000162e'), | ||
traceId: '00000000000004d2000000000000162e', | ||
spanId: '000000000000162e' | ||
@@ -48,5 +45,5 @@ })); | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('00000000000004d2000000000000162e'), | ||
traceId: '00000000000004d2000000000000162e', | ||
spanId: '000000000000162e', | ||
flags: 1 | ||
debug: true | ||
})); | ||
@@ -59,6 +56,5 @@ | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('a'), | ||
traceId: 'a', | ||
parentId: new Some('b'), | ||
spanId: 'c', | ||
sampled: None | ||
spanId: 'c' | ||
})); | ||
@@ -105,8 +101,7 @@ span.setName('GET'); | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('a'), | ||
traceId: 'a', | ||
parentId: new Some('b'), | ||
spanId: 'c', | ||
sampled: None | ||
shared: true | ||
})); | ||
span.setShared(true); | ||
@@ -120,6 +115,5 @@ const spanJson = JSON_V2.encode(span); | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('a'), | ||
traceId: 'a', | ||
parentId: new Some('b'), | ||
spanId: 'c', | ||
sampled: None | ||
spanId: 'c' | ||
})); | ||
@@ -136,6 +130,5 @@ span.setName('GET'); | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('a'), | ||
traceId: 'a', | ||
parentId: new Some('b'), | ||
spanId: 'c', | ||
sampled: None | ||
spanId: 'c' | ||
})); | ||
@@ -159,6 +152,5 @@ span.setName('GET'); | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('a'), | ||
traceId: 'a', | ||
parentId: new Some('b'), | ||
spanId: 'c', | ||
sampled: None | ||
spanId: 'c' | ||
})); | ||
@@ -165,0 +157,0 @@ span.setName('GET'); |
const TraceId = require('../src/tracer/TraceId'); | ||
const {Span, Endpoint} = require('../src/model'); | ||
const {Some} = require('../src/option'); | ||
@@ -19,3 +18,3 @@ describe('Endpoint setters', () => { | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('a'), | ||
traceId: 'a', | ||
spanId: 'b', | ||
@@ -30,3 +29,3 @@ })); | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('a'), | ||
traceId: 'a', | ||
spanId: 'b', | ||
@@ -42,3 +41,3 @@ })); | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('a'), | ||
traceId: 'a', | ||
spanId: 'b', | ||
@@ -55,3 +54,3 @@ })); | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('a'), | ||
traceId: 'a', | ||
spanId: 'b', | ||
@@ -69,3 +68,3 @@ })); | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('a'), | ||
traceId: 'a', | ||
spanId: 'b', | ||
@@ -86,3 +85,3 @@ })); | ||
const span = new Span(new TraceId({ | ||
traceId: new Some('a'), | ||
traceId: 'a', | ||
spanId: 'b', | ||
@@ -89,0 +88,0 @@ })); |
@@ -9,3 +9,2 @@ const Request = require('../src/request.js'); | ||
const traceId = new TraceId({ | ||
traceId: new Some('48485a3953bb6124'), | ||
spanId: '48485a3953bb6124' | ||
@@ -21,6 +20,6 @@ }); | ||
const traceId = new TraceId({ | ||
traceId: new Some('48485a3953bb6124'), | ||
traceId: '48485a3953bb6124', | ||
spanId: '48485a3953bb6124', | ||
parentId: new Some('d56852c923dc9325'), | ||
sampled: new Some('3598a2cc24dc8315') | ||
sampled: new Some(true) | ||
}); | ||
@@ -27,0 +26,0 @@ const req = Request.addZipkinHeaders({}, traceId); |
@@ -8,9 +8,9 @@ const TraceId = require('../src/tracer/TraceId'); | ||
function makeTestTraceId({flags = 0, sampled = None}) { | ||
function makeTestTraceId({debug = false, sampled = None}) { | ||
return new TraceId({ | ||
traceId: new Some('abc'), | ||
traceId: 'abc', | ||
parentId: new Some('123'), | ||
spanId: 'fab', | ||
sampled, | ||
flags | ||
debug | ||
}); | ||
@@ -24,3 +24,3 @@ } | ||
expect( | ||
sampler.shouldSample(makeTestTraceId({flags: 1})) | ||
sampler.shouldSample(makeTestTraceId({debug: true})) | ||
).to.eql(T); | ||
@@ -27,0 +27,0 @@ }); |
@@ -35,3 +35,3 @@ const sinon = require('sinon'); | ||
expect(tracer.id.traceId).to.equal(parentId.traceId); | ||
expect(tracer.id.parentId).to.equal(parentId.spanId); | ||
expect(tracer.id.parentSpanId.getOrElse()).to.equal(parentId.spanId); | ||
@@ -43,3 +43,3 @@ ctxImpl.scoped(() => { | ||
expect(tracer.id.traceId).to.equal(childId.traceId); | ||
expect(tracer.id.parentId).to.equal(childId.spanId); | ||
expect(tracer.id.parentSpanId.getOrElse()).to.equal(childId.spanId); | ||
}); | ||
@@ -406,3 +406,3 @@ }); | ||
expect(newTraceId.traceId).to.eql(rootTraceId.traceId); | ||
expect(newTraceId.parentId).to.eql(rootTraceId.spanId); | ||
expect(newTraceId.parentSpanId).to.eql(new Some(rootTraceId.spanId)); | ||
expect(newTraceId.sampled).to.eql(rootTraceId.sampled); | ||
@@ -409,0 +409,0 @@ expect(newTraceId.flags).to.eql(rootTraceId.flags); |
@@ -1,3 +0,3 @@ | ||
const {Some} = require('../src/option'); | ||
const TraceId = require('../src/tracer/TraceId'); | ||
const {Some, None} = require('../src/option'); | ||
@@ -7,6 +7,7 @@ describe('TraceId', () => { | ||
const traceId = new TraceId({ | ||
traceId: new Some('48485a3953bb6124'), | ||
spanId: '48485a3953bb6124' | ||
traceId: '48485a3953bb6124', | ||
spanId: '863ac35c9f6413ad' | ||
}); | ||
expect(traceId.traceId).to.equal('48485a3953bb6124'); | ||
expect(traceId.spanId).to.equal('863ac35c9f6413ad'); | ||
}); | ||
@@ -16,3 +17,3 @@ | ||
const traceId = new TraceId({ | ||
traceId: new Some('863ac35c9f6413ad48485a3953bb6124'), | ||
traceId: '863ac35c9f6413ad48485a3953bb6124', | ||
spanId: '48485a3953bb6124' | ||
@@ -22,2 +23,88 @@ }); | ||
}); | ||
it('parentSpanId should return None when absent', () => { | ||
const traceId = new TraceId({ | ||
traceId: '863ac35c9f6413ad48485a3953bb6124', | ||
spanId: '48485a3953bb6124' | ||
}); | ||
expect(traceId.parentSpanId).to.equal(None); | ||
}); | ||
it('parentSpanId should return Some when present', () => { | ||
const traceId = new TraceId({ | ||
traceId: 'a', | ||
parentId: new Some('b'), | ||
spanId: 'c' | ||
}); | ||
expect(traceId.parentSpanId.getOrElse()).to.equal('b'); | ||
}); | ||
it('old syntax: traceId can be left out', () => { | ||
const traceId = new TraceId({ | ||
spanId: '48485a3953bb6124' | ||
}); | ||
expect(traceId.traceId).to.equal('48485a3953bb6124'); | ||
expect(traceId.spanId).to.equal('48485a3953bb6124'); | ||
}); | ||
it('old syntax: traceId can be None', () => { | ||
const traceId = new TraceId({ | ||
traceId: None, | ||
spanId: '48485a3953bb6124' | ||
}); | ||
expect(traceId.traceId).to.equal('48485a3953bb6124'); | ||
expect(traceId.spanId).to.equal('48485a3953bb6124'); | ||
}); | ||
it('old syntax: traceId can be Some', () => { | ||
const traceId = new TraceId({ | ||
traceId: new Some('a'), | ||
spanId: 'b' | ||
}); | ||
expect(traceId.traceId).to.equal('a'); | ||
expect(traceId.spanId).to.equal('b'); | ||
}); | ||
it('old syntax: parentId should return spanId when absent', () => { | ||
const traceId = new TraceId({ | ||
traceId: '863ac35c9f6413ad48485a3953bb6124', | ||
spanId: '48485a3953bb6124' | ||
}); | ||
expect(traceId.parentId).to.equal(traceId.spanId); | ||
}); | ||
it('old syntax: parentId should return value when present', () => { | ||
const traceId = new TraceId({ | ||
traceId: 'a', | ||
parentId: new Some('b'), | ||
spanId: 'c', | ||
}); | ||
expect(traceId.parentId).to.equal('b'); | ||
}); | ||
it('old syntax: flags is 0 by default', () => { | ||
const traceId = new TraceId({ | ||
traceId: 'a', | ||
spanId: 'c', | ||
}); | ||
expect(traceId.flags).to.equal(0); | ||
}); | ||
it('old syntax: debug can be set from flags', () => { | ||
const traceId = new TraceId({ | ||
traceId: 'a', | ||
spanId: 'b', | ||
flags: 1 | ||
}); | ||
expect(traceId.isDebug()).to.equal(true); | ||
}); | ||
it('old syntax: flags is 1 when debug', () => { | ||
const traceId = new TraceId({ | ||
traceId: 'a', | ||
spanId: 'c', | ||
debug: true | ||
}); | ||
expect(traceId.flags).to.equal(1); | ||
}); | ||
}); |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85
775715
13781