Java Code Examples for io.micrometer.prometheus.PrometheusConfig#DEFAULT
The following examples show how to use
io.micrometer.prometheus.PrometheusConfig#DEFAULT .
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: CustomMicrometerMetricsITest.java From vertx-micrometer-metrics with Apache License 2.0 | 6 votes |
@Test public void shouldPublishQuantilesWithProvidedRegistry(TestContext context) throws Exception { PrometheusMeterRegistry registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT); vertx = Vertx.vertx(new VertxOptions() .setMetricsOptions(new MicrometerMetricsOptions() .setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true) .setPublishQuantiles(true) .setStartEmbeddedServer(true) .setEmbeddedServerOptions(new HttpServerOptions().setPort(9090))) .setMicrometerRegistry(registry) .setEnabled(true))); Async async = context.async(); // Dummy connection to trigger some metrics PrometheusTestHelper.tryConnect(vertx, context, 9090, "localhost", "/metrics", r1 -> { // Delay to make "sure" metrics are populated vertx.setTimer(500, l -> { assertThat(registry.scrape()).contains("vertx_http_client_responseTime_seconds_bucket{code=\"200\""); async.complete(); }); }); async.awaitSuccess(10000); }
Example 2
Source File: CoreModule.java From EDDI with Apache License 2.0 | 6 votes |
@Provides @Singleton public PrometheusMeterRegistry providePrometheusMeterRegistry(ExecutorService executorService, @Named("systemRuntime.projectName") String projectName) { PrometheusMeterRegistry registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT); new LogbackMetrics().bindTo(registry); new ClassLoaderMetrics().bindTo(registry); new ExecutorServiceMetrics(executorService, projectName + "-ExecutorService", () -> Tags.of(projectName, "ExecutorService").iterator()).bindTo(registry); new JvmMemoryMetrics().bindTo(registry); new JvmGcMetrics().bindTo(registry); new JvmThreadMetrics().bindTo(registry); new ProcessorMetrics().bindTo(registry); new ProcessMemoryMetrics().bindTo(registry); new ProcessThreadMetrics().bindTo(registry); new FileDescriptorMetrics().bindTo(registry); new DiskSpaceMetrics(new File("/")).bindTo(registry); new UptimeMetrics().bindTo(registry); registry.config().commonTags("instance", projectName); registry.config().commonTags("application", projectName); registry.config().commonTags("service", projectName); return registry; }
Example 3
Source File: MetricsUtils.java From konduit-serving with Apache License 2.0 | 5 votes |
/** * Sets up promethues and returns the * registry * @return */ public static Pair<MicrometerMetricsOptions,MeterRegistry> setupPrometheus() { PrometheusMeterRegistry registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT); MicrometerMetricsOptions micrometerMetricsOptions = new MicrometerMetricsOptions() .setMicrometerRegistry(registry) .setPrometheusOptions(new VertxPrometheusOptions() .setEnabled(true)); BackendRegistries.setupBackend(micrometerMetricsOptions); return Pair.of(micrometerMetricsOptions,registry); }
Example 4
Source File: MetricsModule.java From dolphin-platform with Apache License 2.0 | 5 votes |
@Override public void initialize(final ServerCoreComponents coreComponents) { final PlatformConfiguration configuration = coreComponents.getConfiguration(); final ServletContext servletContext = coreComponents.getInstance(ServletContext.class); if(!configuration.getBooleanProperty(METRICS_NOOP_PROPERTY, true)) { final PrometheusMeterRegistry prometheusRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT); final List<Tag> tagList = TagUtil.convertTags(ContextManagerImpl.getInstance().getGlobalContexts()); new ClassLoaderMetrics(tagList).bindTo(prometheusRegistry); new JvmMemoryMetrics(tagList).bindTo(prometheusRegistry); new JvmGcMetrics(tagList).bindTo(prometheusRegistry); new ProcessorMetrics(tagList).bindTo(prometheusRegistry); new JvmThreadMetrics(tagList).bindTo(prometheusRegistry); servletContext.addFilter(METRICS_SERVLET_FILTER_NAME, new RequestMetricsFilter()) .addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, ALL_URL_MAPPING); servletContext.addListener(new MetricsHttpSessionListener()); servletContext.addServlet(METRICS_SERVLET_NAME, new MetricsServlet(prometheusRegistry)) .addMapping(configuration.getProperty(METRICS_ENDPOINT_PROPERTY)); MetricsImpl.getInstance().init(prometheusRegistry); } }
Example 5
Source File: TracingConfig.java From Mastering-Distributed-Tracing with MIT License | 5 votes |
@Bean public PrometheusMeterRegistry micrometerRegistry(CollectorRegistry collector) { PrometheusMeterRegistry registry = new PrometheusMeterRegistry( // PrometheusConfig.DEFAULT, collector, Clock.SYSTEM); io.micrometer.core.instrument.Metrics.addRegistry(registry); return registry; }
Example 6
Source File: CompareHistogramsWithOtherLibraries.java From micrometer with Apache License 2.0 | 5 votes |
@Setup(Level.Iteration) public void setup() { registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT, new CollectorRegistry(), Clock.SYSTEM); summary = DistributionSummary.builder("summary") .publishPercentileHistogram() .register(registry); }
Example 7
Source File: CounterBenchmark.java From micrometer with Apache License 2.0 | 4 votes |
@Setup public void setup() { registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT); counter = registry.counter("counter"); }
Example 8
Source File: MoreNamingConventionsTest.java From armeria with Apache License 2.0 | 4 votes |
private static PrometheusMeterRegistry newPrometheusRegistry() { return new PrometheusMeterRegistry(PrometheusConfig.DEFAULT); }
Example 9
Source File: PrometheusMeterRegistries.java From armeria with Apache License 2.0 | 4 votes |
/** * Returns a newly-created {@link PrometheusMeterRegistry} instance with the specified * {@link CollectorRegistry} and {@link Clock}. */ public static PrometheusMeterRegistry newRegistry(CollectorRegistry registry, Clock clock) { final PrometheusMeterRegistry meterRegistry = new PrometheusMeterRegistry( PrometheusConfig.DEFAULT, requireNonNull(registry, "registry"), requireNonNull(clock, "clock")); return configureRegistry(meterRegistry); }
Example 10
Source File: PrometheusMeterRegistryProvider.java From che with Eclipse Public License 2.0 | 4 votes |
@Inject public PrometheusMeterRegistryProvider(CollectorRegistry registry) { prometheusMeterRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT, registry, Clock.SYSTEM); Metrics.addRegistry(prometheusMeterRegistry); }
Example 11
Source File: PrometheusMetricsReporterConfiguration.java From java-metrics with Apache License 2.0 | 4 votes |
@Bean @ConditionalOnMissingBean public PrometheusMeterRegistry prometheusMeterRegistry() { return new PrometheusMeterRegistry(PrometheusConfig.DEFAULT, collectorRegistry, Clock.SYSTEM); }
Example 12
Source File: PrometheusSample.java From micrometer with Apache License 2.0 | 4 votes |
public static void main(String[] args) { PrometheusMeterRegistry meterRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT); // add any tags here that will apply to all metrics streaming from this app // (e.g. EC2 region, stack, instance id, server group) meterRegistry.config().commonTags("app", "javalin-sample"); new JvmGcMetrics().bindTo(meterRegistry); new JvmHeapPressureMetrics().bindTo(meterRegistry); new JvmMemoryMetrics().bindTo(meterRegistry); new ProcessorMetrics().bindTo(meterRegistry); new FileDescriptorMetrics().bindTo(meterRegistry); Javalin app = Javalin.create(config -> config.registerPlugin(new MicrometerPlugin(meterRegistry))).start(8080); // must manually delegate to Micrometer exception handler for excepton tags to be correct app.exception(IllegalArgumentException.class, (e, ctx) -> { MicrometerPlugin.EXCEPTION_HANDLER.handle(e, ctx); e.printStackTrace(); }); app.get("/", ctx -> ctx.result("Hello World")); app.get("/hello/:name", ctx -> ctx.result("Hello: " + ctx.pathParam("name"))); app.get("/boom", ctx -> { throw new IllegalArgumentException("boom"); }); app.routes(() -> { path("hi", () -> { get(":name", ctx -> ctx.result("Hello: " + ctx.pathParam("name"))); }); }); app.after("/hello/*", ctx -> { System.out.println("hello"); }); app.get("/prometheus", ctx -> ctx .contentType(TextFormat.CONTENT_TYPE_004) .result(meterRegistry.scrape())); }
Example 13
Source File: TimerBenchmark.java From micrometer with Apache License 2.0 | 4 votes |
@Setup public void setup() { registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT); timer = registry.timer("timer"); }
Example 14
Source File: SpringApp.java From rqueue with Apache License 2.0 | 4 votes |
@Bean public PrometheusMeterRegistry meterRegistry() { return new PrometheusMeterRegistry(PrometheusConfig.DEFAULT); }
Example 15
Source File: PrometheusBackendRegistry.java From vertx-micrometer-metrics with Apache License 2.0 | 4 votes |
public PrometheusBackendRegistry(VertxPrometheusOptions options) { this(options, new PrometheusMeterRegistry(PrometheusConfig.DEFAULT)); }
Example 16
Source File: ZipkinServerConfigurationTest.java From pivotal-bank-demo with Apache License 2.0 | 4 votes |
@Bean MeterRegistry registry () { return new PrometheusMeterRegistry(PrometheusConfig.DEFAULT); }
Example 17
Source File: PrometheusMetricsProvider.java From konduit-serving with Apache License 2.0 | 4 votes |
@Override public MeterRegistry getRegistry() { return new PrometheusMeterRegistry(PrometheusConfig.DEFAULT); }
Example 18
Source File: DistributionSummaryTest.java From pepper-metrics with Apache License 2.0 | 4 votes |
@Test public void test() throws InterruptedException { final PrometheusMeterRegistry prometheusRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT); final Timer summary = Timer.builder("test") .distributionStatisticExpiry(Duration.ofSeconds(10)) .publishPercentiles(0.9D, 0.99D, 0.999D) .distributionStatisticBufferLength(20) .publishPercentileHistogram(false) .tags(new String[]{"method", "get()"}) .register(prometheusRegistry); // final DistributionSummary summary = DistributionSummary.builder("test") // .distributionStatisticExpiry(Duration.ofSeconds(30)) // .publishPercentiles(0.9, 0.99, 0.999) // .publishPercentileHistogram(false) // .tags(new String[]{"method", "get()"}) // .register(prometheusRegistry); AtomicInteger second = new AtomicInteger(); Executors.newScheduledThreadPool(1).scheduleAtFixedRate(() -> { final HistogramSnapshot snapshot = summary.takeSnapshot(); final ValueAtPercentile[] valueAtPercentiles = snapshot.percentileValues(); double p90 = 0, p99 = 0, p999 = 0; for (ValueAtPercentile percentile : valueAtPercentiles) { if (percentile.percentile() == 0.9D) { p90 = percentile.value(TimeUnit.MILLISECONDS); } else if (percentile.percentile() == 0.99D) { p99 = percentile.value(TimeUnit.MILLISECONDS); } else { p999 = percentile.value(TimeUnit.MILLISECONDS); } } System.out.println(String.format("second: %s, p90: %s, p99: %s, p999: %s", second.incrementAndGet(), p90, p99, p999)); }, 1, 1, TimeUnit.SECONDS); for (int j = 0; j < 100; j++) { // for (long i = 0; i < 1000; i++) { // summary.record(i, TimeUnit.MILLISECONDS); // } summary.record(j % 10, TimeUnit.MILLISECONDS); TimeUnit.SECONDS.sleep(1); } for (int i = 0; i < 10; i++) { TimeUnit.SECONDS.sleep(1); } for (int i = 0; i < 100; i++) { TimeUnit.SECONDS.sleep(1); } }