A simple HTTP client library for the BugSnag API. For a more complete solution, see XO.Diagnostics.Bugsnag.OpenTelemetry.
-
Populate an instance of
BugsnagClientOptions
with your API key and any information about the host application or device that you want to report.var options = new BugsnagClientOptions { ApiKey = "abcxyz", };
-
Create an instance of
BugsnagClient
using the options.var client = new BugsnagClient(options);
-
Create instances of
NotifyEventApp
andNotifyEventDevice
and customize them as needed.var app = client.CreateDefaultApp(); var device = client.CreateDefaultDevice();
-
Use the client to send events.
var notifyEvent = new NotifyEvent { App = app, Device = device, Exceptions = { new NotifyEventException { "System.Exception", "Something went wrong", stacktrace: new() { new NotifyEventStacktrace("Program.cs", 42, "Program.Main()") { InProject = true }, }, }, }, }; var request = new NotifyRequest(client.Notifier) { Events = { notifyEvent }, }; await client.PostEventsAsync(request, cancellationToken);