oneapm_rpm 1.3.6 → 1.3.7.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/one_apm/agent/agent/start_worker_thread.rb +8 -8
- data/lib/one_apm/agent/cross_app/cross_app_monitor.rb +2 -2
- data/lib/one_apm/agent/cross_app/cross_app_tracing.rb +2 -2
- data/lib/one_apm/agent/database.rb +17 -17
- data/lib/one_apm/agent/database/obfuscation_helpers.rb +13 -13
- data/lib/one_apm/agent/database/obfuscator.rb +5 -5
- data/lib/one_apm/agent/database/postgres_explain_obfuscator.rb +4 -4
- data/lib/one_apm/agent/datastore/metric_helper.rb +12 -12
- data/lib/one_apm/agent/datastore/mongo/command_formatter.rb +6 -6
- data/lib/one_apm/agent/datastore/mongo/metric_translator.rb +6 -6
- data/lib/one_apm/agent/datastore/mongo/obfuscator.rb +2 -2
- data/lib/one_apm/agent/datastore/mongo/statement_formatter.rb +4 -4
- data/lib/one_apm/agent/javascript_instrumentor.rb +22 -22
- data/lib/one_apm/agent/synthetics_monitor.rb +7 -7
- data/lib/one_apm/agent/threading/thread_profile.rb +2 -2
- data/lib/one_apm/collector/collector/http_connection.rb +4 -4
- data/lib/one_apm/collector/collector_service.rb +1 -1
- data/lib/one_apm/collector/commands/thread_profiler_session.rb +4 -4
- data/lib/one_apm/collector/containers/agent_command_router.rb +4 -4
- data/lib/one_apm/collector/containers/custom_event_aggregator.rb +10 -10
- data/lib/one_apm/collector/containers/error_collector.rb +4 -4
- data/lib/one_apm/collector/containers/sql_sampler.rb +2 -2
- data/lib/one_apm/collector/containers/transaction_event_aggregator.rb +36 -36
- data/lib/one_apm/collector/containers/transaction_sampler.rb +4 -4
- data/lib/one_apm/collector/containers/utilization_data.rb +1 -1
- data/lib/one_apm/collector/samplers/delayed_job_sampler.rb +7 -7
- data/lib/one_apm/collector/samplers/vm_sampler.rb +18 -18
- data/lib/one_apm/collector/stats_engine/gc_profiler.rb +6 -6
- data/lib/one_apm/collector/stats_engine/metric_stats.rb +1 -1
- data/lib/one_apm/collector/support/proc_poller.rb +2 -2
- data/lib/one_apm/configuration.rb +2 -2
- data/lib/one_apm/configuration/default_source.rb +2 -2
- data/lib/one_apm/configuration/environment_source.rb +5 -5
- data/lib/one_apm/configuration/high_security_source.rb +7 -7
- data/lib/one_apm/errors/noticed_error.rb +2 -2
- data/lib/one_apm/inst/dispatcher/puma.rb +7 -4
- data/lib/one_apm/inst/framework/grape.rb +9 -9
- data/lib/one_apm/inst/framework/sinatra/transaction_namer.rb +2 -2
- data/lib/one_apm/inst/http_clients/curb.rb +2 -2
- data/lib/one_apm/inst/http_clients/excon.rb +7 -7
- data/lib/one_apm/inst/http_clients/httpclient.rb +2 -2
- data/lib/one_apm/inst/http_clients/typhoeus.rb +2 -2
- data/lib/one_apm/inst/nosql/memcache.rb +5 -5
- data/lib/one_apm/inst/nosql/mongo2.rb +8 -8
- data/lib/one_apm/inst/orm/active_record.rb +2 -2
- data/lib/one_apm/inst/rails3/action_controller.rb +1 -1
- data/lib/one_apm/inst/rails4/action_view_subscriber.rb +2 -2
- data/lib/one_apm/inst/rails4/active_record_subscriber.rb +3 -3
- data/lib/one_apm/inst/support/queue_time.rb +14 -14
- data/lib/one_apm/logger/agent_logger.rb +4 -4
- data/lib/one_apm/metrics/metric_spec.rb +10 -10
- data/lib/one_apm/rack/browser_monitoring.rb +135 -144
- data/lib/one_apm/rack/developer_mode.rb +22 -33
- data/lib/one_apm/rack/developer_mode/helper.rb +1 -1
- data/lib/one_apm/rack/middleware_base.rb +2 -0
- data/lib/one_apm/rack/middleware_helper.rb +21 -0
- data/lib/one_apm/rack/middleware_hooks.rb +10 -8
- data/lib/one_apm/rack/middleware_tracing.rb +47 -44
- data/lib/one_apm/rack/middleware_wrapper.rb +63 -57
- data/lib/one_apm/support/backtrace/backtrace_node.rb +4 -4
- data/lib/one_apm/support/backtrace/backtrace_service.rb +7 -7
- data/lib/one_apm/support/collection_helper.rb +4 -4
- data/lib/one_apm/support/event_buffer/synthetics_event_buffer.rb +2 -2
- data/lib/one_apm/support/json_marshaller.rb +2 -2
- data/lib/one_apm/support/method_tracer.rb +2 -2
- data/lib/one_apm/support/method_tracer/helpers.rb +2 -2
- data/lib/one_apm/support/obfuscator.rb +5 -5
- data/lib/one_apm/support/rules_engine.rb +2 -2
- data/lib/one_apm/support/rules_engine/replacement_rule.rb +4 -4
- data/lib/one_apm/support/rules_engine/segment_terms_rule.rb +8 -8
- data/lib/one_apm/support/supported_versions.rb +9 -13
- data/lib/one_apm/support/vm/rubinius_vm.rb +1 -1
- data/lib/one_apm/transaction.rb +8 -8
- data/lib/one_apm/transaction/class_methods.rb +8 -8
- data/lib/one_apm/transaction/instance_helpers.rb +1 -1
- data/lib/one_apm/transaction/metric_constants.rb +27 -27
- data/lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb +3 -3
- data/lib/one_apm/transaction/sample_buffer/force_persist_sample_buffer.rb +2 -2
- data/lib/one_apm/transaction/sample_buffer/slowest_sample_buffer.rb +2 -2
- data/lib/one_apm/transaction/sample_buffer/transaction_sample_buffer.rb +3 -3
- data/lib/one_apm/transaction/segment.rb +2 -2
- data/lib/one_apm/transaction/transaction_finish_append.rb +3 -3
- data/lib/one_apm/transaction/transaction_jruby_functions.rb +3 -3
- data/lib/one_apm/transaction/transaction_name.rb +3 -3
- data/lib/one_apm/transaction/transaction_namer.rb +7 -7
- data/lib/one_apm/transaction/transaction_sample_builder.rb +3 -3
- data/lib/one_apm/transaction/transaction_summary.rb +4 -4
- data/lib/one_apm/transaction/transaction_timings.rb +1 -1
- data/lib/one_apm/version.rb +3 -2
- metadata +3 -2
@@ -169,7 +169,7 @@ module OneApm
|
|
169
169
|
builder.set_transaction_cpu_time(cpu_time) if builder
|
170
170
|
end
|
171
171
|
|
172
|
-
|
172
|
+
OA_MAX_DATA_LENGTH = 16384
|
173
173
|
# This method is used to record metadata into the currently
|
174
174
|
# active segment like a sql query, memcache key, or Net::HTTP uri
|
175
175
|
#
|
@@ -190,12 +190,12 @@ module OneApm
|
|
190
190
|
|
191
191
|
private :notice_extra_data
|
192
192
|
|
193
|
-
# Truncates the message to `
|
193
|
+
# Truncates the message to `OA_MAX_DATA_LENGTH` if needed, and
|
194
194
|
# appends an ellipsis because it makes the trucation clearer in
|
195
195
|
# the UI
|
196
196
|
def self.truncate_message(message)
|
197
|
-
if message.length > (
|
198
|
-
message[0..
|
197
|
+
if message.length > (OA_MAX_DATA_LENGTH - 4)
|
198
|
+
message[0..OA_MAX_DATA_LENGTH - 4] + '...'
|
199
199
|
else
|
200
200
|
message
|
201
201
|
end
|
@@ -27,15 +27,15 @@ module OneApm
|
|
27
27
|
OneApm::Manager.record_metric("Workers/DelayedJob/locked_jobs", value)
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
OA_FAILED_QUERY = 'failed_at is not NULL'.freeze
|
31
|
+
OA_LOCKED_QUERY = 'locked_by is not NULL'.freeze
|
32
32
|
|
33
33
|
def failed_jobs
|
34
|
-
count(
|
34
|
+
count(OA_FAILED_QUERY)
|
35
35
|
end
|
36
36
|
|
37
37
|
def locked_jobs
|
38
|
-
count(
|
38
|
+
count(OA_LOCKED_QUERY)
|
39
39
|
end
|
40
40
|
|
41
41
|
def count(query)
|
@@ -67,7 +67,7 @@ module OneApm
|
|
67
67
|
OneApm::Manager.record_metric(all_metric, counts.max)
|
68
68
|
end
|
69
69
|
|
70
|
-
|
70
|
+
OA_QUEUE_QUERY_CONDITION = 'run_at <= ? and failed_at is NULL'.freeze
|
71
71
|
|
72
72
|
def record_counts_by(column_name, metric_segment = column_name)
|
73
73
|
all_count = 0
|
@@ -84,9 +84,9 @@ module OneApm
|
|
84
84
|
now = ::Delayed::Job.db_time_now
|
85
85
|
result = if ::ActiveRecord::VERSION::MAJOR.to_i < 4
|
86
86
|
::Delayed::Job.count(:group => column_name,
|
87
|
-
:conditions => [
|
87
|
+
:conditions => [OA_QUEUE_QUERY_CONDITION, now])
|
88
88
|
else
|
89
|
-
::Delayed::Job.where(
|
89
|
+
::Delayed::Job.where(OA_QUEUE_QUERY_CONDITION, now).
|
90
90
|
group(column_name).
|
91
91
|
count
|
92
92
|
end
|
@@ -7,15 +7,15 @@ module OneApm
|
|
7
7
|
module Collector
|
8
8
|
module Samplers
|
9
9
|
class VMSampler < Sampler
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
10
|
+
OA_GC_RUNS_METRIC = 'RubyVM/GC/runs'.freeze
|
11
|
+
OA_HEAP_LIVE_METRIC = 'RubyVM/GC/heap_live'.freeze
|
12
|
+
OA_HEAP_FREE_METRIC = 'RubyVM/GC/heap_free'.freeze
|
13
|
+
OA_THREAD_COUNT_METRIC = 'RubyVM/Threads/all'.freeze
|
14
|
+
OA_OBJECT_ALLOCATIONS_METRIC = 'RubyVM/GC/total_allocated_object'.freeze
|
15
|
+
OA_MAJOR_GC_METRIC = 'RubyVM/GC/major_gc_count'.freeze
|
16
|
+
OA_MINOR_GC_METRIC = 'RubyVM/GC/minor_gc_count'.freeze
|
17
|
+
OA_METHOD_INVALIDATIONS_METRIC = 'RubyVM/CacheInvalidations/method'.freeze
|
18
|
+
OA_CONSTANT_INVALIDATIONS_METRIC = 'RubyVM/CacheInvalidations/constant'.freeze
|
19
19
|
|
20
20
|
attr_reader :transaction_count
|
21
21
|
|
@@ -56,7 +56,7 @@ module OneApm
|
|
56
56
|
gc_runs = snapshot.gc_runs - @last_snapshot.gc_runs
|
57
57
|
end
|
58
58
|
wall_clock_time = snapshot.taken_at - @last_snapshot.taken_at
|
59
|
-
OneApm::Manager.agent.stats_engine.tl_record_unscoped_metrics(
|
59
|
+
OneApm::Manager.agent.stats_engine.tl_record_unscoped_metrics(OA_GC_RUNS_METRIC) do |stats|
|
60
60
|
stats.call_count += txn_count
|
61
61
|
stats.total_call_time += gc_runs if gc_runs
|
62
62
|
stats.total_exclusive_time += gc_time if gc_time
|
@@ -86,19 +86,19 @@ module OneApm
|
|
86
86
|
|
87
87
|
def record_heap_live_metric(snapshot)
|
88
88
|
if snapshot.heap_live
|
89
|
-
record_gauge_metric(
|
89
|
+
record_gauge_metric(OA_HEAP_LIVE_METRIC, snapshot.heap_live)
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
93
|
def record_heap_free_metric(snapshot)
|
94
94
|
if snapshot.heap_free
|
95
|
-
record_gauge_metric(
|
95
|
+
record_gauge_metric(OA_HEAP_FREE_METRIC, snapshot.heap_free)
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
99
|
def record_thread_count_metric(snapshot)
|
100
100
|
if snapshot.thread_count
|
101
|
-
record_gauge_metric(
|
101
|
+
record_gauge_metric(OA_THREAD_COUNT_METRIC, snapshot.thread_count)
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
@@ -107,11 +107,11 @@ module OneApm
|
|
107
107
|
tcount = reset_transaction_count
|
108
108
|
|
109
109
|
record_gc_runs_metric(snap, tcount)
|
110
|
-
record_delta(snap, :total_allocated_object,
|
111
|
-
record_delta(snap, :major_gc_count,
|
112
|
-
record_delta(snap, :minor_gc_count,
|
113
|
-
record_delta(snap, :method_cache_invalidations,
|
114
|
-
record_delta(snap, :constant_cache_invalidations,
|
110
|
+
record_delta(snap, :total_allocated_object, OA_OBJECT_ALLOCATIONS_METRIC, tcount)
|
111
|
+
record_delta(snap, :major_gc_count, OA_MAJOR_GC_METRIC, tcount)
|
112
|
+
record_delta(snap, :minor_gc_count, OA_MINOR_GC_METRIC, tcount)
|
113
|
+
record_delta(snap, :method_cache_invalidations, OA_METHOD_INVALIDATIONS_METRIC, tcount)
|
114
|
+
record_delta(snap, :constant_cache_invalidations, OA_CONSTANT_INVALIDATIONS_METRIC, tcount)
|
115
115
|
record_heap_live_metric(snap)
|
116
116
|
record_heap_free_metric(snap)
|
117
117
|
record_thread_count_metric(snap)
|
@@ -43,22 +43,22 @@ module OneApm
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def self.record_gc_metric(call_count, elapsed)
|
46
|
-
OneApm::Manager.agent.stats_engine.tl_record_scoped_and_unscoped_metrics(gc_metric_name,
|
46
|
+
OneApm::Manager.agent.stats_engine.tl_record_scoped_and_unscoped_metrics(gc_metric_name, OA_GC_ROLLUP) do |stats|
|
47
47
|
stats.call_count += call_count
|
48
48
|
stats.total_call_time += elapsed
|
49
49
|
stats.total_exclusive_time += elapsed
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
OA_GC_ROLLUP = 'GC/Transaction/all'.freeze
|
54
|
+
OA_GC_OTHER = 'GC/Transaction/allOther'.freeze
|
55
|
+
OA_GC_WEB = 'GC/Transaction/allWeb'.freeze
|
56
56
|
|
57
57
|
def self.gc_metric_name
|
58
58
|
if OneApm::Transaction.recording_web_transaction?
|
59
|
-
|
59
|
+
OA_GC_WEB
|
60
60
|
else
|
61
|
-
|
61
|
+
OA_GC_OTHER
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -7,7 +7,7 @@ module OneApm
|
|
7
7
|
class StatsEngine
|
8
8
|
# Handles methods related to actual Metric collection
|
9
9
|
module MetricStats
|
10
|
-
|
10
|
+
OA_SCOPE_PLACEHOLDER = '__SCOPE__'.freeze
|
11
11
|
|
12
12
|
# Update the unscoped metrics given in metric_names.
|
13
13
|
# metric_names may be either a single name, or an array of names.
|
@@ -5,7 +5,7 @@ module OneApm
|
|
5
5
|
module Collector
|
6
6
|
class ProcPoller < OneApm::Collector::ShellPoller
|
7
7
|
|
8
|
-
|
8
|
+
OA_UPTIME_PATH = '/proc/uptime'.freeze
|
9
9
|
|
10
10
|
def self.enable?
|
11
11
|
::RUBY_PLATFORM.downcase =~ /linux/
|
@@ -35,7 +35,7 @@ module OneApm
|
|
35
35
|
private
|
36
36
|
# in seconds
|
37
37
|
def uptime
|
38
|
-
File.read(
|
38
|
+
File.read(OA_UPTIME_PATH).split[0].to_f
|
39
39
|
end
|
40
40
|
|
41
41
|
def proc_status_file
|
@@ -12,7 +12,7 @@ require 'one_apm/configuration/high_security_source'
|
|
12
12
|
module OneApm
|
13
13
|
module Configuration
|
14
14
|
|
15
|
-
|
15
|
+
OA_MASK_DEFAULTS = {
|
16
16
|
:'thread_profiler' => Proc.new { !OneApm::Agent::Threading::BacktraceService.is_supported? },
|
17
17
|
:'thread_profiler.enabled' => Proc.new { !OneApm::Agent::Threading::BacktraceService.is_supported? }
|
18
18
|
}
|
@@ -236,7 +236,7 @@ module OneApm
|
|
236
236
|
end
|
237
237
|
|
238
238
|
def apply_mask(hash)
|
239
|
-
|
239
|
+
OA_MASK_DEFAULTS. \
|
240
240
|
select {|_, proc| proc.call}. \
|
241
241
|
each {|key, _| hash.delete(key) }
|
242
242
|
hash
|
@@ -156,7 +156,7 @@ module OneApm
|
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
159
|
-
|
159
|
+
OA_AUTOSTART_BLACKLISTED_RAKE_TASKS = [
|
160
160
|
'about',
|
161
161
|
'assets:clean',
|
162
162
|
'assets:clobber',
|
@@ -350,7 +350,7 @@ module OneApm
|
|
350
350
|
:description => 'Defines a comma-delimited list of executables that should not be instrumented by the agent (e.g. \'rake,my_ruby_script.rb\').'
|
351
351
|
},
|
352
352
|
:'autostart.blacklisted_rake_tasks' => {
|
353
|
-
:default =>
|
353
|
+
:default => OA_AUTOSTART_BLACKLISTED_RAKE_TASKS,
|
354
354
|
:public => true,
|
355
355
|
:type => String,
|
356
356
|
:notified => false,
|
@@ -4,8 +4,8 @@ module OneApm
|
|
4
4
|
module Configuration
|
5
5
|
class EnvironmentSource < OneApm::Support::DottedHash
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
OA_SUPPORTED_PREFIXES = /^oneapm_/i
|
8
|
+
OA_SPECIAL_CASE_KEYS = [
|
9
9
|
'ONEAPM_ENV', # read by OneApm::Probe::Frameworks::Ruby
|
10
10
|
'ONEAPM_LOG' # read by set_log_file
|
11
11
|
]
|
@@ -64,7 +64,7 @@ module OneApm
|
|
64
64
|
env_var_keys = collect_one_apm_environment_variable_keys
|
65
65
|
|
66
66
|
env_var_keys.each do |key|
|
67
|
-
next if
|
67
|
+
next if OA_SPECIAL_CASE_KEYS.include?(key.upcase)
|
68
68
|
set_value_from_environment_variable(key)
|
69
69
|
end
|
70
70
|
end
|
@@ -99,12 +99,12 @@ module OneApm
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def convert_environment_key_to_config_key(key)
|
102
|
-
stripped_key = key.gsub(
|
102
|
+
stripped_key = key.gsub(OA_SUPPORTED_PREFIXES, '').downcase.to_sym
|
103
103
|
self.alias_map[stripped_key] || stripped_key
|
104
104
|
end
|
105
105
|
|
106
106
|
def collect_one_apm_environment_variable_keys
|
107
|
-
ENV.keys.select { |key| key.match(
|
107
|
+
ENV.keys.select { |key| key.match(OA_SUPPORTED_PREFIXES) }
|
108
108
|
end
|
109
109
|
|
110
110
|
end
|
@@ -6,11 +6,11 @@ module OneApm
|
|
6
6
|
module Configuration
|
7
7
|
class HighSecuritySource < OneApm::Support::DottedHash
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OA_OFF = "off".freeze
|
10
|
+
OA_RAW = "raw".freeze
|
11
|
+
OA_OBFUSCATED = "obfuscated".freeze
|
12
12
|
|
13
|
-
|
13
|
+
OA_SET_TO_OBFUSCATED = [OA_RAW, OA_OBFUSCATED]
|
14
14
|
|
15
15
|
def initialize(local_settings)
|
16
16
|
super({
|
@@ -39,10 +39,10 @@ module OneApm
|
|
39
39
|
|
40
40
|
def record_sql_setting(local_settings, key)
|
41
41
|
original_value = local_settings[key]
|
42
|
-
result = if
|
43
|
-
|
42
|
+
result = if OA_SET_TO_OBFUSCATED.include?(original_value)
|
43
|
+
OA_OBFUSCATED
|
44
44
|
else
|
45
|
-
|
45
|
+
OA_OFF
|
46
46
|
end
|
47
47
|
|
48
48
|
if result != original_value
|
@@ -10,7 +10,7 @@ class OneApm::NoticedError
|
|
10
10
|
attr_accessor :path, :timestamp, :params, :message, :exception_class_name
|
11
11
|
attr_reader :exception_id, :is_internal
|
12
12
|
|
13
|
-
|
13
|
+
OA_STRIPPED_EXCEPTION_REPLACEMENT_MESSAGE = "Message removed by OneApm 'strip_exception_messages' setting"
|
14
14
|
|
15
15
|
def initialize(path, data, exception, timestamp = Time.now)
|
16
16
|
@exception_id = exception.object_id
|
@@ -49,7 +49,7 @@ class OneApm::NoticedError
|
|
49
49
|
# replace error message if enabled
|
50
50
|
if OneApm::Manager.config[:'strip_exception_messages.enabled'] &&
|
51
51
|
!self.class.passes_message_whitelist(exception.class)
|
52
|
-
@message =
|
52
|
+
@message = OA_STRIPPED_EXCEPTION_REPLACEMENT_MESSAGE
|
53
53
|
end
|
54
54
|
|
55
55
|
@timestamp = timestamp
|
@@ -3,10 +3,15 @@
|
|
3
3
|
LibraryDetection.defer do
|
4
4
|
named :puma
|
5
5
|
|
6
|
+
def oa_puma_hooks
|
7
|
+
Puma.cli_config.options[:worker_boot] || Puma.cli_config.options[:before_worker_boot]
|
8
|
+
end
|
9
|
+
|
6
10
|
depends_on do
|
7
11
|
defined?(::Puma) &&
|
8
12
|
defined?(::Puma::Const::VERSION) &&
|
9
|
-
::Puma.respond_to?(:cli_config)
|
13
|
+
::Puma.respond_to?(:cli_config) &&
|
14
|
+
!oa_puma_hooks.nil?
|
10
15
|
end
|
11
16
|
|
12
17
|
executes do
|
@@ -14,9 +19,7 @@ LibraryDetection.defer do
|
|
14
19
|
end
|
15
20
|
|
16
21
|
executes do
|
17
|
-
|
18
|
-
|
19
|
-
hooks << Proc.new do
|
22
|
+
oa_puma_hooks << Proc.new do
|
20
23
|
OneApm::Manager.agent.after_fork(:force_reconnect => true)
|
21
24
|
end
|
22
25
|
end
|
@@ -8,11 +8,11 @@ module OneApm
|
|
8
8
|
module Grape
|
9
9
|
extend self
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
OA_API_ENDPOINT = 'api.endpoint'.freeze
|
12
|
+
OA_FORMAT_REGEX = /\(\/?\.(:format|json)?\)/.freeze
|
13
|
+
OA_VERSION_REGEX = /:version(\/|$)/.freeze
|
14
|
+
OA_EMPTY_STRING = ''.freeze
|
15
|
+
OA_MIN_VERSION = VersionNumber.new('0.2.0')
|
16
16
|
|
17
17
|
def handle_transaction(endpoint, class_name)
|
18
18
|
return unless endpoint && route = endpoint.route
|
@@ -28,11 +28,11 @@ module OneApm
|
|
28
28
|
|
29
29
|
def name_for_transaction(route, class_name)
|
30
30
|
route_path, route_method, route_version = path_method_version_of(route)
|
31
|
-
action_name = route_path.sub(
|
31
|
+
action_name = route_path.sub(OA_FORMAT_REGEX, OA_EMPTY_STRING)
|
32
32
|
method_name = route_method
|
33
33
|
|
34
34
|
if route_version
|
35
|
-
action_name = action_name.sub(
|
35
|
+
action_name = action_name.sub(OA_VERSION_REGEX, OA_EMPTY_STRING)
|
36
36
|
"#{class_name}-#{route_version}#{action_name} (#{method_name})"
|
37
37
|
else
|
38
38
|
"#{class_name}#{action_name} (#{method_name})"
|
@@ -72,7 +72,7 @@ LibraryDetection.defer do
|
|
72
72
|
|
73
73
|
depends_on do
|
74
74
|
defined?(::Grape::VERSION) &&
|
75
|
-
::OneApm::VersionNumber.new(::Grape::VERSION) >= ::OneApm::Agent::Instrumentation::Grape::
|
75
|
+
::OneApm::VersionNumber.new(::Grape::VERSION) >= ::OneApm::Agent::Instrumentation::Grape::OA_MIN_VERSION
|
76
76
|
end
|
77
77
|
|
78
78
|
executes do
|
@@ -87,7 +87,7 @@ LibraryDetection.defer do
|
|
87
87
|
response = call_without_one_apm(env)
|
88
88
|
ensure
|
89
89
|
begin
|
90
|
-
endpoint = env[::OneApm::Agent::Instrumentation::Grape::
|
90
|
+
endpoint = env[::OneApm::Agent::Instrumentation::Grape::OA_API_ENDPOINT]
|
91
91
|
::OneApm::Agent::Instrumentation::Grape.handle_transaction(endpoint, self.class.name)
|
92
92
|
rescue => e
|
93
93
|
OneApm::Manager.logger.warn("Error in Grape instrumentation", e)
|
@@ -15,7 +15,7 @@ module OneApm
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def initial_transaction_name(request)
|
18
|
-
transaction_name(OneApm::Transaction::
|
18
|
+
transaction_name(OneApm::Transaction::OA_UNKNOWN_METRIC, request)
|
19
19
|
end
|
20
20
|
|
21
21
|
def transaction_name(route_text, request)
|
@@ -27,7 +27,7 @@ module OneApm
|
|
27
27
|
name
|
28
28
|
rescue => e
|
29
29
|
OneApm::Manager.logger.debug("#{e.class} : #{e.message} - Error encountered trying to identify Sinatra transaction name")
|
30
|
-
OneApm::Transaction::
|
30
|
+
OneApm::Transaction::OA_UNKNOWN_METRIC
|
31
31
|
end
|
32
32
|
|
33
33
|
def http_verb(request)
|
@@ -3,11 +3,11 @@
|
|
3
3
|
LibraryDetection.defer do
|
4
4
|
named :curb
|
5
5
|
|
6
|
-
|
6
|
+
OA_CURB_MINIMUM_VERSION = ::OneApm::VersionNumber.new("0.8.1")
|
7
7
|
|
8
8
|
depends_on do
|
9
9
|
defined?(::Curl) && defined?(::Curl::CURB_VERSION) &&
|
10
|
-
::OneApm::VersionNumber.new(::Curl::CURB_VERSION) >=
|
10
|
+
::OneApm::VersionNumber.new(::Curl::CURB_VERSION) >= OA_CURB_MINIMUM_VERSION
|
11
11
|
end
|
12
12
|
|
13
13
|
executes do
|
@@ -7,8 +7,8 @@ LibraryDetection.defer do
|
|
7
7
|
# - For newer versions, use the middleware mechanism Excon exposes
|
8
8
|
# - For older versions, monkey-patch Excon::Connection#request
|
9
9
|
#
|
10
|
-
#
|
11
|
-
#
|
10
|
+
# OA_EXCON_MINIMUM_VERSION is the minimum version we attempt to instrument at all.
|
11
|
+
# OA_EXCON_MIDDLEWARE_MINIMUM_VERSION is the min version we use the newer
|
12
12
|
# instrumentation for.
|
13
13
|
#
|
14
14
|
# Note that middlewares were added to Excon prior to 0.19, but we don't
|
@@ -23,8 +23,8 @@ LibraryDetection.defer do
|
|
23
23
|
# so we could safely subscribe and not be clobbered by future subscribers,
|
24
24
|
# but alas, it does not yet.
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
OA_EXCON_MINIMUM_VERSION = ::OneApm::VersionNumber.new("0.10.1")
|
27
|
+
OA_EXCON_MIDDLEWARE_MINIMUM_VERSION = ::OneApm::VersionNumber.new("0.19.0")
|
28
28
|
|
29
29
|
depends_on do
|
30
30
|
defined?(::Excon) && defined?(::Excon::VERSION)
|
@@ -32,10 +32,10 @@ LibraryDetection.defer do
|
|
32
32
|
|
33
33
|
executes do
|
34
34
|
excon_version = OneApm::VersionNumber.new(::Excon::VERSION)
|
35
|
-
if excon_version >=
|
35
|
+
if excon_version >= OA_EXCON_MINIMUM_VERSION
|
36
36
|
install_excon_instrumentation(excon_version)
|
37
37
|
else
|
38
|
-
OneApm::Manager.logger.warn("Excon instrumentation requires at least version #{
|
38
|
+
OneApm::Manager.logger.warn("Excon instrumentation requires at least version #{OA_EXCON_MINIMUM_VERSION}")
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -43,7 +43,7 @@ LibraryDetection.defer do
|
|
43
43
|
require 'one_apm/agent/cross_app/cross_app_tracing'
|
44
44
|
require 'one_apm/support/http_clients/excon_wrappers'
|
45
45
|
|
46
|
-
if excon_version >=
|
46
|
+
if excon_version >= OA_EXCON_MIDDLEWARE_MINIMUM_VERSION
|
47
47
|
install_middleware_excon_instrumentation
|
48
48
|
else
|
49
49
|
install_legacy_excon_instrumentation
|