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
include Sidekiq::Worker
include DedicatedSidekiqQueue
attr_reader :targets # for metrics tags
attr_reader :metrics_tags
def initialize
@targets = {}
@metrics_tags = {}
end
def perform(project_id, user_id, oldrev, newrev, ref)
......@@ -15,10 +15,11 @@ class UpdateMergeRequestsWorker
user = User.find_by(id: user_id)
return unless user
@targets = {
@metrics_tags = {
project_id: project_id,
user_id: user_id
}
MergeRequests::RefreshService.new(project, user).execute(oldrev, newrev, ref)
end
end
---
title: Add metric tagging for sidekiq workers
merge_request: 15111
author:
type: added
......@@ -12,7 +12,7 @@ module Gitlab
trans.set(:sidekiq_queue_duration, Time.now.to_f - (message['enqueued_at'] || message['created_at'] || 0))
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
trans.add_event(:sidekiq_exception)
......
......@@ -47,11 +47,11 @@ describe Gitlab::Metrics::SidekiqMiddleware do
end
it 'tags the metrics accordingly' do
targets = { one: 1, two: 2 }
tags = { one: 1, two: 2 }
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)
.with(tag, value)
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