From 42ba80f21df6a782ab6179b2352fcc1bd98cec2f Mon Sep 17 00:00:00 2001 From: qibaoguang Date: Wed, 4 Mar 2015 22:44:07 +0800 Subject: [PATCH] Update and rename 44.6. Metric repositories to 44.6. Metric repositories.md --- .../44.6. Metric repositories | 0 .../44.6. Metric repositories.md | 5 +++++ 2 files changed, 5 insertions(+) delete mode 100644 V. Spring Boot Actuator: Production-ready features/44.6. Metric repositories create mode 100644 V. Spring Boot Actuator: Production-ready features/44.6. Metric repositories.md diff --git a/V. Spring Boot Actuator: Production-ready features/44.6. Metric repositories b/V. Spring Boot Actuator: Production-ready features/44.6. Metric repositories deleted file mode 100644 index e69de29..0000000 diff --git a/V. Spring Boot Actuator: Production-ready features/44.6. Metric repositories.md b/V. Spring Boot Actuator: Production-ready features/44.6. Metric repositories.md new file mode 100644 index 0000000..df851b7 --- /dev/null +++ b/V. Spring Boot Actuator: Production-ready features/44.6. Metric repositories.md @@ -0,0 +1,5 @@ +### 44.6. 指标仓库 + +指标服务实现通过绑定一个[MetricRepository](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/repository/MetricRepository.java)。`MetricRepository`负责存储和追溯指标信息。Spring Boot提供一个`InMemoryMetricRepository`和一个`RedisMetricRepository`(默认使用in-memory仓库),不过你可以编写自己的`MetricRepository`。`MetricRepository`接口实际是`MetricReader`接口和`MetricWriter`接口的上层组合。具体参考[Javadoc](http://docs.spring.io/spring-boot/docs/1.3.0.BUILD-SNAPSHOT/api/org/springframework/boot/actuate/metrics/repository/MetricRepository.html) + +没有什么能阻止你直接将`MetricRepository`的数据导入应用中的后端存储,但我们建议你使用默认的`InMemoryMetricRepository`(如果担心堆使用情况,你可以使用自定义的Map实例),然后通过一个scheduled export job填充后端仓库(意思是先将数据保存到内存中,然后通过异步job将数据持久化到数据库,可以提高系统性能)。通过这种方式,你可以将指标数据缓存到内存中,然后通过低频率或批量导出来减少网络拥堵。Spring Boot提供一个`Exporter`接口及一些帮你开始的基本实现。