mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
address PR comments
This commit is contained in:
parent
891f92b965
commit
24b6b95972
2 changed files with 10 additions and 14 deletions
|
|
@ -141,12 +141,8 @@ func main() {
|
|||
|
||||
sort.Sort(cli.FlagsByName(app.Flags))
|
||||
sort.Sort(cli.CommandsByName(app.Commands))
|
||||
app.Before = func(ctx *cli.Context) error {
|
||||
return nil
|
||||
}
|
||||
app.After = func(ctx *cli.Context) error {
|
||||
emitMetrics(ctx)
|
||||
return nil
|
||||
return emitMetrics(ctx)
|
||||
}
|
||||
|
||||
err := app.Run(os.Args)
|
||||
|
|
@ -157,7 +153,7 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
func emitMetrics(ctx *cli.Context) {
|
||||
func emitMetrics(ctx *cli.Context) error {
|
||||
if gethmetrics.Enabled {
|
||||
var (
|
||||
endpoint = ctx.GlobalString(swarmmetrics.MetricsInfluxDBEndpointFlag.Name)
|
||||
|
|
@ -166,8 +162,7 @@ func emitMetrics(ctx *cli.Context) {
|
|||
password = ctx.GlobalString(swarmmetrics.MetricsInfluxDBPasswordFlag.Name)
|
||||
hosttag = ctx.GlobalString(swarmmetrics.MetricsInfluxDBHostTagFlag.Name)
|
||||
)
|
||||
|
||||
influxdb.InfluxDBWithTagsOnce(gethmetrics.DefaultRegistry, endpoint, database, username, password, "swarm-smoke.", map[string]string{
|
||||
return influxdb.InfluxDBWithTagsOnce(gethmetrics.DefaultRegistry, endpoint, database, username, password, "swarm-smoke.", map[string]string{
|
||||
"host": hosttag,
|
||||
"version": gitCommit,
|
||||
"filesize": fmt.Sprintf("%v", filesize),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package influxdb
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
uurl "net/url"
|
||||
"time"
|
||||
|
|
@ -59,11 +60,10 @@ func InfluxDBWithTags(r metrics.Registry, d time.Duration, url, database, userna
|
|||
}
|
||||
|
||||
// InfluxDBWithTagsOnce runs once an InfluxDB reporter and post the given metrics.Registry with the specified tags
|
||||
func InfluxDBWithTagsOnce(r metrics.Registry, url, database, username, password, namespace string, tags map[string]string) {
|
||||
func InfluxDBWithTagsOnce(r metrics.Registry, url, database, username, password, namespace string, tags map[string]string) error {
|
||||
u, err := uurl.Parse(url)
|
||||
if err != nil {
|
||||
log.Warn("Unable to parse InfluxDB", "url", url, "err", err)
|
||||
return
|
||||
return errors.New(fmt.Sprintf("Unable to parse InfluxDB. url: %s, err: %v", url, err))
|
||||
}
|
||||
|
||||
rep := &reporter{
|
||||
|
|
@ -77,13 +77,14 @@ func InfluxDBWithTagsOnce(r metrics.Registry, url, database, username, password,
|
|||
cache: make(map[string]int64),
|
||||
}
|
||||
if err := rep.makeClient(); err != nil {
|
||||
log.Warn("Unable to make InfluxDB client", "err", err)
|
||||
return
|
||||
return errors.New(fmt.Sprintf("Unable to make InfluxDB client. err: %v", err))
|
||||
}
|
||||
|
||||
if err := rep.send(); err != nil {
|
||||
log.Warn("Unable to send to InfluxDB", "err", err)
|
||||
return errors.New(fmt.Sprintf("Unable to send to InfluxDB. err: %v", err))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *reporter) makeClient() (err error) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue