Closed skhilliard closed 1 year ago
This PR wont work for the us as it would send all errors/exceptions as traces as well effectively creating duplicate telemetry for everyone using Bunyan.
This PR wont work for the us as it would send all errors/exceptions as traces as well effectively creating duplicate telemetry for everyone using Bunyan.
I can understand that.....as a temporary measure for us, I think we may update the code to also check the severity level rather than create duplicate entries....this is what I am considering.
const subscriber = (event: IStandardEvent<bunyan.IBunyanData>) => {
let message = event.data.result as string;
clients.forEach((client) => {
const AIlevel = bunyanToAILevelMap[event.data.level];
try {
// Try to parse message as Bunyan log is JSON
// Only log as exception for level of Critical
let log: any = JSON.parse(message);
if (log.err && AIlevel === SeverityLevel.Critical) {
let bunyanError = new Error(log.err.message);
bunyanError.name = log.err.name;
bunyanError.stack = log.err.stack;
client.trackException({ exception: bunyanError });
return;
}
}
catch (err) {
// Ignore error
}
client.trackTrace({ message: message, severity: AIlevel });
});
};
Config was added in 2.6.0 to address this, thank you.
Please note that the only "real" change is to AutoCollection/diagnostic-channel/bunyan.sub.ts. The other changes (update to gitignore and including output files) were just convenient for us to use this fork for our code until a final solution is implemented in this code base.
For issue: https://github.com/microsoft/ApplicationInsights-node.js/issues/1120