ApplicationInsights-node.js icon indicating copy to clipboard operation
ApplicationInsights-node.js copied to clipboard

Application insight custom logging - custom properties serialization bug

Open MuhamedSalihSeyedIbrahim opened this issue 3 years ago • 2 comments

Description - Upon assigning circular JSON to custom properties of app insight log methods like trackTrace , trackException, etc.., I experience a bug in the serialization and it's reflected in application insight blade table -> custom dimension column.

Runtime - NodeJSv12.18.3 lib version - applicationinsights@latest

Expected behavior - The JSON must be serialised (by removal of circular reference) and proper json is found in application insght blade table under column custom dimension

Actual behavior - I showing error in custom dimension PFA.

Attachment - Capture

Thanks for reporting the issue @MuhamedSalihSeyedIbrahim, all custom dimensions are send as strings by the SDK, not sure how we can fix this on SDK side, maybe a bug in UX because they are the ones trying to parse it as JSON, where specifically are you seeing this in the portal?, is it possible to validate the custom dimension is well formed on your side before sending it in the SDK?

hectorhdzg avatar Aug 17 '21 16:08 hectorhdzg

I observed it in exception table record (appinsights)

when I spread the error obj of the axios in customproperties of track exception method.

This is the code log.trackException(axiosErrorInstance, {properties: {... axiosErrorInstance} });

My goal is to achieve manually the proposal explained in issue #809

To capture addition information in error Such as axios error object contain Response , request ,config etc.., Which is critical if stack doesn't provide enough detail.

if proper simple json is provided From node side the expected result is achieved but in my case the axios exception have cyclic response object of tcpSocket

@hectorhdzg yes we can validate proper json before passing it to custom dimensions as of now But in varying error type scenario its hard to validate unknown error object type properties

@MuhamedSalihSeyedIbrahim Please ensure that you're sending correctly JSON serializable. There are several 3rd party NPM packages that can help clean up JSON for serialization. Thank you.

JacksonWeber avatar Apr 24 '24 22:04 JacksonWeber