@Test public void shouldBuildGaugeWithLabels() { String metricName = "metric_name"; String help = "help"; List<String> labelNames = Arrays.asList("label_name_1", "label_name_2"); List<List<String>> labelValues = Arrays.asList( Arrays.asList("label_value_a1", "label_value_a2"), Arrays.asList("label_value_b1", "label_value_b2") ); List<Double> values = Arrays.asList(1d, 2d); Gauge gauge = GaugesCreation.buildGaugeWithLabels(metricName, help, labelNames, labelValues, values); assertForGauge(gauge, metricName, help, labelNames, labelValues, values); }
public static Gauge buildGaugeWithLabels(String metricName, String help, List<String> labelNames, List<List<String>> labelValues, List<Double> values) { Gauge gauge = Gauge.build() .name(metricName) .help(help) .labelNames(labelNames.toArray(new String[0])) .create(); ListUtils.zip(labelValues, values).forEach(labelValuesAndValue -> gauge.labels(labelValuesAndValue.getLeft().toArray(new String[0])).set(labelValuesAndValue.getRight()) ); return gauge; }
GaugesCreation { public static Gauge buildGaugeWithLabels(String metricName, String help, List<String> labelNames, List<List<String>> labelValues, List<Double> values) { Gauge gauge = Gauge.build() .name(metricName) .help(help) .labelNames(labelNames.toArray(new String[0])) .create(); ListUtils.zip(labelValues, values).forEach(labelValuesAndValue -> gauge.labels(labelValuesAndValue.getLeft().toArray(new String[0])).set(labelValuesAndValue.getRight()) ); return gauge; } }
GaugesCreation { public static Gauge buildGaugeWithLabels(String metricName, String help, List<String> labelNames, List<List<String>> labelValues, List<Double> values) { Gauge gauge = Gauge.build() .name(metricName) .help(help) .labelNames(labelNames.toArray(new String[0])) .create(); ListUtils.zip(labelValues, values).forEach(labelValuesAndValue -> gauge.labels(labelValuesAndValue.getLeft().toArray(new String[0])).set(labelValuesAndValue.getRight()) ); return gauge; } private  GaugesCreation(); }
GaugesCreation { public static Gauge buildGaugeWithLabels(String metricName, String help, List<String> labelNames, List<List<String>> labelValues, List<Double> values) { Gauge gauge = Gauge.build() .name(metricName) .help(help) .labelNames(labelNames.toArray(new String[0])) .create(); ListUtils.zip(labelValues, values).forEach(labelValuesAndValue -> gauge.labels(labelValuesAndValue.getLeft().toArray(new String[0])).set(labelValuesAndValue.getRight()) ); return gauge; } private  GaugesCreation(); static Gauge buildGaugeWithLabels(String metricName,
                                             String help,
                                             List<String> labelNames,
                                             List<List<String>> labelValues,
                                             List<Double> values); static Gauge buildGaugeWithoutLabels(String metricName,
                                                String help,
                                                double value); }
GaugesCreation { public static Gauge buildGaugeWithLabels(String metricName, String help, List<String> labelNames, List<List<String>> labelValues, List<Double> values) { Gauge gauge = Gauge.build() .name(metricName) .help(help) .labelNames(labelNames.toArray(new String[0])) .create(); ListUtils.zip(labelValues, values).forEach(labelValuesAndValue -> gauge.labels(labelValuesAndValue.getLeft().toArray(new String[0])).set(labelValuesAndValue.getRight()) ); return gauge; } private  GaugesCreation(); static Gauge buildGaugeWithLabels(String metricName,
                                             String help,
                                             List<String> labelNames,
                                             List<List<String>> labelValues,
                                             List<Double> values); static Gauge buildGaugeWithoutLabels(String metricName,
                                                String help,
                                                double value);  }