Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APPENG-927] Yield MetricFilter's as Beans for Spring to apply to MeterRegistry via post processing #46

Merged
merged 8 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.16.3] - 2024-08-7

### Changed

* MeterFilter's applied by the library are no longer explicitly applied and are instead

## [2.16.2] - 2024-07-16

### Added
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=2.16.2
version=2.16.3
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@
import com.transferwise.common.entrypoints.tableaccessstatistics.DefaultTasQueryParsingListener;
import com.transferwise.common.entrypoints.tableaccessstatistics.TableAccessStatisticsBeanPostProcessor;
import com.transferwise.common.entrypoints.tableaccessstatistics.TasFlywayConfigurationCustomizer;
import com.transferwise.common.entrypoints.tableaccessstatistics.TasMeterFilter;
import com.transferwise.common.entrypoints.tableaccessstatistics.TasParsedQueryRegistry;
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;
Expand Down Expand Up @@ -67,13 +70,20 @@ public static TableAccessStatisticsBeanPostProcessor twEntryPointsTableAccessSta
return new TableAccessStatisticsBeanPostProcessor(beanFactory);
}

@Bean
@ConditionalOnProperty(name = "tw-entrypoints.tas.enabled", havingValue = "true", matchIfMissing = true)
public static MeterFilter twEntryPointsTableAccessStatisticsMeterFilter() {
jordanhasgul marked this conversation as resolved.
Show resolved Hide resolved
return new TasMeterFilter();
}

@Bean
@ConditionalOnProperty(name = "tw-entrypoints.tas.enabled", havingValue = "true", matchIfMissing = true)
@ConditionalOnMissingBean(TasParsedQueryRegistry.class)
public DefaultTasParsedQueryRegistry twEntryPointsTableAccessStatisticsParsedQueryRegistry() {
return new DefaultTasParsedQueryRegistry();
}


@Bean
@ConditionalOnProperty(name = "tw-entrypoints.tas.enabled", havingValue = "true", matchIfMissing = true)
@ConditionalOnMissingBean(TasQueryParsingInterceptor.class)
Expand Down Expand Up @@ -109,6 +119,12 @@ public static TransactionStatisticsBeanPostProcessor twEntryPointsTransactionSta
return new TransactionStatisticsBeanPostProcessor(beanFactory);
}

@Bean
@ConditionalOnProperty(name = "tw-entrypoints.ts.enabled", havingValue = "true", matchIfMissing = true)
public static MeterFilter twEntryPointsTransactionStatisticsMetricsFilter() {
return new TsMeterFilter();
}

@Bean
@ConditionalOnProperty(name = "tw-entrypoints.es.enabled", havingValue = "true", matchIfMissing = true)
@ConditionalOnMissingBean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void setup() {
}

@Test
public void successfullTransactionGetsRegisterd() {
public void successfulTransactionGetsRegistered() {
transactionsHelper.withTransaction().call(() -> {
jdbcTemplate.update("update table_a set version=2");
return null;
Expand Down Expand Up @@ -73,7 +73,7 @@ public void successfullTransactionGetsRegisterd() {
}

@Test
public void rollbackGetsRegisterd() {
public void rollbackGetsRegistered() {
try {
transactionsHelper.withTransaction().call(() -> {
jdbcTemplate.update("update table_a set version=2");
Expand Down
10 changes: 6 additions & 4 deletions tw-entrypoints-starter/src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ tw-graceful-shutdown:

---
spring:
datasource:
embedded:
mysql:
port: 3306
enable: true
config:
activate:
on-profile: continuous-integration
embedded:
mysql:
port: 3306
on-profile: continuous-integration
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public TableAccessStatisticsSpyqlListener(IMeterCache meterCache, ExecutorServic
this.tasQueryParsingListener = tasQueryParsingListener;

final MeterRegistry meterRegistry = meterCache.getMeterRegistry();
meterRegistry.config().meterFilter(new TasMeterFilter());

sqlParseResultsCache = Caffeine.newBuilder().maximumWeight(entryPointsProperties.getTas().getSqlParser().getCacheSizeMib() * MIB).recordStats()
.executor(executorService)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public class TransactionsStatisticsSpyqlListener implements SpyqlDataSourceListe
public TransactionsStatisticsSpyqlListener(IMeterCache meterCache, String databaseName) {
this.dbTag = Tag.of(EntryPointsMetrics.TAG_DATABASE, databaseName);
this.meterCache = meterCache;
meterCache.getMeterRegistry().config().meterFilter(new TsMeterFilter());
}

@Override
Expand Down
Loading