diff options
author | Péter Szilágyi <peterke@gmail.com> | 2019-04-05 17:04:15 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2019-04-05 17:13:56 +0800 |
commit | 29bc982d75d498e902b901caaac1a82a205a6cb1 (patch) | |
tree | 37c4087c89f2d896f6556ac1d008fcd0b22e2aad /node/api.go | |
parent | 36f81118f6d00713dbf8d1caf168ad937e0f1a90 (diff) | |
download | go-tangerine-29bc982d75d498e902b901caaac1a82a205a6cb1.tar go-tangerine-29bc982d75d498e902b901caaac1a82a205a6cb1.tar.gz go-tangerine-29bc982d75d498e902b901caaac1a82a205a6cb1.tar.bz2 go-tangerine-29bc982d75d498e902b901caaac1a82a205a6cb1.tar.lz go-tangerine-29bc982d75d498e902b901caaac1a82a205a6cb1.tar.xz go-tangerine-29bc982d75d498e902b901caaac1a82a205a6cb1.tar.zst go-tangerine-29bc982d75d498e902b901caaac1a82a205a6cb1.zip |
cmd/geth, internal, node, vendor: nuke geth monitor
Diffstat (limited to 'node/api.go')
-rw-r--r-- | node/api.go | 147 |
1 files changed, 0 insertions, 147 deletions
diff --git a/node/api.go b/node/api.go index 6e36e505d..cc80efabe 100644 --- a/node/api.go +++ b/node/api.go @@ -20,11 +20,9 @@ import ( "context" "fmt" "strings" - "time" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p/enode" "github.com/ethereum/go-ethereum/rpc" @@ -297,151 +295,6 @@ func (api *PublicAdminAPI) Datadir() string { return api.node.DataDir() } -// PublicDebugAPI is the collection of debugging related API methods exposed over -// both secure and unsecure RPC channels. -type PublicDebugAPI struct { - node *Node // Node interfaced by this API -} - -// NewPublicDebugAPI creates a new API definition for the public debug methods -// of the node itself. -func NewPublicDebugAPI(node *Node) *PublicDebugAPI { - return &PublicDebugAPI{node: node} -} - -// Metrics retrieves all the known system metric collected by the node. -func (api *PublicDebugAPI) Metrics(raw bool) (map[string]interface{}, error) { - // Create a rate formatter - units := []string{"", "K", "M", "G", "T", "E", "P"} - round := func(value float64, prec int) string { - unit := 0 - for value >= 1000 { - unit, value, prec = unit+1, value/1000, 2 - } - return fmt.Sprintf(fmt.Sprintf("%%.%df%s", prec, units[unit]), value) - } - format := func(total float64, rate float64) string { - return fmt.Sprintf("%s (%s/s)", round(total, 0), round(rate, 2)) - } - // Iterate over all the metrics, and just dump for now - counters := make(map[string]interface{}) - metrics.DefaultRegistry.Each(func(name string, metric interface{}) { - // Create or retrieve the counter hierarchy for this metric - root, parts := counters, strings.Split(name, "/") - for _, part := range parts[:len(parts)-1] { - if _, ok := root[part]; !ok { - root[part] = make(map[string]interface{}) - } - root = root[part].(map[string]interface{}) - } - name = parts[len(parts)-1] - - // Fill the counter with the metric details, formatting if requested - if raw { - switch metric := metric.(type) { - case metrics.Counter: - root[name] = map[string]interface{}{ - "Overall": float64(metric.Count()), - } - - case metrics.Meter: - root[name] = map[string]interface{}{ - "AvgRate01Min": metric.Rate1(), - "AvgRate05Min": metric.Rate5(), - "AvgRate15Min": metric.Rate15(), - "MeanRate": metric.RateMean(), - "Overall": float64(metric.Count()), - } - - case metrics.Timer: - root[name] = map[string]interface{}{ - "AvgRate01Min": metric.Rate1(), - "AvgRate05Min": metric.Rate5(), - "AvgRate15Min": metric.Rate15(), - "MeanRate": metric.RateMean(), - "Overall": float64(metric.Count()), - "Percentiles": map[string]interface{}{ - "5": metric.Percentile(0.05), - "20": metric.Percentile(0.2), - "50": metric.Percentile(0.5), - "80": metric.Percentile(0.8), - "95": metric.Percentile(0.95), - }, - } - - case metrics.ResettingTimer: - t := metric.Snapshot() - ps := t.Percentiles([]float64{5, 20, 50, 80, 95}) - root[name] = map[string]interface{}{ - "Measurements": len(t.Values()), - "Mean": t.Mean(), - "Percentiles": map[string]interface{}{ - "5": ps[0], - "20": ps[1], - "50": ps[2], - "80": ps[3], - "95": ps[4], - }, - } - - default: - root[name] = "Unknown metric type" - } - } else { - switch metric := metric.(type) { - case metrics.Counter: - root[name] = map[string]interface{}{ - "Overall": float64(metric.Count()), - } - - case metrics.Meter: - root[name] = map[string]interface{}{ - "Avg01Min": format(metric.Rate1()*60, metric.Rate1()), - "Avg05Min": format(metric.Rate5()*300, metric.Rate5()), - "Avg15Min": format(metric.Rate15()*900, metric.Rate15()), - "Overall": format(float64(metric.Count()), metric.RateMean()), - } - - case metrics.Timer: - root[name] = map[string]interface{}{ - "Avg01Min": format(metric.Rate1()*60, metric.Rate1()), - "Avg05Min": format(metric.Rate5()*300, metric.Rate5()), - "Avg15Min": format(metric.Rate15()*900, metric.Rate15()), - "Overall": format(float64(metric.Count()), metric.RateMean()), - "Maximum": time.Duration(metric.Max()).String(), - "Minimum": time.Duration(metric.Min()).String(), - "Percentiles": map[string]interface{}{ - "5": time.Duration(metric.Percentile(0.05)).String(), - "20": time.Duration(metric.Percentile(0.2)).String(), - "50": time.Duration(metric.Percentile(0.5)).String(), - "80": time.Duration(metric.Percentile(0.8)).String(), - "95": time.Duration(metric.Percentile(0.95)).String(), - }, - } - - case metrics.ResettingTimer: - t := metric.Snapshot() - ps := t.Percentiles([]float64{5, 20, 50, 80, 95}) - root[name] = map[string]interface{}{ - "Measurements": len(t.Values()), - "Mean": time.Duration(t.Mean()).String(), - "Percentiles": map[string]interface{}{ - "5": time.Duration(ps[0]).String(), - "20": time.Duration(ps[1]).String(), - "50": time.Duration(ps[2]).String(), - "80": time.Duration(ps[3]).String(), - "95": time.Duration(ps[4]).String(), - }, - } - - default: - root[name] = "Unknown metric type" - } - } - }) - return counters, nil -} - // PublicWeb3API offers helper utils type PublicWeb3API struct { stack *Node |