diff --git a/lib/pact_broker/config/runtime_configuration_database_methods.rb b/lib/pact_broker/config/runtime_configuration_database_methods.rb index 4e8567de1..92d7a3cc3 100644 --- a/lib/pact_broker/config/runtime_configuration_database_methods.rb +++ b/lib/pact_broker/config/runtime_configuration_database_methods.rb @@ -18,6 +18,7 @@ def self.included(anyway_config) database_sslmode: nil, sql_log_level: :debug, sql_log_warn_duration: 5, + sql_enable_caller_logging: false, database_max_connections: nil, database_pool_timeout: 5, database_connect_max_retries: 0, @@ -36,6 +37,7 @@ def database_configuration encoding: "utf8", sslmode: database_sslmode, sql_log_level: sql_log_level, + enable_caller_logging: sql_enable_caller_logging, log_warn_duration: sql_log_warn_duration, max_connections: database_max_connections, pool_timeout: database_pool_timeout, diff --git a/lib/pact_broker/initializers/database_connection.rb b/lib/pact_broker/initializers/database_connection.rb index 4055f7d7d..7ac224310 100644 --- a/lib/pact_broker/initializers/database_connection.rb +++ b/lib/pact_broker/initializers/database_connection.rb @@ -9,6 +9,7 @@ def self.create_database_connection(config, logger = nil) sequel_config = config.dup max_retries = sequel_config.delete(:connect_max_retries) || 0 connection_validation_timeout = config.delete(:connection_validation_timeout) + enable_caller_logging = config.delete(:enable_caller_logging) configure_logger(sequel_config, logger) create_sqlite_database_dir(config) @@ -18,7 +19,7 @@ def self.create_database_connection(config, logger = nil) logger&.info "Connected to database #{sequel_config[:database]}" - configure_connection(connection, connection_validation_timeout) + configure_connection(connection, connection_validation_timeout, enable_caller_logging) end private_class_method def self.with_retries(max_retries, logger) @@ -72,8 +73,9 @@ def self.create_database_connection(config, logger = nil) # when databases are restarted and connections are killed. This has a performance # penalty, so consider increasing this timeout if building a frequently accessed service. - private_class_method def self.configure_connection(connection, connection_validation_timeout) + private_class_method def self.configure_connection(connection, connection_validation_timeout, enable_caller_logging) connection.extension(:connection_validator) + connection.extension(:caller_logging) if enable_caller_logging connection.pool.connection_validation_timeout = connection_validation_timeout if connection_validation_timeout connection end