Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/XDC/consolecmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func remoteConsole(ctx *cli.Context) error {
func ephemeralConsole(ctx *cli.Context) error {
var b strings.Builder
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:
XDC --exec "%s" console`, b.String())
Expand Down
20 changes: 10 additions & 10 deletions metrics/prometheus/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
ps := m.Percentiles(pv)
c.writeSummaryCounter(name, m.Count())
c.buff.WriteString(fmt.Sprintf(typeSummaryTpl, mutateKey(name)))
fmt.Fprintf(c.buff, typeSummaryTpl, mutateKey(name))
for i := range pv {
c.writeSummaryPercentile(name, strconv.FormatFloat(pv[i], 'f', -1, 64), ps[i])
}
Expand All @@ -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}
ps := m.Percentiles(pv)
c.writeSummaryCounter(name, m.Count())
c.buff.WriteString(fmt.Sprintf(typeSummaryTpl, mutateKey(name)))
fmt.Fprintf(c.buff, typeSummaryTpl, mutateKey(name))
for i := range pv {
c.writeSummaryPercentile(name, strconv.FormatFloat(pv[i], 'f', -1, 64), ps[i])
}
Expand All @@ -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}
ps := m.Percentiles(pv)
c.writeSummaryCounter(name, m.Count())
c.buff.WriteString(fmt.Sprintf(typeSummaryTpl, mutateKey(name)))
fmt.Fprintf(c.buff, typeSummaryTpl, mutateKey(name))
for i := range pv {
c.writeSummaryPercentile(name, strconv.FormatFloat(pv[i], 'f', -1, 64), ps[i])
}
Expand All @@ -137,32 +137,32 @@ func (c *collector) addResettingTimer(name string, m *metrics.ResettingTimerSnap

func (c *collector) writeGaugeInfo(name string, value metrics.GaugeInfoValue) {
name = mutateKey(name)
c.buff.WriteString(fmt.Sprintf(typeGaugeTpl, name))
fmt.Fprintf(c.buff, typeGaugeTpl, name)
c.buff.WriteString(name)
c.buff.WriteString(" ")
var kvs []string
for k, v := range value {
kvs = append(kvs, fmt.Sprintf("%v=%q", k, v))
}
sort.Strings(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{}) {
name = mutateKey(name)
c.buff.WriteString(fmt.Sprintf(typeGaugeTpl, name))
c.buff.WriteString(fmt.Sprintf(keyValueTpl, name, value))
fmt.Fprintf(c.buff, typeGaugeTpl, name)
fmt.Fprintf(c.buff, keyValueTpl, name, value)
}

func (c *collector) writeSummaryCounter(name string, value interface{}) {
name = mutateKey(name + "_count")
c.buff.WriteString(fmt.Sprintf(typeCounterTpl, name))
c.buff.WriteString(fmt.Sprintf(keyValueTpl, name, value))
fmt.Fprintf(c.buff, typeCounterTpl, name)
fmt.Fprintf(c.buff, keyValueTpl, name, value)
}

func (c *collector) writeSummaryPercentile(name, p string, value interface{}) {
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 {
Expand Down