Commit 4ef1a8e3 authored by Kassio Borges's avatar Kassio Borges

GithubImporter: Fix import duration metric

Since `project.full_path` is user provided information, this means that
the cardinality of this metric is not bound and we can't initialize the
metric properly. Because the metric isn't initialized and the project is
included we can never track the rate past 1 for each counter in the
histogram: A histogram is a series of counters, in total there are
`number of buckets * number of label combinations` counters that
Prometheus uses to calculate the quantiles. For that, we're using a
[rate](https://prometheus.io/docs/prometheus/latest/querying/functions/#rate),
which is the increase of a counter in seconds.

Related to: https://gitlab.com/gitlab-org/gitlab/-/issues/341958

Changelog: fixed
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/74610
parent ec60abcf
......@@ -69,11 +69,7 @@ module Gitlab
end
def observe_histogram
if project.github_import?
duration_histogram.observe({ project: project.full_path }, duration)
else
duration_histogram.observe({ importer: importer }, duration)
end
duration_histogram.observe({ importer: importer }, duration)
end
def track_finish_metric
......
......@@ -94,20 +94,6 @@ RSpec.describe Gitlab::Import::Metrics, :aggregate_failures do
expect(histogram).to have_received(:observe).with({ importer: :test_importer }, anything)
end
end
context 'when project is a github import' do
before do
project.import_type = 'github'
end
it 'emits importer metrics' do
expect(subject).to receive(:track_usage_event).with(:github_import_project_success, project.id)
subject.track_finished_import
expect(histogram).to have_received(:observe).with({ project: project.full_path }, anything)
end
end
end
describe '#issues_counter' 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