Generate instrumentation files with custom metric definition generator
We introduced the Usage Ping instrumentation files !57333 (closed)
It would be helpful to have this 2 files with a basic structure generated by the custom generator https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/generators/gitlab/usage_metric_definition_generator.rb
<metric>_metric.rb
-
<metric>_metric_spec
.rb - Files should have the name with
_metric
suffix - Basic structure
# `<metric>_metric.rb`
# frozen_string_literal: true
module Gitlab
module Usage
module Metrics
module Instrumentations
class <MetricName>Metric < <RedisHLL|Generic|Database>Metric
def value
end
end
end
end
end
end
# `<metric>_metric_spec`.rb
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Usage::Metrics::Instrumentations::<MetricName>Metric do
it_behaves_like 'a correct instrumented metric value', <expected value>
end
Proposal
bundle exec rails generate gitlab:usage_metric --type=database
Where type can be database
, redis_hll
, generic
Should have --ee
option for metrics available under ee. In this case metrics should be created under ee/lib/gitlab/usage/metrics/instrumentations/
Edited by Alina Mihaila