Skip to content

Add interactive generator for internal events

Sarah Yasonik requested to merge sy-upgrade-ux-of-internal-events-generator into master

What does this MR do and why?

Adds an interactive CLI for Internal Events. The purpose is to allow users to easily create event/metric definition files without needed to scour the docs for context or encountering unexpected errors.

Functionality currently in-scope:

  1. Creating new event definitions
  2. Creating new metric definitions for internal events
  3. Tailoring usage examples for the specific event

Code structure overview

Script code:

  • Entrypoint for cli: scripts/internal_events/cli.rb
  • Entrypoint for each flow:
    • scripts/internal_events/cli/event_definer.rb --> Define a new event
    • scripts/internal_events/cli/metric_definer.rb --> Define a new metric
    • scripts/internal_events/cli/usage_viewer.rb --> Show usage examples
  • scripts/internal_events/cli/event.rb & scripts/internal_events/cli/metric.rb define structure of definitions
    • Equivalent to generator_templates/gitlab_internal_events/*.yml --> I tried to re-use the existing generator, but it was ultimately simpler/cleaner to define these separately
  • scripts/internal_events/cli/text.rb contains many block strings for easy editing
  • All helpers in scripts/internal_events/cli/helpers/ are grouped in scripts/internal_events/cli/helpers.rb & available across the entire script

Spec code:

  • test cases defined in spec/fixtures/scripts/internal_events/new_metrics.yml & spec/fixtures/scripts/internal_events/new_events.yml assert that for existing files & keystrokes, the correct definitions are created
    • there are a handful of tests for rendering specific behavior, but my goal was to optimize the tests for maintainability as the tool is modified/grows.
  • spec/scripts/internal_events/cli_spec.rb includes examples for all flows & edge cases

Should be in scope but isn't yet:

  1. Manual testing instructions for triggering an event from rails console & verifying service ping output
  2. Spit out command to run internal events monitor for event

Known problems:

  1. File/keypath naming for the aggregate metrics isn't good. It results in really long filenames. Also not sure about introducing this mechanism? AggregatedMetric seems massively overworked & does the same thing as RedisHll when provided multiple events, so I wasn't sure of intent.
  2. RedisHLL metrics are grouped under the redis_hll_counters key by feature category, but feature category isn't a required field for the metric definition anymore. I'm not sold on requesting it from the user. Seems annoying, but then again, so does the mess of info that is the service ping payload. Related: https://gitlab.slack.com/archives/CL3A7GFPF/p1701204578630149.
  3. The methodology for excluding existing metrics relies on the file name, but that's a completely bad assumption. It'll miss lots of things.
  4. I'm not sure about the truth of the frontend-related notes about event identifiers... 😅

How to set up and validate locally

  1. Run ruby scripts/internal_events/cli.rb from gitlab/ directory of gdk

Screenshots or screen recordings

New event flow - 2023-12-05

Screenshot_2023-12-06_at_1.29.57_AM Screenshot_2023-12-06_at_1.30.06_AM Screenshot_2023-12-06_at_1.30.48_AM Screenshot_2023-12-06_at_1.30.55_AM Screenshot_2023-12-06_at_1.31.02_AM Screenshot_2023-12-06_at_1.31.15_AM Screenshot_2023-12-06_at_1.31.23_AM Screenshot_2023-12-06_at_1.31.37_AM Screenshot_2023-12-06_at_1.31.44_AM Screenshot_2023-12-06_at_1.31.51_AM Screenshot_2023-12-06_at_1.31.57_AM

Continue from event to metric flow - 2023-12-05

Screenshot_2023-12-06_at_1.32.18_AM Screenshot_2023-12-06_at_1.32.25_AM Screenshot_2023-12-06_at_1.32.32_AM Screenshot_2023-12-06_at_1.32.53_AM Screenshot_2023-12-06_at_1.33.09_AM Screenshot_2023-12-06_at_1.33.16_AM Screenshot_2023-12-06_at_1.33.23_AM

New metric from existing event flow - 2023-12-05

Screenshot_2023-12-06_at_1.43.22_AM Screenshot_2023-12-06_at_1.43.34_AM Screenshot_2023-12-06_at_1.44.08_AM Screenshot_2023-12-06_at_1.44.16_AM Screenshot_2023-12-06_at_1.44.38_AM Screenshot_2023-12-06_at_1.44.46_AM Screenshot_2023-12-06_at_1.44.53_AM Screenshot_2023-12-06_at_1.45.01_AM Screenshot_2023-12-06_at_1.45.13_AM Screenshot_2023-12-06_at_1.45.25_AM

Previos version - 2023-11-30

Screenshot_2023-11-30_at_7.50.40_PM

Screenshot_2023-11-30_at_7.50.54_PM

Screenshot_2023-11-30_at_7.51.07_PM

Screenshot_2023-11-30_at_7.51.20_PM

Screenshot_2023-11-30_at_8.03.33_PM

Screenshot_2023-11-30_at_7.51.43_PM

Screenshot_2023-11-30_at_7.51.48_PM

Screenshot_2023-11-30_at_7.52.19_PM

Screenshot_2023-11-30_at_7.52.42_PM

Screenshot_2023-11-30_at_7.52.49_PM

Screenshot_2023-11-30_at_7.52.59_PM

Screenshot_2023-11-30_at_7.53.16_PM

Screenshot_2023-11-30_at_7.53.28_PM

Screenshot_2023-11-30_at_7.53.40_PM

Screenshot_2023-11-30_at_7.54.08_PM

Screenshot_2023-11-30_at_7.54.25_PM

Screenshot_2023-11-30_at_7.54.40_PM

Screenshot_2023-11-30_at_7.54.46_PM

Screenshot_2023-11-30_at_7.54.57_PM

Screenshot_2023-11-30_at_7.55.05_PM

Screenshot_2023-11-30_at_7.55.17_PM

Screenshot_2023-11-30_at_7.55.41_PM

Screenshot_2023-11-30_at_7.56.08_PM

Screenshot_2023-11-30_at_7.56.17_PM

Screenshot_2023-11-30_at_7.56.24_PM

Screenshot_2023-11-30_at_7.56.42_PM

Screenshot_2023-11-30_at_8.01.40_PM

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Sarah Yasonik

Merge request reports