概述
Metrics is a Java library which gives you unparalleled insight into what your code does in production.
Metrics provides a powerful toolkit of ways to measure the behavior of critical components in your production environment.
With modules for common libraries like Jetty, Logback, Log4j, Apache HttpClient, Ehcache, JDBI, Jersey and reporting backends like Ganglia and Graphite, Metrics provides you with full-stack visibility.
Dropwizard Metrics 能夠幫助我們從各個(gè)角度度量已存在的java應(yīng)用的成熟框架,簡便地以jar包的方式集成進(jìn)您的系統(tǒng),可以以http、ganglia、graphite、log4j等方式提供全棧式的監(jiān)控視野。
Metrics 類型
度量術(shù)語 | 描述 |
---|---|
Meters | Meter度量一系列事件發(fā)生的速率(rate),例如TPS。Meters會(huì)統(tǒng)計(jì)最近1分鐘,5分鐘,15分鐘,還有全部時(shí)間的速率。 |
Gauges | 某個(gè)特定瞬時(shí)值,例如MQ中消息數(shù)量 |
Counters | Counter 就是計(jì)數(shù)器,Counter 只是用 Gauge 封裝了 AtomicLong |
Histograms | Histogram統(tǒng)計(jì)數(shù)據(jù)的分布情況。比如最小值,最大值,中間值,還有中位數(shù),75百分位, 90百分位, 95百分位, 98百分位, 99百分位, 和 99.9百分位的值(percentiles)。 |
Timers | Timer其實(shí)是 Histogram 和 Meter 的結(jié)合, histogram 某部分代碼/調(diào)用的耗時(shí), meter統(tǒng)計(jì)TPS。 |
Health Checks | 集中式檢測系統(tǒng)的監(jiān)控狀態(tài),例如數(shù)據(jù)庫連接是否正常。 |
Reporting | 度量值可以通過 HTTP,SLF4J,JMX,CSV ,Ganglia,Graphite |
使用
Maven依賴
<dependencies>
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>${metrics.version}</version>
</dependency>
</dependencies>
目前Metrics的最新版本是** 3.2.4 **。