Repository navigation
Description
Problem Statement
We run posthog-rails 3.20 next to sentry-sidekiq on a Rails 8.1 + Sidekiq 7 app. Sidekiq job errors reach PostHog through the Rails error reporter. That works, but it gives a worse result than a dedicated integration can produce:
-
The issue is named after Sidekiq wrapper, not the real error
When a job goes through Sidekiq retry handler, the exception (reported toRails.error) isSidekiq::JobRetry::Handled, and the real error is only itscause. In the last few days we had multiple similar cases, e.g.HandledwrappingPartnerApps::APIError(an embedded partner app errors inside our app). Exclusions and grouping also see the wrapper first (fix(rails): match excluded exceptions on subclasses and cause chain #331 fixes the exclusion side btw). -
Every retry is a separate event
There is no way to report only the final attempt or only dead jobs. One rate-limited job class produced about 35kSidekiq::Limiter::OverLimitretry events in 6 hours. -
Job context is thin
The only job property on the event is$context_sidekiq_job_class. No queue,jid, retry count or (filtered) arguments, so we can't easily a first attempt from a final one or find the job in Sidekiq UI. -
Errors outside a job are not captured
Sidekiq own failures (Redis connection errors, fetch, scheduler errors) go toSidekiq.error_handlers, which posthog-rails doesn't register. There is also no way to turn off the Rails error reporter subscriber on its own while keeping the rest of the integration. Replacing it with a custom handler seems awkward.
Solution Brainstorm
A Sidekiq integration opt-in like auto_instrument_active_job along the lines of sentry-sidekiq:
- Sidekiq server middleware (or
error_handlersentry) that reports the original exception, notHandled, and skips the duplicate report fromRails.error. - Job context of the event: queue,
jid, job class, retry count, arguments passed through the existing parameter filter. - An option to report only when retries are exhausted, plus a separate option for dead jobs.
- An
error_handlersentry for errors raised outside a job. - A
config.report_rails_errors = falsestyle switch for the subscriber.
If we agree on option names (and a general concept) - I could prep a PR.
Activity
posthog commentedon Nov 7, 2026
PostHog self-driving picked up this issue. Status: Research is done.
Somebody may already be working on it, so ask before you start a fix.
Report (team access only): https://us.posthog.com/project/2/inbox/reports/01a1b660-e842-7d9c-8ec4-6ccb570cfa8c?link_source=github_comment
marandaneto commentedon Nov 9, 2026
thanks @mkushner
i have opened 2 PRs to improve this