From 424248908b5878f953ea6e3758d0e3412345c2e9 Mon Sep 17 00:00:00 2001 From: Gary Holtz Date: Wed, 21 May 2025 22:25:51 -0500 Subject: [PATCH 1/3] Adding glab CLI event tracking Changelog: added --- config/events/gitlab_cli_command_used.yml | 23 +++++ ...f_unique_command_subcommand_combo_used.yml | 24 ++++++ .../total_counts_of_unique_commands_used.yml | 24 ++++++ ...otal_counts_of_unique_subcommands_used.yml | 24 ++++++ .../objects_schemas/gitlab_cli_commands.json | 84 +++++++++++++++++++ config/metrics/schema/base.json | 13 ++- ...every_metric_definition_shared_examples.rb | 1 - 7 files changed, 191 insertions(+), 2 deletions(-) create mode 100644 config/events/gitlab_cli_command_used.yml create mode 100644 config/metrics/counts_all/total_counts_of_unique_command_subcommand_combo_used.yml create mode 100644 config/metrics/counts_all/total_counts_of_unique_commands_used.yml create mode 100644 config/metrics/counts_all/total_counts_of_unique_subcommands_used.yml create mode 100644 config/metrics/objects_schemas/gitlab_cli_commands.json diff --git a/config/events/gitlab_cli_command_used.yml b/config/events/gitlab_cli_command_used.yml new file mode 100644 index 00000000000000..719c77a4b1b38f --- /dev/null +++ b/config/events/gitlab_cli_command_used.yml @@ -0,0 +1,23 @@ +description: Command is executed from the GitLab CLI +internal_events: true +action: gitlab_cli_command_used +identifiers: + - project + - namespace + - user +additional_properties: + label: + description: Command used - e.g. 'mr' + property: + description: Subcommand used - e.g. 'view' + command_and_subcommand: + description: Command and subcommand used - e.g. 'mr view' +product_group: code_review +product_categories: + - gitlab_cli +milestone: '18.0' +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/185183 +tiers: + - free + - premium + - ultimate diff --git a/config/metrics/counts_all/total_counts_of_unique_command_subcommand_combo_used.yml b/config/metrics/counts_all/total_counts_of_unique_command_subcommand_combo_used.yml new file mode 100644 index 00000000000000..029c784eab8e74 --- /dev/null +++ b/config/metrics/counts_all/total_counts_of_unique_command_subcommand_combo_used.yml @@ -0,0 +1,24 @@ +data_category: optional +instrumentation_class: UniqueTotalsMetric +key_path: gitlab_cli_commands.total_counts_of_unique_command_subcommand_combo_used +description: Counts of each combination of command and subcommand used from the GitLab CLI +product_group: code_review +product_categories: + - gitlab_cli +value_type: object +status: active +time_frame: + - 28d + - 7d +data_source: internal_events +tiers: + - free + - premium + - ultimate +milestone: "18.0" +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/190595 +value_json_schema: "config/metrics/objects_schemas/gitlab_cli_commands.json" +events: + - name: gitlab_cli_command_used + unique: command_and_subcommand + operator: 'total' diff --git a/config/metrics/counts_all/total_counts_of_unique_commands_used.yml b/config/metrics/counts_all/total_counts_of_unique_commands_used.yml new file mode 100644 index 00000000000000..68107301be78e1 --- /dev/null +++ b/config/metrics/counts_all/total_counts_of_unique_commands_used.yml @@ -0,0 +1,24 @@ +data_category: optional +instrumentation_class: UniqueTotalsMetric +key_path: gitlab_cli_commands.total_counts_of_unique_commands_used +description: Counts of each command used from the GitLab CLI +product_group: code_review +product_categories: + - gitlab_cli +value_type: object +status: active +time_frame: + - 28d + - 7d +data_source: internal_events +tiers: + - free + - premium + - ultimate +milestone: "18.0" +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/190595 +value_json_schema: "config/metrics/objects_schemas/gitlab_cli_commands.json" +events: + - name: gitlab_cli_command_used + unique: label + operator: 'total' diff --git a/config/metrics/counts_all/total_counts_of_unique_subcommands_used.yml b/config/metrics/counts_all/total_counts_of_unique_subcommands_used.yml new file mode 100644 index 00000000000000..92be688f63eea9 --- /dev/null +++ b/config/metrics/counts_all/total_counts_of_unique_subcommands_used.yml @@ -0,0 +1,24 @@ +data_category: optional +instrumentation_class: UniqueTotalsMetric +key_path: gitlab_cli_commands.total_counts_of_unique_subcommands_used +description: Counts of each subcommand used from the GitLab CLI +product_group: code_review +product_categories: + - gitlab_cli +value_type: object +status: active +time_frame: + - 28d + - 7d +data_source: internal_events +tiers: + - free + - premium + - ultimate +milestone: "18.0" +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/190595 +value_json_schema: "config/metrics/objects_schemas/gitlab_cli_commands.json" +events: + - name: gitlab_cli_command_used + unique: property + operator: 'total' diff --git a/config/metrics/objects_schemas/gitlab_cli_commands.json b/config/metrics/objects_schemas/gitlab_cli_commands.json new file mode 100644 index 00000000000000..797d94742446a0 --- /dev/null +++ b/config/metrics/objects_schemas/gitlab_cli_commands.json @@ -0,0 +1,84 @@ +{ + "type": "object", + "properties": { + "instrumentation_class": { + "const": "UniqueTotalsMetric" + }, + "events": { + "type": "array", + "items": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + }, + "unique": { + "type": "string", + "enum": [ + "property", + "value", + "command_and_subcommand" + ] + }, + "filter": { + "type": "object", + "properties": { + "label": { + "type": "string" + }, + "property": { + "type": "string" + }, + "value": { + "type": "number" + } + }, + "additionalProperties": { + "type": [ + "string", + "number" + ] + } + }, + "operator": { + "type": "string", + "enum": [ + "total", + "sum(value)" + ] + } + }, + "additionalProperties": false + } + }, + "oneOf": [ + { + "label": { + "type": "object", + "additionalProperties": { + "type": "number" + } + } + }, + { + "property": { + "type": "object", + "additionalProperties": { + "type": "number" + } + } + }, + { + "command_and_subcommand": { + "type": "object", + "additionalProperties": { + "type": "number" + } + } + } + ] + } +} diff --git a/config/metrics/schema/base.json b/config/metrics/schema/base.json index 465bf5f629e452..6c4edcb332fc90 100644 --- a/config/metrics/schema/base.json +++ b/config/metrics/schema/base.json @@ -181,7 +181,18 @@ ], "allOf": [ { - "$ref": "internal_events.json" + "if": { + "properties": { + "value_json_schema": { + "not": { + "const": "config/metrics/objects_schemas/gitlab_cli_commands.json" + } + } + } + }, + "then": { + "$ref": "internal_events.json" + } }, { "$ref": "redis_hll.json" diff --git a/spec/support/shared_examples/config/metrics/every_metric_definition_shared_examples.rb b/spec/support/shared_examples/config/metrics/every_metric_definition_shared_examples.rb index d26719718edcdf..3bc3a4cb2d6a0e 100644 --- a/spec/support/shared_examples/config/metrics/every_metric_definition_shared_examples.rb +++ b/spec/support/shared_examples/config/metrics/every_metric_definition_shared_examples.rb @@ -127,7 +127,6 @@ def object_with_schema?(key_path) def assert_uses_all_nested_classes(parent_module) parent_module.constants(false).each do |const_name| next if const_name == :TotalSumMetric # TODO: Remove when first metric is implemented - next if const_name == :UniqueTotalsMetric # TODO: Remove when first metric is implemented constant = parent_module.const_get(const_name, false) next if parent_metric_classes.include?(constant) || -- GitLab From a53da4aa5d11d7a8552377a136e083e3adea9dc2 Mon Sep 17 00:00:00 2001 From: Gary Holtz Date: Wed, 21 May 2025 22:29:48 -0500 Subject: [PATCH 2/3] Removing metrics --- ...f_unique_command_subcommand_combo_used.yml | 24 ------------------- .../total_counts_of_unique_commands_used.yml | 24 ------------------- ...otal_counts_of_unique_subcommands_used.yml | 24 ------------------- ...every_metric_definition_shared_examples.rb | 1 + 4 files changed, 1 insertion(+), 72 deletions(-) delete mode 100644 config/metrics/counts_all/total_counts_of_unique_command_subcommand_combo_used.yml delete mode 100644 config/metrics/counts_all/total_counts_of_unique_commands_used.yml delete mode 100644 config/metrics/counts_all/total_counts_of_unique_subcommands_used.yml diff --git a/config/metrics/counts_all/total_counts_of_unique_command_subcommand_combo_used.yml b/config/metrics/counts_all/total_counts_of_unique_command_subcommand_combo_used.yml deleted file mode 100644 index 029c784eab8e74..00000000000000 --- a/config/metrics/counts_all/total_counts_of_unique_command_subcommand_combo_used.yml +++ /dev/null @@ -1,24 +0,0 @@ -data_category: optional -instrumentation_class: UniqueTotalsMetric -key_path: gitlab_cli_commands.total_counts_of_unique_command_subcommand_combo_used -description: Counts of each combination of command and subcommand used from the GitLab CLI -product_group: code_review -product_categories: - - gitlab_cli -value_type: object -status: active -time_frame: - - 28d - - 7d -data_source: internal_events -tiers: - - free - - premium - - ultimate -milestone: "18.0" -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/190595 -value_json_schema: "config/metrics/objects_schemas/gitlab_cli_commands.json" -events: - - name: gitlab_cli_command_used - unique: command_and_subcommand - operator: 'total' diff --git a/config/metrics/counts_all/total_counts_of_unique_commands_used.yml b/config/metrics/counts_all/total_counts_of_unique_commands_used.yml deleted file mode 100644 index 68107301be78e1..00000000000000 --- a/config/metrics/counts_all/total_counts_of_unique_commands_used.yml +++ /dev/null @@ -1,24 +0,0 @@ -data_category: optional -instrumentation_class: UniqueTotalsMetric -key_path: gitlab_cli_commands.total_counts_of_unique_commands_used -description: Counts of each command used from the GitLab CLI -product_group: code_review -product_categories: - - gitlab_cli -value_type: object -status: active -time_frame: - - 28d - - 7d -data_source: internal_events -tiers: - - free - - premium - - ultimate -milestone: "18.0" -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/190595 -value_json_schema: "config/metrics/objects_schemas/gitlab_cli_commands.json" -events: - - name: gitlab_cli_command_used - unique: label - operator: 'total' diff --git a/config/metrics/counts_all/total_counts_of_unique_subcommands_used.yml b/config/metrics/counts_all/total_counts_of_unique_subcommands_used.yml deleted file mode 100644 index 92be688f63eea9..00000000000000 --- a/config/metrics/counts_all/total_counts_of_unique_subcommands_used.yml +++ /dev/null @@ -1,24 +0,0 @@ -data_category: optional -instrumentation_class: UniqueTotalsMetric -key_path: gitlab_cli_commands.total_counts_of_unique_subcommands_used -description: Counts of each subcommand used from the GitLab CLI -product_group: code_review -product_categories: - - gitlab_cli -value_type: object -status: active -time_frame: - - 28d - - 7d -data_source: internal_events -tiers: - - free - - premium - - ultimate -milestone: "18.0" -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/190595 -value_json_schema: "config/metrics/objects_schemas/gitlab_cli_commands.json" -events: - - name: gitlab_cli_command_used - unique: property - operator: 'total' diff --git a/spec/support/shared_examples/config/metrics/every_metric_definition_shared_examples.rb b/spec/support/shared_examples/config/metrics/every_metric_definition_shared_examples.rb index 3bc3a4cb2d6a0e..d26719718edcdf 100644 --- a/spec/support/shared_examples/config/metrics/every_metric_definition_shared_examples.rb +++ b/spec/support/shared_examples/config/metrics/every_metric_definition_shared_examples.rb @@ -127,6 +127,7 @@ def object_with_schema?(key_path) def assert_uses_all_nested_classes(parent_module) parent_module.constants(false).each do |const_name| next if const_name == :TotalSumMetric # TODO: Remove when first metric is implemented + next if const_name == :UniqueTotalsMetric # TODO: Remove when first metric is implemented constant = parent_module.const_get(const_name, false) next if parent_metric_classes.include?(constant) || -- GitLab From 76551cb70943f5aef53fad436a528e8de4bea4b7 Mon Sep 17 00:00:00 2001 From: Gary Holtz Date: Thu, 22 May 2025 09:48:05 -0500 Subject: [PATCH 3/3] Moving json files into other MR --- .../objects_schemas/gitlab_cli_commands.json | 84 ------------------- config/metrics/schema/base.json | 19 +---- 2 files changed, 3 insertions(+), 100 deletions(-) delete mode 100644 config/metrics/objects_schemas/gitlab_cli_commands.json diff --git a/config/metrics/objects_schemas/gitlab_cli_commands.json b/config/metrics/objects_schemas/gitlab_cli_commands.json deleted file mode 100644 index 797d94742446a0..00000000000000 --- a/config/metrics/objects_schemas/gitlab_cli_commands.json +++ /dev/null @@ -1,84 +0,0 @@ -{ - "type": "object", - "properties": { - "instrumentation_class": { - "const": "UniqueTotalsMetric" - }, - "events": { - "type": "array", - "items": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "type": "string" - }, - "unique": { - "type": "string", - "enum": [ - "property", - "value", - "command_and_subcommand" - ] - }, - "filter": { - "type": "object", - "properties": { - "label": { - "type": "string" - }, - "property": { - "type": "string" - }, - "value": { - "type": "number" - } - }, - "additionalProperties": { - "type": [ - "string", - "number" - ] - } - }, - "operator": { - "type": "string", - "enum": [ - "total", - "sum(value)" - ] - } - }, - "additionalProperties": false - } - }, - "oneOf": [ - { - "label": { - "type": "object", - "additionalProperties": { - "type": "number" - } - } - }, - { - "property": { - "type": "object", - "additionalProperties": { - "type": "number" - } - } - }, - { - "command_and_subcommand": { - "type": "object", - "additionalProperties": { - "type": "number" - } - } - } - ] - } -} diff --git a/config/metrics/schema/base.json b/config/metrics/schema/base.json index 6c4edcb332fc90..28bbab8476d1ba 100644 --- a/config/metrics/schema/base.json +++ b/config/metrics/schema/base.json @@ -143,10 +143,8 @@ "name": { "type": "string" }, - "events": { - }, - "time_frame": { - } + "events": {}, + "time_frame": {} }, "oneOf": [ { @@ -181,18 +179,7 @@ ], "allOf": [ { - "if": { - "properties": { - "value_json_schema": { - "not": { - "const": "config/metrics/objects_schemas/gitlab_cli_commands.json" - } - } - } - }, - "then": { - "$ref": "internal_events.json" - } + "$ref": "internal_events.json" }, { "$ref": "redis_hll.json" -- GitLab