mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 17:33:47 +00:00
swarm: update metrics flags names. remove redundant Timer.
This commit is contained in:
parent
b7516e4540
commit
76dd62cb7f
3 changed files with 30 additions and 28 deletions
|
|
@ -38,7 +38,7 @@ func init() {
|
|||
//exp.Exp(DefaultRegistry)
|
||||
}
|
||||
|
||||
// NewResettingTimer create a new ResettingTimer, either a real one of a NOP stub depending
|
||||
// NewResettingTimer creates a new ResettingTimer, either a real one of a NOP stub depending
|
||||
// on the metrics flag.
|
||||
func NewResettingTimer(name string) metrics.ResettingTimer {
|
||||
if !Enabled {
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ var (
|
|||
getListCount = metrics.NewCounter("api.http.get.list.count")
|
||||
getListFail = metrics.NewCounter("api.http.get.list.fail")
|
||||
requestCount = metrics.NewCounter("http.request.count")
|
||||
requestTimer = metrics.NewTimer("http.request.time")
|
||||
requestTimer = metrics.NewResettingTimer("http.request.time")
|
||||
)
|
||||
|
||||
// ServerConfig is the basic configuration needed for the HTTP server and also
|
||||
|
|
@ -644,9 +644,7 @@ func (s *Server) HandleGetFile(w http.ResponseWriter, r *Request) {
|
|||
|
||||
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
requestCount.Inc(1)
|
||||
startTime := time.Now()
|
||||
defer requestTimer.UpdateSince(startTime)
|
||||
defer metrics.NewResettingTimer("http.request.time_resetting").UpdateSince(startTime)
|
||||
defer requestTimer.UpdateSince(time.Now())
|
||||
s.logDebug("HTTP %s request URL: '%s', Host: '%s', Path: '%s', Referer: '%s', Accept: '%s'", r.Method, r.RequestURI, r.URL.Host, r.URL.Path, r.Referer(), r.Header.Get("Accept"))
|
||||
|
||||
uri, err := api.Parse(strings.TrimLeft(r.URL.Path, "/"))
|
||||
|
|
|
|||
|
|
@ -28,29 +28,33 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
metricsEndpointFlag = cli.StringFlag{
|
||||
Name: "metricsendpoint",
|
||||
Usage: "metrics backend endpoint",
|
||||
metricsInfluxDBEndpointFlag = cli.StringFlag{
|
||||
Name: "metrics.influxdb.endpoint",
|
||||
Usage: "Metrics InfluxDB endpoint",
|
||||
Value: "http://127.0.0.1:8086",
|
||||
}
|
||||
metricsDatabaseFlag = cli.StringFlag{
|
||||
Name: "metricsdatabase",
|
||||
Usage: "metrics backend database",
|
||||
metricsInfluxDBDatabaseFlag = cli.StringFlag{
|
||||
Name: "metrics.influxdb.database",
|
||||
Usage: "metrics InfluxDB database",
|
||||
Value: "metrics",
|
||||
}
|
||||
metricsUsernameFlag = cli.StringFlag{
|
||||
Name: "metricsusername",
|
||||
Usage: "metrics backend username",
|
||||
Value: "admin",
|
||||
metricsInfluxDBUsernameFlag = cli.StringFlag{
|
||||
Name: "metrics.influxdb.username",
|
||||
Usage: "metrics InfluxDB username",
|
||||
Value: "",
|
||||
}
|
||||
metricsPasswordFlag = cli.StringFlag{
|
||||
Name: "metricspassword",
|
||||
Usage: "metrics backend password",
|
||||
Value: "admin",
|
||||
metricsInfluxDBPasswordFlag = cli.StringFlag{
|
||||
Name: "metrics.influxdb.password",
|
||||
Usage: "metrics InfluxDB password",
|
||||
Value: "",
|
||||
}
|
||||
metricsHostTagFlag = cli.StringFlag{
|
||||
Name: "metricshosttag",
|
||||
Usage: "metrics host tag",
|
||||
// The `host` tag is part of every measurement sent to InfluxDB. Queries on tags are faster in InfluxDB.
|
||||
// It is used so that we can group all nodes and average a measurement across all of them, but also so
|
||||
// that we can select a specific node and inspect its measurements.
|
||||
// https://docs.influxdata.com/influxdb/v1.4/concepts/key_concepts/#tag-key
|
||||
metricsInfluxDBHostTagFlag = cli.StringFlag{
|
||||
Name: "metrics.influxdb.host.tag",
|
||||
Usage: "metrics InfluxDB `host` tag attached to all measurements",
|
||||
Value: "localhost",
|
||||
}
|
||||
)
|
||||
|
|
@ -58,17 +62,17 @@ var (
|
|||
// Flags holds all command-line flags required for metrics collection.
|
||||
var Flags = []cli.Flag{
|
||||
utils.MetricsEnabledFlag,
|
||||
metricsEndpointFlag, metricsDatabaseFlag, metricsUsernameFlag, metricsPasswordFlag, metricsHostTagFlag,
|
||||
metricsInfluxDBEndpointFlag, metricsInfluxDBDatabaseFlag, metricsInfluxDBUsernameFlag, metricsInfluxDBPasswordFlag, metricsInfluxDBHostTagFlag,
|
||||
}
|
||||
|
||||
func Setup(ctx *cli.Context) {
|
||||
if gethmetrics.Enabled {
|
||||
var (
|
||||
endpoint = ctx.GlobalString(metricsEndpointFlag.Name)
|
||||
database = ctx.GlobalString(metricsDatabaseFlag.Name)
|
||||
username = ctx.GlobalString(metricsUsernameFlag.Name)
|
||||
password = ctx.GlobalString(metricsPasswordFlag.Name)
|
||||
hosttag = ctx.GlobalString(metricsHostTagFlag.Name)
|
||||
endpoint = ctx.GlobalString(metricsInfluxDBEndpointFlag.Name)
|
||||
database = ctx.GlobalString(metricsInfluxDBDatabaseFlag.Name)
|
||||
username = ctx.GlobalString(metricsInfluxDBUsernameFlag.Name)
|
||||
password = ctx.GlobalString(metricsInfluxDBPasswordFlag.Name)
|
||||
hosttag = ctx.GlobalString(metricsInfluxDBHostTagFlag.Name)
|
||||
)
|
||||
|
||||
log.Info("Enabling swarm metrics collection and export")
|
||||
|
|
|
|||
Loading…
Reference in a new issue