Skip to content

enhancement: consider adding context to observability hooks #183

@CybotTM

Description

@CybotTM

Description

Observability hooks don't receive a context, making it difficult for hook implementations to:

  • Respect shutdown signals
  • Implement timeouts
  • Pass tracing context

Location

  • observability.go:ObservabilityHooks struct

Current Signatures

OnSchedule    func(id EntryID, job Job, scheduledTime time.Time)
OnJobStart    func(id EntryID, job Job, scheduledTime time.Time)
OnJobComplete func(id EntryID, job Job, scheduledTime time.Time, duration time.Duration, panicValue any)

Proposed Signatures

OnSchedule    func(ctx context.Context, id EntryID, job Job, scheduledTime time.Time)
OnJobStart    func(ctx context.Context, id EntryID, job Job, scheduledTime time.Time)
OnJobComplete func(ctx context.Context, id EntryID, job Job, scheduledTime time.Time, duration time.Duration, panicValue any)

Benefits

  • Hooks can respect scheduler shutdown
  • Hooks can propagate tracing context
  • Hooks can implement proper timeouts
  • Consistent with Go context patterns

Severity

🟡 Medium - API improvement for better observability integration

Breaking Change

⚠️ This would be a breaking API change, consider for v2.0

Found By

Pre-1.0 release code review with Zen/Gemini

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestobservabilityMetrics and monitoringv2.0Scheduled for v2.0 release (breaking changes)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions