Skip to content
TraceStax Docs

Ruby

The TraceStax Ruby SDK supports Sidekiq (6.x and 7.x) and Solid Queue (Rails 8). One gem, multiple adapters — load only what your app uses.

  • Ruby 3.1+
  • Sidekiq 6.x or 7.x, or Solid Queue ≥ 0.3

Add to your Gemfile:

gem "tracestax"

Then run:

Terminal window
bundle install

config/initializers/tracestax.rb
require "tracestax/sidekiq"
TraceStax::Sidekiq.configure do |config|
config.api_key = ENV["TRACESTAX_API_KEY"]
end
TraceStax::Sidekiq.install!

install! registers TraceStax as a Sidekiq server middleware and starts the heartbeat poller automatically.


TraceStax::Sidekiq.configure do |config|
config.api_key = ENV["TRACESTAX_API_KEY"] # Required
config.enabled = !Rails.env.test?
config.dry_run = false
config.ingest_url = "https://ingest.tracestax.com"
end
OptionEnv varDefaultDescription
api_keyTRACESTAX_API_KEYRequired
enabledTRACESTAX_ENABLEDtrueSet to false in tests
dry_runTRACESTAX_DRY_RUNfalseLog events instead of sending
ingest_urlTRACESTAX_INGEST_URLhttps://ingest.tracestax.comCustom endpoint

Cron jobs (Sidekiq-Cron / Sidekiq Scheduler)

Section titled “Cron jobs (Sidekiq-Cron / Sidekiq Scheduler)”

Periodic jobs scheduled via sidekiq-cron or sidekiq-scheduler are tracked automatically — the middleware fires for every execution. The scheduled: true flag is set on events from jobs that appear in the cron schedule.


# spec/rails_helper.rb or test/test_helper.rb
ENV["TRACESTAX_ENABLED"] = "false"

Or disable via configuration:

TraceStax::Sidekiq.configure { |c| c.enabled = false }

Events not appearing

The middleware fires synchronously on the server side. Confirm that:

  • TRACESTAX_API_KEY is present in the Sidekiq process environment (not just the web process)
  • The Sidekiq process can reach ingest.tracestax.com:443
  • TraceStax logs a [TraceStax] warning line if ingest calls fail — check sidekiq.log

Concurrency impact

Ingest calls are made from a background thread with connection pooling via Faraday. They add < 1ms to job overhead in typical deployments.