gpt4 book ai didi

spring-boot - Spring Boot 不会从类路径 (cloudwatch) 中获取 Micrometer Registry

转载 作者:行者123 更新时间:2023-12-05 06:26:39 25 4
gpt4 key购买 nike

我在类路径上使用带有 micrometer-spring-legacy:1.1.4 和 micrometer-registry-cloudwatch:1.1.4 的 Spring Boot 1.5。根据docs它应该自动获取这个注册表:

Having a dependency on micrometer-registry-{system} in your runtime classpath is enough for Spring Boot to configure the registry.

但是,当我在应用程序启动时查看已注册的 Spring bean 时,只有“simpleMeterRegistry”(我认为这是默认设置)。

为什么它不接收 CloudWatchMeterRegistry ?如何排除故障?谢谢!!!

来自日志:

Condition CompositeMeterRegistryConfiguration.MultipleNonPrimaryMeterRegistriesCondition on io.micrometer.spring.autoconfigure.CompositeMeterRegistryConfiguration did not match due to NoneNestedConditions 1 matched 1 did not; NestedCondition on CompositeMeterRegistryConfiguration.MultipleNonPrimaryMeterRegistriesCondition.SingleInjectableMeterRegistry @ConditionalOnSingleCandidate (types: io.micrometer.core.instrument.MeterRegistry; SearchStrategy: all) found a primary bean from beans 'simpleMeterRegistry'; NestedCondition on CompositeMeterRegistryConfiguration.MultipleNonPrimaryMeterRegistriesCondition.NoMeterRegistryCondition @ConditionalOnMissingBean (types: io.micrometer.core.instrument.MeterRegistry; SearchStrategy: all) found bean 'simpleMeterRegistry'

Condition DataSourcePoolMetricsAutoConfiguration.DataSourcePoolMetricsConditionalOnBeans on io.micrometer.spring.autoconfigure.jdbc.DataSourcePoolMetricsAutoConfiguration matched due to AllNestedConditions 2 matched 0 did not; NestedCondition on DataSourcePoolMetricsAutoConfiguration.DataSourcePoolMetricsConditionalOnBeans.ConditionalOnMeterRegistryBean @ConditionalOnBean (types: io.micrometer.core.instrument.MeterRegistry; SearchStrategy: all) found bean 'simpleMeterRegistry'; NestedCondition on DataSourcePoolMetricsAutoConfiguration.DataSourcePoolMetricsConditionalOnBeans.ConditionalOnDataSourceBean @ConditionalOnBean (types: javax.sql.DataSource; SearchStrategy: all) found bean 'dataSource'

Filter 'webMetricsFilter' configured successfully

更新

我看到有 CloudWatchMetricAutoConfiguration我希望它能产生 CloudWatchMetricWriter Bean 但是没有这样的bean。它还应该创建一个 AmazonCloudWatchAsync bean 但它没有 - 我们拥有的唯一“amazon”bean 是 amazonS3 .

可能的原因

我发现 micrometer-spring-legacy:1.1.4有包裹 io.micrometer.spring.autoconfigure.export.<system><system>MetricsExportAutoConfiguration , <system>Properties , <system>PropertiesConfigAdapter对于每个受支持的系统 - 但不是 CloudWatch。这些类使 *Registry 可用作 Spring bean,并且由于不支持 cloudwatch 注册表,因此不能用作 spring bean。

最佳答案

所以问题是我缺少 CloudWatch 的 micrometer-spring 集成,由于其依赖性,它不包含在 micrometer-spring-legacy 中。相反,它存在于 Spring Cloud AWS 存储库中,即 in the package org.springframework.cloud.aws.autoconfigure.metricsspring-cloud-aws-autoconfigure图书馆。

参见 spring-projects/spring-boot#11276背景。

但是 spring-cloud-aws-autoconfigure 2 需要 Boot 2.x,最新的 Boot 1.5 是 1.2.3,它缺少 CloudWatch 指标集成。因此,唯一的选择是复制、粘贴、调整其 CloudWatchMetricsExportAutoConfiguration

关于spring-boot - Spring Boot 不会从类路径 (cloudwatch) 中获取 Micrometer Registry,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55825454/

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