3.5. 公开数据网格统计
Data Grid 支持 Spring Boot Actuator 将缓存统计信息作为指标公开。
要使用 Actuator,请在 pom.xml 文件中添加以下内容:
然后,您必须以编程方式或声明性激活相应缓存实例的统计信息。
以编程方式
声明性
<local-cache name="my-cache" statistics="true"/>
<local-cache name="my-cache" statistics="true"/>
Spring Boot Actuator registry 在应用程序启动时绑定缓存实例。如果您动态创建缓存,您应该使用 CacheMetricsRegistrar bean 将缓存绑定到 Actuator registry,如下所示: