-
Notifications
You must be signed in to change notification settings - Fork 45
ZH Quick Start
zrbcool edited this page Sep 2, 2019
·
3 revisions
以Mybatis集成为例,更多其他请参考:User Guide
- 增加maven依赖
<dependencies>
<!-- pepper metrics dependencies -->
<dependency>
<groupId>top.zrbcool</groupId>
<artifactId>pepper-metrics-mybatis</artifactId>
<version>1.0.11</version>
</dependency>
<!-- pepper-metrics datasource use prometheus by default -->
<dependency>
<groupId>top.zrbcool</groupId>
<artifactId>pepper-metrics-ds-prometheus</artifactId>
<version>1.0.11</version>
</dependency>
</dependencies>
- 配置Pepper Metrics定制的Mybatis插件使集成生效
<configuration>
<typeAliases>
...
</typeAliases>
<!-- 加入如下配置 -->
<plugins>
<plugin interceptor="com.pepper.metrics.integration.mybatis.MybatisProfilerPlugin" />
</plugins>
<mappers>
...
</mappers>
</configuration>
- 日志输出效果:
18:27:28 [perf-mybatis:20190822182728] ---------------------------------------------------------------------------------------------------------------------------------------------------------
18:27:28 [perf-mybatis:20190822182728] | Metrics Concurrent Count(Err/Sum) P90(ms) P99(ms) P999(ms) Max(ms) Qps |
18:27:28 [perf-mybatis:20190822182728] | com.pepper.metrics.sample.mybatis.mapper.HotelMapper.selectByCityId 0 0/1950 0.6 1.4 2.5 3.5 32.5 |
18:27:28 [perf-mybatis:20190822182728] | sample.mybatis.mapper.CityMapper.selectCityById 0 0/1950 0.8 2.4 56.6 56.6 32.5 |
18:27:28 [perf-mybatis:20190822182728] ---------------------------------------------------------------------------------------------------------------------------------------------------------
- Prometheus指标输出效果(默认的实现,可以修改为其他数据库)
✗ curl localhost:9146/metrics
# HELP app_mapper_summary_seconds_max
# TYPE app_mapper_summary_seconds_max gauge
app_mapper_summary_seconds_max{class="com/pepper/metrics/sample/mybatis/mapper/CityMapper.xml",operation="sample.mybatis.mapper.CityMapper.selectCityById",} 0.051129036
app_mapper_summary_seconds_max{class="com/pepper/metrics/sample/mybatis/mapper/HotelMapper.xml",operation="com.pepper.metrics.sample.mybatis.mapper.HotelMapper.selectByCityId",} 0.011559611
# HELP app_mapper_summary_seconds
# TYPE app_mapper_summary_seconds summary
app_mapper_summary_seconds{class="com/pepper/metrics/sample/mybatis/mapper/CityMapper.xml",operation="sample.mybatis.mapper.CityMapper.selectCityById",quantile="0.9",} 5.5296E-4
app_mapper_summary_seconds{class="com/pepper/metrics/sample/mybatis/mapper/CityMapper.xml",operation="sample.mybatis.mapper.CityMapper.selectCityById",quantile="0.99",} 0.001765376
app_mapper_summary_seconds{class="com/pepper/metrics/sample/mybatis/mapper/CityMapper.xml",operation="sample.mybatis.mapper.CityMapper.selectCityById",quantile="0.999",} 0.052424704
app_mapper_summary_seconds{class="com/pepper/metrics/sample/mybatis/mapper/CityMapper.xml",operation="sample.mybatis.mapper.CityMapper.selectCityById",quantile="0.99999",} 0.052424704
app_mapper_summary_seconds_count{class="com/pepper/metrics/sample/mybatis/mapper/CityMapper.xml",operation="sample.mybatis.mapper.CityMapper.selectCityById",} 3040.0
app_mapper_summary_seconds_sum{class="com/pepper/metrics/sample/mybatis/mapper/CityMapper.xml",operation="sample.mybatis.mapper.CityMapper.selectCityById",} 1.45711331
app_mapper_summary_seconds{class="com/pepper/metrics/sample/mybatis/mapper/HotelMapper.xml",operation="com.pepper.metrics.sample.mybatis.mapper.HotelMapper.selectByCityId",quantile="0.9",} 4.4032E-4
app_mapper_summary_seconds{class="com/pepper/metrics/sample/mybatis/mapper/HotelMapper.xml",operation="com.pepper.metrics.sample.mybatis.mapper.HotelMapper.selectByCityId",quantile="0.99",} 0.001308672
app_mapper_summary_seconds{class="com/pepper/metrics/sample/mybatis/mapper/HotelMapper.xml",operation="com.pepper.metrics.sample.mybatis.mapper.HotelMapper.selectByCityId",quantile="0.999",} 0.002881536
app_mapper_summary_seconds{class="com/pepper/metrics/sample/mybatis/mapper/HotelMapper.xml",operation="com.pepper.metrics.sample.mybatis.mapper.HotelMapper.selectByCityId",quantile="0.99999",} 0.012056576
app_mapper_summary_seconds_count{class="com/pepper/metrics/sample/mybatis/mapper/HotelMapper.xml",operation="com.pepper.metrics.sample.mybatis.mapper.HotelMapper.selectByCityId",} 3040.0
app_mapper_summary_seconds_sum{class="com/pepper/metrics/sample/mybatis/mapper/HotelMapper.xml",operation="com.pepper.metrics.sample.mybatis.mapper.HotelMapper.selectByCityId",} 0.772147736
# HELP app_mapper_concurrent_gauge
# TYPE app_mapper_concurrent_gauge gauge
app_mapper_concurrent_gauge{class="com/pepper/metrics/sample/mybatis/mapper/CityMapper.xml",operation="sample.mybatis.mapper.CityMapper.selectCityById",} 0.0
app_mapper_concurrent_gauge{class="com/pepper/metrics/sample/mybatis/mapper/HotelMapper.xml",operation="com.pepper.metrics.sample.mybatis.mapper.HotelMapper.selectByCityId",} 0.0
以Mybatis为例,更多其他请参考:User Guide
<dependencies>
<!-- pepper metrics dependencies -->
<dependency>
<groupId>top.zrbcool</groupId>
<artifactId>pepper-metrics-mybatis</artifactId>
<version>1.0.11</version>
</dependency>
<!-- pepper-metrics datasource use prometheus by default -->
<dependency>
<groupId>top.zrbcool</groupId>
<artifactId>pepper-metrics-ds-prometheus</artifactId>
<version>1.0.11</version>
</dependency>
</dependencies>
mvn clean package install -DskipTests
酷划在线成立于2014年,是国内激励广告行业的领军者。酷划致力于打造一个用户、广告主、平台三方共赢的激励广告生态体系,旗下产品“酷划锁屏”“淘新闻”分别为锁屏、资讯行业的领跑者。
感谢作者所在公司酷划在线给作者提供开放的技术环境,并充分支持回馈开源社区项目。
Pepper Metrics is released under the Apache License 2.0.