Commit a374d6c1 authored by Stan Hu's avatar Stan Hu

Merge branch '335894-simplify-metrics-statuses' into 'master'

Remove "not_used" and add "active" metric statuses.

See merge request gitlab-org/gitlab!68592
parents f8ce40e9 94feb97a
......@@ -30,7 +30,7 @@
},
"status": {
"type": ["string"],
"enum": ["data_available", "implemented", "not_used", "deprecated", "removed", "broken"]
"enum": ["active", "data_available", "implemented", "deprecated", "removed", "broken"]
},
"milestone": {
"type": ["string", "null"],
......
......@@ -37,7 +37,7 @@ Example response:
product_group: group::global search
product_category: global_search
value_type: number
status: data_available
status: active
time_frame: 28d
data_source: redis_hll
distribution:
......
......@@ -34,7 +34,7 @@ Each metric is defined in a separate YAML file consisting of a number of fields:
| `product_group` | yes | The [group](https://gitlab.com/gitlab-com/www-gitlab-com/blob/master/data/stages.yml) that owns the metric. |
| `product_category` | no | The [product category](https://gitlab.com/gitlab-com/www-gitlab-com/blob/master/data/categories.yml) for the metric. |
| `value_type` | yes | `string`; one of [`string`, `number`, `boolean`, `object`](https://json-schema.org/understanding-json-schema/reference/type.html). |
| `status` | yes | `string`; [status](#metric-statuses) of the metric, may be set to `data_available`, `implemented`, `not_used`, `deprecated`, `removed`, `broken`. |
| `status` | yes | `string`; [status](#metric-statuses) of the metric, may be set to `active`, `deprecated`, `removed`, `broken`. |
| `time_frame` | yes | `string`; may be set to a value like `7d`, `28d`, `all`, `none`. |
| `data_source` | yes | `string`; may be set to a value like `database`, `redis`, `redis_hll`, `prometheus`, `system`. |
| `data_category` | yes | `string`; [categories](#data-category) of the metric, may be set to `operational`, `optional`, `subscription`, `standard`. The default value is `optional`.|
......@@ -53,11 +53,8 @@ Each metric is defined in a separate YAML file consisting of a number of fields:
Metric definitions can have one of the following statuses:
- `data_available`: Metric data is available and used in a Sisense dashboard.
- `implemented`: Metric is implemented but data is not yet available. This is a temporary
status for newly added metrics awaiting inclusion in a new release.
- `active`: Metric is used and reports data.
- `broken`: Metric reports broken data (for example, -1 fallback), or does not report data at all. A metric marked as `broken` must also have the `repair_issue_url` attribute.
- `not_used`: Metric is not used in any dashboard.
- `deprecated`: Metric is deprecated and possibly planned to be removed.
- `removed`: Metric was removed, but it may appear in Service Ping payloads sent from instances running on older versions of GitLab.
......@@ -177,7 +174,7 @@ product_section: growth
product_stage: growth
product_group: group::product intelligence
value_type: string
status: data_available
status: active
milestone: 9.1
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/1521
time_frame: none
......
# frozen_string_literal: true
namespace :gitlab do
namespace :product_intelligence do
# @example
# bundle exec rake gitlab:product_intelligence:activate_metrics MILESTONE=14.0
desc 'GitLab | Product Intelligence | Update milestone metrics status to data_available'
task activate_metrics: :environment do
milestone = ENV['MILESTONE']
raise "Please supply the MILESTONE env var".color(:red) unless milestone.present?
Gitlab::Usage::MetricDefinition.definitions.values.each do |metric|
next if metric.attributes[:milestone] != milestone || metric.attributes[:status] != 'implemented'
metric.attributes[:status] = 'data_available'
path = metric.path
File.open(path, "w") { |file| file << metric.to_h.deep_stringify_keys.to_yaml }
end
puts "Task completed successfully"
end
end
end
......@@ -9,7 +9,7 @@ RSpec.describe Gitlab::Usage::MetricDefinition do
value_type: 'string',
product_category: 'collection',
product_stage: 'growth',
status: 'data_available',
status: 'active',
default_generation: 'generation_1',
key_path: 'uuid',
product_group: 'group::product analytics',
......@@ -127,9 +127,7 @@ RSpec.describe Gitlab::Usage::MetricDefinition do
where(:status, :skip_validation?) do
'deprecated' | true
'removed' | true
'data_available' | false
'implemented' | false
'not_used' | false
'active' | false
end
with_them do
......@@ -191,7 +189,7 @@ RSpec.describe Gitlab::Usage::MetricDefinition do
value_type: 'string',
product_category: 'collection',
product_stage: 'growth',
status: 'data_available',
status: 'active',
default_generation: 'generation_1',
key_path: 'counter.category.event',
product_group: 'group::product analytics',
......
......@@ -15,7 +15,7 @@ RSpec.describe Gitlab::Usage::Metric do
product_group: "group::plan",
product_category: "issue_tracking",
value_type: "number",
status: "data_available",
status: "active",
time_frame: "all",
data_source: "database",
instrumentation_class: "CountIssuesMetric",
......
# frozen_string_literal: true
require 'rake_helper'
RSpec.describe 'gitlab:product_intelligence:activate_metrics', :silence_stdout do
def fake_metric(key_path, milestone: 'test_milestone', status: 'implemented')
Gitlab::Usage::MetricDefinition.new(key_path, { key_path: key_path, milestone: milestone, status: status })
end
before do
Rake.application.rake_require 'tasks/gitlab/product_intelligence'
stub_warn_user_is_not_gitlab
end
describe 'activate_metrics' do
it 'fails if the MILESTONE env var is not set' do
stub_env('MILESTONE' => nil)
expect { run_rake_task('gitlab:product_intelligence:activate_metrics') }.to raise_error(RuntimeError, 'Please supply the MILESTONE env var')
end
context 'with MILESTONE env var' do
subject do
updated_metrics = []
file = double('file')
allow(file).to receive(:<<) { |contents| updated_metrics << YAML.safe_load(contents) }
allow(File).to receive(:open).and_yield(file)
stub_env('MILESTONE' => 'test_milestone')
run_rake_task('gitlab:product_intelligence:activate_metrics')
updated_metrics
end
let(:metric_definitions) do
{
matching_metric: fake_metric('matching_metric'),
matching_metric2: fake_metric('matching_metric2'),
other_status_metric: fake_metric('other_status_metric', status: 'deprecated'),
other_milestone_metric: fake_metric('other_milestone_metric', milestone: 'other_milestone')
}
end
before do
allow(Gitlab::Usage::MetricDefinition).to receive(:definitions).and_return(metric_definitions)
end
context 'with metric matching status and milestone' do
it 'updates matching_metric yaml file' do
expect(subject).to eq([
{ 'key_path' => 'matching_metric', 'milestone' => 'test_milestone', 'status' => 'data_available' },
{ 'key_path' => 'matching_metric2', 'milestone' => 'test_milestone', 'status' => 'data_available' }
])
end
end
context 'without metrics definitions' do
let(:metric_definitions) { {} }
it 'runs successfully with no updates' do
expect(subject).to eq([])
end
end
context 'without matching metrics' do
let(:metric_definitions) do
{
other_status_metric: fake_metric('other_status_metric', status: 'deprecated'),
other_milestone_metric: fake_metric('other_milestone_metric', milestone: 'other_milestone')
}
end
it 'runs successfully with no updates' do
expect(subject).to eq([])
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment