@Test(expected = RuntimeException.class) public void convertShouldThrowOnLabelValueExtractionError() { ReportEntry counterReportEntryWithoutLabel = mock(ReportEntry.class); when(counterReportEntryWithoutLabel.getType()).thenReturn(ReportEntryType.COUNTER); List<ReportEntry> reportEntries = Collections.singletonList(counterReportEntryWithoutLabel); Map<String, LabeledMetricConf> labeledMetricConfByPattern = Collections.singletonMap("key", mock(LabeledMetricConf.class)); ExtractedMetric extractedMetricWithoutLabel = mock(ExtractedMetric.class); when(extractedMetricWithoutLabel.getMetricName()).thenReturn("metric_name_without_labels"); when(extractedMetricWithoutLabel.getLabelValues()).thenReturn(Collections.emptyList()); when(extractedMetricWithoutLabel.getValue()).thenReturn(null); CounterReportEntryMetricExtraction.Extractor counterMetricExtractor = mock(CounterReportEntryMetricExtraction.Extractor.class); when(counterMetricExtractor.extract(counterReportEntryWithoutLabel, labeledMetricConfByPattern)).thenReturn(extractedMetricWithoutLabel); ReportEntryToMetricConverter.convert(reportEntries, "path", labeledMetricConfByPattern, counterMetricExtractor, mock(DurationReportEntryMetricExtraction.Extractor.class), mock(GaugesCreation.BuilderWithoutLabels.class), mock(GaugesCreation.BuilderWithLabels.class) ); }
public static List<Gauge> convert(List<ReportEntry> reportEntries, String path, Map<String, LabeledMetricConf> labeledMetricConfByPattern) { return convert(reportEntries, path, labeledMetricConfByPattern, CounterReportEntryMetricExtraction::extractMetricFromReportEntry, DurationReportEntryMetricExtraction::extractMetricFromReportEntry, GaugesCreation::buildGaugeWithoutLabels, GaugesCreation::buildGaugeWithLabels); }
ReportEntryToMetricConverter { public static List<Gauge> convert(List<ReportEntry> reportEntries, String path, Map<String, LabeledMetricConf> labeledMetricConfByPattern) { return convert(reportEntries, path, labeledMetricConfByPattern, CounterReportEntryMetricExtraction::extractMetricFromReportEntry, DurationReportEntryMetricExtraction::extractMetricFromReportEntry, GaugesCreation::buildGaugeWithoutLabels, GaugesCreation::buildGaugeWithLabels); } }
ReportEntryToMetricConverter { public static List<Gauge> convert(List<ReportEntry> reportEntries, String path, Map<String, LabeledMetricConf> labeledMetricConfByPattern) { return convert(reportEntries, path, labeledMetricConfByPattern, CounterReportEntryMetricExtraction::extractMetricFromReportEntry, DurationReportEntryMetricExtraction::extractMetricFromReportEntry, GaugesCreation::buildGaugeWithoutLabels, GaugesCreation::buildGaugeWithLabels); }  }
ReportEntryToMetricConverter { public static List<Gauge> convert(List<ReportEntry> reportEntries, String path, Map<String, LabeledMetricConf> labeledMetricConfByPattern) { return convert(reportEntries, path, labeledMetricConfByPattern, CounterReportEntryMetricExtraction::extractMetricFromReportEntry, DurationReportEntryMetricExtraction::extractMetricFromReportEntry, GaugesCreation::buildGaugeWithoutLabels, GaugesCreation::buildGaugeWithLabels); }  static List<Gauge> convert(List<ReportEntry> reportEntries,
                                      String path,
                                      Map<String, LabeledMetricConf> labeledMetricConfByPattern); static List<Gauge> convert(List<ReportEntry> reportEntries,
                                      String path,
                                      Map<String, LabeledMetricConf> labeledMetricConfByPattern,
                                      CounterReportEntryMetricExtraction.Extractor counterReportEntryMetricExtractor,
                                      DurationReportEntryMetricExtraction.Extractor durationReportEntryMetricExtractor,
                                      GaugesCreation.BuilderWithoutLabels gaugesBuilderWithoutLabels,
                                      GaugesCreation.BuilderWithLabels gaugesBuilderWithLabelsBuilder); static X uniqueElementOrThrow(List<E> list, Function<E, X> mapper); }
ReportEntryToMetricConverter { public static List<Gauge> convert(List<ReportEntry> reportEntries, String path, Map<String, LabeledMetricConf> labeledMetricConfByPattern) { return convert(reportEntries, path, labeledMetricConfByPattern, CounterReportEntryMetricExtraction::extractMetricFromReportEntry, DurationReportEntryMetricExtraction::extractMetricFromReportEntry, GaugesCreation::buildGaugeWithoutLabels, GaugesCreation::buildGaugeWithLabels); }  static List<Gauge> convert(List<ReportEntry> reportEntries,
                                      String path,
                                      Map<String, LabeledMetricConf> labeledMetricConfByPattern); static List<Gauge> convert(List<ReportEntry> reportEntries,
                                      String path,
                                      Map<String, LabeledMetricConf> labeledMetricConfByPattern,
                                      CounterReportEntryMetricExtraction.Extractor counterReportEntryMetricExtractor,
                                      DurationReportEntryMetricExtraction.Extractor durationReportEntryMetricExtractor,
                                      GaugesCreation.BuilderWithoutLabels gaugesBuilderWithoutLabels,
                                      GaugesCreation.BuilderWithLabels gaugesBuilderWithLabelsBuilder); static X uniqueElementOrThrow(List<E> list, Function<E, X> mapper); static final String REPORT_ENTRY_KEY_SEP; static final String METRIC_NAME_SEP; static final String LABEL_PATTERN_VALUE_TOKEN; static final String DURATION_METRIC_NAME_SUFFIX; }