Skip to content

Redirect internal events monitor users who call the monitor script incorrectly

Sarah Yasonik requested to merge sy-help-users-calling-the-monitor-wrong into master

What does this MR do and why?

I can never remember what the command to start the Internal Events Monitor is. To avoid opening the docs, I regularly try to run it with:

  • scripts/internal_events/monitor.rb event_name_1 event_name_2
  • ruby scripts/internal_events/monitor.rb event_name_1 event_name_2

This MR adds logic to print an informative error message with the correct command when the script is run outside of rails.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Before After
$ scripts/internal_events/monitor.rb event_name_1 event_name_2
zsh: permission denied: scripts/internal_events/monitor.rb
$ scripts/internal_events/monitor.rb event_name_1 event_name_2

Error! The Internal Events Tracking Monitor could not access the rails context!

  Ensure GDK is running, then run:

  bin/rails runner scripts/internal_events/monitor.rb event_name_1 event_name_2
$ ruby scripts/internal_events/monitor.rb event_name_1 event_name_2
/Users/syasonik/workspace/gdk/gitlab/spec/support/helpers/service_ping_helpers.rb
:85:in `<class:ClassWithStubbedTimeframe>': uninitialized constant ServicePingHel
pers::ClassWithStubbedTimeframe::Gitlab (NameError)

    include Gitlab::Usage::TimeFrame.dup
                         ^^^^^^^^^^^
	from /Users/syasonik/workspace/gdk/gitlab/spec/support/helpers/service_pi
ng_helpers.rb:84:in `<module:ServicePingHelpers>'
	from /Users/syasonik/workspace/gdk/gitlab/spec/support/helpers/service_pi
ng_helpers.rb:6:in `<top (required)>'
	from scripts/internal_events/monitor.rb:25:in `require_relative'
	from scripts/internal_events/monitor.rb:25:in `<main>'
$ ruby scripts/internal_events/monitor.rb protect_branch event_name_1 event_name_2

Error! The Internal Events Tracking Monitor could not access the rails context!

  Ensure GDK is running, then run:

  bin/rails runner scripts/internal_events/monitor.rb event_name_1 event_name_2

Merge request reports

Loading