Skip to content
This repository was archived by the owner on Nov 21, 2025. It is now read-only.

Commit 126bc75

Browse files
shkjin
authored andcommitted
fix: use req.ip in express and koa plugin (#944)
1 parent 0b404a1 commit 126bc75

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/plugins/plugin-express.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function patchModuleRoot(express: Express4Module, api: PluginTypes.Tracer) {
6161
const url = `${req.protocol}://${req.headers.host}${req.originalUrl}`;
6262
rootSpan.addLabel(labels.HTTP_METHOD_LABEL_KEY, req.method);
6363
rootSpan.addLabel(labels.HTTP_URL_LABEL_KEY, url);
64-
rootSpan.addLabel(labels.HTTP_SOURCE_IP, req.connection.remoteAddress);
64+
rootSpan.addLabel(labels.HTTP_SOURCE_IP, req.ip);
6565

6666
// wrap end
6767
const originalEnd = res.end;

src/plugins/plugin-koa.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function startSpanForRequest<T>(
8686
// middlewear runs.
8787
root.addLabel(api.labels.HTTP_METHOD_LABEL_KEY, req.method);
8888
root.addLabel(api.labels.HTTP_URL_LABEL_KEY, url);
89-
root.addLabel(api.labels.HTTP_SOURCE_IP, req.connection.remoteAddress);
89+
root.addLabel(api.labels.HTTP_SOURCE_IP, ctx.request.ip);
9090

9191
// wrap end
9292
res.end = function(this: ServerResponse) {

0 commit comments

Comments
 (0)