Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions log/wideevent_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ const (
simpleLogEventName = "log.record"
)

var _ logger = (*WideEventLogger)(nil)

// NewWideEventLogger creates a wide-event logger.
func NewWideEventLogger(w io.Writer, s Sampler, loggerType string, contextKeys map[string]any) *WideEventLogger {
// If no sampler provided, use a keep-all sampler to prevent nil panics
Expand Down
14 changes: 8 additions & 6 deletions scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"errors"
"fmt"
"log/slog"
"time"

"github.com/platforma-dev/platforma/application"
Expand Down Expand Up @@ -77,16 +78,17 @@ func (s *Scheduler) Run(ctx context.Context) error {

// Wrap runner to maintain consistent logging with trace IDs
_, err := cronScheduler.AddFunc(s.cronExpr, func() {
event := log.NewEvent("scheduler.task.run")

runCtx := context.WithValue(ctx, log.TraceIDKey, uuid.NewString())
log.InfoContext(runCtx, "scheduler task started")
runCtx = context.WithValue(runCtx, log.WideEventKey, event)

event.AddStep(slog.LevelInfo, "scheduler task started")

err := s.runner.Run(runCtx)
if err != nil {
log.ErrorContext(runCtx, "error in scheduler", "error", err)
return
}
event.AddError(err)

log.InfoContext(runCtx, "scheduler task finished")
event.AddStep(slog.LevelInfo, "scheduler task finished")
})
if err != nil {
return fmt.Errorf("failed to add cron task: %w", err)
Expand Down
Loading