Search in sources :

Example 1 with PrometheusMetricsTrackerFactory

use of com.zaxxer.hikari.metrics.prometheus.PrometheusMetricsTrackerFactory in project curiostack by curioswitch.

the class DatabaseModule method dataSource.

@Provides
@Singleton
static DataSource dataSource(DatabaseConfig config) {
    HikariConfig hikari = new HikariConfig();
    hikari.setJdbcUrl(config.getJdbcUrl());
    hikari.setUsername(config.getUsername());
    hikari.setPassword(config.getPassword());
    hikari.addDataSourceProperty("cachePrepStmts", true);
    hikari.addDataSourceProperty("prepStmtCacheSize", 250);
    hikari.addDataSourceProperty("prepStmtCacheSqlLimit", 2048);
    hikari.addDataSourceProperty("useServerPrepStmts", true);
    hikari.addDataSourceProperty("useLocalSessionState", true);
    hikari.addDataSourceProperty("useLocalTransactionState", true);
    hikari.addDataSourceProperty("rewriteBatchedStatements", true);
    hikari.addDataSourceProperty("cacheResultSetMetadata", true);
    hikari.addDataSourceProperty("cacheServerConfiguration", true);
    hikari.addDataSourceProperty("elideSetAutoCommits", true);
    hikari.addDataSourceProperty("maintainTimeStats", false);
    hikari.addDataSourceProperty("statementInterceptors", "brave.mysql.TracingStatementInterceptor");
    hikari.setMetricsTrackerFactory(new PrometheusMetricsTrackerFactory());
    return new HikariDataSource(hikari);
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) PrometheusMetricsTrackerFactory(com.zaxxer.hikari.metrics.prometheus.PrometheusMetricsTrackerFactory) HikariConfig(com.zaxxer.hikari.HikariConfig) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Aggregations

HikariConfig (com.zaxxer.hikari.HikariConfig)1 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1 PrometheusMetricsTrackerFactory (com.zaxxer.hikari.metrics.prometheus.PrometheusMetricsTrackerFactory)1 Provides (dagger.Provides)1 Singleton (javax.inject.Singleton)1