chore: ran v fmt for v 0.3.3 changes
parent
0df06647b3
commit
79079bbcd4
|
@ -10,7 +10,7 @@ pub:
|
|||
}
|
||||
|
||||
pub fn (m &Metric) str() string {
|
||||
return '$m.name $m.labels'
|
||||
return '${m.name} ${m.labels}'
|
||||
}
|
||||
|
||||
pub interface MetricsCollector {
|
||||
|
|
14
prometheus.v
14
prometheus.v
|
@ -27,10 +27,10 @@ fn join_two_array(arr [2]string) string {
|
|||
|
||||
pub fn (e &PrometheusExporter) serialize_metric(metric Metric) string {
|
||||
if metric.labels.len == 0 {
|
||||
return '$e.prefix$metric.name'
|
||||
return '${e.prefix}${metric.name}'
|
||||
}
|
||||
|
||||
return '$e.prefix$metric.name{${metric.labels.map(join_two_array(it)).join(',')}}'
|
||||
return '${e.prefix}${metric.name}{${metric.labels.map(join_two_array(it)).join(',')}}'
|
||||
}
|
||||
|
||||
pub fn (mut e PrometheusExporter) export_to_string() !string {
|
||||
|
@ -44,14 +44,14 @@ pub fn (mut e PrometheusExporter) export_to_string() !string {
|
|||
pub fn (mut e PrometheusExporter) export_to_writer(mut writer io.Writer) ! {
|
||||
for counter in e.collector.counters() {
|
||||
val := e.collector.counter_get(counter) or { return error("This can't happen.") }
|
||||
line := '${e.serialize_metric(counter)} $val\n'
|
||||
line := '${e.serialize_metric(counter)} ${val}\n'
|
||||
|
||||
writer.write(line.bytes())!
|
||||
}
|
||||
|
||||
for gauge in e.collector.gauges() {
|
||||
val := e.collector.gauge_get(gauge) or { return error("This can't happen.") }
|
||||
line := '${e.serialize_metric(gauge)} $val\n'
|
||||
line := '${e.serialize_metric(gauge)} ${val}\n'
|
||||
|
||||
writer.write(line.bytes())!
|
||||
}
|
||||
|
@ -63,13 +63,13 @@ pub fn (mut e PrometheusExporter) export_to_writer(mut writer io.Writer) ! {
|
|||
...hist
|
||||
name: '${hist.name}_count'
|
||||
}
|
||||
writer.write('${e.serialize_metric(m)} $hist_data.total_count\n'.bytes())!
|
||||
writer.write('${e.serialize_metric(m)} ${hist_data.total_count}\n'.bytes())!
|
||||
|
||||
m = Metric{
|
||||
...hist
|
||||
name: '${hist.name}_sum'
|
||||
}
|
||||
writer.write('${e.serialize_metric(m)} $hist_data.sum\n'.bytes())!
|
||||
writer.write('${e.serialize_metric(m)} ${hist_data.sum}\n'.bytes())!
|
||||
|
||||
mut le_labels := [][2]string{}
|
||||
le_labels.prepend(hist.labels)
|
||||
|
@ -95,7 +95,7 @@ pub fn (mut e PrometheusExporter) export_to_writer(mut writer io.Writer) ! {
|
|||
labels: le_labels
|
||||
}
|
||||
|
||||
writer.write('${e.serialize_metric(m)} $hist_data.total_count\n'.bytes())!
|
||||
writer.write('${e.serialize_metric(m)} ${hist_data.total_count}\n'.bytes())!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue