Module: Oboe::Rails

Defined in:
lib/oboe/frameworks/rails.rb

Defined Under Namespace

Modules: Helpers

Class Method Summary collapse

Class Method Details

.include_helpersObject



75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/oboe/frameworks/rails.rb', line 75

def self.include_helpers
  # TBD: This would make the helpers available to controllers which is occasionally desired.
  # ActiveSupport.on_load(:action_controller) do
  #   include Oboe::Rails::Helpers
  # end
  if ::Rails::VERSION::MAJOR > 2
    ActiveSupport.on_load(:action_view) do
      include Oboe::Rails::Helpers
    end
  else
    ActionView::Base.send :include, Oboe::Rails::Helpers
  end
end

.load_initializerObject

Helpers



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/oboe/frameworks/rails.rb', line 44

def self.load_initializer
  # Force load the TraceView Rails initializer if there is one
  # Prefer oboe.rb but give priority to the legacy tracelytics.rb if it exists
  if ::Rails::VERSION::MAJOR > 2
    rails_root = "#{::Rails.root.to_s}"
  else
    rails_root = "#{RAILS_ROOT}"
  end

  if File.exists?("#{rails_root}/config/initializers/tracelytics.rb")
    tr_initializer = "#{rails_root}/config/initializers/tracelytics.rb"
  else
    tr_initializer = "#{rails_root}/config/initializers/oboe.rb"
  end
  require tr_initializer if File.exists?(tr_initializer)
end

.load_instrumentationObject



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/oboe/frameworks/rails.rb', line 61

def self.load_instrumentation
  # Load the Rails specific instrumentation
  pattern = File.join(File.dirname(__FILE__), 'rails/inst', '*.rb')
  Dir.glob(pattern) do |f|
    begin
      require f
    rescue => e
      Oboe.logger.error "[oboe/loading] Error loading rails insrumentation file '#{f}' : #{e}"
    end
  end

  Oboe.logger.info "TraceView oboe gem #{Oboe::Version::STRING} successfully loaded."
end