microsoft / ApplicationInsights-node.js

Microsoft Application Insights SDK for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Do not know how to serialize a BigInt

brianpham93 opened this issue · comments

I use winston and winston-azure-application-insights to log directly to application insights
I'm getting this error when log an object that contains BigInt data

ApplicationInsights:Failed to serialize payload [
  TypeError: Do not know how to serialize a BigInt
      at JSON.stringify (<anonymous>)
      at Util.stringify (./my-project/node_modules/applicationinsights/out/Library/Util.js:373:25)
      at EnvelopeFactory.truncateProperties (./my-project/node_modules/applicationinsights/out/Library/EnvelopeFactory.js:135:60)
      at EnvelopeFactory.createTraceData (./my-project/node_modules/applicationinsights/out/Library/EnvelopeFactory.js:153:33)
      at EnvelopeFactory.createEnvelope (./my-project/node_modules/applicationinsights/out/Library/EnvelopeFactory.js:24:40)
      at TelemetryClient.track (./my-project/node_modules/applicationinsights/out/Library/TelemetryClient.js:134:44)
      at TelemetryClient.trackTrace (./my-project/node_modules/applicationinsights/out/Library/TelemetryClient.js:60:14)
      at ./my-project/node_modules/applicationinsights/out/AutoCollection/diagnostic-channel/winston.sub.js:55:20
      at Array.forEach (<anonymous>)
      at subscriber (./my-project/node_modules/applicationinsights/out/AutoCollection/diagnostic-channel/winston.sub.js:40:13)

Does ApplicationInsights support BigInt or is there anything wrong with the way i'm logging data ?

Version: 2.9.1
Host: macOS 14, Apple Silicon

@brianpham93 looks like the issue is in JSON.stringify, after a quick internet search looks like some type replacement can be done to prevent this error, can you share some sample winston log we can use to reproduce?