-
Notifications
You must be signed in to change notification settings - Fork 21.1k
rpc: add metrics for generic json rpc #20847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2020 The go-ethereum Authors | ||
// This file is part of the go-ethereum library. | ||
// | ||
// The go-ethereum library is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// The go-ethereum library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
package rpc | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/ethereum/go-ethereum/metrics" | ||
) | ||
|
||
var ( | ||
jsonrpcRequestGauge = metrics.NewRegisteredGauge("rpc/jsonrpc/count/in", nil) | ||
successfulRequestGauge = metrics.NewRegisteredGauge("rpc/jsonrpc/count/success", nil) | ||
failedReqeustGauge = metrics.NewRegisteredGauge("rpc/jsonrpc/count/failure", nil) | ||
rjl493456442 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
jsonrpcServingTimer = metrics.NewRegisteredTimer("rpc/jsonrpc/duration/all", nil) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any particular reason for adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the rpc can have severval protocols to support e.g. graphql There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, wouldn't those be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
) | ||
|
||
func newJsonrpcServingTimer(method string, valid bool) metrics.Timer { | ||
flag := "success" | ||
if !valid { | ||
flag = "failure" | ||
} | ||
m := fmt.Sprintf("rpc/jsonrpc/duration/%s/%s", method, flag) | ||
return metrics.GetOrRegisterTimer(m, nil) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like you filter out
unsubscribe
, but notsubscribe
. Is that intended?Otherwise, you can define a flag
noMetering
and set totrue
in the checks above regarding subscriptions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
subscribe
is handled byhandleSubscribe
.