1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package backend
import (
"github.com/ethereum-optimism/optimism/op-service/sources/caching"
"github.com/ethereum-optimism/optimism/op-supervisor/supervisor/backend/db/logs"
"github.com/ethereum-optimism/optimism/op-supervisor/supervisor/types"
)
type Metrics interface {
CacheAdd(chainID types.ChainID, label string, cacheSize int, evicted bool)
CacheGet(chainID types.ChainID, label string, hit bool)
RecordDBEntryCount(chainID types.ChainID, kind string, count int64)
RecordDBSearchEntriesRead(chainID types.ChainID, count int64)
}
// chainMetrics is an adapter between the metrics API expected by clients that assume there's only a single chain
// and the actual metrics implementation which requires a chain ID to identify the source chain.
type chainMetrics struct {
chainID types.ChainID
delegate Metrics
}
func newChainMetrics(chainID types.ChainID, delegate Metrics) *chainMetrics {
return &chainMetrics{
chainID: chainID,
delegate: delegate,
}
}
func (c *chainMetrics) CacheAdd(label string, cacheSize int, evicted bool) {
c.delegate.CacheAdd(c.chainID, label, cacheSize, evicted)
}
func (c *chainMetrics) CacheGet(label string, hit bool) {
c.delegate.CacheGet(c.chainID, label, hit)
}
func (c *chainMetrics) RecordDBEntryCount(kind string, count int64) {
c.delegate.RecordDBEntryCount(c.chainID, kind, count)
}
func (c *chainMetrics) RecordDBSearchEntriesRead(count int64) {
c.delegate.RecordDBSearchEntriesRead(c.chainID, count)
}
var _ caching.Metrics = (*chainMetrics)(nil)
var _ logs.Metrics = (*chainMetrics)(nil)