lib/one_apm/inst/framework/grape.rb in oneapm_rpm-1.3.6 vs lib/one_apm/inst/framework/grape.rb in oneapm_rpm-1.3.7.rc1
- old
+ new
@@ -6,15 +6,15 @@
module Agent
module Instrumentation
module Grape
extend self
- API_ENDPOINT = 'api.endpoint'.freeze
- FORMAT_REGEX = /\(\/?\.(:format|json)?\)/.freeze
- VERSION_REGEX = /:version(\/|$)/.freeze
- EMPTY_STRING = ''.freeze
- MIN_VERSION = VersionNumber.new('0.2.0')
+ OA_API_ENDPOINT = 'api.endpoint'.freeze
+ OA_FORMAT_REGEX = /\(\/?\.(:format|json)?\)/.freeze
+ OA_VERSION_REGEX = /:version(\/|$)/.freeze
+ OA_EMPTY_STRING = ''.freeze
+ OA_MIN_VERSION = VersionNumber.new('0.2.0')
def handle_transaction(endpoint, class_name)
return unless endpoint && route = endpoint.route
name_transaction(route, class_name)
capture_params(endpoint) if OneApm::Manager.config[:capture_params]
@@ -26,15 +26,15 @@
Transaction.set_default_transaction_name(txn_name, :grape, segment_name)
end
def name_for_transaction(route, class_name)
route_path, route_method, route_version = path_method_version_of(route)
- action_name = route_path.sub(FORMAT_REGEX, EMPTY_STRING)
+ action_name = route_path.sub(OA_FORMAT_REGEX, OA_EMPTY_STRING)
method_name = route_method
if route_version
- action_name = action_name.sub(VERSION_REGEX, EMPTY_STRING)
+ action_name = action_name.sub(OA_VERSION_REGEX, OA_EMPTY_STRING)
"#{class_name}-#{route_version}#{action_name} (#{method_name})"
else
"#{class_name}#{action_name} (#{method_name})"
end
end
@@ -70,11 +70,11 @@
OneApm::Manager.config[:disable_grape] == false
end
depends_on do
defined?(::Grape::VERSION) &&
- ::OneApm::VersionNumber.new(::Grape::VERSION) >= ::OneApm::Agent::Instrumentation::Grape::MIN_VERSION
+ ::OneApm::VersionNumber.new(::Grape::VERSION) >= ::OneApm::Agent::Instrumentation::Grape::OA_MIN_VERSION
end
executes do
OneApm::Manager.logger.info 'Installing Grape instrumentation'
instrument_call
@@ -85,10 +85,10 @@
def call_with_one_apm(env)
begin
response = call_without_one_apm(env)
ensure
begin
- endpoint = env[::OneApm::Agent::Instrumentation::Grape::API_ENDPOINT]
+ endpoint = env[::OneApm::Agent::Instrumentation::Grape::OA_API_ENDPOINT]
::OneApm::Agent::Instrumentation::Grape.handle_transaction(endpoint, self.class.name)
rescue => e
OneApm::Manager.logger.warn("Error in Grape instrumentation", e)
end
end