zipkin-instrumentation-cujojs-rest
Advanced tools
Comparing version 0.18.4 to 0.18.5
@@ -10,13 +10,11 @@ "use strict"; | ||
function getRequestMethod(req) { | ||
var method = 'get'; | ||
if (req.entity) { | ||
method = 'post'; | ||
return 'post'; | ||
} | ||
if (req.method) { | ||
method = req.method; | ||
return req.method; | ||
} | ||
return method; | ||
return 'get'; | ||
} | ||
@@ -23,0 +21,0 @@ |
{ | ||
"name": "zipkin-instrumentation-cujojs-rest", | ||
"version": "0.18.4", | ||
"version": "0.18.5", | ||
"description": "Interceptor for instrumenting HTTP calls from the cujoJS rest library", | ||
@@ -8,3 +8,3 @@ "main": "lib/index.js", | ||
"build": "babel src -d lib", | ||
"test": "mocha --require ../../test/helper.js --require @babel/register && karma start --single-run --browsers ChromeHeadless,FirefoxHeadless ../../karma.conf.js", | ||
"test": "mocha --exit --require ../../test/helper.js --require @babel/register && karma start --single-run --browsers ChromeHeadless,FirefoxHeadless ../../karma.conf.js", | ||
"test-browser": "karma start --single-run --browsers ChromeHeadless ../../karma.conf.js", | ||
@@ -17,7 +17,9 @@ "test-debug": "mocha --inspect-brk --exit --require ../../test/helper.js", | ||
"repository": "https://github.com/openzipkin/zipkin-js", | ||
"dependencies": { | ||
"zipkin": "^0.18.5" | ||
}, | ||
"devDependencies": { | ||
"rest": "^1.3.2", | ||
"zipkin": "^0.18.4" | ||
"rest": "^1.3.2" | ||
}, | ||
"gitHead": "2c9ea42842e03343fa6b2066dedf6e760f38e9f6" | ||
"gitHead": "201c6f6360d7ae79eaa04d5e53660908e3602358" | ||
} |
@@ -5,13 +5,12 @@ /* eslint-disable no-param-reassign */ | ||
Instrumentation | ||
} = require('zipkin'); | ||
} = require('zipkin'); | ||
function getRequestMethod(req) { | ||
let method = 'get'; | ||
if (req.entity) { | ||
method = 'post'; | ||
return 'post'; | ||
} | ||
if (req.method) { | ||
method = req.method; | ||
return req.method; | ||
} | ||
return method; | ||
return 'get'; | ||
} | ||
@@ -22,4 +21,3 @@ | ||
return tracer.scoped(() => { | ||
const reqWithHeaders = | ||
this.instrumentation.recordRequest(req, req.path, getRequestMethod(req)); | ||
const reqWithHeaders = this.instrumentation.recordRequest(req, req.path, getRequestMethod(req)); | ||
this.traceId = tracer.id; | ||
@@ -26,0 +24,0 @@ return reqWithHeaders; |
const {expect} = require('chai'); | ||
const {ExplicitContext, Tracer} = require('zipkin'); | ||
const rest = require('rest'); | ||
const { | ||
@@ -8,5 +11,2 @@ maybeMiddleware, | ||
} = require('../../../test/testFixture'); | ||
const {ExplicitContext, Tracer} = require('zipkin'); | ||
const rest = require('rest'); | ||
const restInterceptor = require('../src/restInterceptor'); | ||
@@ -43,3 +43,7 @@ | ||
spans = []; | ||
tracer = new Tracer({ctxImpl: new ExplicitContext(), recorder: newSpanRecorder(spans)}); | ||
tracer = new Tracer({ | ||
ctxImpl: new ExplicitContext(), | ||
localServiceName: serviceName, | ||
recorder: newSpanRecorder(spans) | ||
}); | ||
}); | ||
@@ -53,3 +57,3 @@ | ||
function getClient() { | ||
return rest.wrap(restInterceptor, {tracer, serviceName, remoteServiceName}); | ||
return rest.wrap(restInterceptor, {tracer, remoteServiceName}); | ||
} | ||
@@ -69,3 +73,3 @@ | ||
'http.path': path, | ||
'http.status_code': '202' | ||
'http.status_code': '200' | ||
} | ||
@@ -103,3 +107,3 @@ }); | ||
it('should report 400 in tags', () => { | ||
it('should report 401 in tags', () => { | ||
const path = '/weather/securedTown'; | ||
@@ -114,4 +118,4 @@ return getClient()(url(path)) | ||
'http.path': path, | ||
'http.status_code': '400', | ||
error: '400' | ||
'http.status_code': '401', | ||
error: '401' | ||
} | ||
@@ -118,0 +122,0 @@ })); |
7313
1
193
1
+ Addedzipkin@^0.18.5
+ Addedbase64-js@1.5.1(transitive)
+ Addedis-promise@2.2.2(transitive)
+ Addedzipkin@0.18.6(transitive)