zipkin-instrumentation-cujojs-rest
Advanced tools
Comparing version 0.9.0 to 0.10.0
@@ -7,4 +7,3 @@ 'use strict'; | ||
var _require = require('zipkin'), | ||
Annotation = _require.Annotation, | ||
Request = _require.Request; | ||
Instrumentation = _require.Instrumentation; | ||
@@ -30,19 +29,6 @@ function getRequestMethod(req) { | ||
this.instrumentation = new Instrumentation.HttpClient({ tracer: tracer, serviceName: serviceName, remoteServiceName: remoteServiceName }); | ||
return tracer.scoped(function () { | ||
tracer.setId(tracer.createChildId()); | ||
var traceId = tracer.id; | ||
_this.traceId = traceId; | ||
var reqWithHeaders = Request.addZipkinHeaders(req, traceId); | ||
var method = getRequestMethod(reqWithHeaders); | ||
tracer.recordServiceName(serviceName); | ||
tracer.recordRpc(method.toUpperCase()); | ||
tracer.recordBinary('http.url', reqWithHeaders.path); | ||
tracer.recordAnnotation(new Annotation.ClientSend()); | ||
if (remoteServiceName) { | ||
// TODO: can we get the host and port of the http connection? | ||
tracer.recordAnnotation(new Annotation.ServerAddr({ | ||
serviceName: remoteServiceName | ||
})); | ||
} | ||
var reqWithHeaders = _this.instrumentation.recordRequest(req, req.path, getRequestMethod(req)); | ||
_this.traceId = tracer.id; | ||
return reqWithHeaders; | ||
@@ -58,5 +44,3 @@ }); | ||
tracer.scoped(function () { | ||
tracer.setId(_this2.traceId); | ||
tracer.recordBinary('http.status_code', res.status.code.toString()); | ||
tracer.recordAnnotation(new Annotation.ClientRecv()); | ||
_this2.instrumentation.recordResponse(_this2.traceId, res.status.code); | ||
}); | ||
@@ -63,0 +47,0 @@ return res; |
{ | ||
"name": "zipkin-instrumentation-cujojs-rest", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"description": "Interceptor for instrumenting HTTP calls from the cujoJS rest library", | ||
@@ -19,4 +19,4 @@ "main": "lib/index.js", | ||
"rest": "^1.3.2", | ||
"zipkin": "^0.9.0" | ||
"zipkin": "^0.10.0" | ||
} | ||
} |
/* eslint-disable no-param-reassign */ | ||
const interceptor = require('rest/interceptor'); | ||
const { | ||
Annotation, | ||
Request | ||
Instrumentation | ||
} = require('zipkin'); | ||
@@ -20,19 +19,7 @@ | ||
function request(req, {tracer, serviceName = 'unknown', remoteServiceName}) { | ||
this.instrumentation = new Instrumentation.HttpClient({tracer, serviceName, remoteServiceName}); | ||
return tracer.scoped(() => { | ||
tracer.setId(tracer.createChildId()); | ||
const traceId = tracer.id; | ||
this.traceId = traceId; | ||
const reqWithHeaders = Request.addZipkinHeaders(req, traceId); | ||
const method = getRequestMethod(reqWithHeaders); | ||
tracer.recordServiceName(serviceName); | ||
tracer.recordRpc(method.toUpperCase()); | ||
tracer.recordBinary('http.url', reqWithHeaders.path); | ||
tracer.recordAnnotation(new Annotation.ClientSend()); | ||
if (remoteServiceName) { | ||
// TODO: can we get the host and port of the http connection? | ||
tracer.recordAnnotation(new Annotation.ServerAddr({ | ||
serviceName: remoteServiceName | ||
})); | ||
} | ||
const reqWithHeaders = | ||
this.instrumentation.recordRequest(req, req.path, getRequestMethod(req)); | ||
this.traceId = tracer.id; | ||
return reqWithHeaders; | ||
@@ -44,5 +31,3 @@ }); | ||
tracer.scoped(() => { | ||
tracer.setId(this.traceId); | ||
tracer.recordBinary('http.status_code', res.status.code.toString()); | ||
tracer.recordAnnotation(new Annotation.ClientRecv()); | ||
this.instrumentation.recordResponse(this.traceId, res.status.code); | ||
}); | ||
@@ -49,0 +34,0 @@ return res; |
6881
8
142