diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 18:40:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 18:40:28 +0300 |
commit | b595cb0c1dec83de5bdee18284abe86614bed33b (patch) | |
tree | 8c3d4540f193c5ff98019352f554e921b3a41a72 /lib/gitlab/usage_data_counters | |
parent | 2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff) |
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'lib/gitlab/usage_data_counters')
8 files changed, 110 insertions, 40 deletions
diff --git a/lib/gitlab/usage_data_counters/editor_unique_counter.rb b/lib/gitlab/usage_data_counters/editor_unique_counter.rb index 8feb24e49ac..5ede840661a 100644 --- a/lib/gitlab/usage_data_counters/editor_unique_counter.rb +++ b/lib/gitlab/usage_data_counters/editor_unique_counter.rb @@ -10,24 +10,24 @@ module Gitlab EDIT_BY_LIVE_PREVIEW = 'g_edit_by_live_preview' class << self - def track_web_ide_edit_action(author:, time: Time.zone.now) - track_unique_action(EDIT_BY_WEB_IDE, author, time) + def track_web_ide_edit_action(author:, time: Time.zone.now, project:) + track_unique_action(EDIT_BY_WEB_IDE, author, time, project) end def count_web_ide_edit_actions(date_from:, date_to:) count_unique(EDIT_BY_WEB_IDE, date_from, date_to) end - def track_sfe_edit_action(author:, time: Time.zone.now) - track_unique_action(EDIT_BY_SFE, author, time) + def track_sfe_edit_action(author:, time: Time.zone.now, project:) + track_unique_action(EDIT_BY_SFE, author, time, project) end def count_sfe_edit_actions(date_from:, date_to:) count_unique(EDIT_BY_SFE, date_from, date_to) end - def track_snippet_editor_edit_action(author:, time: Time.zone.now) - track_unique_action(EDIT_BY_SNIPPET_EDITOR, author, time) + def track_snippet_editor_edit_action(author:, time: Time.zone.now, project:) + track_unique_action(EDIT_BY_SNIPPET_EDITOR, author, time, project) end def count_snippet_editor_edit_actions(date_from:, date_to:) @@ -39,15 +39,25 @@ module Gitlab count_unique(events, date_from, date_to) end - def track_live_preview_edit_action(author:, time: Time.zone.now) - track_unique_action(EDIT_BY_LIVE_PREVIEW, author, time) + def track_live_preview_edit_action(author:, time: Time.zone.now, project:) + track_unique_action(EDIT_BY_LIVE_PREVIEW, author, time, project) end private - def track_unique_action(action, author, time) + def track_unique_action(action, author, time, project = nil) return unless author + if Feature.enabled?(:route_hll_to_snowplow_phase2) + Gitlab::Tracking.event( + 'ide_edit', + action.to_s, + project: project, + namespace: project&.namespace, + user: author + ) + end + Gitlab::UsageDataCounters::HLLRedisCounter.track_event(action, values: author.id, time: time) end diff --git a/lib/gitlab/usage_data_counters/hll_redis_counter.rb b/lib/gitlab/usage_data_counters/hll_redis_counter.rb index 0ace6e99c59..40581bda81b 100644 --- a/lib/gitlab/usage_data_counters/hll_redis_counter.rb +++ b/lib/gitlab/usage_data_counters/hll_redis_counter.rb @@ -33,10 +33,24 @@ module Gitlab pipeline_authoring quickactions search - testing user_packages ].freeze + CATEGORIES_COLLECTED_FROM_METRICS_DEFINITIONS = %w[ + ci_users + error_tracking + ide_edit + importer + incident_management_alerts + pipeline_authoring + secure + snippets + source_code + terraform + testing + work_items + ].freeze + # Track event on entity_id # Increment a Redis HLL counter for unique event_name and entity_id # @@ -114,7 +128,7 @@ module Gitlab # - Most of the metrics have weekly aggregation. We recommend this as it generates fewer keys in Redis to store. # - The aggregation used doesn't affect data granulation. def unique_events_data - categories.each_with_object({}) do |category, category_results| + categories_pending_migration.each_with_object({}) do |category, category_results| events_names = events_for_category(category) event_results = events_names.each_with_object({}) do |event, hash| @@ -148,6 +162,14 @@ module Gitlab private + def categories_pending_migration + if ::Feature.enabled?(:use_redis_hll_instrumentation_classes) + (categories - CATEGORIES_COLLECTED_FROM_METRICS_DEFINITIONS) + else + categories + end + end + def track(values, event_name, context: '', time: Time.zone.now) return unless ::ServicePing::ServicePingSettings.enabled? diff --git a/lib/gitlab/usage_data_counters/issue_activity_unique_counter.rb b/lib/gitlab/usage_data_counters/issue_activity_unique_counter.rb index 083de402175..9d463e11772 100644 --- a/lib/gitlab/usage_data_counters/issue_activity_unique_counter.rb +++ b/lib/gitlab/usage_data_counters/issue_activity_unique_counter.rb @@ -149,6 +149,19 @@ module Gitlab Gitlab::UsageDataCounters::HLLRedisCounter.track_event(action, values: author.id) end + + def track_snowplow_action(action, author, project) + return unless Feature.enabled?(:route_hll_to_snowplow_phase2, project&.namespace) + return unless author + + Gitlab::Tracking.event( + ISSUE_CATEGORY, + action.to_s, + project: project, + namespace: project&.namespace, + user: author + ) + end end end end diff --git a/lib/gitlab/usage_data_counters/known_events/analytics.yml b/lib/gitlab/usage_data_counters/known_events/analytics.yml index 5a1e7f03278..76c97a974d7 100644 --- a/lib/gitlab/usage_data_counters/known_events/analytics.yml +++ b/lib/gitlab/usage_data_counters/known_events/analytics.yml @@ -78,3 +78,31 @@ category: analytics redis_slot: analytics aggregation: weekly +- name: p_analytics_ci_cd_time_to_restore_service + category: analytics + redis_slot: analytics + aggregation: weekly +- name: p_analytics_ci_cd_change_failure_rate + category: analytics + redis_slot: analytics + aggregation: weekly +- name: g_analytics_ci_cd_release_statistics + category: analytics + redis_slot: analytics + aggregation: weekly +- name: g_analytics_ci_cd_deployment_frequency + category: analytics + redis_slot: analytics + aggregation: weekly +- name: g_analytics_ci_cd_lead_time + category: analytics + redis_slot: analytics + aggregation: weekly +- name: g_analytics_ci_cd_time_to_restore_service + category: analytics + redis_slot: analytics + aggregation: weekly +- name: g_analytics_ci_cd_change_failure_rate + category: analytics + redis_slot: analytics + aggregation: weekly diff --git a/lib/gitlab/usage_data_counters/known_events/ci_users.yml b/lib/gitlab/usage_data_counters/known_events/ci_users.yml index 5159dcf62ab..b012d61eef5 100644 --- a/lib/gitlab/usage_data_counters/known_events/ci_users.yml +++ b/lib/gitlab/usage_data_counters/known_events/ci_users.yml @@ -3,3 +3,8 @@ redis_slot: ci_users aggregation: weekly feature_flag: +- name: ci_users_executing_verify_environment_job + category: ci_users + redis_slot: ci_users + aggregation: weekly + feature_flag: diff --git a/lib/gitlab/usage_data_counters/known_events/common.yml b/lib/gitlab/usage_data_counters/known_events/common.yml index 0dcbaf59c9c..88c9f44c165 100644 --- a/lib/gitlab/usage_data_counters/known_events/common.yml +++ b/lib/gitlab/usage_data_counters/known_events/common.yml @@ -157,34 +157,6 @@ category: testing redis_slot: testing aggregation: weekly -- name: i_testing_metrics_report_widget_total - category: testing - redis_slot: testing - aggregation: weekly -- name: i_testing_group_code_coverage_visit_total - category: testing - redis_slot: testing - aggregation: weekly -- name: i_testing_full_code_quality_report_total - category: testing - redis_slot: testing - aggregation: weekly -- name: i_testing_web_performance_widget_total - category: testing - redis_slot: testing - aggregation: weekly -- name: i_testing_group_code_coverage_project_click_total - category: testing - redis_slot: testing - aggregation: weekly -- name: i_testing_load_performance_widget_total - category: testing - redis_slot: testing - aggregation: weekly -- name: i_testing_metrics_report_artifact_uploaders - category: testing - redis_slot: testing - aggregation: weekly - name: i_testing_summary_widget_total category: testing redis_slot: testing @@ -390,3 +362,8 @@ category: growth redis_slot: users aggregation: weekly +# Manage +- name: unique_active_user + category: manage + aggregation: weekly + expiry: 42 diff --git a/lib/gitlab/usage_data_counters/merge_request_activity_unique_counter.rb b/lib/gitlab/usage_data_counters/merge_request_activity_unique_counter.rb index 9c0f8fe9a80..fbb03a31a6f 100644 --- a/lib/gitlab/usage_data_counters/merge_request_activity_unique_counter.rb +++ b/lib/gitlab/usage_data_counters/merge_request_activity_unique_counter.rb @@ -76,8 +76,19 @@ module Gitlab track_unique_action_by_user(MR_REOPEN_ACTION, user) end - def track_approve_mr_action(user:) + def track_approve_mr_action(user:, merge_request:) track_unique_action_by_user(MR_APPROVE_ACTION, user) + + project = merge_request.target_project + return unless Feature.enabled?(:route_hll_to_snowplow_phase2, project.namespace) + + Gitlab::Tracking.event( + 'merge_requests', + MR_APPROVE_ACTION, + project: project, + namespace: project.namespace, + user: user + ) end def track_unapprove_mr_action(user:) diff --git a/lib/gitlab/usage_data_counters/work_item_activity_unique_counter.rb b/lib/gitlab/usage_data_counters/work_item_activity_unique_counter.rb index 6f5300405c7..51bca8b51fe 100644 --- a/lib/gitlab/usage_data_counters/work_item_activity_unique_counter.rb +++ b/lib/gitlab/usage_data_counters/work_item_activity_unique_counter.rb @@ -26,3 +26,7 @@ module Gitlab end end end + +# rubocop:disable Layout/LineLength +Gitlab::UsageDataCounters::WorkItemActivityUniqueCounter.prepend_mod_with('Gitlab::UsageDataCounters::WorkItemActivityUniqueCounter') +# rubocop:enable Layout/LineLength |