microsoft / botbuilder-js

Welcome to the Bot Framework SDK for JavaScript repository, which is the home for the libraries and packages that enable developers to build sophisticated bot applications using JavaScript.
https://github.com/Microsoft/botframework
MIT License
680 stars 276 forks source link

DialogContextError showing as multiple Trace entries in Application Insights #3673

Closed EricDahlvang closed 1 year ago

EricDahlvang commented 3 years ago

Versions

4.13.1 Deployed Azure function bot from Composer

Describe the bug

DialogContextError are split in app insights telemetry logs into multiple entries (see image below)

To Reproduce

Steps to reproduce the behavior:

  1. Create a Node Azure Functions bot (this is likely not an azure functions runtime issue though)
  2. Add app insights
  3. Add code or a dialog to throw a DialogContextError in the bot.
  4. Message the bot.
  5. Look for Dialog context error in Telemetry (see image below)

Screenshots

image

joshgummersall commented 3 years ago

@EricDahlvang, TRACE events seem to correspond to individual lines of stderr, i.e. there will be entries for each line of a stack trace. Even a regular console.error(new Error("stderr")) yields the following in the transaction search log:

Screen Shot 2021-07-01 at 11 56 51 AM

That said, using trackException produces a more useful entry:

Screen Shot 2021-07-01 at 11 59 09 AM

This expands to:

Screen Shot 2021-07-01 at 11 58 11 AM

I don't think there's anything useful we can do here aside from possibly using the telemetry client to call trackException in the Bot Adapter onTurnError handler. What do you think?

EricDahlvang commented 3 years ago

That's odd. This would at lest produce a single line in the log: console.log(JSON.stringify(new Error("stderr"))) trackException looks best though!

It looks like Application Insights is switching to #azure/log soon: https://github.com/microsoft/ApplicationInsights-node.js/pull/733 maybe this will help?

sw-joelmut commented 2 years ago

Hi @EricDahlvang and @joshgummersall We tried to reproduce the issue without success, using both a Composer bot and a bot sample.

  1. Using an Azure function Composer bot locally or deployed, the traces are not being registered in the Application Insights, but shown in BotFramework Emulator. image
  2. Using the 21.corebot-app-insights sample with a simple console.error(new Error("stderr")), thrown when the beginDialog is executed and then captured by the onTurnError handler, the Application Insights showed a singular trace instead of multiple. image

Regarding Composer, is there any telemetry configuration we are missing?, causing the traces to not be properly shown in Application Insights? Here is the configuration we used to connect to the Application Insights.

"telemetry": {
  "logActivities": true,
  "logPersonalInformation": true,
  "options": {
    "connectionString": "InstrumentationKey=<INSTRUMENTATION_KEY>;IngestionEndpoint=https://westus-0.in.applicationinsights.azure.com/"
  }
}