Skip to content

Commit

Permalink
fix: use req.ip in express and koa plugin (#944)
Browse files Browse the repository at this point in the history
  • Loading branch information
sh authored and kjin committed Dec 17, 2018
1 parent 0b404a1 commit 126bc75
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/plugins/plugin-express.ts
Expand Up @@ -61,7 +61,7 @@ function patchModuleRoot(express: Express4Module, api: PluginTypes.Tracer) {
const url = `${req.protocol}://${req.headers.host}${req.originalUrl}`;
rootSpan.addLabel(labels.HTTP_METHOD_LABEL_KEY, req.method);
rootSpan.addLabel(labels.HTTP_URL_LABEL_KEY, url);
rootSpan.addLabel(labels.HTTP_SOURCE_IP, req.connection.remoteAddress);
rootSpan.addLabel(labels.HTTP_SOURCE_IP, req.ip);

// wrap end
const originalEnd = res.end;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/plugin-koa.ts
Expand Up @@ -86,7 +86,7 @@ function startSpanForRequest<T>(
// middlewear runs.
root.addLabel(api.labels.HTTP_METHOD_LABEL_KEY, req.method);
root.addLabel(api.labels.HTTP_URL_LABEL_KEY, url);
root.addLabel(api.labels.HTTP_SOURCE_IP, req.connection.remoteAddress);
root.addLabel(api.labels.HTTP_SOURCE_IP, ctx.request.ip);

// wrap end
res.end = function(this: ServerResponse) {
Expand Down

0 comments on commit 126bc75

Please sign in to comment.