diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
commit | 311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch) | |
tree | 07e7870bca8aed6d61fdcc810731c50d2c40af47 /lib/gitlab/metrics/background_transaction.rb | |
parent | 27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff) |
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'lib/gitlab/metrics/background_transaction.rb')
-rw-r--r-- | lib/gitlab/metrics/background_transaction.rb | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/gitlab/metrics/background_transaction.rb b/lib/gitlab/metrics/background_transaction.rb index a1fabe75a97..54095461dd4 100644 --- a/lib/gitlab/metrics/background_transaction.rb +++ b/lib/gitlab/metrics/background_transaction.rb @@ -2,14 +2,17 @@ module Gitlab module Metrics + # Exclusive transaction-type metrics for background jobs (Sidekiq). One + # instance of this class is created for each job going through the Sidekiq + # metric middleware. Any metrics dispatched with this instance include + # metadata such as endpoint_id, queue, and feature category. class BackgroundTransaction < Transaction - # Separate web transaction instance and background transaction instance - BACKGROUND_THREAD_KEY = :_gitlab_metrics_background_transaction - BACKGROUND_BASE_LABEL_KEYS = %i(endpoint_id feature_category).freeze + THREAD_KEY = :_gitlab_metrics_background_transaction + BASE_LABEL_KEYS = %i(queue endpoint_id feature_category).freeze class << self def current - Thread.current[BACKGROUND_THREAD_KEY] + Thread.current[THREAD_KEY] end def prometheus_metric(name, type, &block) @@ -19,17 +22,17 @@ module Gitlab evaluate(&block) # always filter sensitive labels and merge with base ones - label_keys BACKGROUND_BASE_LABEL_KEYS | (label_keys - ::Gitlab::Metrics::Transaction::FILTERED_LABEL_KEYS) + label_keys BASE_LABEL_KEYS | (label_keys - ::Gitlab::Metrics::Transaction::FILTERED_LABEL_KEYS) end end end def run - Thread.current[BACKGROUND_THREAD_KEY] = self + Thread.current[THREAD_KEY] = self yield ensure - Thread.current[BACKGROUND_THREAD_KEY] = nil + Thread.current[THREAD_KEY] = nil end def labels |