module Atatus::Sinatra
Module for starting the Atatus
agent and hooking into Sinatra
.
Public Instance Methods
start(app, config = {})
click to toggle source
Start the Atatus
agent and hook into Sinatra
.
@param app [Sinatra::Base] A Sinatra
app. @param config [Config, Hash] An instance of Config
or a Hash config. @return [true, nil] true if the agent was started, nil otherwise.
# File lib/atatus/sinatra.rb, line 29 def start(app, config = {}) config = Config.new(config) unless config.is_a?(Config) configure_app(app, config) Atatus.start(config) Atatus.running? rescue StandardError => e config.logger.error format('Failed to start: %s', e.message) config.logger.debug "Backtrace:\n" + e.backtrace.join("\n") end
Private Instance Methods
configure_app(app, config)
click to toggle source
# File lib/atatus/sinatra.rb, line 42 def configure_app(app, config) config.service_name ||= format_name(app.to_s) config.framework_name ||= 'Sinatra' config.framework_version ||= ::Sinatra::VERSION config.__root_path ||= Dir.pwd end
format_name(str)
click to toggle source
# File lib/atatus/sinatra.rb, line 49 def format_name(str) str&.gsub('::', '_') end