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

FINERACT-2081: Make MeterRegistry optional #4259

Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.zaxxer.hikari.HikariConfig;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.micrometer.core.instrument.MeterRegistry;
import java.util.Optional;
import javax.sql.DataSource;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -53,7 +54,7 @@ public class DataSourcePerTenantServiceFactory {
private final HikariDataSourceFactory hikariDataSourceFactory;

private final DatabasePasswordEncryptor databasePasswordEncryptor;
private final MeterRegistry meterRegistry;
private final Optional<MeterRegistry> meterRegistry;

@SuppressFBWarnings(value = "SLF4J_SIGN_ONLY_FORMAT")
public DataSource createNewDataSourceFor(FineractPlatformTenant tenant, FineractPlatformTenantConnection tenantConnection) {
Expand Down Expand Up @@ -97,7 +98,9 @@ public DataSource createNewDataSourceFor(FineractPlatformTenant tenant, Fineract

// https://github.com/brettwooldridge/HikariCP/wiki/MBean-(JMX)-Monitoring-and-Management
config.setRegisterMbeans(true);
config.setMetricsTrackerFactory(new TenantConnectionPoolMetricsTrackerFactory(tenant.getTenantIdentifier(), meterRegistry));
meterRegistry.ifPresent(registry -> {
config.setMetricsTrackerFactory(new TenantConnectionPoolMetricsTrackerFactory(tenant.getTenantIdentifier(), registry));
});

// https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration
// These are the properties for each Tenant DB; the same configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import io.micrometer.core.instrument.MeterRegistry;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.util.Optional;
import java.util.Properties;
import javax.sql.DataSource;
import org.apache.fineract.infrastructure.core.config.FineractProperties;
Expand Down Expand Up @@ -113,6 +115,9 @@ public class DataSourcePerTenantServiceFactoryTest {
@Mock
private DatabasePasswordEncryptor databasePasswordEncryptor;

@Mock
private Optional<MeterRegistry> meterRegistry;

@InjectMocks
private DataSourcePerTenantServiceFactory underTest;

Expand Down
Loading