Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/plugins/ExpressPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class ExpressPlugin implements SwPlugin {
|| (req.connection.remoteFamily === 'IPv6'
? `[${req.connection.remoteAddress}]:${req.connection.remotePort}`
: `${req.connection.remoteAddress}:${req.connection.remotePort}`);
span.tag(Tag.httpURL((req.headers.host || '') + req.url));
span.tag(Tag.httpMethod(req.method));

const ret = _handle.call(this, req, res, (err: Error) => {
Expand All @@ -95,6 +94,8 @@ class ExpressPlugin implements SwPlugin {
} catch (e) {
stopIfNotStopped(e);
throw e;
} finally { // req.protocol is only possibly available after call to _handle()
span.tag(Tag.httpURL(((req as any).protocol ? (req as any).protocol + '://' : '') + (req.headers.host || '') + req.url));
}
};
}
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/HttpPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class HttpPlugin implements SwPlugin {
const https = require('https');

this.interceptClientRequest(http);
this.interceptServerRequest(http);
this.interceptServerRequest(http, 'http');
this.interceptClientRequest(https);
this.interceptServerRequest(https);
this.interceptServerRequest(https, 'https');
}

private interceptClientRequest(module: any) {
Expand Down Expand Up @@ -120,7 +120,7 @@ class HttpPlugin implements SwPlugin {
};
}

private interceptServerRequest(module: any) {
private interceptServerRequest(module: any, protocol: string) {
/// TODO? full event protocol support not currently implemented (prependListener(), removeListener(), etc...)
const _addListener = module.Server.prototype.addListener;

Expand Down Expand Up @@ -159,7 +159,7 @@ class HttpPlugin implements SwPlugin {
|| (req.connection.remoteFamily === 'IPv6'
? `[${req.connection.remoteAddress}]:${req.connection.remotePort}`
: `${req.connection.remoteAddress}:${req.connection.remotePort}`);
span.tag(Tag.httpURL((req.headers.host || '') + req.url));
span.tag(Tag.httpURL(protocol + '://' + (req.headers.host || '') + req.url));
span.tag(Tag.httpMethod(req.method));

let ret = handler.call(this, req, res, ...reqArgs);
Expand Down
4 changes: 2 additions & 2 deletions tests/plugins/axios/expected.data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ segmentItems:
skipAnalysis: false
tags:
- key: http.url
value: server:5000/axios
value: http://server:5000/axios
- key: http.method
value: GET
- key: http.status.code
Expand Down Expand Up @@ -102,7 +102,7 @@ segmentItems:
spanLayer: Http
tags:
- key: http.url
value: localhost:5001/axios
value: http://localhost:5001/axios
- key: http.method
value: GET
- key: http.status.code
Expand Down
8 changes: 4 additions & 4 deletions tests/plugins/express/expected.data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ segmentItems:
spanId: 0
spanLayer: Http
tags:
- key: http.url
value: server:5000/express
- key: http.method
value: GET
- key: http.url
value: http://server:5000/express
- key: http.status.code
value: '200'
- key: http.status.msg
Expand Down Expand Up @@ -101,10 +101,10 @@ segmentItems:
spanId: 0
spanLayer: Http
tags:
- key: http.url
value: localhost:5001/express
- key: http.method
value: GET
- key: http.url
value: http://localhost:5001/express
- key: http.status.code
value: '200'
- key: http.status.msg
Expand Down
4 changes: 2 additions & 2 deletions tests/plugins/http/expected.data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ segmentItems:
skipAnalysis: false
tags:
- key: http.url
value: server:5000/test
value: http://server:5000/test
- key: http.method
value: GET
- key: http.status.code
Expand Down Expand Up @@ -86,7 +86,7 @@ segmentItems:
skipAnalysis: false
tags:
- key: http.url
value: localhost:5001/test
value: http://localhost:5001/test
- key: http.method
value: GET
- key: http.status.code
Expand Down