module ElasticAPM::Grape
def attach_subscriber(agent)
def attach_subscriber(agent) return unless agent agent.instrumenter.subscriber = ElasticAPM::Subscriber.new(agent) end
def configure_app(app, config)
def configure_app(app, config) config.service_name ||= app.name config.framework_name ||= 'Grape' config.framework_version ||= ::Grape::VERSION config.logger ||= app.logger config.__root_path ||= Dir.pwd end
def start(app, config = {})
-
(true, nil)
- true if the agent was started, nil otherwise.
Parameters:
-
config
(Config, Hash
) -- An instance of Config or a Hash config. -
app
(Grape::API
) -- A Grape app.
def start(app, config = {}) config = Config.new(config) unless config.is_a?(Config) configure_app(app, config) ElasticAPM.start(config).tap do |agent| attach_subscriber(agent) end 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