sentry-ruby 7.0 on Ruby 4.0.
Send errors with OpenTelemetry
1
Add the gems
Gemfile
bundle install.2
Configure the SDK
- Rails
- Sinatra and Rack
config/initializers/opentelemetry.rb
use_all turns on the instrumentation for each gem that it finds, such as Rack, Rails,
Sinatra, and ActiveRecord.3
Set the exporter variables
production environment, so set deployment.environment.name to production in production.
How errors become issues
A span with the error status becomes an issue. Squasher titles the issue with the status message, or with the span name when the message is empty. An exception recorded on a span without the error status also becomes an issue, titled with the exception message.-
An unhandled exception in a Sinatra request. The Rack instrumentation marks the request span
as an error, with the exception class as the message, and records the exception. The issue title
is, for example,
RuntimeError. -
An error that you catch. Record it on a span and set the status yourself:
The issue title is the error message.
record_exceptionalone also makes an issue, titled with the exception message.
record_exception sends.
Use the Sentry SDK for Ruby
If your app already usessentry-ruby, point its DSN at Squasher. Squasher reads the gzip envelopes
that sentry-ruby sends for large events.
config/initializers/sentry.rb
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 module posts one error to the ingest endpoint with the standard library:lib/squasher.rb
Squasher.capture_exception(e, order_id: order.id) where you rescue an error. The call
blocks until Squasher answers, so in a web request, run it in a background job. stack is shown as
the stack trace on the issue page. See the HTTP API for all fields.
Send a test error
- OpenTelemetry: add a route that runs
raise "Squasher test error", and open it once. - HTTP API: run
Squasher.capture_exception(RuntimeError.new("Squasher test error")).
Give the setup to a coding agent
Copy this prompt into your coding agent to set up Ruby 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.