module ElasticAPM::Sinatra

def configure_app(app, config)

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

def format_name(str)

def format_name(str)
  str&.gsub('::', '_')
end

def start(app, config = {})

Returns:
  • (true, nil) - true if the agent was started, nil otherwise.

Parameters:
  • config (Config, Hash) -- An instance of Config or a Hash config.
  • app (Sinatra::Base) -- A Sinatra app.
def start(app, config = {})
  config = Config.new(config) unless config.is_a?(Config)
  configure_app(app, config)
  ElasticAPM.start(config)
  ElasticAPM.running?
rescue StandardError => e
  config.logger.error format('Failed to start: %s', e.message)
  config.logger.debug "Backtrace:\n" + e.backtrace.join("\n")
end