@@ -16,38 +16,37 @@ public class PrometheusMetricsCatalog {
16
16
private HashMap metrics ;
17
17
private CollectorRegistry registry ;
18
18
19
- public PrometheusMetricsCatalog (String cluster , String metric_prefix ){
19
+ public PrometheusMetricsCatalog (String cluster , String metric_prefix ) {
20
20
this .cluster = cluster ;
21
21
this .metric_prefix = metric_prefix ;
22
22
this .metrics = new HashMap ();
23
23
this .registry = new CollectorRegistry ();
24
24
}
25
25
26
- public void registerGauge (String metric , String help , String ... labels ){
27
- String [] extended_labels = new String [labels .length +1 ];
28
- extended_labels [0 ]= "cluster" ;
26
+ public void registerGauge (String metric , String help , String ... labels ) {
27
+ String [] extended_labels = new String [labels .length + 1 ];
28
+ extended_labels [0 ] = "cluster" ;
29
29
for (int i = 0 ; i < labels .length ; i ++) extended_labels [i + 1 ] = labels [i ];
30
30
31
- Gauge gauge = Gauge .build ().name (this .metric_prefix + metric ).help (help ).labelNames (extended_labels ).register (this .registry );
32
- this .metrics .put (metric ,gauge );
31
+ Gauge gauge = Gauge .build ().name (this .metric_prefix + metric ).help (help ).labelNames (extended_labels ).register (this .registry );
32
+ this .metrics .put (metric , gauge );
33
33
}
34
34
35
- public void setGauge (String metric , double value , String ... label_values ){
36
- String [] extended_label_values = new String [label_values .length +1 ];
37
- extended_label_values [0 ]= this .cluster ;
35
+ public void setGauge (String metric , double value , String ... label_values ) {
36
+ String [] extended_label_values = new String [label_values .length + 1 ];
37
+ extended_label_values [0 ] = this .cluster ;
38
38
for (int i = 0 ; i < label_values .length ; i ++) extended_label_values [i + 1 ] = label_values [i ];
39
39
40
40
Gauge gauge = (Gauge ) this .metrics .get (metric );
41
41
gauge .labels (extended_label_values ).set (value );
42
42
}
43
43
44
- public String toTextFormat () throws IOException {
45
- try {
44
+ public String toTextFormat () throws IOException {
45
+ try {
46
46
Writer writer = new StringWriter ();
47
47
TextFormat .write004 (writer , this .registry .metricFamilySamples ());
48
48
return writer .toString ();
49
- }
50
- catch (IOException e ){
49
+ } catch (IOException e ) {
51
50
throw e ;
52
51
}
53
52
}
0 commit comments