Commit e06b922e authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '341626-import-metrics-project_counter-does-not-need-to-be-public' into 'master'

Make Import Metrics project_counter private

See merge request gitlab-org/gitlab!71114
parents f566268a 4692fa0f
...@@ -19,13 +19,6 @@ module Gitlab ...@@ -19,13 +19,6 @@ module Gitlab
projects_counter.increment projects_counter.increment
end end
def projects_counter
@projects_counter ||= Gitlab::Metrics.counter(
:"#{importer}_imported_projects_total",
'The number of imported projects'
)
end
def issues_counter def issues_counter
@issues_counter ||= Gitlab::Metrics.counter( @issues_counter ||= Gitlab::Metrics.counter(
:"#{importer}_imported_issues_total", :"#{importer}_imported_issues_total",
...@@ -50,6 +43,13 @@ module Gitlab ...@@ -50,6 +43,13 @@ module Gitlab
IMPORT_DURATION_BUCKETS IMPORT_DURATION_BUCKETS
) )
end end
def projects_counter
@projects_counter ||= Gitlab::Metrics.counter(
:"#{importer}_imported_projects_total",
'The number of imported projects'
)
end
end end
end end
end end
...@@ -2,20 +2,22 @@ ...@@ -2,20 +2,22 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Gitlab::Import::Metrics do RSpec.describe Gitlab::Import::Metrics, :aggregate_failures do
let(:importer) { :test_importer } let(:importer) { :test_importer }
let(:project) { create(:project) } let(:project) { double(:project, created_at: Time.current) }
let(:histogram) { double(:histogram) } let(:histogram) { double(:histogram) }
let(:counter) { double(:counter) } let(:counter) { double(:counter) }
subject { described_class.new(importer, project) } subject { described_class.new(importer, project) }
describe '#report_import_time' do
before do before do
allow(Gitlab::Metrics).to receive(:counter) { counter } allow(Gitlab::Metrics).to receive(:counter) { counter }
allow(Gitlab::Metrics).to receive(:histogram) { histogram }
allow(counter).to receive(:increment) allow(counter).to receive(:increment)
allow(counter).to receive(:observe) end
describe '#track_finished_import' do
before do
allow(Gitlab::Metrics).to receive(:histogram) { histogram }
end end
it 'emits importer metrics' do it 'emits importer metrics' do
...@@ -37,4 +39,26 @@ RSpec.describe Gitlab::Import::Metrics do ...@@ -37,4 +39,26 @@ RSpec.describe Gitlab::Import::Metrics do
subject.track_finished_import subject.track_finished_import
end end
end end
describe '#issues_counter' do
it 'creates a counter for issues' do
expect(Gitlab::Metrics).to receive(:counter).with(
:test_importer_imported_issues_total,
'The number of imported issues'
)
subject.issues_counter
end
end
describe '#merge_requests_counter' do
it 'creates a counter for issues' do
expect(Gitlab::Metrics).to receive(:counter).with(
:test_importer_imported_merge_requests_total,
'The number of imported merge (pull) requests'
)
subject.merge_requests_counter
end
end
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