我已添加statistics-enabled="true"
到我的独立数据源中:
<datasource jndi-name="java:jboss/datasources/RenavamDS"
pool-name="RenavamDS" enabled="true" use-java-context="true" statistics-enabled="true">
但是当我尝试访问时http://localhost:9990/metrics
,出现以下内部错误:
ERROR [io.undertow.request] (management I/O-1) UT005071: Undertow request failed HttpServerExchange{ GET /metrics}: java.lang.IllegalStateException: WFLYMETRICS0003: Unable to read attribute second-level-cache-hit-count on [
renavam-integrador-consulta_1 | ("subsystem" => "jpa"),
renavam-integrador-consulta_1 | ("hibernate-persistence-unit" => "renavam-integrador-consulta.war#BaseCorrenteRenavamPersistenceUnit"),
renavam-integrador-consulta_1 | ("entity-cache" => "renavam.integrador.tabelas.domain.Especie")
renavam-integrador-consulta_1 | ]: "WFLYCTL0158: Operation handler failed: java.lang.NullPointerException".
通过谷歌搜索(https://developer.jboss.org/thread/280621),我发现禁用 Hibernate 的二级缓存可以解决问题(在 persistence.xml 中):
<persistence-unit name="RenavamPersistenceUnit"
transaction-type="JTA">
<jta-data-source>java:jboss/datasources/RenavamDS</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
<property name="hibernate.cache.use_second_level_cache" value="false"/>
</properties>
</persistence-unit>
但是仅仅为了获得一些指标而禁用“二级缓存”似乎并不明智。
任何人都知道如何在 Wildfly 17 中正确启用数据源的指标收集?我对 metric 特别感兴趣wildfly_datasources_pool_available_count
。
太感谢了