/** * Returns a newly-created {@link PrometheusMeterRegistry} instance with a new {@link CollectorRegistry}. */ public static PrometheusMeterRegistry newRegistry() { return newRegistry(new CollectorRegistry()); }
/** * Creates a new {@link alluxio.metrics.sink.PrometheusMetricsServlet} with a * {@link MetricRegistry}. * * @param registry the metric registry to register */ public PrometheusMetricsServlet(MetricRegistry registry) { mCollectorRegistry = new CollectorRegistry(); mCollectorRegistry.register(new DropwizardExports(registry)); }
@Setup(Level.Iteration) public void setup() { registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT, new CollectorRegistry(), Clock.SYSTEM); summary = DistributionSummary.builder("summary") .publishPercentileHistogram() .register(registry); }
@Test public void testInstrumentsSuccessfulCall() throws Exception { // Given final CollectorRegistry registry = new CollectorRegistry(); final CallMeter timer = CallMeter.ofCollectorRegistry("some_call", "Some help", registry); // When timer.executeRunnable(() -> { try { Thread.sleep(50); } catch (InterruptedException e) { fail(); } }); // Then assertThat(registry.getSampleValue( "some_call_total", new String[]{}, new String[]{})) .isEqualTo(1.0); assertThat(registry.getSampleValue( "some_call_failures_total", new String[]{}, new String[]{})) .isEqualTo(0.0); assertThat(registry.getSampleValue( "some_call_latency_count", new String[]{}, new String[]{})) .isEqualTo(1.0); }
final CollectorRegistry registry = new CollectorRegistry();
@Test public void testExportsCircuitBreakerStates() { // Given final CollectorRegistry registry = new CollectorRegistry(); final Bulkhead bulkhead = Bulkhead.ofDefaults("foo"); BulkheadExports.ofIterable("boo_bulkhead", singletonList(bulkhead)).register(registry); final Supplier<Map<String, Double>> values = () -> HashSet .of("available_concurrent_calls") .map(param -> Tuple.of(param, registry.getSampleValue( "boo_bulkhead", new String[]{"name", "param"}, new String[]{"foo", param}))) .toMap(t -> t); // When final Map<String, Double> initialValues = values.get(); // Then assertThat(initialValues).isEqualTo(HashMap.of("available_concurrent_calls", 25.0)); }
@Test public void testExportsRateLimiterMetrics() { // Given final CollectorRegistry registry = new CollectorRegistry(); final RateLimiter rateLimiter = RateLimiter.ofDefaults("foo"); RateLimiterExports.ofIterable("boo_rate_limiter", singletonList(rateLimiter)).register(registry); final Supplier<Map<String, Double>> values = () -> HashSet .of("available_permissions", "waiting_threads") .map(param -> Tuple.of(param, registry.getSampleValue( "boo_rate_limiter", new String[]{"name", "param"}, new String[]{"foo", param}))) .toMap(t -> t); // When final Map<String, Double> initialValues = values.get(); // Then assertThat(initialValues).isEqualTo(HashMap.of( "available_permissions", 50.0, "waiting_threads", 0.0 )); }
@Test public void testExportsCircuitBreakerStates() { final CollectorRegistry registry = new CollectorRegistry();
@Test public void testExportsCircuitBreakerMetrics() { final CollectorRegistry registry = new CollectorRegistry();
final CollectorRegistry registry = new CollectorRegistry();
final CollectorRegistry registry = new CollectorRegistry();
/** * Pushes all metrics in a Collector, replacing only previously pushed metrics of the same name, job and grouping key. * <p> * This is useful for pushing a single Gauge. * <p> * This uses the POST HTTP method. */ public void pushAdd(Collector collector, String job, Map<String, String> groupingKey) throws IOException { CollectorRegistry registry = new CollectorRegistry(); collector.register(registry); pushAdd(registry, job, groupingKey); }
/** * Pushes all metrics in a Collector, replacing all those with the same job and no grouping key. * <p> * This is useful for pushing a single Gauge. * <p> * This uses the PUT HTTP method. */ public void push(Collector collector, String job) throws IOException { CollectorRegistry registry = new CollectorRegistry(); collector.register(registry); push(registry, job); }
/** * Pushes all metrics in a Collector, replacing all those with the same job and grouping key. * <p> * This is useful for pushing a single Gauge. * <p> * This uses the PUT HTTP method. */ public void push(Collector collector, String job, Map<String, String> groupingKey) throws IOException { CollectorRegistry registry = new CollectorRegistry(); collector.register(registry); push(registry, job, groupingKey); }
/** * Pushes all metrics in a Collector, replacing only previously pushed metrics of the same name and job and no grouping key. * <p> * This is useful for pushing a single Gauge. * <p> * This uses the POST HTTP method. */ public void pushAdd(Collector collector, String job) throws IOException { CollectorRegistry registry = new CollectorRegistry(); collector.register(registry); pushAdd(registry, job); }
@Bean @ConditionalOnMissingBean public CollectorRegistry collectorRegistry() { return new CollectorRegistry(true); }
@Bean @ConditionalOnMissingBean public CollectorRegistry collectorRegistry() { return new CollectorRegistry(true); }
/** * Creates a new {@link alluxio.metrics.sink.PrometheusMetricsServlet} with a * {@link MetricRegistry}. * * @param registry the metric registry to register */ public PrometheusMetricsServlet(MetricRegistry registry) { mCollectorRegistry = new CollectorRegistry(); mCollectorRegistry.register(new DropwizardExports(registry)); }
/** * Returns a configured Prometheus collector registry based on a * Dropwizard metric registry. * * @return The Prometheus collector registry. */ static CollectorRegistry getConfiguredCollectorRegistry() { CollectorRegistry r = new CollectorRegistry(); r.register(new DropwizardExports(MonitorRegistries.getMetricRegistry())); return r; }
public MetricsServlet getMetricsServlet() { CollectorRegistry collectorRegistry = new CollectorRegistry(); collectorRegistry.register(new MetricRegistryDecorator(registry, job, getResolvedLabels())); return new MetricsServlet(collectorRegistry); } }