Commit 2b7e03cf authored by micael.bergeron's avatar micael.bergeron

reword `targets` to `metric tags`

add changelog
parent 7799a9bc
...@@ -2,10 +2,10 @@ class UpdateMergeRequestsWorker ...@@ -2,10 +2,10 @@ class UpdateMergeRequestsWorker
include Sidekiq::Worker include Sidekiq::Worker
include DedicatedSidekiqQueue include DedicatedSidekiqQueue
attr_reader :targets # for metrics tags attr_reader :metrics_tags
def initialize def initialize
@targets = {} @metrics_tags = {}
end end
def perform(project_id, user_id, oldrev, newrev, ref) def perform(project_id, user_id, oldrev, newrev, ref)
...@@ -15,10 +15,11 @@ class UpdateMergeRequestsWorker ...@@ -15,10 +15,11 @@ class UpdateMergeRequestsWorker
user = User.find_by(id: user_id) user = User.find_by(id: user_id)
return unless user return unless user
@targets = { @metrics_tags = {
project_id: project_id, project_id: project_id,
user_id: user_id user_id: user_id
} }
MergeRequests::RefreshService.new(project, user).execute(oldrev, newrev, ref) MergeRequests::RefreshService.new(project, user).execute(oldrev, newrev, ref)
end end
end end
---
title: Add metric tagging for sidekiq workers
merge_request: 15111
author:
type: added
...@@ -12,7 +12,7 @@ module Gitlab ...@@ -12,7 +12,7 @@ module Gitlab
trans.set(:sidekiq_queue_duration, Time.now.to_f - (message['enqueued_at'] || message['created_at'] || 0)) trans.set(:sidekiq_queue_duration, Time.now.to_f - (message['enqueued_at'] || message['created_at'] || 0))
trans.run { yield } trans.run { yield }
worker.targets.each { |name, target| trans.add_tag(name, target) } if worker.respond_to?(:targets) worker.metrics_tags.each { |tag, value| trans.add_tag(tag, value) } if worker.respond_to?(:metrics_tags)
rescue Exception => error # rubocop: disable Lint/RescueException rescue Exception => error # rubocop: disable Lint/RescueException
trans.add_event(:sidekiq_exception) trans.add_event(:sidekiq_exception)
......
...@@ -47,11 +47,11 @@ describe Gitlab::Metrics::SidekiqMiddleware do ...@@ -47,11 +47,11 @@ describe Gitlab::Metrics::SidekiqMiddleware do
end end
it 'tags the metrics accordingly' do it 'tags the metrics accordingly' do
targets = { one: 1, two: 2 } tags = { one: 1, two: 2 }
worker = double(:worker, class: double(:class, name: 'TestWorker')) worker = double(:worker, class: double(:class, name: 'TestWorker'))
allow(worker).to receive(:targets).and_return(targets) allow(worker).to receive(:metrics_tags).and_return(tags)
targets.each do |tag, value| tags.each do |tag, value|
expect_any_instance_of(Gitlab::Metrics::Transaction).to receive(:add_tag) expect_any_instance_of(Gitlab::Metrics::Transaction).to receive(:add_tag)
.with(tag, value) .with(tag, value)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment