Commit fc8d41f2 authored by Yorick Peterse's avatar Yorick Peterse

Change StuckImportJobsWorker to match CE

The EE version of StuckImportJobsWorker contained some additional
metrics code, which relied on deprecated methods that did not exist in
CE. Since the data is not particularly helpful, instead of trying to
make this work in CE we just remove it entirely.
parent c8249327
......@@ -10,16 +10,9 @@ class StuckImportJobsWorker
import_state_without_jid_count = mark_import_states_without_jid_as_failed!
import_state_with_jid_count = mark_import_states_with_jid_as_failed!
values = {
projects_without_jid_count: import_state_without_jid_count,
projects_with_jid_count: import_state_with_jid_count
}
Gitlab::Metrics.add_event_with_values(:stuck_import_jobs, values)
stuck_import_jobs_worker_runs_counter.increment
import_state_without_jid_metric.set({}, import_state_without_jid_count)
import_state_with_jid_metric.set({}, import_state_with_jid_count)
Gitlab::Metrics.add_event(:stuck_import_jobs,
projects_without_jid_count: import_state_without_jid_count,
projects_with_jid_count: import_state_with_jid_count)
end
private
......@@ -72,17 +65,4 @@ class StuckImportJobsWorker
def error_message
_("Import timed out. Import took longer than %{import_jobs_expiration} seconds") % { import_jobs_expiration: IMPORT_JOBS_EXPIRATION }
end
def stuck_import_jobs_worker_runs_counter
@stuck_import_jobs_worker_runs_counter ||= Gitlab::Metrics.counter(:gitlab_stuck_import_jobs_worker_runs_total,
'Stuck import jobs worker runs count')
end
def import_state_without_jid_metric
@import_state_without_jid_metric ||= Gitlab::Metrics.gauge(:gitlab_projects_without_jid, 'Projects without Job ids')
end
def import_state_with_jid_metric
@import_state_with_jid_metric ||= Gitlab::Metrics.gauge(:gitlab_projects_with_jid, 'Projects with Job ids')
end
end
......@@ -150,10 +150,6 @@ module Gitlab
current_transaction&.add_event(*args)
end
def add_event_with_values(*args)
current_transaction&.add_event_with_values(*args)
end
# Returns the prefix to use for the name of a series.
def series_prefix
@series_prefix ||= Sidekiq.server? ? 'sidekiq_' : 'rails_'
......
......@@ -79,15 +79,6 @@ module Gitlab
@metrics << Metric.new(EVENT_SERIES, { count: 1 }, tags.merge(event: event_name), :event)
end
#
# Deprecated
def add_event_with_values(event_name, values, tags = {})
@metrics << Metric.new(EVENT_SERIES,
{ count: 1 }.merge(values),
{ event: event_name }.merge(tags),
:event)
end
# Returns a MethodCall object for the given name.
def method_call_for(name, module_name, method_name)
unless method = @methods[name]
......
......@@ -155,30 +155,6 @@ describe Gitlab::Metrics::WebTransaction do
end
end
describe '#add_event_with_values' do
it 'adds a metric' do
transaction.add_event_with_values(:meow, {})
expect(transaction.metrics[0]).to be_an_instance_of(Gitlab::Metrics::Metric)
end
it 'tracks values for every event' do
transaction.add_event_with_values(:meow, { number: 10 })
metric = transaction.metrics[0]
expect(metric.values).to eq(count: 1, number: 10)
end
it 'allows tracking of custom tags' do
transaction.add_event_with_values(:meow, {}, animal: 'cat')
metric = transaction.metrics[0]
expect(metric.tags).to eq(event: :meow, animal: 'cat')
end
end
describe '#labels' do
context 'when request goes to Grape endpoint' do
before do
......
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