Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
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
vicotor
mybee
Commits
d174a004
Unverified
Commit
d174a004
authored
Jun 17, 2021
by
metacertain
Committed by
GitHub
Jun 17, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: Detailed accounting disconnect metrics (#2120)
parent
3a92ef59
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
12 deletions
+37
-12
accounting.go
pkg/accounting/accounting.go
+4
-1
metrics.go
pkg/accounting/metrics.go
+33
-11
No files found.
pkg/accounting/accounting.go
View file @
d174a004
...
...
@@ -363,6 +363,7 @@ func (a *Accounting) settle(peer swarm.Address, balance *accountingPeer) error {
acceptedAmount
,
timestamp
,
err
:=
a
.
refreshFunction
(
context
.
Background
(),
peer
,
paymentAmount
,
shadowBalance
)
if
err
!=
nil
{
a
.
metrics
.
AccountingDisconnectsEnforceRefreshCount
.
Inc
()
_
=
a
.
blocklist
(
peer
,
1
)
return
fmt
.
Errorf
(
"refresh failure: %w"
,
err
)
}
...
...
@@ -998,7 +999,7 @@ func (d *debitAction) Apply() error {
if
nextBalance
.
Cmp
(
a
.
disconnectLimit
)
>=
0
{
// peer too much in debt
a
.
metrics
.
AccountingDisconnectsCount
.
Inc
()
a
.
metrics
.
AccountingDisconnects
Overdraw
Count
.
Inc
()
disconnectFor
,
err
:=
a
.
blocklistUntil
(
d
.
peer
,
1
)
if
err
!=
nil
{
...
...
@@ -1020,6 +1021,7 @@ func (d *debitAction) Cleanup() {
d
.
accountingPeer
.
shadowReservedBalance
=
new
(
big
.
Int
)
.
Sub
(
d
.
accountingPeer
.
shadowReservedBalance
,
d
.
price
)
d
.
accountingPeer
.
ghostBalance
=
new
(
big
.
Int
)
.
Add
(
d
.
accountingPeer
.
ghostBalance
,
d
.
price
)
if
d
.
accountingPeer
.
ghostBalance
.
Cmp
(
a
.
disconnectLimit
)
>
0
{
a
.
metrics
.
AccountingDisconnectsGhostOverdrawCount
.
Inc
()
_
=
a
.
blocklist
(
d
.
peer
,
1
)
}
}
...
...
@@ -1083,6 +1085,7 @@ func (a *Accounting) Connect(peer swarm.Address) {
timeNow
:=
a
.
timeNow
()
.
Unix
()
if
timeNow
<
accountingPeer
.
reconnectAllowTimestamp
{
disconnectFor
:=
accountingPeer
.
reconnectAllowTimestamp
-
timeNow
a
.
metrics
.
AccountingDisconnectsReconnectCount
.
Inc
()
_
=
a
.
p2p
.
Blocklist
(
peer
,
time
.
Duration
(
disconnectFor
)
*
time
.
Second
)
}
}
...
...
pkg/accounting/metrics.go
View file @
d174a004
...
...
@@ -13,15 +13,18 @@ type metrics struct {
// all metrics fields must be exported
// to be able to return them by Metrics()
// using reflection
TotalDebitedAmount
prometheus
.
Counter
TotalCreditedAmount
prometheus
.
Counter
DebitEventsCount
prometheus
.
Counter
CreditEventsCount
prometheus
.
Counter
AccountingDisconnectsCount
prometheus
.
Counter
AccountingBlocksCount
prometheus
.
Counter
AccountingReserveCount
prometheus
.
Counter
TotalOriginatedCreditedAmount
prometheus
.
Counter
OriginatedCreditEventsCount
prometheus
.
Counter
TotalDebitedAmount
prometheus
.
Counter
TotalCreditedAmount
prometheus
.
Counter
DebitEventsCount
prometheus
.
Counter
CreditEventsCount
prometheus
.
Counter
AccountingDisconnectsEnforceRefreshCount
prometheus
.
Counter
AccountingDisconnectsOverdrawCount
prometheus
.
Counter
AccountingDisconnectsGhostOverdrawCount
prometheus
.
Counter
AccountingDisconnectsReconnectCount
prometheus
.
Counter
AccountingBlocksCount
prometheus
.
Counter
AccountingReserveCount
prometheus
.
Counter
TotalOriginatedCreditedAmount
prometheus
.
Counter
OriginatedCreditEventsCount
prometheus
.
Counter
}
func
newMetrics
()
metrics
{
...
...
@@ -52,12 +55,31 @@ func newMetrics() metrics {
Name
:
"credit_events_count"
,
Help
:
"Number of occurrences of BZZ credit events towards peers"
,
}),
AccountingDisconnectsCount
:
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
AccountingDisconnects
EnforceRefresh
Count
:
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Namespace
:
m
.
Namespace
,
Subsystem
:
subsystem
,
Name
:
"accounting_disconnects_count"
,
Name
:
"disconnects_enforce_refresh_count"
,
Help
:
"Number of occurrences of peers disconnected based on failed refreshment attempts"
,
}),
AccountingDisconnectsOverdrawCount
:
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Namespace
:
m
.
Namespace
,
Subsystem
:
subsystem
,
Name
:
"disconnects_overdraw_count"
,
Help
:
"Number of occurrences of peers disconnected based on payment thresholds"
,
}),
AccountingDisconnectsGhostOverdrawCount
:
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Namespace
:
m
.
Namespace
,
Subsystem
:
subsystem
,
Name
:
"disconnects_ghost_overdraw_count"
,
Help
:
"Number of occurrences of peers disconnected based on undebitable requests thresholds"
,
}),
AccountingDisconnectsReconnectCount
:
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Namespace
:
m
.
Namespace
,
Subsystem
:
subsystem
,
Name
:
"disconnects_reconnect_count"
,
Help
:
"Number of occurrences of peers disconnected based on early attempt to reconnect"
,
}),
AccountingBlocksCount
:
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Namespace
:
m
.
Namespace
,
Subsystem
:
subsystem
,
...
...
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