io.micrometer.core.instrument.dropwizard.DropwizardMeterRegistry Java Examples
The following examples show how to use
io.micrometer.core.instrument.dropwizard.DropwizardMeterRegistry.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JHipsterLoggingMetricsExportConfiguration.java From jhipster with Apache License 2.0 | 6 votes |
/** * <p>consoleLoggingRegistry.</p> * * @param dropwizardRegistry a {@link com.codahale.metrics.MetricRegistry} object. * @return a {@link io.micrometer.core.instrument.MeterRegistry} object. */ @Bean public MeterRegistry consoleLoggingRegistry(MetricRegistry dropwizardRegistry) { DropwizardConfig dropwizardConfig = new DropwizardConfig() { @Override public String prefix() { return "console"; } @Override public String get(String key) { return null; } }; return new DropwizardMeterRegistry(dropwizardConfig, dropwizardRegistry, HierarchicalNameMapper.DEFAULT, Clock.SYSTEM) { @Override protected Double nullGaugeValue() { return null; } }; }
Example #2
Source File: DropwizardMeterRegistries.java From armeria with Apache License 2.0 | 6 votes |
/** * Returns a newly-created {@link DropwizardMeterRegistry} instance with the specified * {@link MetricRegistry}, {@link HierarchicalNameMapper} and {@link Clock}. */ public static DropwizardMeterRegistry newRegistry(MetricRegistry registry, HierarchicalNameMapper nameMapper, Clock clock) { final DropwizardMeterRegistry meterRegistry = new DropwizardMeterRegistry( DEFAULT_DROPWIZARD_CONFIG, requireNonNull(registry, "registry"), requireNonNull(nameMapper, "nameMapper"), requireNonNull(clock, "clock")) { @Override protected Double nullGaugeValue() { return 0.0; } }; return configureRegistry(meterRegistry); }
Example #3
Source File: DropwizardMeterRegistries.java From armeria with Apache License 2.0 | 6 votes |
/** * Configures the {@link DropwizardMeterRegistry} with Armeria's defaults. Useful when using a different * implementation of {@link DropwizardMeterRegistry}, e.g., a {@code JmxMeterRegistry}. * * @return the specified {@link DropwizardMeterRegistry} */ public static <T extends DropwizardMeterRegistry> T configureRegistry(T meterRegistry) { requireNonNull(meterRegistry, "meterRegistry"); meterRegistry.config().meterFilter(new MeterFilter() { @Override public MeterFilterReply accept(Meter.Id id) { if (id.getName().endsWith(".percentile") && id.getTag("phi") != null) { return MeterFilterReply.DENY; } if (id.getName().endsWith(".histogram") && id.getTag("le") != null) { return MeterFilterReply.DENY; } return MeterFilterReply.NEUTRAL; } }); meterRegistry.config().namingConvention(MoreNamingConventions.dropwizard()); return meterRegistry; }
Example #4
Source File: DropwizardMeterRegistriesTest.java From armeria with Apache License 2.0 | 6 votes |
@Test void filteredGaugesDoNotAffectOthers() { final CompositeMeterRegistry micrometer = new CompositeMeterRegistry(); final PrometheusMeterRegistry prometheus = PrometheusMeterRegistries.newRegistry(); final DropwizardMeterRegistry dropwizard = DropwizardMeterRegistries.newRegistry(); micrometer.add(prometheus).add(dropwizard); final DistributionSummary summary = DistributionSummary.builder("summary") .publishPercentiles(0.5, 0.99) .register(micrometer); summary.record(42); // Make sure Dropwizard registry does not have unwanted gauges. assertThat(dropwizard.getDropwizardRegistry().getMetrics()).containsOnlyKeys("summary"); // Make sure Prometheus registry collects all samples. final MetricFamilySamples prometheusSamples = findPrometheusSample(prometheus, "summary"); assertThat(prometheusSamples.samples).containsExactly( new Sample("summary", ImmutableList.of("quantile"), ImmutableList.of("0.5"), 42), new Sample("summary", ImmutableList.of("quantile"), ImmutableList.of("0.99"), 42), new Sample("summary_count", ImmutableList.of(), ImmutableList.of(), 1), new Sample("summary_sum", ImmutableList.of(), ImmutableList.of(), 42)); }
Example #5
Source File: MoreNamingConventionsTest.java From armeria with Apache License 2.0 | 6 votes |
private static DropwizardMeterRegistry newDropwizardRegistry() { return new DropwizardMeterRegistry(new DropwizardConfig() { @Override public String prefix() { return "dropwizard"; } @Override @Nullable public String get(String k) { return null; } }, new MetricRegistry(), HierarchicalNameMapper.DEFAULT, Clock.SYSTEM) { @Override protected Double nullGaugeValue() { return 0.0; } }; }
Example #6
Source File: DropwizardMeterRegistriesTest.java From armeria with Apache License 2.0 | 5 votes |
@Test void unwantedGaugesAreFilteredOut() { final DropwizardMeterRegistry micrometer = DropwizardMeterRegistries.newRegistry(); final MetricRegistry dropwizard = micrometer.getDropwizardRegistry(); final DistributionSummary percentileSummary = DistributionSummary.builder("percentileSummary") .publishPercentiles(0.5, 0.99) .register(micrometer); final DistributionSummary histogramSummary = DistributionSummary.builder("histogramSummary") .sla(10, 100) .register(micrometer); final Timer percentileTimer = Timer.builder("percentileTimer") .publishPercentiles(0.5, 0.99) .register(micrometer); final Timer histogramTimer = Timer.builder("histogramTimer") .sla(Duration.ofSeconds(10), Duration.ofSeconds(100)) .register(micrometer); percentileSummary.record(42); histogramSummary.record(42); percentileTimer.record(42, TimeUnit.SECONDS); histogramTimer.record(42, TimeUnit.SECONDS); final Map<String, Double> measurements = MoreMeters.measureAll(micrometer); measurements.forEach((key, value) -> assertThat(key).doesNotContain(".percentile") .doesNotContain(".histogram") .doesNotContain("phi=") .doesNotContain("le=")); // Must be exported as 2 Histograms and 2 Timers only. assertThat(dropwizard.getHistograms()).hasSize(2); assertThat(dropwizard.getTimers()).hasSize(2); }
Example #7
Source File: DropwizardMeterRegistries.java From armeria with Apache License 2.0 | 4 votes |
/** * Returns a newly-created {@link DropwizardMeterRegistry} instance with the specified * {@link MetricRegistry} and {@link HierarchicalNameMapper}. */ public static DropwizardMeterRegistry newRegistry(MetricRegistry registry, HierarchicalNameMapper nameMapper) { return newRegistry(registry, nameMapper, Clock.SYSTEM); }
Example #8
Source File: DropwizardMeterRegistriesTest.java From armeria with Apache License 2.0 | 4 votes |
@Test void micrometerAddsUnwantedGauges() { final DropwizardMeterRegistry micrometer = new DropwizardMeterRegistry( DEFAULT_DROPWIZARD_CONFIG, new MetricRegistry(), DEFAULT_NAME_MAPPER, Clock.SYSTEM) { @Override protected Double nullGaugeValue() { return 0.0; } }; final MetricRegistry dropwizard = micrometer.getDropwizardRegistry(); final DistributionSummary percentileSummary = DistributionSummary.builder("percentileSummary") .publishPercentiles(0.5) .register(micrometer); final DistributionSummary histogramSummary = DistributionSummary.builder("histogramSummary") .sla(10) .register(micrometer); final Timer percentileTimer = Timer.builder("percentileTimer") .publishPercentiles(0.5) .register(micrometer); final Timer histogramTimer = Timer.builder("histogramTimer") .sla(Duration.ofSeconds(10)) .register(micrometer); percentileSummary.record(42); histogramSummary.record(42); percentileTimer.record(42, TimeUnit.SECONDS); histogramTimer.record(42, TimeUnit.SECONDS); // Make sure Micrometer by default registers the unwanted gauges. final Map<String, Double> measurements = MoreMeters.measureAll(micrometer); assertThat(measurements).containsKeys( "percentileSummary.percentile#value{phi=0.5}", "histogramSummary.histogram#value{le=10}", "percentileTimer.percentile#value{phi=0.5}", "histogramTimer.histogram#value{le=10000}"); assertThat(dropwizard.getGauges()).containsKeys( "percentileSummaryPercentile.phi:0.5", "histogramSummaryHistogram.le:10", "percentileTimerPercentile.phi:0.5", "histogramTimerHistogram.le:10000"); }
Example #9
Source File: DropwizardMeterRegistries.java From armeria with Apache License 2.0 | 2 votes |
/** * Returns a newly-created {@link DropwizardMeterRegistry} instance with the default * {@link HierarchicalNameMapper}. */ public static DropwizardMeterRegistry newRegistry() { return newRegistry(new MetricRegistry(), DEFAULT_NAME_MAPPER); }
Example #10
Source File: DropwizardMeterRegistries.java From armeria with Apache License 2.0 | 2 votes |
/** * Returns a newly-created {@link DropwizardMeterRegistry} instance with the specified * {@link MetricRegistry} and the default {@link HierarchicalNameMapper}. */ public static DropwizardMeterRegistry newRegistry(MetricRegistry registry) { return newRegistry(registry, DEFAULT_NAME_MAPPER); }
Example #11
Source File: DropwizardMeterRegistries.java From armeria with Apache License 2.0 | 2 votes |
/** * Returns a newly-created {@link DropwizardMeterRegistry} instance with the specified * {@link HierarchicalNameMapper}. */ public static DropwizardMeterRegistry newRegistry(HierarchicalNameMapper nameMapper) { return newRegistry(new MetricRegistry(), nameMapper, Clock.SYSTEM); }
Example #12
Source File: DropwizardMeterRegistries.java From armeria with Apache License 2.0 | 2 votes |
/** * Returns a newly-created {@link DropwizardMeterRegistry} instance with the specified * {@link HierarchicalNameMapper} and {@link Clock}. */ public static DropwizardMeterRegistry newRegistry(HierarchicalNameMapper nameMapper, Clock clock) { return newRegistry(new MetricRegistry(), nameMapper, clock); }