@Test public void test_WHEN_SuffixAndExtraLabels_THEN_ShouldReturnCorrectSample() { final DefaultSampleBuilder builder = new DefaultSampleBuilder(); final Collector.MetricFamilySamples.Sample result = builder.createSample("org.github.name", "suffix.test", Collections.singletonList("another"), Arrays.asList("label"), 1d); Assert.assertEquals( new Collector.MetricFamilySamples.Sample("org_github_namesuffix_test", Collections.singletonList("another"), Arrays.asList("label"), 1d), result); }
@Override public Collector.MetricFamilySamples.Sample createSample(final String dropwizardName, final String nameSuffix, final List<String> additionalLabelNames, final List<String> additionalLabelValues, final double value) { final String suffix = nameSuffix == null ? "" : nameSuffix; final List<String> labelNames = additionalLabelNames == null ? Collections.<String>emptyList() : additionalLabelNames; final List<String> labelValues = additionalLabelValues == null ? Collections.<String>emptyList() : additionalLabelValues; return new Collector.MetricFamilySamples.Sample( Collector.sanitizeMetricName(dropwizardName + suffix), new ArrayList<String>(labelNames), new ArrayList<String>(labelValues), value ); }
DefaultSampleBuilder implements SampleBuilder { @Override public Collector.MetricFamilySamples.Sample createSample(final String dropwizardName, final String nameSuffix, final List<String> additionalLabelNames, final List<String> additionalLabelValues, final double value) { final String suffix = nameSuffix == null ? "" : nameSuffix; final List<String> labelNames = additionalLabelNames == null ? Collections.<String>emptyList() : additionalLabelNames; final List<String> labelValues = additionalLabelValues == null ? Collections.<String>emptyList() : additionalLabelValues; return new Collector.MetricFamilySamples.Sample( Collector.sanitizeMetricName(dropwizardName + suffix), new ArrayList<String>(labelNames), new ArrayList<String>(labelValues), value ); } }
DefaultSampleBuilder implements SampleBuilder { @Override public Collector.MetricFamilySamples.Sample createSample(final String dropwizardName, final String nameSuffix, final List<String> additionalLabelNames, final List<String> additionalLabelValues, final double value) { final String suffix = nameSuffix == null ? "" : nameSuffix; final List<String> labelNames = additionalLabelNames == null ? Collections.<String>emptyList() : additionalLabelNames; final List<String> labelValues = additionalLabelValues == null ? Collections.<String>emptyList() : additionalLabelValues; return new Collector.MetricFamilySamples.Sample( Collector.sanitizeMetricName(dropwizardName + suffix), new ArrayList<String>(labelNames), new ArrayList<String>(labelValues), value ); }  }
DefaultSampleBuilder implements SampleBuilder { @Override public Collector.MetricFamilySamples.Sample createSample(final String dropwizardName, final String nameSuffix, final List<String> additionalLabelNames, final List<String> additionalLabelValues, final double value) { final String suffix = nameSuffix == null ? "" : nameSuffix; final List<String> labelNames = additionalLabelNames == null ? Collections.<String>emptyList() : additionalLabelNames; final List<String> labelValues = additionalLabelValues == null ? Collections.<String>emptyList() : additionalLabelValues; return new Collector.MetricFamilySamples.Sample( Collector.sanitizeMetricName(dropwizardName + suffix), new ArrayList<String>(labelNames), new ArrayList<String>(labelValues), value ); }  @Override Collector.MetricFamilySamples.Sample createSample(final String dropwizardName, final String nameSuffix, final List<String> additionalLabelNames, final List<String> additionalLabelValues, final double value); }
DefaultSampleBuilder implements SampleBuilder { @Override public Collector.MetricFamilySamples.Sample createSample(final String dropwizardName, final String nameSuffix, final List<String> additionalLabelNames, final List<String> additionalLabelValues, final double value) { final String suffix = nameSuffix == null ? "" : nameSuffix; final List<String> labelNames = additionalLabelNames == null ? Collections.<String>emptyList() : additionalLabelNames; final List<String> labelValues = additionalLabelValues == null ? Collections.<String>emptyList() : additionalLabelValues; return new Collector.MetricFamilySamples.Sample( Collector.sanitizeMetricName(dropwizardName + suffix), new ArrayList<String>(labelNames), new ArrayList<String>(labelValues), value ); }  @Override Collector.MetricFamilySamples.Sample createSample(final String dropwizardName, final String nameSuffix, final List<String> additionalLabelNames, final List<String> additionalLabelValues, final double value);  }