Skip to content

Commit

Permalink
Set metrics in buffer, remove ticker
Browse files Browse the repository at this point in the history
  • Loading branch information
ogtownsend committed Jan 23, 2024
1 parent 7f2db32 commit 1449121
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller"
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/prommetrics"
)

var (
Expand Down Expand Up @@ -232,7 +233,7 @@ func (b *logEventBuffer) enqueue(id *big.Int, logs ...logpoller.Log) int {
}
if added > 0 {
lggr.Debugw("Added logs to buffer", "addedLogs", added, "dropped", dropped, "latestBlock", latestBlock)
atomic.AddInt64(&b.logsInBuffer, int64(added-dropped))
prommetrics.AutomationLogsInLogBuffer.Set(float64(atomic.AddInt64(&b.logsInBuffer, int64(added-dropped))))
}

return added - dropped
Expand Down Expand Up @@ -334,7 +335,7 @@ func (b *logEventBuffer) dequeueRange(start, end int64, upkeepLimit, totalLimit

if len(results) > 0 {
b.lggr.Debugw("Dequeued logs", "results", len(results), "start", start, "end", end)
atomic.AddInt64(&b.logsInBuffer, -int64(len(results)))
prommetrics.AutomationLogsInLogBuffer.Set(float64(atomic.AddInt64(&b.logsInBuffer, -int64(len(results)))))
}

return results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_utils_2_1"
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/core"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/prommetrics"
"github.com/smartcontractkit/chainlink/v2/core/services/pg"
"github.com/smartcontractkit/chainlink/v2/core/utils"
)
Expand Down Expand Up @@ -103,8 +102,6 @@ type logEventProvider struct {
opts LogTriggersOptions

currentPartitionIdx uint64

servedLogs int64
}

func NewLogProvider(lggr logger.Logger, poller logpoller.LogPoller, packer LogDataPacker, filterStore UpkeepFilterStore, opts LogTriggersOptions) *logEventProvider {
Expand Down Expand Up @@ -145,21 +142,6 @@ func (p *logEventProvider) Start(context.Context) error {
})
})

p.threadCtrl.Go(func(ctx context.Context) {
ticker := time.NewTicker(5 * time.Second)
defer ticker.Stop()
for {
select {
case <-ticker.C:
p.lggr.Debugw("logs stats", "servedLogs", atomic.LoadInt64(&p.servedLogs), "logsInBuffer", atomic.LoadInt64(&p.buffer.logsInBuffer), "latestBlockSeen", p.buffer.latestBlockSeen())
prommetrics.AutomationLogsInLogBuffer.Set(float64(atomic.LoadInt64(&p.buffer.logsInBuffer)))
case <-ctx.Done():
return

}
}
})

return nil
})
}
Expand Down

0 comments on commit 1449121

Please sign in to comment.