question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Framework breadcrumbs are not captured in the event

See original GitHub issue

Environment

Using ASP.NET Core 3.1 and Sentry.AspNetCore 3.12.3, sending events to our Sentry SaaS account.

Steps to Reproduce

Send an event to Sentry after having performed an HTTP request with a System.Net.Http.HttpClient, with global default log level of Information and Sentry breadcrumbs enabled at the Information level.

Expected Result

All information logs are included in the event, including the request / response information logs from System.Net.Http.HttpClient (request method / URL, response code).

Actual Result

System.* / Microsoft.* logs appear to be excluded from breadcrumbs. Other information logs are correctly included (application and third party libraries). System.* / Microsoft.* logs are correctly displayed in the console when running locally with the same appsettings.json.

Is this normal behavior (e.g. to avoid overloading the breacrumbs array)? Some of these logs are pretty useful to perform diagnostics.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
madmoxcommented, Mar 16, 2022

Making this breaking change would likely have other unintended side effects, such as long trails of breadcrumbs and other events that should have been discarded.

This remark of yours is important in my opinion. If these use cases exist, wouldn’t there be applications where you want both behaviors? i.e. drop undesired events unrelated to the error (I still have to find a use case), and include others (like the HTTP client logs in my client example). It’s the whole “dropping child logging scopes” that I don’t understand and that should be questioned in the first place - I think.

If the behavior has no use case, the boolean parameter approach is good, but it should be set to true by default starting with the next major release and marked as obsolete from there. If this behavior has use cases, I think you might want to consider another approach that allows users more control than a simple on/off switch.

Or maybe the “fix” should be made in .NET and they should stop using nested logging scopes in wrong places, but I doubt that’s the case (I think the primary use case for logging scopes is adding hierarchical metadata to a set of related logs, which could make sense here).

1reaction
mattjohnsonpintcommented, Mar 15, 2022

This won’t be a simple fix, as it would require some changes that would significantly change the current behavior. As documented here (emphasis mine):

The scope will hold useful information that should be sent along with the event. For instance contexts or breadcrumbs are stored on the scope. When a scope is pushed, it inherits all data from the parent scope and when it pops all modifications are reverted.

The default SDK integrations will push and pop scopes intelligently. For instance web framework integrations will create and destroy scopes around your routes or controllers.

So, right now everything is working as designed. The problem is that it’s not always obvious that calling a bit of code (like methods on HttpClient) will create and dispose a new logging scope. As a developer, I don’t have a clean way to explicitly opt-in to keep items from child scopes.

FWIW, I tried the following three different approaches for resolving this.

  • Attempt 1 copies breadcrumbs from the child scope to the parent scope.
  • Attempt 2 uses the existing lock/unlock scope APIs. The net result is that _hub.PushScope doesn’t actually push a new scope but instead applies the state to the current scope. In talking with @bruno-garcia, I’ve come to understand that the whole lock/unlock thing is somewhat of a hack anyway and should probably be removed at some point.
  • Attempt 3 completely avoids _hub.PushScope and just makes logger.BeginScope a no-op - effectively just using a single Sentry scope. In doing so, there are three unit tests that break because they were testing the old behavior.

IMHO, none of these is the right approach. Making this breaking change would likely have other unintended side effects, such as long trails of breadcrumbs and other events that should have been discarded.

We need to think through this better, but probably not right at this moment. Will keep it on the backlog for now. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

UI Breadcrumbs for Android Error Events
When we record breadcrumbs, we capture some useful metadata of the target view; information like view id, view class, and scroll direction (in ......
Read more >
Capturing Events with Breadcrumbs - PHP Honeybadger ...
Breadcrumbs are records of events that happened within your application — external API ... Honeybadger can automatically capture breadcrumbs from your app.
Read more >
Capturing Events with Breadcrumbs - Javascript Honeybadger ...
Breadcrumbs are events that happen right before an error occurs. Honeybadger captures many types of breadcrumbs automatically, such as click events, console ...
Read more >
Automatic breadcrumb logging in Raygun4Net – how to get ...
The NLog log event does not automatically capture the stack trace at the time you log a message. However, we've added a configuration...
Read more >
How can server-side breadcrumbs stop debugging ...
Breadcrumbs are no different. Each one marks a distinct point in the application where a significant event occurred.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found