项目作者: aha-oretama

项目描述 :
This repository is a prometheus's spring boot library for easily collecting the duration metrics of all methods in all RestController or Controller classes.
高级语言: Java
项目地址: git://github.com/aha-oretama/prometheus_auto_timing.git
创建时间: 2018-02-26T09:29:45Z
项目社区:https://github.com/aha-oretama/prometheus_auto_timing

开源协议:

下载


prometheus_auto_timing

Prometheus is nice open-source monitoring tools which covers applications and infrastructures.
Prometheus has many client libraries that matches the language in which your application is written.(See here).

Prometheus client libraries include Java client library which supports spring framework, spring boot.
The instrument by Spring AOP is nice solution,
however, it is a lot of cost to implement for collecing duration metrics of all methods in all RestController or Controller classes.

This repository is a spring boot library for this solution to make it easy and simple.
You only add dependency and one annotation,
then, you can collect the duration metrics of all methods in all RestController or Controller classes.

How to use

Now, this library is not uploaded in maven repository.(You make issue if you want. I’ll upload soon.)

As a temporary measure, you must install library as follows.

  1. $ git clone https://github.com/aha-oretama/prometheus_auto_timing.git
  2. $ cd prometheus_auto_timing.git
  3. $ mvn install

You only add dependency.

  1. <dependency>
  2. <groupId>jp.aha-oretama</groupId>
  3. <artifactId>prometheus_auto_timing</artifactId>
  4. <version>0.1.0-RELEASE</version>
  5. </dependency>

And you only add one annotaion @EnablePrometheusAutoTiming.

  1. @SpringBootApplication
  2. @EnablePrometheusEndpoint
  3. @EnableSpringBootMetricsCollector
  4. @EnablePrometheusAutoTiming
  5. public class Application {
  6. public static void main(String[] args) {
  7. SpringApplication.run(Application.class, args);
  8. }
  9. }

Notification: You do not need to implement for collecting duration metrics of all methods in all RestController or Controller classes, but you need to implement for exposing prometheus API by spring boot. It is realised by simpleclient_spring_boot.