Skip to content

Log Sidekiq and Puma errors with typed fields, and an ActiveJob job's Sidekiq error unless ActiveJob logged it - #22

Merged
ndbroadbent merged 3 commits into
mainfrom
nathan/error-lines
Oct 18, 2026
Merged

ndbroadbent merged 3 commits into
mainfrom
nathan/error-lines

Conversation

@ndbroadbent

@ndbroadbent ndbroadbent commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Seventh of twelve stacked PRs for 0.2.0.

What this fixes

  • An error raised before ActiveJob ran a job was in no log line. Sidekiq's error handler skipped every ActiveJob
    job's error and left it to the ActiveJob integration, so the NameError for a job class a deploy removed (raised
    while Sidekiq deserializes the job) wasn't logged anywhere. The handler now skips only the errors the ActiveJob
    integration logged (LogStruct::LoggedErrors), as the GoodJob integration does.
  • Sidekiq and Puma error lines have typed fields. Their fields (Sidekiq's context, the job's ID, class, queue and
    retry count; Puma's context, method and path) were in additional_data, which is for fields LogStruct doesn't know.
    They're new events with schema fields: Log::Sidekiq::Error and Log::Puma::Error, with an error_context field
    for what Sidekiq or Puma was doing. Breaking: Log::Sidekiq is now Log::Sidekiq::Log.
  • The Sidekiq error line has the job's jid and class in ctx, like the lines logged while the job ran, so a query
    on ctx.jid finds the error too.
  • Puma's request errors that aren't StandardErrors are logged too.
  • The generated TypeScript types error_class as a string. It was any once Log::Error's error_class became
    T.class_of(Exception).

Testing

New tests for each change. Sorbet and the unit suite (310 tests) pass at this branch's tip.


Stack for 0.2.0, merged in order: #16 → #17 → #18 → #19 → #20 → #21 → #22 → #23 → #24 → #25 → #26 → #27

The TypeScript generator mapped T.class_of(StandardError) to string but not
T.class_of(Exception), the type Log::Error's error_class has now, so the
generated error_class became `any`.
Sidekiq's job error line and Puma's request error line put their fields
(Sidekiq's context, the job ID and class, queue and retry count; Puma's context,
method and path) in additional_data, which is only for fields LogStruct doesn't
know about. They're new events with schema fields now: Log::Sidekiq::Error and
Log::Puma::Error, with a new error_context field for what Sidekiq or Puma was
doing. Log::Sidekiq becomes Log::Sidekiq::Log.

The Sidekiq error line has the job's ID and class in ctx, like the lines
logged while the job ran, so a query on ctx.jid finds the error too. Sidekiq
calls its error handlers after the job's middleware has finished, so the line
is logged with the same tags. Puma's request errors that aren't StandardErrors
are logged too.
Sidekiq's error handler skipped every ActiveJob job's error, leaving it to the
ActiveJob integration. An error raised before ActiveJob ran the job, such as
the NameError for a job class a deploy removed, was then in no log line. The
handler now skips only the errors the ActiveJob integration logged
(LogStruct::LoggedErrors), as the GoodJob integration does.
@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 91140ca2-f863-4f0b-abd1-ddc19e73aa42
📥 Commits

Reviewing files that changed from the base of the PR and between c9a1947 and 2bb51df.

📒 Files selected for processing: 18
  • docs/lib/log-generation/log-generator.ts
  • docs/lib/log-generation/sample-data.ts
  • docs/lib/log-structure-descriptions.ts
  • lib/log_struct/enums/log_field.rb
  • lib/log_struct/integrations/puma.rb
  • lib/log_struct/integrations/sidekiq.rb
  • lib/log_struct/integrations/sidekiq/logger.rb
  • lib/log_struct/log/puma.rb
  • lib/log_struct/log/puma/error.rb
  • lib/log_struct/log/sidekiq.rb
  • lib/log_struct/log/sidekiq/error.rb
  • lib/log_struct/log/sidekiq/log.rb
  • schemas/log_sources/puma.yml
  • schemas/log_sources/sidekiq.yml
  • schemas/meta/log-fields.json
  • test/log_struct/integrations/puma_unit_test.rb
  • test/log_struct/integrations/sidekiq_test.rb
  • tools/codegen/helpers.rb
+-------------------------------------------------------+
| I raised 60 million carrots in my last funding round. |
+-------------------------------------------------------+
  \
   \     /)/)
        ( '')
        /  |
      o(___)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant