Skip to content

Commit

Permalink
refactor: httpclient args tracer to be enforced (#1421)
Browse files Browse the repository at this point in the history
  • Loading branch information
leoner authored and popomore committed Sep 15, 2017
1 parent c56274b commit 6eac07e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/core/httpclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ class HttpClient extends urllib.HttpClient {

args = args || {};

if (!args.ctx && !args.tracer) {
args.tracer = this.app.tracer;
if (args.ctx && args.ctx.tracer) {
args.tracer = args.ctx.tracer;
} else {
args.tracer = args.tracer || this.app.tracer;
}

return super.request(url, args, callback);
Expand Down
4 changes: 2 additions & 2 deletions test/lib/core/httpclient.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,11 @@ describe('test/lib/core/httpclient.test.js', () => {
let resTracer;

httpclient.on('request', function(options) {
reqTracer = options.args.tracer || options.ctx.tracer;
reqTracer = options.args.tracer;
});

httpclient.on('response', function(options) {
resTracer = options.req.args.tracer || options.ctx.tracer;
resTracer = options.req.args.tracer;
});

let res = yield httpclient.request('https://www.alipay.com', {
Expand Down

0 comments on commit 6eac07e

Please sign in to comment.