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
::Gitlab::Ci::Trace::Checksum.new(build).then do |checksum|
unless checksum.valid?
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?
metrics.increment_trace_operation(operation: :corrupted)
metrics.increment_error_counter(type: :chunks_invalid_size)
metrics.increment_error_counter(error_reason: :chunks_invalid_size)
end
next unless log_invalid_chunks?
......
......@@ -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_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_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
......
......@@ -62,7 +62,7 @@ module Gitlab
trace_metadata.update!(remote_checksum: remote_checksum)
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
......
......@@ -21,7 +21,7 @@ module Gitlab
:corrupted # malformed trace found after comparing CRC32 and size
].freeze
TRACE_ERROR_TYPES = [
TRACE_ERROR_REASONS = [
:chunks_invalid_size, # used to be :corrupted
:chunks_invalid_checksum, # used to be :invalid
:archive_invalid_checksum # malformed trace found into object store after comparing MD5
......@@ -39,12 +39,12 @@ module Gitlab
self.class.trace_bytes.increment({}, size.to_i)
end
def increment_error_counter(type: :unknown)
unless TRACE_ERROR_TYPES.include?(type)
raise ArgumentError, "unknown error type: #{type}"
def increment_error_counter(error_reason: :unknown)
unless TRACE_ERROR_REASONS.include?(error_reason)
raise ArgumentError, "unknown error reason: #{error_reason}"
end
self.class.trace_errors_counter.increment(type: type)
self.class.trace_errors_counter.increment(error_reason: error_reason)
end
def observe_migration_duration(seconds)
......
......@@ -40,7 +40,7 @@ RSpec.describe Gitlab::Ci::Trace::Archive do
expect(trace_metadata.remote_checksum).to be_nil
expect(metrics)
.not_to have_received(:increment_error_counter)
.with(type: :archive_invalid_checksum)
.with(error_reason: :archive_invalid_checksum)
end
end
......@@ -56,7 +56,7 @@ RSpec.describe Gitlab::Ci::Trace::Archive do
expect(trace_metadata.remote_checksum).to be_nil
expect(metrics)
.not_to have_received(:increment_error_counter)
.with(type: :archive_invalid_checksum)
.with(error_reason: :archive_invalid_checksum)
end
end
......@@ -72,7 +72,7 @@ RSpec.describe Gitlab::Ci::Trace::Archive do
expect(trace_metadata.remote_checksum).to eq(src_checksum)
expect(metrics)
.not_to have_received(:increment_error_counter)
.with(type: :archive_invalid_checksum)
.with(error_reason: :archive_invalid_checksum)
end
context 'when the checksum does not match' do
......@@ -92,7 +92,7 @@ RSpec.describe Gitlab::Ci::Trace::Archive do
expect(trace_metadata.remote_checksum).to eq(invalid_remote_checksum)
expect(metrics)
.to have_received(:increment_error_counter)
.with(type: :archive_invalid_checksum)
.with(error_reason: :archive_invalid_checksum)
end
end
end
......
......@@ -17,23 +17,23 @@ RSpec.describe Gitlab::Ci::Trace::Metrics, :prometheus do
end
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
subject.increment_error_counter(type: :chunks_invalid_size)
subject.increment_error_counter(type: :chunks_invalid_checksum)
subject.increment_error_counter(type: :archive_invalid_checksum)
subject.increment_error_counter(error_reason: :chunks_invalid_size)
subject.increment_error_counter(error_reason: :chunks_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(type: :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: :chunks_invalid_size)).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(error_reason: :archive_invalid_checksum)).to eq 1
expect(described_class.trace_errors_counter.values.count).to eq 3
end
end
context 'when the operation type is known' do
context 'when the error reason is unknown' 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)
end
end
......
......@@ -118,7 +118,7 @@ RSpec.describe Ci::UpdateBuildStateService do
expect(metrics)
.not_to have_received(:increment_error_counter)
.with(type: :chunks_invalid_checksum)
.with(error_reason: :chunks_invalid_checksum)
end
end
......@@ -188,7 +188,7 @@ RSpec.describe Ci::UpdateBuildStateService do
expect(metrics)
.to have_received(:increment_error_counter)
.with(type: :chunks_invalid_checksum)
.with(error_reason: :chunks_invalid_checksum)
end
end
......@@ -210,11 +210,11 @@ RSpec.describe Ci::UpdateBuildStateService do
expect(metrics)
.not_to have_received(:increment_error_counter)
.with(type: :chunks_invalid_checksum)
.with(error_reason: :chunks_invalid_checksum)
expect(metrics)
.not_to have_received(:increment_error_counter)
.with(type: :chunks_invalid_size)
.with(error_reason: :chunks_invalid_size)
end
context 'when using deprecated parameters' do
......@@ -235,11 +235,11 @@ RSpec.describe Ci::UpdateBuildStateService do
expect(metrics)
.not_to have_received(:increment_error_counter)
.with(type: :chunks_invalid_checksum)
.with(error_reason: :chunks_invalid_checksum)
expect(metrics)
.not_to have_received(:increment_error_counter)
.with(type: :chunks_invalid_size)
.with(error_reason: :chunks_invalid_size)
end
end
end
......@@ -262,11 +262,11 @@ RSpec.describe Ci::UpdateBuildStateService do
expect(metrics)
.to have_received(:increment_error_counter)
.with(type: :chunks_invalid_checksum)
.with(error_reason: :chunks_invalid_checksum)
expect(metrics)
.to have_received(:increment_error_counter)
.with(type: :chunks_invalid_size)
.with(error_reason: :chunks_invalid_size)
end
end
......@@ -284,7 +284,7 @@ RSpec.describe Ci::UpdateBuildStateService do
expect(metrics)
.to have_received(:increment_error_counter)
.with(type: :chunks_invalid_checksum)
.with(error_reason: :chunks_invalid_checksum)
expect(metrics)
.not_to have_received(:increment_trace_operation)
......@@ -292,7 +292,7 @@ RSpec.describe Ci::UpdateBuildStateService do
expect(metrics)
.not_to have_received(:increment_error_counter)
.with(type: :chunks_invalid_size)
.with(error_reason: :chunks_invalid_size)
end
end
......@@ -376,7 +376,7 @@ RSpec.describe Ci::UpdateBuildStateService do
expect(metrics)
.not_to have_received(:increment_error_counter)
.with(type: :chunks_invalid_checksum)
.with(error_reason: :chunks_invalid_checksum)
end
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