Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
7f42e184
Unverified
Commit
7f42e184
authored
Mar 07, 2022
by
Matthew Slipper
Committed by
GitHub
Mar 07, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2272 from mslipper/bugfix/metrics
indexer: fix metrics, reduce DB load
parents
29799d9d
f02b940e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
21 deletions
+29
-21
metrics.go
go/indexer/metrics/metrics.go
+5
-5
service.go
go/indexer/services/l1/service.go
+8
-4
service.go
go/indexer/services/l2/service.go
+16
-12
No files found.
go/indexer/metrics/metrics.go
View file @
7f42e184
...
@@ -43,8 +43,8 @@ func NewMetrics(monitoredTokens map[string]string) *Metrics {
...
@@ -43,8 +43,8 @@ func NewMetrics(monitoredTokens map[string]string) *Metrics {
return
&
Metrics
{
return
&
Metrics
{
SyncHeight
:
promauto
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
SyncHeight
:
promauto
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
Name
:
"
l1_
sync_height"
,
Name
:
"sync_height"
,
Help
:
"The max height of the indexer's last batch of L1 blocks."
,
Help
:
"The max height of the indexer's last batch of L1
/L1
blocks."
,
Namespace
:
metricsNamespace
,
Namespace
:
metricsNamespace
,
},
[]
string
{
},
[]
string
{
"chain"
,
"chain"
,
...
@@ -66,7 +66,7 @@ func NewMetrics(monitoredTokens map[string]string) *Metrics {
...
@@ -66,7 +66,7 @@ func NewMetrics(monitoredTokens map[string]string) *Metrics {
"symbol"
,
"symbol"
,
}),
}),
StateBatchesCount
:
prom
etheus
.
NewCounter
(
prometheus
.
CounterOpts
{
StateBatchesCount
:
prom
auto
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"state_batches_count"
,
Name
:
"state_batches_count"
,
Help
:
"The number of state batches indexed."
,
Help
:
"The number of state batches indexed."
,
Namespace
:
metricsNamespace
,
Namespace
:
metricsNamespace
,
...
@@ -101,7 +101,7 @@ func NewMetrics(monitoredTokens map[string]string) *Metrics {
...
@@ -101,7 +101,7 @@ func NewMetrics(monitoredTokens map[string]string) *Metrics {
"chain"
,
"chain"
,
}),
}),
CachedTokensCount
:
prom
etheus
.
NewCounterVec
(
prometheus
.
CounterOpts
{
CachedTokensCount
:
prom
auto
.
NewCounterVec
(
prometheus
.
CounterOpts
{
Name
:
"cached_tokens_count"
,
Name
:
"cached_tokens_count"
,
Help
:
"How many tokens are in the cache"
,
Help
:
"How many tokens are in the cache"
,
Namespace
:
metricsNamespace
,
Namespace
:
metricsNamespace
,
...
@@ -118,7 +118,7 @@ func (m *Metrics) SetL1SyncHeight(height uint64) {
...
@@ -118,7 +118,7 @@ func (m *Metrics) SetL1SyncHeight(height uint64) {
}
}
func
(
m
*
Metrics
)
SetL2SyncHeight
(
height
uint64
)
{
func
(
m
*
Metrics
)
SetL2SyncHeight
(
height
uint64
)
{
m
.
SyncHeight
.
WithLabelValues
(
"l
1
"
)
.
Set
(
float64
(
height
))
m
.
SyncHeight
.
WithLabelValues
(
"l
2
"
)
.
Set
(
float64
(
height
))
}
}
func
(
m
*
Metrics
)
RecordDeposit
(
addr
common
.
Address
)
{
func
(
m
*
Metrics
)
RecordDeposit
(
addr
common
.
Address
)
{
...
...
go/indexer/services/l1/service.go
View file @
7f42e184
...
@@ -94,9 +94,9 @@ type Service struct {
...
@@ -94,9 +94,9 @@ type Service struct {
latestHeader
uint64
latestHeader
uint64
headerSelector
*
ConfirmedHeaderSelector
headerSelector
*
ConfirmedHeaderSelector
metrics
*
metrics
.
Metrics
metrics
*
metrics
.
Metrics
tokenCache
map
[
common
.
Address
]
*
db
.
Token
tokenCache
map
[
common
.
Address
]
*
db
.
Token
wg
sync
.
WaitGroup
wg
sync
.
WaitGroup
}
}
type
IndexerStatus
struct
{
type
IndexerStatus
struct
{
...
@@ -289,10 +289,15 @@ func (s *Service) Update(newHeader *types.Header) error {
...
@@ -289,10 +289,15 @@ func (s *Service) Update(newHeader *types.Header) error {
logger
.
Error
(
"Error querying state batches"
,
"err"
,
err
)
logger
.
Error
(
"Error querying state batches"
,
"err"
,
err
)
}
}
for
_
,
header
:=
range
headers
{
for
i
,
header
:=
range
headers
{
blockHash
:=
header
.
Hash
blockHash
:=
header
.
Hash
number
:=
header
.
Number
.
Uint64
()
number
:=
header
.
Number
.
Uint64
()
deposits
:=
depositsByBlockHash
[
blockHash
]
deposits
:=
depositsByBlockHash
[
blockHash
]
batches
:=
stateBatches
[
blockHash
]
if
len
(
deposits
)
==
0
&&
len
(
batches
)
==
0
&&
i
!=
len
(
headers
)
-
1
{
continue
}
block
:=
&
db
.
IndexedL1Block
{
block
:=
&
db
.
IndexedL1Block
{
Hash
:
blockHash
,
Hash
:
blockHash
,
...
@@ -313,7 +318,6 @@ func (s *Service) Update(newHeader *types.Header) error {
...
@@ -313,7 +318,6 @@ func (s *Service) Update(newHeader *types.Header) error {
return
err
return
err
}
}
batches
:=
stateBatches
[
blockHash
]
err
=
s
.
cfg
.
DB
.
AddStateBatch
(
batches
)
err
=
s
.
cfg
.
DB
.
AddStateBatch
(
batches
)
if
err
!=
nil
{
if
err
!=
nil
{
logger
.
Error
(
logger
.
Error
(
...
...
go/indexer/services/l2/service.go
View file @
7f42e184
...
@@ -69,15 +69,15 @@ func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) {
...
@@ -69,15 +69,15 @@ func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) {
}
}
type
ServiceConfig
struct
{
type
ServiceConfig
struct
{
Context
context
.
Context
Context
context
.
Context
Metrics
*
metrics
.
Metrics
Metrics
*
metrics
.
Metrics
L2Client
*
l2ethclient
.
Client
L2Client
*
l2ethclient
.
Client
ChainID
*
big
.
Int
ChainID
*
big
.
Int
ConfDepth
uint64
ConfDepth
uint64
MaxHeaderBatchSize
uint64
MaxHeaderBatchSize
uint64
StartBlockNumber
uint64
StartBlockNumber
uint64
StartBlockHash
string
StartBlockHash
string
DB
*
db
.
Database
DB
*
db
.
Database
}
}
type
Service
struct
{
type
Service
struct
{
...
@@ -89,9 +89,9 @@ type Service struct {
...
@@ -89,9 +89,9 @@ type Service struct {
latestHeader
uint64
latestHeader
uint64
headerSelector
*
ConfirmedHeaderSelector
headerSelector
*
ConfirmedHeaderSelector
metrics
*
metrics
.
Metrics
metrics
*
metrics
.
Metrics
tokenCache
map
[
common
.
Address
]
*
db
.
Token
tokenCache
map
[
common
.
Address
]
*
db
.
Token
wg
sync
.
WaitGroup
wg
sync
.
WaitGroup
}
}
type
IndexerStatus
struct
{
type
IndexerStatus
struct
{
...
@@ -267,11 +267,15 @@ func (s *Service) Update(newHeader *types.Header) error {
...
@@ -267,11 +267,15 @@ func (s *Service) Update(newHeader *types.Header) error {
}
}
}
}
for
_
,
header
:=
range
headers
{
for
i
,
header
:=
range
headers
{
blockHash
:=
header
.
Hash
()
blockHash
:=
header
.
Hash
()
number
:=
header
.
Number
.
Uint64
()
number
:=
header
.
Number
.
Uint64
()
withdrawals
:=
withdrawalsByBlockHash
[
blockHash
]
withdrawals
:=
withdrawalsByBlockHash
[
blockHash
]
if
len
(
withdrawals
)
==
0
&&
i
!=
len
(
headers
)
-
1
{
continue
}
block
:=
&
db
.
IndexedL2Block
{
block
:=
&
db
.
IndexedL2Block
{
Hash
:
blockHash
,
Hash
:
blockHash
,
ParentHash
:
header
.
ParentHash
,
ParentHash
:
header
.
ParentHash
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment