Skip to content

Commit

Permalink
fix: Fix for traceId in error reporting (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
sumitsuthar authored Aug 14, 2024
1 parent e7c842c commit df7379c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/nr-security-agent/lib/core/ExceptionReporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ function exceptionReporting(exception, request, responseCode) {
this.category = exception.name;
this.traceId = shaUtil.getSHA256ForData(this.exception.stackTrace.join('|') + this.category + this.httpRequest.route + this.httpRequest.method);
}
else {
this.traceId = shaUtil.getSHA256ForData(this.category + this.httpRequest.route + this.httpRequest.method);
}

if (responseCode) {
if (responseCode >= 500) {
this.category = http.STATUS_CODES[responseCode];
Expand All @@ -124,6 +122,9 @@ function exceptionReporting(exception, request, responseCode) {
function generateExceptionReportingEvent(error, request) {
try {
const exception = new exceptionReporting(error, request);
if(!exception.traceId){
return;
}
let key = exception.exception.type + exception.exception.stackTrace[0];
if (!exceptionsMap.has(key)) {
exceptionsMap.set(key, exception);
Expand All @@ -141,6 +142,9 @@ function generateExceptionReportingEvent(error, request) {
function generate5xxReportingEvent(error, request, responseCode) {
try {
const exception = new exceptionReporting(error, request, responseCode);
if(!exception.traceId){
return;
}
let key = (request.uri ? request.uri : request.url) + responseCode;
if (!exceptionsMap.has(key)) {
exceptionsMap.set(key, exception);
Expand Down

0 comments on commit df7379c

Please sign in to comment.