Add Redis Metric instrumentation class
We currently have
We should add support for RedisMetrics in instrumentation classes
Overview
classDiagram
BaseMetric --|> DatabaseMetric
BaseMetric --|> RedisMetric
BaseMetric --|> RedisHLLMetric
BaseMetric --|> GenericMetric
This will likely require code changes similar to the following:
- Might be similar to RedisHLLMetric
- Add a new type of metric instrumentation class specific to regular Redis counters under metrics
- class should accept
options
we should be able to send event names that are set in metrics definitions - class should have a
suggested_name
- class should accept
- Examples of Redis counter are https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/usage_data_counters.rb
- Add instrumentation class for one of the Redis metrics. Update metric definition YAML file, for example
counts.source_code_pushes
- Update custom rails generator
lib/generators/gitlab/usage_metric/usage_metric_generator.rb
- Update cop https://gitlab.com/gitlab-org/gitlab/-/blob/master/rubocop/rubocop-usage-data.yml#L122
- Add tests for the new metric type class
- Add test for instrumented class
- Update tests for usage_data_metrics
- Update Metrics instrumentation docs
Note: This is a proposal might be other ways to implement this metric class.
class RedisMetric < BaseMetric
def initialize(time_frame:, options: {})
super
raise ArgumentError, "options events are required" unless metric_events.present?
end
def metric_events
options[:events]
end
def suggested_name
# ...
end
def value
redis_usage_data { Gitlab::UsageDataCounters::SourceCodeCounter.read(metric_events) }
end
end
options:
events: [pushes]
instrumentation_class: RedisMetric
Edited by Alina Mihaila