observe-node 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/http/express.js +8 -11
package/package.json
CHANGED
package/src/http/express.js
CHANGED
|
@@ -44,6 +44,8 @@ function expressMiddleware(observe, opts = {}) {
|
|
|
44
44
|
return function (req, res, next) {
|
|
45
45
|
const start = Date.now();
|
|
46
46
|
|
|
47
|
+
const capturedRequest = pickRequestBody(req.body, maxRequestBytes);
|
|
48
|
+
|
|
47
49
|
// ✅ capture response body
|
|
48
50
|
let capturedResponse;
|
|
49
51
|
const _json = res.json.bind(res);
|
|
@@ -112,8 +114,6 @@ res.send = (body) => {
|
|
|
112
114
|
// ✅ auth info (don’t log token)
|
|
113
115
|
const hasAuth = !!req.headers.authorization;
|
|
114
116
|
|
|
115
|
-
// ✅ body (only if parsed)
|
|
116
|
-
const requestBody = req.body ? redact(req.body) : undefined;
|
|
117
117
|
|
|
118
118
|
observe.emit({
|
|
119
119
|
event_name: "http.response",
|
|
@@ -130,15 +130,12 @@ res.send = (body) => {
|
|
|
130
130
|
ip: req.ip,
|
|
131
131
|
},
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
body: requestBody, // parsed body (if express.json ran before)
|
|
140
|
-
bodyPayload: capturedRequest,
|
|
141
|
-
},
|
|
133
|
+
|
|
134
|
+
request: {
|
|
135
|
+
query: req.query,
|
|
136
|
+
params: req.params,
|
|
137
|
+
body: capturedRequest,
|
|
138
|
+
},
|
|
142
139
|
|
|
143
140
|
response: {
|
|
144
141
|
status: res.statusCode,
|