io.micrometer.core.instrument.binder.system.FileDescriptorMetrics Java Examples

The following examples show how to use io.micrometer.core.instrument.binder.system.FileDescriptorMetrics. 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: CentralDogma.java    From centraldogma with Apache License 2.0 7 votes vote down vote up
private void configureMetrics(ServerBuilder sb, PrometheusMeterRegistry registry) {
    sb.meterRegistry(registry);
    sb.service(METRICS_PATH, new PrometheusExpositionService(registry.getPrometheusRegistry()));
    sb.decorator(MetricCollectingService.newDecorator(MeterIdPrefixFunction.ofDefault("api")));

    // Bind system metrics.
    new FileDescriptorMetrics().bindTo(registry);
    new ProcessorMetrics().bindTo(registry);
    new ClassLoaderMetrics().bindTo(registry);
    new UptimeMetrics().bindTo(registry);
    new DiskSpaceMetrics(cfg.dataDir()).bindTo(registry);
    new JvmGcMetrics().bindTo(registry);
    new JvmMemoryMetrics().bindTo(registry);
    new JvmThreadMetrics().bindTo(registry);

    // Bind global thread pool metrics.
    ExecutorServiceMetrics.monitor(registry, ForkJoinPool.commonPool(), "commonPool");
}
 
Example #2
Source File: CoreModule.java    From EDDI with Apache License 2.0 6 votes vote down vote up
@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: MetricsModule.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void configure() {
  bind(MetricsServer.class).asEagerSingleton();
  bind(MetricsBinder.class).asEagerSingleton();
  bind(CollectorRegistry.class).toInstance(CollectorRegistry.defaultRegistry);
  bind(PrometheusMeterRegistry.class)
      .toProvider(PrometheusMeterRegistryProvider.class)
      .asEagerSingleton();
  bind(MeterRegistry.class).to(PrometheusMeterRegistry.class);

  Multibinder<MeterBinder> meterMultibinder =
      Multibinder.newSetBinder(binder(), MeterBinder.class);
  meterMultibinder.addBinding().to(ClassLoaderMetrics.class);
  meterMultibinder.addBinding().to(JvmMemoryMetrics.class);
  meterMultibinder.addBinding().to(JvmGcMetrics.class);
  meterMultibinder.addBinding().to(JvmThreadMetrics.class);
  meterMultibinder.addBinding().to(LogbackMetrics.class);
  meterMultibinder.addBinding().to(FileDescriptorMetrics.class);
  meterMultibinder.addBinding().to(ProcessorMetrics.class);
  meterMultibinder.addBinding().to(UptimeMetrics.class);
  meterMultibinder.addBinding().to(FileStoresMeterBinder.class);
  meterMultibinder.addBinding().to(ApiResponseCounter.class);
  meterMultibinder.addBinding().to(ProcessMemoryMetrics.class);
  meterMultibinder.addBinding().to(ProcessThreadMetrics.class);

  bind(EventListener.class).toProvider(OkHttpMetricsEventListenerProvider.class);
}
 
Example #4
Source File: SystemMetricsAutoConfiguration.java    From foremast with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnProperty(name = "management.metrics.binders.files.enabled", matchIfMissing = true)
@ConditionalOnMissingBean(FileDescriptorMetrics.class)
public FileDescriptorMetrics fileDescriptorMetrics() {
    return new FileDescriptorMetrics();
}
 
Example #5
Source File: MetricsAutoConfiguration.java    From foremast with Apache License 2.0 4 votes vote down vote up
@Bean
public FileDescriptorMetrics fileDescriptorMetrics() {
    return new FileDescriptorMetrics();
}
 
Example #6
Source File: PrometheusSample.java    From micrometer with Apache License 2.0 4 votes vote down vote up
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 #7
Source File: ArmeriaSpringBoot1MeterBindersConfiguration.java    From armeria with Apache License 2.0 4 votes vote down vote up
/**
 * Returns {@link FileDescriptorMetrics}.
 */
@Bean
@ConditionalOnMissingBean(FileDescriptorMetrics.class)
public FileDescriptorMetrics fileDescriptorMetrics() {
    return new FileDescriptorMetrics();
}