Socket
Socket
Sign inDemoInstall

@hypertrace/nodejsagent

Package Overview
Dependencies
147
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.8.0 to 1.8.1-dev

26

lib/instrumentation/HttpInstrumentationWrapper.js

@@ -19,2 +19,3 @@ "use strict";

const http_2 = __importDefault(require("http"));
const node_stream_1 = __importDefault(require("node:stream"));
const _RECORDABLE_CONTENT_TYPES = ['application/json', 'application/graphql', 'application/x-www-form-urlencoded'];

@@ -178,11 +179,20 @@ class HttpInstrumentationWrapper {

let bodyCapture = new BodyCapture_1.BodyCapture(config_1.Config.getInstance().config.data_capture.body_max_size_bytes, 0);
const listener = (chunk) => {
bodyCapture.appendData(chunk);
const chunks = [];
const originalEmit = response.emit;
response.emit = function (eventName, ...args) {
if (eventName === 'data') {
chunks.push(Buffer.from(args[0]));
}
else if (eventName === 'end') {
const bodyBuffer = Buffer.concat(chunks);
let bodyString = bodyBuffer.toString('utf-8');
span.setAttribute("http.response.body", bodyString);
// @ts-ignore
if (response.stream) {
// @ts-ignore
response.stream = node_stream_1.default.Readable.from(bodyBuffer);
}
}
return originalEmit.apply(response, [eventName, ...args]);
};
response.on("data", listener);
response.once("end", () => {
response.removeListener('data', listener);
let bodyString = bodyCapture.dataString();
span.setAttribute("http.response.body", bodyString);
});
}

@@ -189,0 +199,0 @@ }

{
"name": "@hypertrace/nodejsagent",
"version": "1.8.0",
"version": "1.8.1-dev",
"description": "Hypertrace Node.js Agent",

@@ -5,0 +5,0 @@ "author": "Traceable Inc.",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc