2020-09-09 12:08:22 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
class Trace
|
|
|
|
class Metrics
|
|
|
|
extend Gitlab::Utils::StrongMemoize
|
|
|
|
|
2020-09-15 18:09:43 +00:00
|
|
|
OPERATIONS = [:appended, :mutated, :overwrite, :accepted,
|
|
|
|
:finalized, :discarded, :flaky].freeze
|
2020-09-09 12:08:22 +00:00
|
|
|
|
|
|
|
def increment_trace_operation(operation: :unknown)
|
|
|
|
unless OPERATIONS.include?(operation)
|
|
|
|
raise ArgumentError, 'unknown trace operation'
|
|
|
|
end
|
|
|
|
|
|
|
|
self.class.trace_operations.increment(operation: operation)
|
|
|
|
end
|
|
|
|
|
|
|
|
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
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|