Wildfly 26 上的 Microprofile 指标问题
Problem with Microprofile Metrics on Wildfly 26
我目前正在从 Wildfly 20 升级到 Wildfly 26。standalone.xml
没有启动,因为注入了 MetricRegistry
和新丢失的 microprofile.metrics-smallrye
-扩展(已在下面描述:)。
但是,如果我启动 standalone-microprofile.xml
或添加扩展(请参阅下面的 CLI 命令),我 运行 会出现相同的错误。
可能 Keycloak-Integration-Workaround 存在冲突。 Wildfly 内部的 OIDC 适配器实际上无法在仅承载模式下工作。所以我安装了当前的 keycloak-client (keycloak-oidc-wildfly-adapter-16.1.1
) 和解决方法(见最后的代码模板)。
2022-02-21 12:44:09,176 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.deployment.unit."xyz.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."xyz.war".WeldStartService: Failed to start service
at org.jboss.msc@1.4.13.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1731)
at org.jboss.msc@1.4.13.Final//org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1559)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.jboss.weld.exceptions.DeploymentException: SRMET00013: Description is different from the description in previous usage
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.bootstrap.events.AbstractDeploymentContainerEvent.fire(AbstractDeploymentContainerEvent.java:38)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.bootstrap.events.AfterDeploymentValidationImpl.fire(AfterDeploymentValidationImpl.java:28)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:510)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:93)
at org.jboss.as.weld@26.0.1.Final//org.jboss.as.weld.WeldStartService.start(WeldStartService.java:98)
at org.jboss.msc@1.4.13.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1739)
at org.jboss.msc@1.4.13.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1701)
... 6 more
Caused by: java.lang.IllegalStateException: SRMET00013: Description is different from the description in previous usage
at io.smallrye.metrics//io.smallrye.metrics.MetricsRegistryImpl.verifyMetadataEquality(MetricsRegistryImpl.java:188)
at io.smallrye.metrics//io.smallrye.metrics.MetricsRegistryImpl.get(MetricsRegistryImpl.java:459)
at io.smallrye.metrics//io.smallrye.metrics.MetricsRegistryImpl.get(MetricsRegistryImpl.java:402)
at io.smallrye.metrics//io.smallrye.metrics.MetricsRegistryImpl.timer(MetricsRegistryImpl.java:371)
at io.smallrye.metrics//io.smallrye.metrics.setup.MetricsMetadata.registerMetrics(MetricsMetadata.java:111)
at io.smallrye.metrics//io.smallrye.metrics.setup.MetricCdiInjectionExtension.registerMetrics(MetricCdiInjectionExtension.java:186)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:95)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.injection.MethodInvocationStrategy$SpecialParamPlusBeanManagerStrategy.invoke(MethodInvocationStrategy.java:187)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:330)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:123)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:308)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:286)
at javax.enterprise.api//javax.enterprise.inject.spi.ObserverMethod.notify(ObserverMethod.java:124)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.util.Observers.notify(Observers.java:166)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ObserverNotifier.notifySyncObservers(ObserverNotifier.java:285)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ObserverNotifier.notify(ObserverNotifier.java:273)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:177)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:171)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:53)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.bootstrap.events.AbstractDeploymentContainerEvent.fire(AbstractDeploymentContainerEvent.java:35)
扩展 standalone.xml
的 CLI 命令
wildfly/bin/jboss-cli.sh -c "/extension=org.wildfly.extension.microprofile.metrics-smallrye:add()"
wildfly/bin/jboss-cli.sh -c "/subsystem=microprofile-metrics-smallrye:add()"
wildfly/bin/jboss-cli.sh -c "/extension=org.wildfly.extension.microprofile.fault-tolerance-smallrye:add()"
wildfly/bin/jboss-cli.sh -c "/subsystem=microprofile-fault-tolerance-smallrye:add()"
OIDC-解决方法(安装 keycloak 客户端)
embed-server --server-config=${server.config:standalone.xml}
batch
/subsystem=undertow/application-security-domain=other:undefine-attribute(name=security-domain)
/subsystem=undertow/application-security-domain=other:write-attribute(name=http-authentication-factory,value=keycloak-http-authentication)
run-batch
/subsystem=ejb3/application-security-domain=other:write-attribute(name=security-domain,value=KeycloakDomain)
reload
哦,我花了几个小时来解决这个问题..但是在写这篇文章 post 几分钟后,我就找到了“坏人”。
Microprofile 版本 3.3(在 Wildfly 20 上)忽略了 interface-methods 处的注释(如 @Timed
)。新的4.1版本(Wildfly 26)向他们致敬..
很简单,之后:)
边注:
如果您在 Wildfly 上部署了多个 WAR,其中一个正在使用另一个 public API,那么您将 运行 进入 hot-deployments 的问题。
我假设,在我的例子中,它发生是因为我将 Timed
-注释放在 implementation-class 而不是用作 ResteasyClient-proxy 的界面上。每次我在 WAR rest-api-defining WAR 之后部署依赖项时,我都会遇到异常:no metric mapped
。
rest-api-defining WAR 的重新部署解决了这个问题:)
通常使用匿名用户(prometheus scraper)查询 /metrics 端点,这意味着您可能必须启用 MONITOR 角色才能包含所有内容。这样,对 /metrics 的匿名访问将能够读取额外的线程数据。
^^我不确定此配置的安全影响。
我目前正在从 Wildfly 20 升级到 Wildfly 26。standalone.xml
没有启动,因为注入了 MetricRegistry
和新丢失的 microprofile.metrics-smallrye
-扩展(已在下面描述:standalone-microprofile.xml
或添加扩展(请参阅下面的 CLI 命令),我 运行 会出现相同的错误。
可能 Keycloak-Integration-Workaround 存在冲突。 Wildfly 内部的 OIDC 适配器实际上无法在仅承载模式下工作。所以我安装了当前的 keycloak-client (keycloak-oidc-wildfly-adapter-16.1.1
) 和解决方法(见最后的代码模板)。
2022-02-21 12:44:09,176 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.deployment.unit."xyz.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."xyz.war".WeldStartService: Failed to start service
at org.jboss.msc@1.4.13.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1731)
at org.jboss.msc@1.4.13.Final//org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1559)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.jboss.weld.exceptions.DeploymentException: SRMET00013: Description is different from the description in previous usage
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.bootstrap.events.AbstractDeploymentContainerEvent.fire(AbstractDeploymentContainerEvent.java:38)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.bootstrap.events.AfterDeploymentValidationImpl.fire(AfterDeploymentValidationImpl.java:28)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:510)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:93)
at org.jboss.as.weld@26.0.1.Final//org.jboss.as.weld.WeldStartService.start(WeldStartService.java:98)
at org.jboss.msc@1.4.13.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1739)
at org.jboss.msc@1.4.13.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1701)
... 6 more
Caused by: java.lang.IllegalStateException: SRMET00013: Description is different from the description in previous usage
at io.smallrye.metrics//io.smallrye.metrics.MetricsRegistryImpl.verifyMetadataEquality(MetricsRegistryImpl.java:188)
at io.smallrye.metrics//io.smallrye.metrics.MetricsRegistryImpl.get(MetricsRegistryImpl.java:459)
at io.smallrye.metrics//io.smallrye.metrics.MetricsRegistryImpl.get(MetricsRegistryImpl.java:402)
at io.smallrye.metrics//io.smallrye.metrics.MetricsRegistryImpl.timer(MetricsRegistryImpl.java:371)
at io.smallrye.metrics//io.smallrye.metrics.setup.MetricsMetadata.registerMetrics(MetricsMetadata.java:111)
at io.smallrye.metrics//io.smallrye.metrics.setup.MetricCdiInjectionExtension.registerMetrics(MetricCdiInjectionExtension.java:186)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:95)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.injection.MethodInvocationStrategy$SpecialParamPlusBeanManagerStrategy.invoke(MethodInvocationStrategy.java:187)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:330)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:123)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:308)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:286)
at javax.enterprise.api//javax.enterprise.inject.spi.ObserverMethod.notify(ObserverMethod.java:124)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.util.Observers.notify(Observers.java:166)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ObserverNotifier.notifySyncObservers(ObserverNotifier.java:285)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ObserverNotifier.notify(ObserverNotifier.java:273)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:177)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:171)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:53)
at org.jboss.weld.core@3.1.8.Final//org.jboss.weld.bootstrap.events.AbstractDeploymentContainerEvent.fire(AbstractDeploymentContainerEvent.java:35)
扩展 standalone.xml
的 CLI 命令wildfly/bin/jboss-cli.sh -c "/extension=org.wildfly.extension.microprofile.metrics-smallrye:add()"
wildfly/bin/jboss-cli.sh -c "/subsystem=microprofile-metrics-smallrye:add()"
wildfly/bin/jboss-cli.sh -c "/extension=org.wildfly.extension.microprofile.fault-tolerance-smallrye:add()"
wildfly/bin/jboss-cli.sh -c "/subsystem=microprofile-fault-tolerance-smallrye:add()"
OIDC-解决方法(安装 keycloak 客户端)
embed-server --server-config=${server.config:standalone.xml}
batch
/subsystem=undertow/application-security-domain=other:undefine-attribute(name=security-domain)
/subsystem=undertow/application-security-domain=other:write-attribute(name=http-authentication-factory,value=keycloak-http-authentication)
run-batch
/subsystem=ejb3/application-security-domain=other:write-attribute(name=security-domain,value=KeycloakDomain)
reload
哦,我花了几个小时来解决这个问题..但是在写这篇文章 post 几分钟后,我就找到了“坏人”。
Microprofile 版本 3.3(在 Wildfly 20 上)忽略了 interface-methods 处的注释(如 @Timed
)。新的4.1版本(Wildfly 26)向他们致敬..
很简单,之后:)
边注:
如果您在 Wildfly 上部署了多个 WAR,其中一个正在使用另一个 public API,那么您将 运行 进入 hot-deployments 的问题。
我假设,在我的例子中,它发生是因为我将 Timed
-注释放在 implementation-class 而不是用作 ResteasyClient-proxy 的界面上。每次我在 WAR rest-api-defining WAR 之后部署依赖项时,我都会遇到异常:no metric mapped
。
rest-api-defining WAR 的重新部署解决了这个问题:)
通常使用匿名用户(prometheus scraper)查询 /metrics 端点,这意味着您可能必须启用 MONITOR 角色才能包含所有内容。这样,对 /metrics 的匿名访问将能够读取额外的线程数据。
^^我不确定此配置的安全影响。