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
projects_counter.increment
end
def projects_counter
@projects_counter ||= Gitlab::Metrics.counter(
:"#{importer}_imported_projects_total",
'The number of imported projects'
)
end
def issues_counter
@issues_counter ||= Gitlab::Metrics.counter(
:"#{importer}_imported_issues_total",
......@@ -50,6 +43,13 @@ module Gitlab
IMPORT_DURATION_BUCKETS
)
end
def projects_counter
@projects_counter ||= Gitlab::Metrics.counter(
:"#{importer}_imported_projects_total",
'The number of imported projects'
)
end
end
end
end
......@@ -2,20 +2,22 @@
require 'spec_helper'
RSpec.describe Gitlab::Import::Metrics do
RSpec.describe Gitlab::Import::Metrics, :aggregate_failures do
let(:importer) { :test_importer }
let(:project) { create(:project) }
let(:project) { double(:project, created_at: Time.current) }
let(:histogram) { double(:histogram) }
let(:counter) { double(:counter) }
subject { described_class.new(importer, project) }
describe '#report_import_time' do
before do
allow(Gitlab::Metrics).to receive(:counter) { counter }
allow(counter).to receive(:increment)
end
describe '#track_finished_import' do
before do
allow(Gitlab::Metrics).to receive(:counter) { counter }
allow(Gitlab::Metrics).to receive(:histogram) { histogram }
allow(counter).to receive(:increment)
allow(counter).to receive(:observe)
end
it 'emits importer metrics' do
......@@ -37,4 +39,26 @@ RSpec.describe Gitlab::Import::Metrics do
subject.track_finished_import
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
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