Commit 8f73123e authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'ci-gitlab-trace-metrics-errors' into 'master'

Rename metrics label for trace error metrics

See merge request gitlab-org/gitlab!72508
parents b38b0ad1 622be959
...@@ -73,11 +73,11 @@ module Ci ...@@ -73,11 +73,11 @@ module Ci
::Gitlab::Ci::Trace::Checksum.new(build).then do |checksum| ::Gitlab::Ci::Trace::Checksum.new(build).then do |checksum|
unless checksum.valid? unless checksum.valid?
metrics.increment_trace_operation(operation: :invalid) metrics.increment_trace_operation(operation: :invalid)
metrics.increment_error_counter(type: :chunks_invalid_checksum) metrics.increment_error_counter(error_reason: :chunks_invalid_checksum)
if checksum.corrupted? if checksum.corrupted?
metrics.increment_trace_operation(operation: :corrupted) metrics.increment_trace_operation(operation: :corrupted)
metrics.increment_error_counter(type: :chunks_invalid_size) metrics.increment_error_counter(error_reason: :chunks_invalid_size)
end end
next unless log_invalid_chunks? next unless log_invalid_chunks?
......
...@@ -143,7 +143,7 @@ The following metrics are available: ...@@ -143,7 +143,7 @@ The following metrics are available:
| `gitlab_snowplow_events_total` | Counter | 14.1 | Total number of GitLab Snowplow product intelligence events emitted | | | `gitlab_snowplow_events_total` | Counter | 14.1 | Total number of GitLab Snowplow product intelligence events emitted | |
| `gitlab_snowplow_failed_events_total` | Counter | 14.1 | Total number of GitLab Snowplow product intelligence events emission failures | | | `gitlab_snowplow_failed_events_total` | Counter | 14.1 | Total number of GitLab Snowplow product intelligence events emission failures | |
| `gitlab_snowplow_successful_events_total` | Counter | 14.1 | Total number of GitLab Snowplow product intelligence events emission successes | | | `gitlab_snowplow_successful_events_total` | Counter | 14.1 | Total number of GitLab Snowplow product intelligence events emission successes | |
| `gitlab_ci_build_trace_errors_total` | Counter | 14.4 | Total amount of different error types on a build trace | `type` | | `gitlab_ci_build_trace_errors_total` | Counter | 14.4 | Total amount of different error types on a build trace | `error_reason` |
## Metrics controlled by a feature flag ## Metrics controlled by a feature flag
......
...@@ -62,7 +62,7 @@ module Gitlab ...@@ -62,7 +62,7 @@ module Gitlab
trace_metadata.update!(remote_checksum: remote_checksum) trace_metadata.update!(remote_checksum: remote_checksum)
unless trace_metadata.remote_checksum_valid? unless trace_metadata.remote_checksum_valid?
metrics.increment_error_counter(type: :archive_invalid_checksum) metrics.increment_error_counter(error_reason: :archive_invalid_checksum)
end end
end end
......
...@@ -21,7 +21,7 @@ module Gitlab ...@@ -21,7 +21,7 @@ module Gitlab
:corrupted # malformed trace found after comparing CRC32 and size :corrupted # malformed trace found after comparing CRC32 and size
].freeze ].freeze
TRACE_ERROR_TYPES = [ TRACE_ERROR_REASONS = [
:chunks_invalid_size, # used to be :corrupted :chunks_invalid_size, # used to be :corrupted
:chunks_invalid_checksum, # used to be :invalid :chunks_invalid_checksum, # used to be :invalid
:archive_invalid_checksum # malformed trace found into object store after comparing MD5 :archive_invalid_checksum # malformed trace found into object store after comparing MD5
...@@ -39,12 +39,12 @@ module Gitlab ...@@ -39,12 +39,12 @@ module Gitlab
self.class.trace_bytes.increment({}, size.to_i) self.class.trace_bytes.increment({}, size.to_i)
end end
def increment_error_counter(type: :unknown) def increment_error_counter(error_reason: :unknown)
unless TRACE_ERROR_TYPES.include?(type) unless TRACE_ERROR_REASONS.include?(error_reason)
raise ArgumentError, "unknown error type: #{type}" raise ArgumentError, "unknown error reason: #{error_reason}"
end end
self.class.trace_errors_counter.increment(type: type) self.class.trace_errors_counter.increment(error_reason: error_reason)
end end
def observe_migration_duration(seconds) def observe_migration_duration(seconds)
......
...@@ -40,7 +40,7 @@ RSpec.describe Gitlab::Ci::Trace::Archive do ...@@ -40,7 +40,7 @@ RSpec.describe Gitlab::Ci::Trace::Archive do
expect(trace_metadata.remote_checksum).to be_nil expect(trace_metadata.remote_checksum).to be_nil
expect(metrics) expect(metrics)
.not_to have_received(:increment_error_counter) .not_to have_received(:increment_error_counter)
.with(type: :archive_invalid_checksum) .with(error_reason: :archive_invalid_checksum)
end end
end end
...@@ -56,7 +56,7 @@ RSpec.describe Gitlab::Ci::Trace::Archive do ...@@ -56,7 +56,7 @@ RSpec.describe Gitlab::Ci::Trace::Archive do
expect(trace_metadata.remote_checksum).to be_nil expect(trace_metadata.remote_checksum).to be_nil
expect(metrics) expect(metrics)
.not_to have_received(:increment_error_counter) .not_to have_received(:increment_error_counter)
.with(type: :archive_invalid_checksum) .with(error_reason: :archive_invalid_checksum)
end end
end end
...@@ -72,7 +72,7 @@ RSpec.describe Gitlab::Ci::Trace::Archive do ...@@ -72,7 +72,7 @@ RSpec.describe Gitlab::Ci::Trace::Archive do
expect(trace_metadata.remote_checksum).to eq(src_checksum) expect(trace_metadata.remote_checksum).to eq(src_checksum)
expect(metrics) expect(metrics)
.not_to have_received(:increment_error_counter) .not_to have_received(:increment_error_counter)
.with(type: :archive_invalid_checksum) .with(error_reason: :archive_invalid_checksum)
end end
context 'when the checksum does not match' do context 'when the checksum does not match' do
...@@ -92,7 +92,7 @@ RSpec.describe Gitlab::Ci::Trace::Archive do ...@@ -92,7 +92,7 @@ RSpec.describe Gitlab::Ci::Trace::Archive do
expect(trace_metadata.remote_checksum).to eq(invalid_remote_checksum) expect(trace_metadata.remote_checksum).to eq(invalid_remote_checksum)
expect(metrics) expect(metrics)
.to have_received(:increment_error_counter) .to have_received(:increment_error_counter)
.with(type: :archive_invalid_checksum) .with(error_reason: :archive_invalid_checksum)
end end
end end
end end
......
...@@ -17,23 +17,23 @@ RSpec.describe Gitlab::Ci::Trace::Metrics, :prometheus do ...@@ -17,23 +17,23 @@ RSpec.describe Gitlab::Ci::Trace::Metrics, :prometheus do
end end
describe '#increment_error_counter' do describe '#increment_error_counter' do
context 'when the operation type is known' do context 'when the error reason is known' do
it 'increments the counter' do it 'increments the counter' do
subject.increment_error_counter(type: :chunks_invalid_size) subject.increment_error_counter(error_reason: :chunks_invalid_size)
subject.increment_error_counter(type: :chunks_invalid_checksum) subject.increment_error_counter(error_reason: :chunks_invalid_checksum)
subject.increment_error_counter(type: :archive_invalid_checksum) subject.increment_error_counter(error_reason: :archive_invalid_checksum)
expect(described_class.trace_errors_counter.get(type: :chunks_invalid_size)).to eq 1 expect(described_class.trace_errors_counter.get(error_reason: :chunks_invalid_size)).to eq 1
expect(described_class.trace_errors_counter.get(type: :chunks_invalid_checksum)).to eq 1 expect(described_class.trace_errors_counter.get(error_reason: :chunks_invalid_checksum)).to eq 1
expect(described_class.trace_errors_counter.get(type: :archive_invalid_checksum)).to eq 1 expect(described_class.trace_errors_counter.get(error_reason: :archive_invalid_checksum)).to eq 1
expect(described_class.trace_errors_counter.values.count).to eq 3 expect(described_class.trace_errors_counter.values.count).to eq 3
end end
end end
context 'when the operation type is known' do context 'when the error reason is unknown' do
it 'raises an exception' do it 'raises an exception' do
expect { subject.increment_error_counter(type: :invalid_type) } expect { subject.increment_error_counter(error_reason: :invalid_type) }
.to raise_error(ArgumentError) .to raise_error(ArgumentError)
end end
end end
......
...@@ -118,7 +118,7 @@ RSpec.describe Ci::UpdateBuildStateService do ...@@ -118,7 +118,7 @@ RSpec.describe Ci::UpdateBuildStateService do
expect(metrics) expect(metrics)
.not_to have_received(:increment_error_counter) .not_to have_received(:increment_error_counter)
.with(type: :chunks_invalid_checksum) .with(error_reason: :chunks_invalid_checksum)
end end
end end
...@@ -188,7 +188,7 @@ RSpec.describe Ci::UpdateBuildStateService do ...@@ -188,7 +188,7 @@ RSpec.describe Ci::UpdateBuildStateService do
expect(metrics) expect(metrics)
.to have_received(:increment_error_counter) .to have_received(:increment_error_counter)
.with(type: :chunks_invalid_checksum) .with(error_reason: :chunks_invalid_checksum)
end end
end end
...@@ -210,11 +210,11 @@ RSpec.describe Ci::UpdateBuildStateService do ...@@ -210,11 +210,11 @@ RSpec.describe Ci::UpdateBuildStateService do
expect(metrics) expect(metrics)
.not_to have_received(:increment_error_counter) .not_to have_received(:increment_error_counter)
.with(type: :chunks_invalid_checksum) .with(error_reason: :chunks_invalid_checksum)
expect(metrics) expect(metrics)
.not_to have_received(:increment_error_counter) .not_to have_received(:increment_error_counter)
.with(type: :chunks_invalid_size) .with(error_reason: :chunks_invalid_size)
end end
context 'when using deprecated parameters' do context 'when using deprecated parameters' do
...@@ -235,11 +235,11 @@ RSpec.describe Ci::UpdateBuildStateService do ...@@ -235,11 +235,11 @@ RSpec.describe Ci::UpdateBuildStateService do
expect(metrics) expect(metrics)
.not_to have_received(:increment_error_counter) .not_to have_received(:increment_error_counter)
.with(type: :chunks_invalid_checksum) .with(error_reason: :chunks_invalid_checksum)
expect(metrics) expect(metrics)
.not_to have_received(:increment_error_counter) .not_to have_received(:increment_error_counter)
.with(type: :chunks_invalid_size) .with(error_reason: :chunks_invalid_size)
end end
end end
end end
...@@ -262,11 +262,11 @@ RSpec.describe Ci::UpdateBuildStateService do ...@@ -262,11 +262,11 @@ RSpec.describe Ci::UpdateBuildStateService do
expect(metrics) expect(metrics)
.to have_received(:increment_error_counter) .to have_received(:increment_error_counter)
.with(type: :chunks_invalid_checksum) .with(error_reason: :chunks_invalid_checksum)
expect(metrics) expect(metrics)
.to have_received(:increment_error_counter) .to have_received(:increment_error_counter)
.with(type: :chunks_invalid_size) .with(error_reason: :chunks_invalid_size)
end end
end end
...@@ -284,7 +284,7 @@ RSpec.describe Ci::UpdateBuildStateService do ...@@ -284,7 +284,7 @@ RSpec.describe Ci::UpdateBuildStateService do
expect(metrics) expect(metrics)
.to have_received(:increment_error_counter) .to have_received(:increment_error_counter)
.with(type: :chunks_invalid_checksum) .with(error_reason: :chunks_invalid_checksum)
expect(metrics) expect(metrics)
.not_to have_received(:increment_trace_operation) .not_to have_received(:increment_trace_operation)
...@@ -292,7 +292,7 @@ RSpec.describe Ci::UpdateBuildStateService do ...@@ -292,7 +292,7 @@ RSpec.describe Ci::UpdateBuildStateService do
expect(metrics) expect(metrics)
.not_to have_received(:increment_error_counter) .not_to have_received(:increment_error_counter)
.with(type: :chunks_invalid_size) .with(error_reason: :chunks_invalid_size)
end end
end end
...@@ -376,7 +376,7 @@ RSpec.describe Ci::UpdateBuildStateService do ...@@ -376,7 +376,7 @@ RSpec.describe Ci::UpdateBuildStateService do
expect(metrics) expect(metrics)
.not_to have_received(:increment_error_counter) .not_to have_received(:increment_error_counter)
.with(type: :chunks_invalid_checksum) .with(error_reason: :chunks_invalid_checksum)
end end
context 'when build pending state is outdated' do context 'when build pending state is outdated' 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