From a4aec2df15766ae2e3d5630e48161ccb7ae69f4b Mon Sep 17 00:00:00 2001 From: Jordan Hasgul Date: Wed, 7 Aug 2024 22:03:54 +0800 Subject: [PATCH] just supply beans of meterfilter Signed-off-by: Jordan Hasgul --- .../EntryPointsAutoConfiguration.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tw-entrypoints-starter/src/main/java/com/transferwise/common/entrypoints/EntryPointsAutoConfiguration.java b/tw-entrypoints-starter/src/main/java/com/transferwise/common/entrypoints/EntryPointsAutoConfiguration.java index 351c83b..b7c983b 100644 --- a/tw-entrypoints-starter/src/main/java/com/transferwise/common/entrypoints/EntryPointsAutoConfiguration.java +++ b/tw-entrypoints-starter/src/main/java/com/transferwise/common/entrypoints/EntryPointsAutoConfiguration.java @@ -19,8 +19,8 @@ import com.transferwise.common.entrypoints.tableaccessstatistics.TasQueryParsingInterceptor; import com.transferwise.common.entrypoints.tableaccessstatistics.TasQueryParsingListener; import com.transferwise.common.entrypoints.transactionstatistics.TransactionStatisticsBeanPostProcessor; -import com.transferwise.common.entrypoints.transactionstatistics.TsMeterFilter; import io.micrometer.core.instrument.MeterRegistry; +import io.micrometer.core.instrument.config.MeterFilter; import org.springframework.beans.factory.BeanFactory; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -65,12 +65,16 @@ public static DatabaseAccessStatisticsBeanPostProcessor twEntryPointsDatabaseAcc @Bean @ConditionalOnProperty(name = "tw-entrypoints.tas.enabled", havingValue = "true", matchIfMissing = true) @ConditionalOnMissingBean - public static TableAccessStatisticsBeanPostProcessor twEntryPointsTableAccessStatisticsBeanPostProcessor(BeanFactory beanFactory, - MeterRegistry meterRegistry) { - meterRegistry.config().meterFilter(new TasMeterFilter()); + public static TableAccessStatisticsBeanPostProcessor twEntryPointsTableAccessStatisticsBeanPostProcessor(BeanFactory beanFactory) { return new TableAccessStatisticsBeanPostProcessor(beanFactory); } + @Bean + @ConditionalOnProperty(name = "tw-entrypoints.tas.enabled", havingValue = "true", matchIfMissing = true) + public static MeterFilter twEntryPointsTableAccessStatisticsMeterFilter() { + return new TasMeterFilter(); + } + @Bean @ConditionalOnProperty(name = "tw-entrypoints.tas.enabled", havingValue = "true", matchIfMissing = true) @ConditionalOnMissingBean(TasParsedQueryRegistry.class) @@ -78,6 +82,7 @@ public DefaultTasParsedQueryRegistry twEntryPointsTableAccessStatisticsParsedQue return new DefaultTasParsedQueryRegistry(); } + @Bean @ConditionalOnProperty(name = "tw-entrypoints.tas.enabled", havingValue = "true", matchIfMissing = true) @ConditionalOnMissingBean(TasQueryParsingInterceptor.class) @@ -109,12 +114,16 @@ public TasFlywayConfigurationCustomizer tasFlywayConfigurationCustomizer() { @Bean @ConditionalOnProperty(name = "tw-entrypoints.ts.enabled", havingValue = "true", matchIfMissing = true) @ConditionalOnMissingBean - public static TransactionStatisticsBeanPostProcessor twEntryPointsTransactionStatisticsBeanPostProcessor(BeanFactory beanFactory, - MeterRegistry meterRegistry) { - meterRegistry.config().meterFilter(new TsMeterFilter()); + public static TransactionStatisticsBeanPostProcessor twEntryPointsTransactionStatisticsBeanPostProcessor(BeanFactory beanFactory) { return new TransactionStatisticsBeanPostProcessor(beanFactory); } + @Bean + @ConditionalOnProperty(name = "tw-entrypoints.ts.enabled", havingValue = "true", matchIfMissing = true) + public static MeterFilter twEntryPointsTransactionStatisticsMetricsFilter() { + return new TasMeterFilter(); + } + @Bean @ConditionalOnProperty(name = "tw-entrypoints.es.enabled", havingValue = "true", matchIfMissing = true) @ConditionalOnMissingBean