Sha256: 21b137dad97ec91226cb75b502489bebf354d7cc3e88d9bc581ec6dfeb3fe047
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true module ElasticAPM # Module for starting the ElasticAPM agent and hooking into Sinatra. module Sinatra extend self # Start the ElasticAPM 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. 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 private 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) str && str.gsub('::', '_') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
elastic-apm-3.1.0 | lib/elastic_apm/sinatra.rb |