Skip to content

Any way for extension to properly report exceptions #217

@kmagiera

Description

@kmagiera

Thanks for maintaining this package!

Wanted to ask if there's any way for extension to report exceptions in a way that they can be recognized as errors by the Application Insights.

Currently, all errors are reported as events with unhandlederror name. This makes them impossible to properly aggregate and identify issues as they fall under a single category and the important details like stack traces can be extracted for individual records only making it difficult to see what type of errors occur at what frequency.

In ApplicationInsights-JS package, there's a trackException method which seem to work ok. However, using that package in my vscode extension seem very unstable as I get a tons of errors about retries and other stuff. I dig a bit into the source code of that package, and tried to replicate its behavior when sending exceptions, specifically in appInsightsClientFactory I tried to add logException method that'd construct an event that would match what the JS module seem to generate:

appInsightsClient?.track({
    name: "Exception",
    baseType: "ExceptionData",
    baseData: {
      severityLevel: "Error",
      exceptions: [
        {
          message: "Error Message",
          typeName: "SomeErrorType",
          parsedStack: [],
          hasFullStack: true,
        },
      ],
    },
  });

With this approach, errors are now recognized and reported under "Failure" in Application Insights, however, they still don't have the correct shape and the data seem to just be serialized to JSON and put as description while stack trace doesn't get extracted properly:
Image

I was wondering if there's a better way this can be done such that we can rely on Application Insights in our extension for error tracking,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions