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
bde2ff03
Commit
bde2ff03
authored
Jun 23, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/geth, rpc/api: move the metrics into the new console
parent
803b3c4a
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
1003 deletions
+69
-1003
admin.go
cmd/geth/admin.go
+0
-1003
debug.go
rpc/api/debug.go
+64
-0
debug_js.go
rpc/api/debug_js.go
+5
-0
No files found.
cmd/geth/admin.go
deleted
100644 → 0
View file @
803b3c4a
This diff is collapsed.
Click to expand it.
rpc/api/debug.go
View file @
bde2ff03
...
@@ -2,6 +2,8 @@ package api
...
@@ -2,6 +2,8 @@ package api
import
(
import
(
"fmt"
"fmt"
"strings"
"time"
"github.com/ethereum/ethash"
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/state"
...
@@ -11,6 +13,7 @@ import (
...
@@ -11,6 +13,7 @@ import (
"github.com/ethereum/go-ethereum/rpc/codec"
"github.com/ethereum/go-ethereum/rpc/codec"
"github.com/ethereum/go-ethereum/rpc/shared"
"github.com/ethereum/go-ethereum/rpc/shared"
"github.com/ethereum/go-ethereum/xeth"
"github.com/ethereum/go-ethereum/xeth"
"github.com/rcrowley/go-metrics"
)
)
const
(
const
(
...
@@ -26,6 +29,7 @@ var (
...
@@ -26,6 +29,7 @@ var (
"debug_processBlock"
:
(
*
debugApi
)
.
ProcessBlock
,
"debug_processBlock"
:
(
*
debugApi
)
.
ProcessBlock
,
"debug_seedHash"
:
(
*
debugApi
)
.
SeedHash
,
"debug_seedHash"
:
(
*
debugApi
)
.
SeedHash
,
"debug_setHead"
:
(
*
debugApi
)
.
SetHead
,
"debug_setHead"
:
(
*
debugApi
)
.
SetHead
,
"debug_metrics"
:
(
*
debugApi
)
.
Metrics
,
}
}
)
)
...
@@ -171,3 +175,63 @@ func (self *debugApi) SeedHash(req *shared.Request) (interface{}, error) {
...
@@ -171,3 +175,63 @@ func (self *debugApi) SeedHash(req *shared.Request) (interface{}, error) {
return
nil
,
err
return
nil
,
err
}
}
}
}
func
(
self
*
debugApi
)
Metrics
(
req
*
shared
.
Request
)
(
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
switch
metric
:=
metric
.
(
type
)
{
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
()),
"Total"
:
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
()),
"Count"
:
format
(
float64
(
metric
.
Count
()),
metric
.
RateMean
()),
"Maximum"
:
time
.
Duration
(
metric
.
Max
())
.
String
(),
"Minimum"
:
time
.
Duration
(
metric
.
Min
())
.
String
(),
"Percentile"
:
map
[
string
]
interface
{}{
"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
(),
"99"
:
time
.
Duration
(
metric
.
Percentile
(
0.99
))
.
String
(),
},
}
default
:
root
[
name
]
=
"Unknown metric type"
}
})
return
counters
,
nil
}
rpc/api/debug_js.go
View file @
bde2ff03
...
@@ -50,6 +50,11 @@ web3._extend({
...
@@ -50,6 +50,11 @@ web3._extend({
],
],
properties:
properties:
[
[
new web3._extend.Property({
name: 'metrics',
getter: 'debug_metrics',
outputFormatter: function(obj) { return obj; }
})
]
]
});
});
`
`
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