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

Open
#3,217 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
54/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
ruby

Research direction

Start by reading the current ActiveJobExtension context and error-data path; the issue explicitly says to use it rather than the removed SentryReporter.sentry_context. Check how that path builds contexts and handles optional job methods, then compare the result with the Good Job identity APIs in the specification. Done means the documented good_job context includes labels and any present legacy concurrency key, with neither field added as a tag.

Written by the indexing model from the issue text.

Description

Feature Ruby Waiting for: Product Owner

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

  • Official Good Job cron / ActiveJob work: #3199, #3200
  • Community sentry-good_job ContextHelpers (prior art only)

Unresolved questions

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

References

Dominant language
Ruby
Stars
990
Forks
553
Avg merge
1d 19h
Merged PRs (30d)
31

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from getsentry/sentry-ruby

All issues in getsentry/sentry-ruby

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.