Add `-sentry-extra-trace` flag for enhanced Sentry error tracing
- Dominant language
- Go
- Stars
- 2.6k
- Forks
- 147
- PR merge metrics
- No merged PRs in 30d
Description
### 🧩 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
```bash
$ ./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
```json
{
"extra": {
"job.exit_code": 1,
"job.duration": "5.32s",
"job.stdout": "Starting backup...\nConnecting to database...",
"job.stderr": "pg_dump: connection failed: timeout"
}
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading main.go for flag handling and cron.go for runJob, the 64 KB ring buffer, Sentry extra fields, and handleExecError(). Check README.md, go.mod, and go.sum for the documented interface and dependencies. Done means failed jobs can optionally include recent stdout and stderr in Sentry while normal logging and existing behavior remain unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend, observability
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100