Class: Oboe::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/rails/generators/oboe/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_initializerObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rails/generators/oboe/install_generator.rb', line 9

def copy_initializer
  # Set defaults
  @tracing_mode = 'through'
  @sample_rate = '300000'
  @verbose = 'false'

  say ""
  say shell.set_color "Welcome to the TraceView Ruby instrumentation setup.", :green, :bold
  say ""
  say "To instrument your Rails application, you can setup your tracing strategy here."
  say ""
  say shell.set_color "Documentation Links", :magenta
  say "-------------------"
  say ""
  say "Details on configuring your sample rate:"
  say "http://support.tv.appneta.com/support/solutions/articles/86336-configuring-sampling"
  say ""
  say "More information on instrumenting Ruby applications can be found here:"
  say "http://support.tv.appneta.com/support/solutions/articles/86393-instrumenting-ruby-apps"
  while true do
    say ""
    say shell.set_color "Tracing Mode", :magenta
    say "------------"
    say "Tracing Mode determines when traces should be initiated for incoming requests.  Valid"
    say "options are #{shell.set_color "always", :yellow}, #{shell.set_color "through", :yellow} (when using an instrumented Apache or Nginx) and #{shell.set_color "never", :yellow}."
    say ""
    say "If you're not using an instrumented Apache or Nginx, set this directive to #{shell.set_color "always", :yellow} in"
    say "order to initiate tracing from Ruby."
    say ""
    user_tracing_mode = ask shell.set_color "* Tracing Mode? [through]:", :yellow
    user_tracing_mode.downcase!

    break if user_tracing_mode.blank?
    valid = ['always', 'through', 'never'].include?(user_tracing_mode)
    say shell.set_color "Valid values are 'always', 'through' or 'never'", :red, :bold unless valid
    if valid
      @tracing_mode = user_tracing_mode
      break
    end
  end

  say ""
  say "You can change configuration values in the future by modifying config/initializers/oboe.rb"
  say ""
  say "Thanks! Creating the TraceView initializer..."
  say ""

  template "oboe_initializer.rb", "config/initializers/oboe.rb"
end