Skip to content

Commit

Permalink
Fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
onukristo committed Jan 26, 2024
1 parent 46b1087 commit 7ffd464
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.transferwise.common.spyql.listener.SpyqlConnectionListener;
import com.transferwise.common.spyql.listener.SpyqlDataSourceListener;
import io.micrometer.core.instrument.Gauge;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.binder.cache.CaffeineCacheMetrics;
import java.time.Duration;
Expand Down Expand Up @@ -93,7 +94,7 @@ public TableAccessStatisticsSpyqlListener(IMeterCache meterCache, ExecutorServic
this.tasQueryParsingInterceptor = tasQueryParsingInterceptor;
this.tasQueryParsingListener = tasQueryParsingListener;

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

sqlParseResultsCache = Caffeine.newBuilder().maximumWeight(entryPointsProperties.getTas().getSqlParser().getCacheSizeMib() * MIB).recordStats()
Expand Down Expand Up @@ -128,8 +129,8 @@ protected ParsedQuery parseSql(String sql, TwContext context) {
return new ParsedQuery();
}

final var result = new ParsedQuery();
final var startTimeMs = System.currentTimeMillis();
final ParsedQuery result = new ParsedQuery();
final long startTimeMs = System.currentTimeMillis();
try {
final Statements stmts = sqlParser.parse(sql, entryPointsProperties.getTas().getSqlParser().getTimeout());

Expand Down Expand Up @@ -185,7 +186,7 @@ protected ParsedQuery parseSql(String sql, TwContext context) {
)).increment();
tasQueryParsingListener.parsingFailed(sql, Duration.of(System.currentTimeMillis() - startTimeMs, ChronoUnit.MILLIS), t);
} finally {
var durationMs = System.currentTimeMillis() - startTimeMs;
long durationMs = System.currentTimeMillis() - startTimeMs;
if (durationMs > entryPointsProperties.getTas().getSqlParser().getParseDurationWarnThreshold().toMillis()) {
meterCache.counter(COUNTER_SLOW_PARSES, TagsSet.of(
EntryPointsMetrics.TAG_DATABASE, databaseName,
Expand Down Expand Up @@ -245,7 +246,7 @@ public void onStatementExecuteFailure(StatementExecuteFailureEvent event) {
}

protected void registerSql(String sql, boolean isInTransaction, boolean succeeded, long executionTimeNs) {
final var context = TwContext.current();
final TwContext context = TwContext.current();
final Tag inTransactionTag = isInTransaction ? TAG_IN_TRANSACTION_TRUE : TAG_IN_TRANSACTION_FALSE;
final Tag successTag = succeeded ? TAG_SUCCESS_TRUE : TAG_SUCCESS_FALSE;

Expand Down

0 comments on commit 7ffd464

Please sign in to comment.