Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Commit

Permalink
feat: support custom http trace name
Browse files Browse the repository at this point in the history
  • Loading branch information
mariodu committed Dec 12, 2018
1 parent fdda32d commit 724f159
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/hook/src/patch/HttpServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -35,7 +36,8 @@ export class HttpServerPatcher extends Patcher {
recordPostData?: boolean,
bufferTransformer?: bufferTransformer,
requestFilter?: requestFilter,
recordUrl?: boolean
recordUrl?: boolean,
traceName?: (span) => string
}) {
super(options || {});

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 724f159

Please sign in to comment.