mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-16 18:00:46 +00:00
cmd/XDC, metrics/prometheus: fix staticcheck QF1012 (#1713)
This commit is contained in:
parent
8129ac77cd
commit
640d448491
2 changed files with 11 additions and 11 deletions
|
|
@ -167,7 +167,7 @@ func remoteConsole(ctx *cli.Context) error {
|
||||||
func ephemeralConsole(ctx *cli.Context) error {
|
func ephemeralConsole(ctx *cli.Context) error {
|
||||||
var b strings.Builder
|
var b strings.Builder
|
||||||
for _, file := range ctx.Args().Slice() {
|
for _, file := range ctx.Args().Slice() {
|
||||||
b.WriteString(fmt.Sprintf("loadScript('%s');", file))
|
fmt.Fprintf(&b, "loadScript('%s');", file)
|
||||||
}
|
}
|
||||||
utils.Fatalf(`The "js" command is deprecated. Please use the following instead:
|
utils.Fatalf(`The "js" command is deprecated. Please use the following instead:
|
||||||
XDC --exec "%s" console`, b.String())
|
XDC --exec "%s" console`, b.String())
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ func (c *collector) addHistogram(name string, m metrics.HistogramSnapshot) {
|
||||||
pv := []float64{0.5, 0.75, 0.95, 0.99, 0.999, 0.9999}
|
pv := []float64{0.5, 0.75, 0.95, 0.99, 0.999, 0.9999}
|
||||||
ps := m.Percentiles(pv)
|
ps := m.Percentiles(pv)
|
||||||
c.writeSummaryCounter(name, m.Count())
|
c.writeSummaryCounter(name, m.Count())
|
||||||
c.buff.WriteString(fmt.Sprintf(typeSummaryTpl, mutateKey(name)))
|
fmt.Fprintf(c.buff, typeSummaryTpl, mutateKey(name))
|
||||||
for i := range pv {
|
for i := range pv {
|
||||||
c.writeSummaryPercentile(name, strconv.FormatFloat(pv[i], 'f', -1, 64), ps[i])
|
c.writeSummaryPercentile(name, strconv.FormatFloat(pv[i], 'f', -1, 64), ps[i])
|
||||||
}
|
}
|
||||||
|
|
@ -114,7 +114,7 @@ func (c *collector) addTimer(name string, m *metrics.TimerSnapshot) {
|
||||||
pv := []float64{0.5, 0.75, 0.95, 0.99, 0.999, 0.9999}
|
pv := []float64{0.5, 0.75, 0.95, 0.99, 0.999, 0.9999}
|
||||||
ps := m.Percentiles(pv)
|
ps := m.Percentiles(pv)
|
||||||
c.writeSummaryCounter(name, m.Count())
|
c.writeSummaryCounter(name, m.Count())
|
||||||
c.buff.WriteString(fmt.Sprintf(typeSummaryTpl, mutateKey(name)))
|
fmt.Fprintf(c.buff, typeSummaryTpl, mutateKey(name))
|
||||||
for i := range pv {
|
for i := range pv {
|
||||||
c.writeSummaryPercentile(name, strconv.FormatFloat(pv[i], 'f', -1, 64), ps[i])
|
c.writeSummaryPercentile(name, strconv.FormatFloat(pv[i], 'f', -1, 64), ps[i])
|
||||||
}
|
}
|
||||||
|
|
@ -128,7 +128,7 @@ func (c *collector) addResettingTimer(name string, m *metrics.ResettingTimerSnap
|
||||||
pv := []float64{0.5, 0.75, 0.95, 0.99, 0.999, 0.9999}
|
pv := []float64{0.5, 0.75, 0.95, 0.99, 0.999, 0.9999}
|
||||||
ps := m.Percentiles(pv)
|
ps := m.Percentiles(pv)
|
||||||
c.writeSummaryCounter(name, m.Count())
|
c.writeSummaryCounter(name, m.Count())
|
||||||
c.buff.WriteString(fmt.Sprintf(typeSummaryTpl, mutateKey(name)))
|
fmt.Fprintf(c.buff, typeSummaryTpl, mutateKey(name))
|
||||||
for i := range pv {
|
for i := range pv {
|
||||||
c.writeSummaryPercentile(name, strconv.FormatFloat(pv[i], 'f', -1, 64), ps[i])
|
c.writeSummaryPercentile(name, strconv.FormatFloat(pv[i], 'f', -1, 64), ps[i])
|
||||||
}
|
}
|
||||||
|
|
@ -137,7 +137,7 @@ func (c *collector) addResettingTimer(name string, m *metrics.ResettingTimerSnap
|
||||||
|
|
||||||
func (c *collector) writeGaugeInfo(name string, value metrics.GaugeInfoValue) {
|
func (c *collector) writeGaugeInfo(name string, value metrics.GaugeInfoValue) {
|
||||||
name = mutateKey(name)
|
name = mutateKey(name)
|
||||||
c.buff.WriteString(fmt.Sprintf(typeGaugeTpl, name))
|
fmt.Fprintf(c.buff, typeGaugeTpl, name)
|
||||||
c.buff.WriteString(name)
|
c.buff.WriteString(name)
|
||||||
c.buff.WriteString(" ")
|
c.buff.WriteString(" ")
|
||||||
kvs := make([]string, 0, len(value))
|
kvs := make([]string, 0, len(value))
|
||||||
|
|
@ -145,24 +145,24 @@ func (c *collector) writeGaugeInfo(name string, value metrics.GaugeInfoValue) {
|
||||||
kvs = append(kvs, fmt.Sprintf("%v=%q", k, v))
|
kvs = append(kvs, fmt.Sprintf("%v=%q", k, v))
|
||||||
}
|
}
|
||||||
slices.Sort(kvs)
|
slices.Sort(kvs)
|
||||||
c.buff.WriteString(fmt.Sprintf("{%v} 1\n\n", strings.Join(kvs, ", ")))
|
fmt.Fprintf(c.buff, "{%v} 1\n\n", strings.Join(kvs, ", "))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *collector) writeGaugeCounter(name string, value interface{}) {
|
func (c *collector) writeGaugeCounter(name string, value interface{}) {
|
||||||
name = mutateKey(name)
|
name = mutateKey(name)
|
||||||
c.buff.WriteString(fmt.Sprintf(typeGaugeTpl, name))
|
fmt.Fprintf(c.buff, typeGaugeTpl, name)
|
||||||
c.buff.WriteString(fmt.Sprintf(keyValueTpl, name, value))
|
fmt.Fprintf(c.buff, keyValueTpl, name, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *collector) writeSummaryCounter(name string, value interface{}) {
|
func (c *collector) writeSummaryCounter(name string, value interface{}) {
|
||||||
name = mutateKey(name + "_count")
|
name = mutateKey(name + "_count")
|
||||||
c.buff.WriteString(fmt.Sprintf(typeCounterTpl, name))
|
fmt.Fprintf(c.buff, typeCounterTpl, name)
|
||||||
c.buff.WriteString(fmt.Sprintf(keyValueTpl, name, value))
|
fmt.Fprintf(c.buff, keyValueTpl, name, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *collector) writeSummaryPercentile(name, p string, value interface{}) {
|
func (c *collector) writeSummaryPercentile(name, p string, value interface{}) {
|
||||||
name = mutateKey(name)
|
name = mutateKey(name)
|
||||||
c.buff.WriteString(fmt.Sprintf(keyQuantileTagValueTpl, name, p, value))
|
fmt.Fprintf(c.buff, keyQuantileTagValueTpl, name, p, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func mutateKey(key string) string {
|
func mutateKey(key string) string {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue