Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
张蕾
Geth-Modification
Commits
106a162b
Unverified
Commit
106a162b
authored
2 years ago
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rpc: swap out timer metrics to histograms
parent
138f0d74
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
8 deletions
+19
-8
handler.go
rpc/handler.go
+1
-1
metrics.go
rpc/metrics.go
+18
-7
No files found.
rpc/handler.go
View file @
106a162b
...
...
@@ -346,7 +346,7 @@ func (h *handler) handleCall(cp *callProc, msg *jsonrpcMessage) *jsonrpcMessage
successfulRequestGauge
.
Inc
(
1
)
}
rpcServingTimer
.
UpdateSince
(
start
)
newRPCServingTimer
(
msg
.
Method
,
answer
.
Error
==
nil
)
.
UpdateSince
(
start
)
updateServeTimeHistogram
(
msg
.
Method
,
answer
.
Error
==
nil
,
time
.
Since
(
start
)
)
}
return
answer
}
...
...
This diff is collapsed.
Click to expand it.
rpc/metrics.go
View file @
106a162b
...
...
@@ -18,6 +18,7 @@ package rpc
import
(
"fmt"
"time"
"github.com/ethereum/go-ethereum/metrics"
)
...
...
@@ -26,14 +27,24 @@ var (
rpcRequestGauge
=
metrics
.
NewRegisteredGauge
(
"rpc/requests"
,
nil
)
successfulRequestGauge
=
metrics
.
NewRegisteredGauge
(
"rpc/success"
,
nil
)
failedRequestGauge
=
metrics
.
NewRegisteredGauge
(
"rpc/failure"
,
nil
)
rpcServingTimer
=
metrics
.
NewRegisteredTimer
(
"rpc/duration/all"
,
nil
)
// serveTimeHistName is the prefix of the per-request serving time histograms.
serveTimeHistName
=
"rpc/duration"
rpcServingTimer
=
metrics
.
NewRegisteredTimer
(
"rpc/duration/all"
,
nil
)
)
func
newRPCServingTimer
(
method
string
,
valid
bool
)
metrics
.
Timer
{
flag
:=
"success"
if
!
valid
{
flag
=
"failure"
// updateServeTimeHistogram tracks the serving time of a remote RPC call.
func
updateServeTimeHistogram
(
method
string
,
success
bool
,
elapsed
time
.
Duration
)
{
note
:=
"success"
if
!
success
{
note
=
"failure"
}
h
:=
fmt
.
Sprintf
(
"%s/%s/%s"
,
serveTimeHistName
,
method
,
note
)
sampler
:=
func
()
metrics
.
Sample
{
return
metrics
.
ResettingSample
(
metrics
.
NewExpDecaySample
(
1028
,
0.015
),
)
}
m
:=
fmt
.
Sprintf
(
"rpc/duration/%s/%s"
,
method
,
flag
)
return
metrics
.
GetOrRegisterTimer
(
m
,
nil
)
metrics
.
GetOrRegisterHistogramLazy
(
h
,
nil
,
sampler
)
.
Update
(
elapsed
.
Microseconds
())
}
This diff is collapsed.
Click to expand it.
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