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
3f08a8c8
Unverified
Commit
3f08a8c8
authored
Mar 19, 2021
by
Ralph Pichler
Committed by
GitHub
Mar 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add metrics to track number of cheques (#1446)
parent
b90bd7cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
metrics.go
pkg/settlement/swap/metrics.go
+14
-0
swap.go
pkg/settlement/swap/swap.go
+2
-0
No files found.
pkg/settlement/swap/metrics.go
View file @
3f08a8c8
...
...
@@ -12,6 +12,8 @@ import (
type
metrics
struct
{
TotalReceived
prometheus
.
Counter
TotalSent
prometheus
.
Counter
ChequesReceived
prometheus
.
Counter
ChequesSent
prometheus
.
Counter
ChequesRejected
prometheus
.
Counter
AvailableBalance
prometheus
.
Gauge
}
...
...
@@ -32,6 +34,18 @@ func newMetrics() metrics {
Name
:
"total_sent"
,
Help
:
"Amount of tokens sent to peers (costs paid by the node)"
,
}),
ChequesReceived
:
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Namespace
:
m
.
Namespace
,
Subsystem
:
subsystem
,
Name
:
"cheques_received"
,
Help
:
"Number of cheques received from peers"
,
}),
ChequesSent
:
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Namespace
:
m
.
Namespace
,
Subsystem
:
subsystem
,
Name
:
"cheques_sent"
,
Help
:
"Number of cheques sent to peers"
,
}),
ChequesRejected
:
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Namespace
:
m
.
Namespace
,
Subsystem
:
subsystem
,
...
...
pkg/settlement/swap/swap.go
View file @
3f08a8c8
...
...
@@ -101,6 +101,7 @@ func (s *Service) ReceiveCheque(ctx context.Context, peer swarm.Address, cheque
}
s
.
metrics
.
TotalReceived
.
Add
(
float64
(
amount
.
Uint64
()))
s
.
metrics
.
ChequesReceived
.
Inc
()
return
s
.
notifyPaymentFunc
(
peer
,
amount
)
}
...
...
@@ -129,6 +130,7 @@ func (s *Service) Pay(ctx context.Context, peer swarm.Address, amount *big.Int)
s
.
metrics
.
AvailableBalance
.
Set
(
bal
)
amountFloat
,
_
:=
big
.
NewFloat
(
0
)
.
SetInt
(
amount
)
.
Float64
()
s
.
metrics
.
TotalSent
.
Add
(
amountFloat
)
s
.
metrics
.
ChequesSent
.
Inc
()
return
nil
}
...
...
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