From a6467e2e6a3fe5ea8df9f382abf0b69a729bccc7 Mon Sep 17 00:00:00 2001 From: Jordan Hasgul Date: Thu, 8 Aug 2024 17:15:31 +0800 Subject: [PATCH] add remaining filters as beans Signed-off-by: Jordan Hasgul --- .../EntryPointsAutoConfiguration.java | 26 +++++++++++++++---- ...AccessStatisticsEntryPointInterceptor.java | 1 - ...cutionStatisticsEntryPointInterceptor.java | 1 - 3 files changed, 21 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 f808502..5df4695 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 @@ -5,9 +5,11 @@ import com.transferwise.common.baseutils.meters.cache.IMeterCache; import com.transferwise.common.baseutils.meters.cache.MeterCache; import com.transferwise.common.context.TwContext; +import com.transferwise.common.entrypoints.databaseaccessstatistics.DasMeterFilter; import com.transferwise.common.entrypoints.databaseaccessstatistics.DasUnknownCallsCollector; import com.transferwise.common.entrypoints.databaseaccessstatistics.DatabaseAccessStatisticsBeanPostProcessor; import com.transferwise.common.entrypoints.databaseaccessstatistics.DatabaseAccessStatisticsEntryPointInterceptor; +import com.transferwise.common.entrypoints.executionstatistics.EsMeterFilter; import com.transferwise.common.entrypoints.executionstatistics.ExecutionStatisticsEntryPointInterceptor; import com.transferwise.common.entrypoints.tableaccessstatistics.DefaultTasParsedQueryRegistry; import com.transferwise.common.entrypoints.tableaccessstatistics.DefaultTasQueryParsingInterceptor; @@ -59,20 +61,27 @@ public DatabaseAccessStatisticsEntryPointInterceptor twEntryPointsDatabaseAccess @Bean @ConditionalOnProperty(name = "tw-entrypoints.das.enabled", havingValue = "true", matchIfMissing = true) @ConditionalOnMissingBean - public static DatabaseAccessStatisticsBeanPostProcessor twEntryPointsDatabaseAccessStatisticsBeanPostProcessor() { + public DatabaseAccessStatisticsBeanPostProcessor twEntryPointsDatabaseAccessStatisticsBeanPostProcessor() { return new DatabaseAccessStatisticsBeanPostProcessor(); } + + @Bean + @ConditionalOnProperty(name = "tw-entrypoints.das.enabled", havingValue = "true", matchIfMissing = true) + public MeterFilter twEntryPointsDatabaseAccessStatisticsMeterFilter() { + return new DasMeterFilter(); + } + @Bean @ConditionalOnProperty(name = "tw-entrypoints.tas.enabled", havingValue = "true", matchIfMissing = true) @ConditionalOnMissingBean - public static TableAccessStatisticsBeanPostProcessor twEntryPointsTableAccessStatisticsBeanPostProcessor(BeanFactory beanFactory) { + public TableAccessStatisticsBeanPostProcessor twEntryPointsTableAccessStatisticsBeanPostProcessor(BeanFactory beanFactory) { return new TableAccessStatisticsBeanPostProcessor(beanFactory); } @Bean @ConditionalOnProperty(name = "tw-entrypoints.tas.enabled", havingValue = "true", matchIfMissing = true) - public static MeterFilter twEntryPointsTableAccessStatisticsMeterFilter() { + public MeterFilter twEntryPointsTableAccessStatisticsMeterFilter() { return new TasMeterFilter(); } @@ -115,13 +124,13 @@ public TasFlywayConfigurationCustomizer tasFlywayConfigurationCustomizer() { @Bean @ConditionalOnProperty(name = "tw-entrypoints.ts.enabled", havingValue = "true", matchIfMissing = true) @ConditionalOnMissingBean - public static TransactionStatisticsBeanPostProcessor twEntryPointsTransactionStatisticsBeanPostProcessor(BeanFactory beanFactory) { + public TransactionStatisticsBeanPostProcessor twEntryPointsTransactionStatisticsBeanPostProcessor(BeanFactory beanFactory) { return new TransactionStatisticsBeanPostProcessor(beanFactory); } @Bean @ConditionalOnProperty(name = "tw-entrypoints.ts.enabled", havingValue = "true", matchIfMissing = true) - public static MeterFilter twEntryPointsTransactionStatisticsMetricsFilter() { + public MeterFilter twEntryPointsTransactionStatisticsMetricsFilter() { return new TsMeterFilter(); } @@ -134,6 +143,13 @@ public ExecutionStatisticsEntryPointInterceptor twEntryPointsExecutionStatistics return interceptor; } + @Bean + @ConditionalOnProperty(name = "tw-entrypoints.es.enabled", havingValue = "true", matchIfMissing = true) + public MeterFilter twEntryPointsExecutionStatisticsMetricsFilter() { + return new EsMeterFilter(); + } + + @Bean @ConditionalOnMissingBean(IExecutorServicesProvider.class) public DefaultExecutorServicesProvider twDefaultExecutorServicesProvider() { diff --git a/tw-entrypoints/src/main/java/com/transferwise/common/entrypoints/databaseaccessstatistics/DatabaseAccessStatisticsEntryPointInterceptor.java b/tw-entrypoints/src/main/java/com/transferwise/common/entrypoints/databaseaccessstatistics/DatabaseAccessStatisticsEntryPointInterceptor.java index 62d08a2..696dd60 100644 --- a/tw-entrypoints/src/main/java/com/transferwise/common/entrypoints/databaseaccessstatistics/DatabaseAccessStatisticsEntryPointInterceptor.java +++ b/tw-entrypoints/src/main/java/com/transferwise/common/entrypoints/databaseaccessstatistics/DatabaseAccessStatisticsEntryPointInterceptor.java @@ -35,7 +35,6 @@ public class DatabaseAccessStatisticsEntryPointInterceptor implements TwContextE public DatabaseAccessStatisticsEntryPointInterceptor(IMeterCache meterCache) { this.meterCache = meterCache; - meterCache.getMeterRegistry().config().meterFilter(new DasMeterFilter()); } @Override diff --git a/tw-entrypoints/src/main/java/com/transferwise/common/entrypoints/executionstatistics/ExecutionStatisticsEntryPointInterceptor.java b/tw-entrypoints/src/main/java/com/transferwise/common/entrypoints/executionstatistics/ExecutionStatisticsEntryPointInterceptor.java index d4c3341..30c1ce3 100644 --- a/tw-entrypoints/src/main/java/com/transferwise/common/entrypoints/executionstatistics/ExecutionStatisticsEntryPointInterceptor.java +++ b/tw-entrypoints/src/main/java/com/transferwise/common/entrypoints/executionstatistics/ExecutionStatisticsEntryPointInterceptor.java @@ -18,7 +18,6 @@ public class ExecutionStatisticsEntryPointInterceptor implements TwContextExecut public ExecutionStatisticsEntryPointInterceptor(IMeterCache meterCache) { this.meterCache = meterCache; - meterCache.getMeterRegistry().config().meterFilter(new EsMeterFilter()); } @Override