Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate required field Message with n/a if it is empty #2857

Merged

Conversation

NeilMountford
Copy link
Contributor

Fix Issue #1066.

Changes

Application Insights rejects exceptions that have empty messages. This means that some exceptions are lost, making investigation of runtime issues difficult. I noticed this when investigating an issue in a .NET 8 API, where a CosmosException for a conflict occurred, was logged on the console but wasn't logged in App Insights.

There was previously a PR #2697 that never got merged due to lack of tests.

Original example from the other PR:

var configuration = TelemetryConfiguration.CreateDefault();
configuration.ConnectionString = "InstrumentationKey=...";
var telemetryClient = new TelemetryClient(configuration);
telemetryClient.TrackException(new Exception("")); // ignored
telemetryClient.TrackException(new Exception("foo")); // logged
telemetryClient.Flush();

Original response from the other PR:

{
    "itemsReceived": 1,
    "itemsAccepted": 0,
    "errors":
    [
        {
            "index": 0,
            "statusCode": 400,
            "message": "109: Field 'message' on type 'ExceptionDetails' is required but missing or empty. Expected: string, Actual: undefined"
        }
    ]
}

Checklist

  • [✅] I ran Unit Tests locally.*
  • [✅] CHANGELOG.md updated with one line description of the fix, and a link to the original issue if available.
  • I had some test failures on a fresh clone, but the tests for the relevant part of the code were passing, so I'm hoping it's just an issue with some dependencies on my machine.

For significant contributions please make sure you have completed the following items:

  • [N/A] Design discussion issue #
  • [N/A] Changes in public surface reviewed

The PR will trigger build, unit tests, and functional tests automatically. Please follow these instructions to build and test locally.

Notes for authors:

  • FxCop and other analyzers will fail the build. To see these errors yourself, compile localy using the Release configuration.

@NeilMountford
Copy link
Contributor Author

@microsoft-github-policy-service agree

Copy link
Contributor

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks good!

Will ask one more owner to review before merge, as we are adding limited additions (including fixes) to this repo.

@NeilMountford
Copy link
Contributor Author

Thanks @cijothomas, I've pushed a further change to move using Microsoft.ApplicationInsights.DataContracts; into the namespace block to make the build happy for the net4* builds - apologies for not catching this locally, I don't have access to a Windows machine currently. Could you approve the workflows again please? 🙂

Copy link
Member

@TimothyMothra TimothyMothra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please address comments

Copy link
Member

@TimothyMothra TimothyMothra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@NeilMountford
Copy link
Contributor Author

@TimothyMothra What are the next steps to get this merged/released? Let me know if you need anything from me 🙂

@cijothomas cijothomas merged commit e2d1d0b into microsoft:main Mar 27, 2024
66 checks passed
@cijothomas
Copy link
Contributor

@TimothyMothra What are the next steps to get this merged/released? Let me know if you need anything from me 🙂

Merged!
We don't have a planned date for the next release.

@jiilaa
Copy link

jiilaa commented Sep 16, 2024

So, half a year since this fix was merged (and even longer since the latest release for this library), maybe a good time for a release? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants