Skip to content

Add -sentry-extra-trace flag for enhanced Sentry error tracing #202

Description

@guillaumetorresani

🧩 Context

Currently, when Supercronic reports errors to Sentry using the -sentry-dsn flag, the job’s stdout and stderr outputs are not included in the Sentry events.
This makes it harder to diagnose job failures due to missing runtime context.

💡 Proposal

Introduce a new optional flag:

-sentry-extra-trace

When enabled, Supercronic will attach the latest stdout and stderr output from failed jobs to the Sentry event’s extra field.
This provides better visibility into job failures without changing the normal logging behavior.

✅ Example usage

$ ./supercronic -sentry-dsn https://examplePublicKey@o0.ingest.sentry.io/0 -sentry-extra-trace true

🧰 Technical details

  • Added -sentry-extra-trace flag in main.go
  • Updated cron.go:
    • Captured stdout and stderr via a 64 KB ring buffer
    • Returned captured data from runJob
    • Conditionally attached it to Sentry extra fields when -sentry-extra-trace is enabled
  • Refactored exec.Command.Start/Wait error handling into handleExecError()
  • Updated README.md and dependencies (go.mod, go.sum)

🚀 Benefits

  • Improved debugging visibility in Sentry
  • No performance or logging regressions
  • Backward-compatible with existing jobs

📦 Example of enriched Sentry payload

{
  "extra": {
    "job.exit_code": 1,
    "job.duration": "5.32s",
    "job.stdout": "Starting backup...\nConnecting to database...",
    "job.stderr": "pg_dump: connection failed: timeout"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions