Skip to content

Add usage_metric_definition generator to generate new yaml metric file

Alina Mihaila requested to merge 270107-add-script-fenerate-new-metric-file into master

What does this MR do?

Add custom metric generator

Documentation will follow in a separate MR

The generator has

  • one required option --dir , inticates the location of metric one of counts_7d, counts_28d, counts_all, settings, license/
  • one optional option --ee for ee metrics.

Description:

 rails g gitlab:usage_metric_definition  --help
Usage:
  rails generate gitlab:usage_metric_definition KEY_PATH [options]

Options:
  [--skip-namespace], [--no-skip-namespace]  # Skip namespace (affects only isolated applications)
  [--ee], [--no-ee]                          # Indicates if metric is for ee
  [--dir=DIR]                                # Indicates the metric location. It must be one of: "counts_7d", "counts_28d", "counts_all", "settings", "license"

Runtime options:
  -f, [--force]                    # Overwrite files that already exist
  -p, [--pretend], [--no-pretend]  # Run but do not make any changes
  -q, [--quiet], [--no-quiet]      # Suppress status output
  -s, [--skip], [--no-skip]        # Skip files that already exist

Generates a metric definition yml file

Docs

Docs will follow-up in separate MR if this approach gets approved

Description: Create usage metric definition generator files for usage_metric_definition generator.

Usage

➜  gitlab git:(270107-add-script-fenerate-new-metric-file) rails g gitlab:usage_metric_definition  my.metric.is.cool --ee --dir=settings
      create  ee/config/metrics/settings/cool.yml

Output file

---
key_path: my.metric.is.cool
value_type:
product_category:
stage:
status:
milestone:
introduced_by_url:
group:
time_frame: none
data_source:
# distribution: [ee, ce]
distribution:
# tier: ['free', 'starter', 'premium', 'ultimate', 'bronze', 'silver', 'gold']
tier:

Screenshots (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Related to #300179 (closed)

Edited by Alina Mihaila

Merge request reports