Ruby client for Splatty. Captures exceptions and logs and ships them over the Sentry-compatible envelope protocol.
Add to your Gemfile:
gem "splatty"Splatty.init do |config|
config.url = ENV.fetch("SPLATTY_URL", "https://splatty.app")
config.dsn = ENV["SPLATTY_DSN"]
config.environment = ENV.fetch("RACK_ENV", "development")
config.release = ENV["SPLATTY_RELEASE"]
# config.logs = false # disable log shipping (default: true)
# config.send_default_pii = true # send request headers verbatim (default: false)
endBy default (send_default_pii = false) sensitive request headers — Cookie,
Authorization, CSRF tokens, API keys and similar — are replaced with
[Filtered] before an event leaves the process. Set send_default_pii = true
only if you understand that cookies and auth tokens will then be transmitted and
stored.
begin
do_something
rescue => e
Splatty.capture_exception(e)
end
Splatty.capture_message("hello", level: :info)use Splatty::RackThe Railtie auto-loads when Rails is present. Configure in an initializer:
# config/initializers/splatty.rb
Splatty.init do |config|
config.dsn = ENV["SPLATTY_DSN"]
# config.url defaults to https://splatty.app — override with ENV["SPLATTY_URL"] if needed
endSplatty.init installs error handlers for the job backends it finds loaded, so
failures outside the request cycle are reported too:
- Active Job — subscribes to
perform.active_joband reports any job whose exception escapedretry_on/discard_on. Jobs that are about to be retried and jobs discarded on purpose are not reported. Events are tagged withjob_class,job_queueandjob_backend(the queue adapter name), and carry the job id, attempt count and serialized arguments as extra data. - Sidekiq — appends an error handler to
Sidekiq.configure_server, which also covers failures Active Job never sees: plainSidekiq::Jobclasses, unparseable payloads and errors raised while dispatching a job. - Solid Queue — chains onto
SolidQueue.on_thread_error(any previously configured handler still runs), catching worker, dispatcher and supervisor thread errors on top of the job failures Active Job reports.
An exception object is only reported once, so a job failure that surfaces through two of these paths produces a single event.
Splatty ships semantic_logger as a dependency and auto-registers a Splatty
appender on Splatty.init, so any code that logs through SemanticLogger is
forwarded to Splatty. In Rails apps, rails_semantic_logger is also pulled in
and required by Splatty's railtie, which replaces Rails.logger and Rails'
log subscribers with semantic_logger — so request/controller/SQL logs flow to
Splatty with no extra wiring. Disable with config.logs = false.
The gem is available as open source under the terms of the MIT License.