From 724f159cf5f1a7d8e9862ff6991002f7003cb350 Mon Sep 17 00:00:00 2001 From: Mario Du Date: Wed, 12 Dec 2018 18:11:42 +0800 Subject: [PATCH 1/3] feat: support custom http trace name --- packages/hook/src/patch/HttpServer.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/hook/src/patch/HttpServer.ts b/packages/hook/src/patch/HttpServer.ts index 934a5294..e53634f3 100644 --- a/packages/hook/src/patch/HttpServer.ts +++ b/packages/hook/src/patch/HttpServer.ts @@ -5,6 +5,7 @@ import { parse as parseUrl } from 'url'; import { parse as parseQS, ParsedUrlQuery } from 'querystring'; import * as http from 'http'; import { IncomingMessage } from 'http'; +import * as is from 'is-type-of'; const debug = require('debug')('Pandora:Hook:HttpServerPatcher'); @@ -35,7 +36,8 @@ export class HttpServerPatcher extends Patcher { recordPostData?: boolean, bufferTransformer?: bufferTransformer, requestFilter?: requestFilter, - recordUrl?: boolean + recordUrl?: boolean, + traceName?: (span) => string }) { super(options || {}); @@ -204,7 +206,12 @@ export class HttpServerPatcher extends Patcher { }); } - tracer.named(`HTTP-${tags[ 'http.method' ].value}:${tags[ 'http.url' ].value}`); + if (options.traceName && is.isFunction(options.traceName)) { + tracer.named(`HTTP-${options.traceName(span)}`); + } else { + tracer.named(`HTTP-${tags[ 'http.method' ].value}:${tags[ 'http.url' ].value}`); + } + tracer.setCurrentSpan(span); function onFinishedFactory(eventName) { From f11ab569856074f7564ce1773da7ac518c01701d Mon Sep 17 00:00:00 2001 From: Mario Du Date: Wed, 12 Dec 2018 18:43:20 +0800 Subject: [PATCH 2/3] fix: fix hub test --- packages/hub/test/hub/Hub.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/hub/test/hub/Hub.test.ts b/packages/hub/test/hub/Hub.test.ts index 34af9018..2df3b8fe 100644 --- a/packages/hub/test/hub/Hub.test.ts +++ b/packages/hub/test/hub/Hub.test.ts @@ -34,7 +34,7 @@ describe('Hub', function () { const hub = new Hub(); await hub.start(); await new Promise(resolve => ( hub).messengerServer.close(resolve)); - await expect(hub.stop()).to.be.rejectedWith('Not running'); + await expect(hub.stop()).to.be.rejectedWith('not running'); }); }); From da4093b938a4b40e7ee0663307f071aae549c064 Mon Sep 17 00:00:00 2001 From: Mario Du Date: Fri, 14 Dec 2018 11:22:20 +0800 Subject: [PATCH 3/3] fix: fix hub test --- packages/hub/test/hub/Hub.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/hub/test/hub/Hub.test.ts b/packages/hub/test/hub/Hub.test.ts index 2df3b8fe..d40376fc 100644 --- a/packages/hub/test/hub/Hub.test.ts +++ b/packages/hub/test/hub/Hub.test.ts @@ -34,7 +34,7 @@ describe('Hub', function () { const hub = new Hub(); await hub.start(); await new Promise(resolve => ( hub).messengerServer.close(resolve)); - await expect(hub.stop()).to.be.rejectedWith('not running'); + await expect(hub.stop()).to.be.rejectedWith(/not running/i); }); });