Send errors with OpenTelemetry
1
Add the packages
2
Register OpenTelemetry
Program.cs
UseOtlpExporter sends traces and ILogger logs. It reads its settings from the environment
variables in the next step.3
Set the exporter variables
OTEL_EXPORTER_OTLP_PROTOCOL=grpc. You can also keep
the endpoint above and use http/protobuf. OTLP requests do not need the project ID. To get a
key, see Create an ingest key.production environment,
so set deployment.environment.name to production in production.
How errors become issues
- An unhandled exception in a request. ASP.NET Core marks the server span as an error. Squasher
makes an issue from the span, titled with the span name, for example
GET /checkout. Kestrel also logs the exception at error level, which makes a second issue. - An
ILoggerlog at error level. Squasher makes an issue titled with the message template, for exampleCheckout failed for order {OrderId}. The template values and the exception become attributes of the record.
exception.stacktrace attribute.
Use the Sentry SDK for .NET
If your app already uses the Sentry SDK, point its DSN at Squasher. Squasher reads the gzip envelopes that the SDK sends.Program.cs
https://<ingest key>@ingest.squasher.ai/1. The ingest key selects the project; the SDK
needs a number at the end. Squasher keeps errors, traces, logs, metrics, and sessions from the SDK,
so you can keep tracing on. See Sentry for what each item becomes.
Send errors with the HTTP API
This class posts one error to the ingest endpoint withHttpClient:
Squasher.cs
await Squasher.CaptureErrorAsync(e) where you catch an exception. stack is shown as the
stack trace on the issue page. See the HTTP API for all fields.
Send a test error
Add an endpoint that throws, and open it once:Program.cs
Squasher.CaptureErrorAsync with the same exception. Then select Issues
in the sidebar of your project. If the error does not appear, see
Troubleshooting.
Give the setup to a coding agent
Copy this prompt into your coding agent to set up .NET the same way:Next steps
OpenTelemetry
See which OTLP data Squasher accepts.
Move from Sentry
Move an app from Sentry to Squasher.
HTTP API
See every field of the ingest endpoint.
Troubleshooting
Find out why an event does not appear.