observe-node 1.0.6 → 1.0.7

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "observe-node",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Structured logs + Prometheus metrics SDK for Node.js (Loki/Grafana ready)",
5
5
  "main": "src/index.js",
6
6
  "type": "commonjs",
@@ -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",
@@ -136,8 +136,7 @@ res.send = (body) => {
136
136
  query: req.query, // parsed query object
137
137
  query_string: queryString, // raw query string
138
138
  params: req.params, // may be empty (see note)
139
- body: requestBody, // parsed body (if express.json ran before)
140
- bodyPayload: capturedRequest,
139
+ body: capturedRequest
141
140
  },
142
141
 
143
142
  response: {