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
Show 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 {
return
&
Metrics
{
SyncHeight
:
promauto
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
Name
:
"
l1_
sync_height"
,
Help
:
"The max height of the indexer's last batch of L1 blocks."
,
Name
:
"sync_height"
,
Help
:
"The max height of the indexer's last batch of L1
/L1
blocks."
,
Namespace
:
metricsNamespace
,
},
[]
string
{
"chain"
,
...
...
@@ -66,7 +66,7 @@ func NewMetrics(monitoredTokens map[string]string) *Metrics {
"symbol"
,
}),
StateBatchesCount
:
prom
etheus
.
NewCounter
(
prometheus
.
CounterOpts
{
StateBatchesCount
:
prom
auto
.
NewCounter
(
prometheus
.
CounterOpts
{
Name
:
"state_batches_count"
,
Help
:
"The number of state batches indexed."
,
Namespace
:
metricsNamespace
,
...
...
@@ -101,7 +101,7 @@ func NewMetrics(monitoredTokens map[string]string) *Metrics {
"chain"
,
}),
CachedTokensCount
:
prom
etheus
.
NewCounterVec
(
prometheus
.
CounterOpts
{
CachedTokensCount
:
prom
auto
.
NewCounterVec
(
prometheus
.
CounterOpts
{
Name
:
"cached_tokens_count"
,
Help
:
"How many tokens are in the cache"
,
Namespace
:
metricsNamespace
,
...
...
@@ -118,7 +118,7 @@ func (m *Metrics) SetL1SyncHeight(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
)
{
...
...
go/indexer/services/l1/service.go
View file @
7f42e184
...
...
@@ -289,10 +289,15 @@ func (s *Service) Update(newHeader *types.Header) error {
logger
.
Error
(
"Error querying state batches"
,
"err"
,
err
)
}
for
_
,
header
:=
range
headers
{
for
i
,
header
:=
range
headers
{
blockHash
:=
header
.
Hash
number
:=
header
.
Number
.
Uint64
()
deposits
:=
depositsByBlockHash
[
blockHash
]
batches
:=
stateBatches
[
blockHash
]
if
len
(
deposits
)
==
0
&&
len
(
batches
)
==
0
&&
i
!=
len
(
headers
)
-
1
{
continue
}
block
:=
&
db
.
IndexedL1Block
{
Hash
:
blockHash
,
...
...
@@ -313,7 +318,6 @@ func (s *Service) Update(newHeader *types.Header) error {
return
err
}
batches
:=
stateBatches
[
blockHash
]
err
=
s
.
cfg
.
DB
.
AddStateBatch
(
batches
)
if
err
!=
nil
{
logger
.
Error
(
...
...
go/indexer/services/l2/service.go
View file @
7f42e184
...
...
@@ -267,11 +267,15 @@ func (s *Service) Update(newHeader *types.Header) error {
}
}
for
_
,
header
:=
range
headers
{
for
i
,
header
:=
range
headers
{
blockHash
:=
header
.
Hash
()
number
:=
header
.
Number
.
Uint64
()
withdrawals
:=
withdrawalsByBlockHash
[
blockHash
]
if
len
(
withdrawals
)
==
0
&&
i
!=
len
(
headers
)
-
1
{
continue
}
block
:=
&
db
.
IndexedL2Block
{
Hash
:
blockHash
,
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