Skip to content

rails: add optional Good Job labels and concurrency key to ActiveJob error context #3217

Open

Description

@amkisko

Summary

When an ActiveJob instance exposes Good Job identity APIs, attach labels and legacy concurrency_key under a good_job context on error (and optionally on the job scope).

Motivation

Official ActiveJob / job-extension reporting already records queue, executions, latency, and messaging fields. It does not record Good Job's concurrency identity (good_job_labels, and on older 4.x good_job_concurrency_key). Those fields help explain why a job was limited or which concurrency cohort it belonged to.

Specification

  • Duck-type only:
    • if job.respond_to?(:good_job_labels) -> contexts.good_job.labels = Array(job.good_job_labels)
    • if job.respond_to?(:good_job_concurrency_key) and value present -> contexts.good_job.concurrency_key
  • Do not set these as tags (label cardinality).
  • Hook current ActiveJobExtension context / error-data path (not removed SentryReporter.sentry_context).
  • No-op when methods are absent.

Guide-level

A failing job that uses Good Job concurrency labels shows contexts.good_job.labels on the event. Hosts on Good Job 5+ without concurrency_key simply omit that field.

Drawbacks / alternatives

  • Adopt: small adapter-specific branch in a shared ActiveJob path.
  • Do nothing: lose concurrency cohort signal on errors.
  • Rejected: tags for labels.
  • Rejected: nest only under extra if contexts.good_job is unacceptable; prefer contexts for structured identity.

Prior art

Unresolved questions

  • Apply on successful transactions too, or only on captured exceptions?
  • Name the context key good_job vs extend active_job?

References

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions