Skip to content

Commit

Permalink
commenting res and req hook
Browse files Browse the repository at this point in the history
  • Loading branch information
aritro66 committed Jan 18, 2024
1 parent 7df706f commit 6a999c3
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions server/src/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,29 +118,29 @@ const sdk = new NodeSDK({
getNodeAutoInstrumentations({
"@opentelemetry/instrumentation-http": {
enabled: true,
requestHook: (span, req) => {
let body = "";
req.on("data", (chunk) => {
body += chunk;
});
req.on("end", (chunk) => {
try {
span.setAttribute("http.request.body", body);
} catch (error) {
console.log(error);
}
});
},
responseHook: (span, response) => {
let body = "";
response.on("data", (chunk) => {
body += chunk.toString();
});
response.on("end", () => {
span.setAttribute("http.response.body", body);
response.removeAllListeners();
});
},
// requestHook: (span, req) => {
// let body = "";
// req.on("data", (chunk) => {
// body += chunk;
// });
// req.on("end", (chunk) => {
// try {
// span.setAttribute("http.request.body", body);
// } catch (error) {
// console.log(error);
// }
// });
// },
// responseHook: (span, response) => {
// let body = "";
// response.on("data", (chunk) => {
// body += chunk.toString();
// });
// response.on("end", () => {
// span.setAttribute("http.response.body", body);
// response.removeAllListeners();
// });
// },
},
"@opentelemetry/instrumentation-express": {
enabled: true,
Expand Down

0 comments on commit 6a999c3

Please sign in to comment.