diff --git a/pkg/capabilities/consensus/ocr3/datafeeds/feeds_aggregator.go b/pkg/capabilities/consensus/ocr3/datafeeds/feeds_aggregator.go index e7cab87a4..a40cc88bb 100644 --- a/pkg/capabilities/consensus/ocr3/datafeeds/feeds_aggregator.go +++ b/pkg/capabilities/consensus/ocr3/datafeeds/feeds_aggregator.go @@ -16,6 +16,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/capabilities/consensus/ocr3/types" "github.com/smartcontractkit/chainlink-common/pkg/capabilities/datastreams" "github.com/smartcontractkit/chainlink-common/pkg/logger" + "github.com/smartcontractkit/chainlink-common/pkg/logger/lk" "github.com/smartcontractkit/chainlink-common/pkg/values" ) @@ -112,12 +113,12 @@ func (a *dataFeedsAggregator) Aggregate(lggr logger.Logger, previousOutcome *typ previousReportInfo := currentState.FeedInfo[feedIDStr] feedID, err2 := datastreams.NewFeedID(feedIDStr) if err2 != nil { - lggr.Errorw("could not convert %s to feedID", "feedID", feedID) + lggr.Errorw("could not convert %s to feedID", lk.FeedID, feedID) continue } latestReport, ok := latestReportPerFeed[feedID] if !ok { - lggr.Errorw("no new Mercury report for feed", "feedID", feedID) + lggr.Errorw("no new Mercury report for feed", lk.FeedID, feedID) continue } config := a.config.Feeds[feedID] @@ -126,7 +127,7 @@ func (a *dataFeedsAggregator) Aggregate(lggr logger.Logger, previousOutcome *typ currDeviation := deviation(oldPrice, newPrice) currStaleness := latestReport.ObservationTimestamp - previousReportInfo.ObservationTimestamp lggr.Debugw("checking deviation and heartbeat", - "feedID", feedID, + lk.FeedID, feedID, "currentTs", latestReport.ObservationTimestamp, "oldTs", previousReportInfo.ObservationTimestamp, "currStaleness", currStaleness, @@ -213,14 +214,14 @@ func (a *dataFeedsAggregator) initializeCurrentState(lggr logger.Logger, previou ObservationTimestamp: 0, // will always trigger an update BenchmarkPrice: big.NewInt(0).Bytes(), } - lggr.Debugw("initializing empty onchain state for feed", "feedID", feedID.String()) + lggr.Debugw("initializing empty onchain state for feed", lk.FeedID, feedID.String()) } } // remove obsolete feeds from state for feedID := range currentState.FeedInfo { if _, ok := a.config.Feeds[datastreams.FeedID(feedID)]; !ok { delete(currentState.FeedInfo, feedID) - lggr.Debugw("removed obsolete feedID from state", "feedID", feedID) + lggr.Debugw("removed obsolete feedID from state", lk.FeedID, feedID) } } lggr.Debugw("current state initialized", "state", currentState, "previousOutcome", previousOutcome) diff --git a/pkg/logger/lk/logkey.go b/pkg/logger/lk/logkey.go new file mode 100644 index 000000000..f5bfd09c6 --- /dev/null +++ b/pkg/logger/lk/logkey.go @@ -0,0 +1,10 @@ +package lk + +const ( + ChainID = "chainID" // string + ContractID = "contractID" // string + FeedID = "feedID" // string - hex-encoded 32-byte value, prefixed with "0x", all lowercase + JobID = "jobID" // int32 + JobName = "jobName" // string + TransmitterID = "transmitterID" // string +) diff --git a/pkg/loop/context.go b/pkg/loop/context.go index 9237e8e4c..2ce20895e 100644 --- a/pkg/loop/context.go +++ b/pkg/loop/context.go @@ -1,6 +1,10 @@ package loop -import "context" +import ( + "context" + + "github.com/smartcontractkit/chainlink-common/pkg/logger/lk" +) type ctxKey int @@ -25,19 +29,19 @@ type ContextValues struct { // Args returns a slice of args to pass to [logger.Logger.With]. func (v *ContextValues) Args() (a []any) { if v.JobID != nil { - a = append(a, "jobID", v.JobID) + a = append(a, lk.JobID, v.JobID) } if v.JobName != nil { - a = append(a, "jobName", v.JobName) + a = append(a, lk.JobName, v.JobName) } if v.ContractID != nil { - a = append(a, "contractID", v.ContractID) + a = append(a, lk.ContractID, v.ContractID) } if v.FeedID != nil { - a = append(a, "feedID", v.FeedID) + a = append(a, lk.FeedID, v.FeedID) } if v.TransmitterID != nil { - a = append(a, "transmitterID", v.TransmitterID) + a = append(a, lk.TransmitterID, v.TransmitterID) } return }