Skip to content
代码片段 群组 项目
未验证 提交 cfe82ee9 编辑于 作者: Laura Montemayor's avatar Laura Montemayor
浏览文件

Merge branch '411394/Add_component_usage_tracking' into 'master'

No related branches found
No related tags found
无相关合并请求
---
key_path: redis_hll_counters.pipeline_authoring.count_cicd_component_usage_monthly
description: Monthly count of CI/CD component usage
product_section: ops
product_stage: verify
product_group: pipeline_authoring
value_type: number
status: active
milestone: "16.4"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/129016
time_frame: 28d
data_source: redis_hll
data_category: optional
instrumentation_class: RedisHLLMetric
performance_indicator_type: []
distribution:
- ce
tier:
- premium
- ultimate
options:
events:
- cicd_component_usage
---
key_path: redis_hll_counters.pipeline_authoring.count_cicd_component_usage_weekly
description: Weekly count of CI/CD component usage
product_section: ops
product_stage: verify
product_group: pipeline_authoring
value_type: number
status: active
milestone: "16.4"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/129016
time_frame: 7d
data_source: redis_hll
data_category: optional
instrumentation_class: RedisHLLMetric
performance_indicator_type: []
distribution:
- ce
tier:
- premium
- ultimate
options:
events:
- cicd_component_usage
......@@ -18,6 +18,8 @@ def initialize(params, context)
def content
return unless component_result.success?
::Gitlab::UsageDataCounters::HLLRedisCounter.track_event('cicd_component_usage', values: context.user.id)
component_result.payload.fetch(:content)
end
strong_memoize_attr :content
......
......@@ -120,6 +120,41 @@
end
end
describe '#content' do
context 'when component is valid' do
let(:content) do
<<~COMPONENT
job:
script: echo
COMPONENT
end
let(:response) do
ServiceResponse.success(payload: {
content: content,
path: instance_double(::Gitlab::Ci::Components::InstancePath, project: project, sha: '12345')
})
end
it 'tracks the event' do
expect(::Gitlab::UsageDataCounters::HLLRedisCounter).to receive(:track_event).with('cicd_component_usage',
values: external_resource.context.user.id)
external_resource.content
end
end
context 'when component is invalid' do
let(:content) { 'the-content' }
it 'does not track the event' do
expect(::Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event)
external_resource.content
end
end
end
describe '#metadata' do
subject(:metadata) { external_resource.metadata }
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册