Resolve "Add add operation"
What does this MR do and why?
Describe in detail what your merge request does and why.
Resolves #332713 (closed)
Add the add
operation to metrics instrumentation classes
The add operation is adding up an array of values
Current implementation
#lib/gitlab/utils/usage_data.rb
def add(*args)
return -1 if args.any?(&:negative?)
args.sum
rescue StandardError
FALLBACK
end
=> add(12, 2, 1)
=> 15
- This operation might not fit under the
DatabaseMetric
as it is not taking a relation as a parameter. - This could be a different type of instrumentation class that can handle an array of numbers on which we can have arithmetic operations.
Proposal for API for this metric and operation
BoardsCountMetric < NumbersMetric
operation :add
data { [1, 10] }
Having an instrumentation class that supports adding array of numbers will enable us to move away from using usage_data.rb
Screenshots or screen recordings
These are strongly recommended to assist reviewers and reduce the time to merge your change.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Tarun Vellishetty