diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /lib/gitlab/database.rb | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'lib/gitlab/database.rb')
-rw-r--r-- | lib/gitlab/database.rb | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb index d88ca6d7fe3..e7df9fd27f0 100644 --- a/lib/gitlab/database.rb +++ b/lib/gitlab/database.rb @@ -2,8 +2,6 @@ module Gitlab module Database - include Gitlab::Metrics::Methods - # Minimum PostgreSQL version requirement per documentation: # https://docs.gitlab.com/ee/install/requirements.html#postgresql-requirements MINIMUM_POSTGRES_VERSION = 11 @@ -24,6 +22,7 @@ module Gitlab # https://www.postgresql.org/docs/9.2/static/datatype-numeric.html MAX_INT_VALUE = 2147483647 + MIN_INT_VALUE = -2147483648 # The max value between MySQL's TIMESTAMP and PostgreSQL's timestampz: # https://www.postgresql.org/docs/9.1/static/datatype-datetime.html @@ -50,10 +49,6 @@ module Gitlab # It does not include the default public schema EXTRA_SCHEMAS = [DYNAMIC_PARTITIONS_SCHEMA, STATIC_PARTITIONS_SCHEMA].freeze - define_histogram :gitlab_database_transaction_seconds do - docstring "Time spent in database transactions, in seconds" - end - def self.config ActiveRecord::Base.configurations[Rails.env] end @@ -80,7 +75,7 @@ module Gitlab # @deprecated def self.postgresql? - adapter_name.casecmp('postgresql').zero? + adapter_name.casecmp('postgresql') == 0 end def self.read_only? @@ -363,8 +358,11 @@ module Gitlab # observe_transaction_duration is called from ActiveRecordBaseTransactionMetrics.transaction and used to # record transaction durations. def self.observe_transaction_duration(duration_seconds) - labels = Gitlab::Metrics::Transaction.current&.labels || {} - gitlab_database_transaction_seconds.observe(labels, duration_seconds) + if current_transaction = ::Gitlab::Metrics::Transaction.current + current_transaction.observe(:gitlab_database_transaction_seconds, duration_seconds) do + docstring "Time spent in database transactions, in seconds" + end + end rescue Prometheus::Client::LabelSetValidator::LabelSetError => err # Ensure that errors in recording these metrics don't affect the operation of the application Rails.logger.error("Unable to observe database transaction duration: #{err}") # rubocop:disable Gitlab/RailsLogger |