Comparing version 0.2.2 to 0.2.4
{ | ||
"name": "zipkin", | ||
"version": "0.2.2", | ||
"version": "0.2.4", | ||
"description": "The core tracer for zipkin.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -9,2 +9,6 @@ const thriftTypes = require('./gen-nodejs/zipkinCore_types'); | ||
} | ||
function formatIPv4(host) { | ||
return host ? | ||
`${host >> 24 & 255}.${(host >> 16) & 255}.${(host >> 8) & 255}.${host & 255}` : 0; | ||
} | ||
Endpoint.prototype.isUnknown = function isUnknown() { | ||
@@ -19,2 +23,8 @@ return this.host === 0 && this.port === 0; | ||
}; | ||
Endpoint.prototype.toJSON = function toJSON() { | ||
return { | ||
ipv4: formatIPv4(this.host), | ||
port: this.port | ||
}; | ||
}; | ||
@@ -41,2 +51,15 @@ function ZipkinAnnotation({timestamp, value, endpoint, duration}) { | ||
}; | ||
ZipkinAnnotation.prototype.toJSON = function toJSON() { | ||
const res = { | ||
value: this.value, | ||
timestamp: this.timestamp | ||
}; | ||
if (this.endpoint) { | ||
res.endpoint = this.endpoint.toJSON(); | ||
} | ||
if (this.duration) { | ||
res.duration = this.duration; | ||
} | ||
return res; | ||
}; | ||
ZipkinAnnotation.prototype.toString = function toString() { | ||
@@ -62,2 +85,12 @@ return `Annotation(value="${this.value}")`; | ||
}; | ||
BinaryAnnotation.prototype.toJSON = function toJSON() { | ||
const res = { | ||
key: this.key, | ||
value: this.value | ||
}; | ||
if (this.endpoint) { | ||
res.endpoint = this.endpoint.toJSON(); | ||
} | ||
return res; | ||
}; | ||
@@ -106,2 +139,7 @@ function MutableSpan(traceId) { | ||
}; | ||
MutableSpan.prototype.overrideEndpointJSON = function overrideEndpointJSON(ann) { | ||
if (!ann.endpoint) { | ||
ann.endpoint = this.endpoint.toJSON(); | ||
} | ||
}; | ||
MutableSpan.prototype.toThrift = function toThrift() { | ||
@@ -133,2 +171,27 @@ const span = new thriftTypes.Span(); | ||
}; | ||
MutableSpan.prototype.toJSON = function toJSON() { | ||
const trace = this.traceId; | ||
const spanJson = { | ||
traceId: trace.traceId, | ||
name: this.name.getOrElse('Unknown'), | ||
id: trace.spanId, | ||
timestamp: this.started | ||
}; | ||
trace._parentId.ifPresent(id => { | ||
spanJson.parentId = id; | ||
}); | ||
spanJson.annotations = this.annotations.map(ann => { | ||
const annotationJson = ann.toJSON(); | ||
this.overrideEndpointJSON(annotationJson); | ||
annotationJson.endpoint.serviceName = this.service.getOrElse('Unknown'); | ||
return annotationJson; | ||
}); | ||
spanJson.binaryAnnotations = this.binaryAnnotations.map(ann => { | ||
const annotationJson = ann.toJSON(); | ||
this.overrideEndpointJSON(annotationJson); | ||
annotationJson.endpoint.serviceName = this.service.getOrElse('Unknown'); | ||
return annotationJson; | ||
}); | ||
return spanJson; | ||
}; | ||
MutableSpan.prototype.toString = function toString() { | ||
@@ -135,0 +198,0 @@ const annotations = this.annotations.map(a => a.toString()).join(', '); |
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
51621
31
1685