From d257f3e454bed4e5cdcf335e036b6578240875ab Mon Sep 17 00:00:00 2001 From: patrickhuie19 Date: Fri, 10 Jan 2025 16:13:25 -0500 Subject: [PATCH] minor refactoring --- core/services/chainlink/application.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/core/services/chainlink/application.go b/core/services/chainlink/application.go index 44923037ab5..e7c7c87287d 100644 --- a/core/services/chainlink/application.go +++ b/core/services/chainlink/application.go @@ -231,26 +231,21 @@ 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 } @@ -258,6 +253,10 @@ 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