Skip to content

Commit

Permalink
minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhuie19 committed Jan 10, 2025
1 parent d4519a9 commit d257f3e
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions core/services/chainlink/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,33 +231,32 @@ func (h *ApplicationHeartbeat) start(_ context.Context) error {
cme := custmsg.NewLabeler()

// Define tick functions
beatFn := func(engCtx context.Context) {
beatFn := func(ctx context.Context) {
// TODO allow override of tracer provider into engine for beholder
_, innerSpan := beholder.GetTracer().Start(engCtx, "heartbeat.beat")
_, innerSpan := beholder.GetTracer().Start(ctx, "heartbeat.beat")
defer innerSpan.End()

gauge.Record(engCtx, 1)
count.Record(engCtx, 1)
gauge.Record(ctx, 1)
count.Record(ctx, 1)

err = cme.Emit(engCtx, "heartbeat")
err = cme.Emit(ctx, "heartbeat")
if err != nil {
h.eng.Errorw("heartbeat emit failed", "err", err)
}
}

// consistent tick period
constantTickFn := func() time.Duration {
return h.beat
}

h.eng.GoTick(timeutil.NewTicker(constantTickFn), beatFn)
h.eng.GoTick(timeutil.NewTicker(h.getBeat), beatFn)
return nil
}

func (h *ApplicationHeartbeat) close() error {
return nil
}

func (h *ApplicationHeartbeat) getBeat() time.Duration {
return h.beat
}

// NewApplication initializes a new store if one is not already
// present at the configured root directory (default: ~/.chainlink),
// the logger at the same directory and returns the Application to
Expand Down

0 comments on commit d257f3e

Please sign in to comment.