Skip to content
代码片段 群组 项目
未验证 提交 28b4cf43 编辑于 作者: Daniele Rossetti's avatar Daniele Rossetti 提交者: GitLab
浏览文件

Add metric to check how many groups have enabled observability features ff

上级 e239ed52
No related branches found
No related tags found
无相关合并请求
---
key_path: settings.observability_features_ff
description: Count of groups with the observability_features feature flag enabled, where the flag is disabled globally
product_group: observability
value_type: boolean
status: active
milestone: "17.3"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/159930
time_frame: none
data_source: database
data_category: optional
instrumentation_class: ObservabilityFeaturesFfMetric
performance_indicator_type: []
distribution:
- ee
tier:
- ultimate
# frozen_string_literal: true
module Gitlab
module Usage
module Metrics
module Instrumentations
class ObservabilityFeaturesFfMetric < GenericMetric
value do
# rubocop:disable Gitlab/FeatureFlagWithoutActor -- we are checking if the flag is enabled for all groups
if Feature.enabled?(:observability_features, type: :wip)
# If the flag is globally enabled, it's enabled for all groups.
# Querying for Group.count here would not be a performant option,
# Keeping it as -1 to indicate it is enabled for all.
-1
# rubocop:enable Gitlab/FeatureFlagWithoutActor
else
Feature.group_ids_for(:observability_features).length
end
end
end
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Usage::Metrics::Instrumentations::ObservabilityFeaturesFfMetric, feature_category: :product_analytics_data_management do
context 'with FF enabled globally' do
it_behaves_like 'a correct instrumented metric value', { time_frame: 'none', data_source: 'database' } do
let(:expected_value) { -1 }
end
end
# stub_feature_flags: disabled is required for Feature#group_ids_for to work correctly
context 'with FF enabled for specific groups', stub_feature_flags: false do
before do
stub_feature_flags(observability_features: create_list(:group, 3))
end
it_behaves_like 'a correct instrumented metric value', { time_frame: 'none', data_source: 'database' } do
let(:expected_value) { 3 }
end
end
context 'with FF disabled' do
before do
stub_feature_flags(observability_features: false)
end
it_behaves_like 'a correct instrumented metric value', { time_frame: 'none', data_source: 'database' } do
let(:expected_value) { 0 }
end
end
end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册