Class: Gitlab::Ci::Trace::Metrics
- Inherits:
-
Object
- Object
- Gitlab::Ci::Trace::Metrics
- Extended by:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/ci/trace/metrics.rb
Constant Summary collapse
- OPERATIONS =
[ :appended, # new trace data has been written to a chunk :streamed, # new trace data has been sent by a runner :chunked, # new trace chunk has been created :mutated, # trace has been mutated when removing secrets :accepted, # scheduled chunks for migration and responded with 202 :finalized, # all live build trace chunks have been persisted :discarded, # failed to persist live chunks before timeout :conflict, # runner has sent unrecognized build state details :locked, # build trace has been locked by a different mechanism :stalled, # failed to migrate chunk due to a worker duplication :invalid, # invalid build trace has been detected using CRC32 :corrupted # malformed trace found after comparing CRC32 and size ].freeze
- 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 ].freeze
Class Method Summary collapse
- .finalize_histogram ⇒ Object
- .trace_bytes ⇒ Object
- .trace_errors_counter ⇒ Object
- .trace_operations ⇒ Object
Instance Method Summary collapse
- #increment_error_counter(error_reason: :unknown) ⇒ Object
- #increment_trace_bytes(size) ⇒ Object
- #increment_trace_operation(operation: :unknown) ⇒ Object
- #observe_migration_duration(seconds) ⇒ Object
Class Method Details
.finalize_histogram ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/gitlab/ci/trace/metrics.rb', line 72 def self.finalize_histogram strong_memoize(:finalize_histogram) do name = :gitlab_ci_trace_finalize_duration_seconds comment = 'Duration of build trace chunks migration to object storage' buckets = [0.1, 0.5, 1.0, 2.0, 3.0, 5.0, 7.0, 10.0, 20.0, 30.0, 60.0, 300.0] labels = {} ::Gitlab::Metrics.histogram(name, comment, labels, buckets) end end |
.trace_bytes ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/gitlab/ci/trace/metrics.rb', line 63 def self.trace_bytes strong_memoize(:trace_bytes) do name = :gitlab_ci_trace_bytes_total comment = 'Total amount of build trace bytes transferred' Gitlab::Metrics.counter(name, comment) end end |
.trace_errors_counter ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/gitlab/ci/trace/metrics.rb', line 83 def self.trace_errors_counter strong_memoize(:trace_errors_counter) do name = :gitlab_ci_build_trace_errors_total comment = 'Total amount of different error types on a build trace' Gitlab::Metrics.counter(name, comment) end end |
.trace_operations ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/gitlab/ci/trace/metrics.rb', line 54 def self.trace_operations strong_memoize(:trace_operations) do name = :gitlab_ci_trace_operations_total comment = 'Total amount of different operations on a build trace' Gitlab::Metrics.counter(name, comment) end end |
Instance Method Details
#increment_error_counter(error_reason: :unknown) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/gitlab/ci/trace/metrics.rb', line 42 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(error_reason: error_reason) end |
#increment_trace_bytes(size) ⇒ Object
38 39 40 |
# File 'lib/gitlab/ci/trace/metrics.rb', line 38 def increment_trace_bytes(size) self.class.trace_bytes.increment({}, size.to_i) end |
#increment_trace_operation(operation: :unknown) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/gitlab/ci/trace/metrics.rb', line 30 def increment_trace_operation(operation: :unknown) unless OPERATIONS.include?(operation) raise ArgumentError, "unknown trace operation: #{operation}" end self.class.trace_operations.increment(operation: operation) end |
#observe_migration_duration(seconds) ⇒ Object
50 51 52 |
# File 'lib/gitlab/ci/trace/metrics.rb', line 50 def observe_migration_duration(seconds) self.class.finalize_histogram.observe({}, seconds.to_f) end |