Breadcrumbs .NET 6+

Breadcrumbs let you provide logging points in your code that will be collected and sent along with any exception sent to Raygun. This lets you have a better understanding of the events that happened in the system that lead up to the exception.

To record a basic breadcrumb with a custom message using the Record(string message) method.

RaygunBreadcrumbs.Record("Example breadcrumb")

note: When using the RecordBreadcrumb method all other properties will be set to defaults.

We provide an overload for Record so that you can pass in your own instance of the RaygunBreadcrumb object.

RaygunBreadcrumbs.Record(new RaygunBreadcrumb()
    Message = "Breadcrumbs :)",
    Type = "navigation",
    CustomData = new Dictionary<string, object>() { { "Custom", "Data" } }

Information on location automatically gets overwritten with the location of the call from the stack frame.

The location e.g. line number, method name, class name, are all automatically included inside each breadcrumb. This can help you identify where the breadcrumb was recorded in the event of similar breadcrumb names.

In the Record overload we can specify the tye of breadcrumb we are recording.

These include the following:

  • manual
  • click-event
  • navigation
  • console
  • request

These will provide different icons in your breadcrumb trace depending on the type you provided.

By default, the type is manual.

There are two storage options offered by us, AsyncLocalBreadcrumbStore and InMemoryBreadcrumbStore.

The default store is the AsyncLocalBreadcrumb store where the breadcrumbs are local to the asynchronous context they are invoked in. For ASP .NET Core we have begun an async context at the start of each request so all breadcrumbs in that request are in scope.

InMemoryBreadcrumbStore is a global context breadcrumb storage. For MAUI this is assigned as the default storage

You can change the storage type yourself by reassigning the storage object.

RaygunBreadcrumbs.Storage = new InMemoryBreadcrumbStorage();

We also provide an interface IRaygunBreadcrumbStorage which you can use to implement your own store, though this is not required or recommended.

There are two key differences from the Framework implementation of breadcrumbs.

  • We do not support breadcrumb levels, they are defaulted to info with no ability to change this.
  • Location is not optional, this is always recorded now.