-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_template.txt
More file actions
36 lines (35 loc) · 1.22 KB
/
test_template.txt
File metadata and controls
36 lines (35 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use std::{env, thread, time};
fn main() {
let network = env::var("STATSHOUSE_NETWORK").unwrap_or_else(|_| "udp".to_string());
let mut t = if network == "tcp" {
statshouse::Transport::tcp("127.0.0.1:13337")
} else {
statshouse::Transport::udp("127.0.0.1:13337")
};
let mut i = 0;
while i<{{.NumberOfIterations}} {
{{- range $v := .Metrics }}
statshouse::MetricBuilder::new(b"{{ $v.Name }}")
{{- range $v := $v.Tags -}}
.tag(b"{{ index $v 0 }}",b"{{ index $v 1 }}")
{{- end -}}
{{- if eq $v.Kind 2 -}}
.write_uniques(&mut t, &[
{{- range $i, $v := $v.Uniques -}}
{{ if $i }},{{ end }}{{ $v }}
{{- end -}}
],{{ printf "%.1f" $v.Count }},{{ $v.Timestamp }});
{{- else if eq $v.Kind 1 -}}
.write_values(&mut t, &[
{{- range $i, $v := $v.Values -}}
{{ if $i }},{{ end }}{{ $v }}
{{- end -}}
],{{ printf "%.1f" $v.Count }},{{ $v.Timestamp }});
{{- else -}}
.write_count(&mut t, {{ printf "%.1f" $v.Count }},{{ $v.Timestamp }});
{{- end -}}
{{- end }}
i+=1;
thread::sleep(time::Duration::from_millis(100));
}
}