Comparing version 0.12.0 to 0.13.0
@@ -302,4 +302,4 @@ // TypeScript type definitions | ||
readHeader: <T> (header: string) => option.IOption<T> | ||
): string; | ||
recordResponse(traceId: string, statusCode: string, error?: Error): void; | ||
): TraceId; | ||
recordResponse(traceId: TraceId, statusCode: string, error?: Error): void; | ||
} | ||
@@ -315,4 +315,4 @@ | ||
): T; | ||
recordResponse(traceId: string, statusCode: string): void; | ||
recordError(traceId: string, error: Error): void; | ||
recordResponse(traceId: TraceId, statusCode: string): void; | ||
recordError(traceId: TraceId, error: Error): void; | ||
} | ||
@@ -319,0 +319,0 @@ } |
@@ -76,2 +76,50 @@ 'use strict'; | ||
var ProducerStart = function (_SimpleAnnotation5) { | ||
_inherits(ProducerStart, _SimpleAnnotation5); | ||
function ProducerStart() { | ||
_classCallCheck(this, ProducerStart); | ||
return _possibleConstructorReturn(this, (ProducerStart.__proto__ || Object.getPrototypeOf(ProducerStart)).apply(this, arguments)); | ||
} | ||
return ProducerStart; | ||
}(SimpleAnnotation); | ||
var ProducerStop = function (_SimpleAnnotation6) { | ||
_inherits(ProducerStop, _SimpleAnnotation6); | ||
function ProducerStop() { | ||
_classCallCheck(this, ProducerStop); | ||
return _possibleConstructorReturn(this, (ProducerStop.__proto__ || Object.getPrototypeOf(ProducerStop)).apply(this, arguments)); | ||
} | ||
return ProducerStop; | ||
}(SimpleAnnotation); | ||
var ConsumerStart = function (_SimpleAnnotation7) { | ||
_inherits(ConsumerStart, _SimpleAnnotation7); | ||
function ConsumerStart() { | ||
_classCallCheck(this, ConsumerStart); | ||
return _possibleConstructorReturn(this, (ConsumerStart.__proto__ || Object.getPrototypeOf(ConsumerStart)).apply(this, arguments)); | ||
} | ||
return ConsumerStart; | ||
}(SimpleAnnotation); | ||
var ConsumerStop = function (_SimpleAnnotation8) { | ||
_inherits(ConsumerStop, _SimpleAnnotation8); | ||
function ConsumerStop() { | ||
_classCallCheck(this, ConsumerStop); | ||
return _possibleConstructorReturn(this, (ConsumerStop.__proto__ || Object.getPrototypeOf(ConsumerStop)).apply(this, arguments)); | ||
} | ||
return ConsumerStop; | ||
}(SimpleAnnotation); | ||
function LocalOperationStart(name) { | ||
@@ -84,4 +132,4 @@ this.name = name; | ||
var LocalOperationStop = function (_SimpleAnnotation5) { | ||
_inherits(LocalOperationStop, _SimpleAnnotation5); | ||
var LocalOperationStop = function (_SimpleAnnotation9) { | ||
_inherits(LocalOperationStop, _SimpleAnnotation9); | ||
@@ -153,2 +201,15 @@ function LocalOperationStop() { | ||
function MessageAddr(_ref4) { | ||
var serviceName = _ref4.serviceName, | ||
host = _ref4.host, | ||
port = _ref4.port; | ||
this.serviceName = serviceName; | ||
this.host = host; | ||
this.port = port; | ||
} | ||
MessageAddr.prototype.toString = function () { | ||
return 'MessageAddr(serviceName="' + this.serviceName + '", host="' + this.host + '", port=' + this.port + ')'; | ||
}; | ||
function BinaryAnnotation(key, value) { | ||
@@ -167,2 +228,7 @@ this.key = key; | ||
ServerRecv: ServerRecv, | ||
ProducerStart: ProducerStart, | ||
ProducerStop: ProducerStop, | ||
ConsumerStart: ConsumerStart, | ||
ConsumerStop: ConsumerStop, | ||
MessageAddr: MessageAddr, | ||
Message: Message, | ||
@@ -169,0 +235,0 @@ ServiceName: ServiceName, |
@@ -124,2 +124,23 @@ 'use strict'; | ||
break; | ||
case 'ProducerStart': | ||
span.delegate.setKind('PRODUCER'); | ||
break; | ||
case 'ProducerStop': | ||
span.finish(); | ||
span.delegate.setKind('PRODUCER'); | ||
break; | ||
case 'ConsumerStart': | ||
span.delegate.setKind('CONSUMER'); | ||
break; | ||
case 'ConsumerStop': | ||
span.finish(); | ||
span.delegate.setKind('CONSUMER'); | ||
break; | ||
case 'MessageAddr': | ||
span.delegate.setRemoteEndpoint(new Endpoint({ | ||
serviceName: rec.annotation.serviceName, | ||
ipv4: rec.annotation.host && rec.annotation.host.ipv4(), | ||
port: rec.annotation.port | ||
})); | ||
break; | ||
case 'LocalOperationStart': | ||
@@ -126,0 +147,0 @@ span.delegate.setName(rec.annotation.name); |
@@ -60,2 +60,16 @@ 'use strict'; | ||
break; | ||
case 'PRODUCER': | ||
beginAnnotation = span.timestamp ? 'ms' : undefined; | ||
endAnnotation = 'ws'; | ||
addressKey = 'ma'; | ||
break; | ||
case 'CONSUMER': | ||
if (span.timestamp && span.duration) { | ||
beginAnnotation = 'wr'; | ||
endAnnotation = 'mr'; | ||
} else if (span.timestamp) { | ||
beginAnnotation = 'mr'; | ||
} | ||
addressKey = 'ma'; | ||
break; | ||
default: | ||
@@ -62,0 +76,0 @@ } |
{ | ||
"name": "zipkin", | ||
"version": "0.12.0", | ||
"version": "0.13.0", | ||
"description": "The core tracer for zipkin.js", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -22,2 +22,3 @@ # zipkin | ||
// Tracer will be a one to many relationship with instrumentation that use it (like express) | ||
const tracer = new zipkin.Tracer({ | ||
@@ -24,0 +25,0 @@ ctxImpl, |
@@ -12,2 +12,6 @@ const InetAddress = require('./InetAddress'); | ||
class ServerRecv extends SimpleAnnotation {} | ||
class ProducerStart extends SimpleAnnotation {} | ||
class ProducerStop extends SimpleAnnotation {} | ||
class ConsumerStart extends SimpleAnnotation {} | ||
class ConsumerStop extends SimpleAnnotation {} | ||
@@ -69,2 +73,11 @@ function LocalOperationStart(name) { | ||
function MessageAddr({serviceName, host, port}) { | ||
this.serviceName = serviceName; | ||
this.host = host; | ||
this.port = port; | ||
} | ||
MessageAddr.prototype.toString = function() { | ||
return `MessageAddr(serviceName="${this.serviceName}", host="${this.host}", port=${this.port})`; | ||
}; | ||
function BinaryAnnotation(key, value) { | ||
@@ -83,2 +96,7 @@ this.key = key; | ||
ServerRecv, | ||
ProducerStart, | ||
ProducerStop, | ||
ConsumerStart, | ||
ConsumerStop, | ||
MessageAddr, | ||
Message, | ||
@@ -85,0 +103,0 @@ ServiceName, |
@@ -102,2 +102,23 @@ const {now, hrtime} = require('./time'); | ||
break; | ||
case 'ProducerStart': | ||
span.delegate.setKind('PRODUCER'); | ||
break; | ||
case 'ProducerStop': | ||
span.finish(); | ||
span.delegate.setKind('PRODUCER'); | ||
break; | ||
case 'ConsumerStart': | ||
span.delegate.setKind('CONSUMER'); | ||
break; | ||
case 'ConsumerStop': | ||
span.finish(); | ||
span.delegate.setKind('CONSUMER'); | ||
break; | ||
case 'MessageAddr': | ||
span.delegate.setRemoteEndpoint(new Endpoint({ | ||
serviceName: rec.annotation.serviceName, | ||
ipv4: rec.annotation.host && rec.annotation.host.ipv4(), | ||
port: rec.annotation.port | ||
})); | ||
break; | ||
case 'LocalOperationStart': | ||
@@ -104,0 +125,0 @@ span.delegate.setName(rec.annotation.name); |
@@ -57,2 +57,16 @@ function toV1Endpoint(endpoint) { | ||
break; | ||
case 'PRODUCER': | ||
beginAnnotation = span.timestamp ? 'ms' : undefined; | ||
endAnnotation = 'ws'; | ||
addressKey = 'ma'; | ||
break; | ||
case 'CONSUMER': | ||
if (span.timestamp && span.duration) { | ||
beginAnnotation = 'wr'; | ||
endAnnotation = 'mr'; | ||
} else if (span.timestamp) { | ||
beginAnnotation = 'mr'; | ||
} | ||
addressKey = 'ma'; | ||
break; | ||
default: | ||
@@ -59,0 +73,0 @@ } |
@@ -244,2 +244,34 @@ const sinon = require('sinon'); | ||
}); | ||
it('should capture MessageAddr event', () => { | ||
const logSpan = sinon.spy(); | ||
const ctxImpl = new ExplicitContext(); | ||
const logger = {logSpan}; | ||
const recorder = new BatchRecorder({logger}); | ||
const trace = new Tracer({ctxImpl, recorder}); | ||
ctxImpl.scoped(() => { | ||
trace.setId(new TraceId({ | ||
traceId: None, | ||
parentId: new Some('a'), | ||
spanId: 'c', | ||
sampled: new Some(true) | ||
})); | ||
trace.recordServiceName('producer'); | ||
trace.recordRpc('send-msg'); | ||
trace.recordAnnotation(new Annotation.ProducerStart()); | ||
trace.recordAnnotation(new Annotation.MessageAddr({ | ||
serviceName: 'mq', | ||
host: new InetAddress('127.0.0.2'), | ||
port: 7072 | ||
})); | ||
trace.recordAnnotation(new Annotation.ProducerStop()); | ||
const loggedSpan = logSpan.getCall(0).args[0]; | ||
expect(loggedSpan.remoteEndpoint.serviceName).to.equal('mq'); | ||
expect(loggedSpan.remoteEndpoint.ipv4).to.equal('127.0.0.2'); | ||
expect(loggedSpan.remoteEndpoint.port).to.equal(7072); | ||
}); | ||
}); | ||
}); |
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
53
152393
60
4254