gpt4 book ai didi

Spring boot 2 执行器缓存指标

转载 作者:行者123 更新时间:2023-12-05 07:07:38 29 4
gpt4 key购买 nike

我在 sprint boot 2 执行器中找不到缓存指标。我应该如何查询或激活或调试它们?

org.springframework.boot:spring-boot-starter-actuator:2.2.5.RELEASE

我可以在下面看到两个缓存 http://localhost:8080/actuator/caches ->

{
"cacheManagers": {
"cacheManager": {
"caches": {
"calendar": {
"target": "org.ehcache.jsr107.Eh107Cache"
},
"foo": {
"target": "org.ehcache.jsr107.Eh107Cache"
}
}
}
}
}

ehcache.xml:


<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.ehcache.org/v3"
xmlns:jsr107="http://www.ehcache.org/v3/jsr107"
xsi:schemaLocation="
http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core-3.0.xsd
http://www.ehcache.org/v3/jsr107 http://www.ehcache.org/schema/ehcache-107-ext-3.0.xsd">
<cache alias="calendar" >
<expiry>
<ttl unit="seconds">60</ttl>
</expiry>
<resources>
<heap unit="entries">2</heap>
<offheap unit="MB">100</offheap>
</resources>
</cache>
<cache alias="foo" >
<expiry>
<ttl unit="seconds">60</ttl>
</expiry>
<resources>
<heap unit="entries">2</heap>
<offheap unit="MB">100</offheap>
</resources>
</cache>
</config>

我既看不到缓存,也看不到日历,也看不到 foo http://localhost:8080/actuator/metrics/ (其他指标如“jvm.memory.max”可见)

同样

http://localhost:8080/actuator/metrics/cache.calendar.size

http://localhost:8080/actuator/metrics/cache.calendar.gets

http://localhost:8080//actuator/metrics/cache.gets

不返回任何东西。

如何获取缓存指标?

http://localhost:8080/actuator/metrics/cache?tag=calendar:size也不返回任何内容,在日志中我可以看到:

2020-05-28 15:57:35.207 DEBUG 12490 --- [nio-8080-exec-3] org.apache.tomcat.util.http.Parameters   : Decoding query null UTF-8
2020-05-28 15:57:35.207 DEBUG 12490 --- [nio-8080-exec-3] org.apache.tomcat.util.http.Parameters : Start processing with input [tag=calendar:size]
2020-05-28 15:57:35.207 DEBUG 12490 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet : GET "/actuator/metrics/cache?tag=calendar:size", parameters={masked}
2020-05-28 15:57:35.207 DEBUG 12490 --- [nio-8080-exec-3] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped to Actuator web endpoint 'metrics-requiredMetricName'
2020-05-28 15:57:35.208 DEBUG 12490 --- [nio-8080-exec-3] o.s.w.s.m.m.a.HttpEntityMethodProcessor : Using 'application/vnd.spring-boot.actuator.v3+json;q=0.8', given [text/html, application/xhtml+xml, image/webp, application/xml;q=0.9, */*;q=0.8] and supported [application/vnd.spring-boot.actuator.v3+json, application/vnd.spring-boot.actuator.v2+json, application/json]
2020-05-28 15:57:35.209 DEBUG 12490 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet : Completed 404 NOT_FOUND
2020-05-28 15:57:35.209 DEBUG 12490 --- [nio-8080-exec-3] o.s.s.w.a.ExceptionTranslationFilter : Chain processed normally

最佳答案

在您的缓存配置中,您可以启用统计信息:

<cache alias="calendar" >
...
<jsr107:mbeans enable-statistics="true" />
</cache>

关于Spring boot 2 执行器缓存指标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62065084/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com