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.
Files changed (91) hide show
  1. checksums.yaml +8 -8
  2. data/lib/one_apm/agent/agent/start_worker_thread.rb +8 -8
  3. data/lib/one_apm/agent/cross_app/cross_app_monitor.rb +2 -2
  4. data/lib/one_apm/agent/cross_app/cross_app_tracing.rb +2 -2
  5. data/lib/one_apm/agent/database.rb +17 -17
  6. data/lib/one_apm/agent/database/obfuscation_helpers.rb +13 -13
  7. data/lib/one_apm/agent/database/obfuscator.rb +5 -5
  8. data/lib/one_apm/agent/database/postgres_explain_obfuscator.rb +4 -4
  9. data/lib/one_apm/agent/datastore/metric_helper.rb +12 -12
  10. data/lib/one_apm/agent/datastore/mongo/command_formatter.rb +6 -6
  11. data/lib/one_apm/agent/datastore/mongo/metric_translator.rb +6 -6
  12. data/lib/one_apm/agent/datastore/mongo/obfuscator.rb +2 -2
  13. data/lib/one_apm/agent/datastore/mongo/statement_formatter.rb +4 -4
  14. data/lib/one_apm/agent/javascript_instrumentor.rb +22 -22
  15. data/lib/one_apm/agent/synthetics_monitor.rb +7 -7
  16. data/lib/one_apm/agent/threading/thread_profile.rb +2 -2
  17. data/lib/one_apm/collector/collector/http_connection.rb +4 -4
  18. data/lib/one_apm/collector/collector_service.rb +1 -1
  19. data/lib/one_apm/collector/commands/thread_profiler_session.rb +4 -4
  20. data/lib/one_apm/collector/containers/agent_command_router.rb +4 -4
  21. data/lib/one_apm/collector/containers/custom_event_aggregator.rb +10 -10
  22. data/lib/one_apm/collector/containers/error_collector.rb +4 -4
  23. data/lib/one_apm/collector/containers/sql_sampler.rb +2 -2
  24. data/lib/one_apm/collector/containers/transaction_event_aggregator.rb +36 -36
  25. data/lib/one_apm/collector/containers/transaction_sampler.rb +4 -4
  26. data/lib/one_apm/collector/containers/utilization_data.rb +1 -1
  27. data/lib/one_apm/collector/samplers/delayed_job_sampler.rb +7 -7
  28. data/lib/one_apm/collector/samplers/vm_sampler.rb +18 -18
  29. data/lib/one_apm/collector/stats_engine/gc_profiler.rb +6 -6
  30. data/lib/one_apm/collector/stats_engine/metric_stats.rb +1 -1
  31. data/lib/one_apm/collector/support/proc_poller.rb +2 -2
  32. data/lib/one_apm/configuration.rb +2 -2
  33. data/lib/one_apm/configuration/default_source.rb +2 -2
  34. data/lib/one_apm/configuration/environment_source.rb +5 -5
  35. data/lib/one_apm/configuration/high_security_source.rb +7 -7
  36. data/lib/one_apm/errors/noticed_error.rb +2 -2
  37. data/lib/one_apm/inst/dispatcher/puma.rb +7 -4
  38. data/lib/one_apm/inst/framework/grape.rb +9 -9
  39. data/lib/one_apm/inst/framework/sinatra/transaction_namer.rb +2 -2
  40. data/lib/one_apm/inst/http_clients/curb.rb +2 -2
  41. data/lib/one_apm/inst/http_clients/excon.rb +7 -7
  42. data/lib/one_apm/inst/http_clients/httpclient.rb +2 -2
  43. data/lib/one_apm/inst/http_clients/typhoeus.rb +2 -2
  44. data/lib/one_apm/inst/nosql/memcache.rb +5 -5
  45. data/lib/one_apm/inst/nosql/mongo2.rb +8 -8
  46. data/lib/one_apm/inst/orm/active_record.rb +2 -2
  47. data/lib/one_apm/inst/rails3/action_controller.rb +1 -1
  48. data/lib/one_apm/inst/rails4/action_view_subscriber.rb +2 -2
  49. data/lib/one_apm/inst/rails4/active_record_subscriber.rb +3 -3
  50. data/lib/one_apm/inst/support/queue_time.rb +14 -14
  51. data/lib/one_apm/logger/agent_logger.rb +4 -4
  52. data/lib/one_apm/metrics/metric_spec.rb +10 -10
  53. data/lib/one_apm/rack/browser_monitoring.rb +135 -144
  54. data/lib/one_apm/rack/developer_mode.rb +22 -33
  55. data/lib/one_apm/rack/developer_mode/helper.rb +1 -1
  56. data/lib/one_apm/rack/middleware_base.rb +2 -0
  57. data/lib/one_apm/rack/middleware_helper.rb +21 -0
  58. data/lib/one_apm/rack/middleware_hooks.rb +10 -8
  59. data/lib/one_apm/rack/middleware_tracing.rb +47 -44
  60. data/lib/one_apm/rack/middleware_wrapper.rb +63 -57
  61. data/lib/one_apm/support/backtrace/backtrace_node.rb +4 -4
  62. data/lib/one_apm/support/backtrace/backtrace_service.rb +7 -7
  63. data/lib/one_apm/support/collection_helper.rb +4 -4
  64. data/lib/one_apm/support/event_buffer/synthetics_event_buffer.rb +2 -2
  65. data/lib/one_apm/support/json_marshaller.rb +2 -2
  66. data/lib/one_apm/support/method_tracer.rb +2 -2
  67. data/lib/one_apm/support/method_tracer/helpers.rb +2 -2
  68. data/lib/one_apm/support/obfuscator.rb +5 -5
  69. data/lib/one_apm/support/rules_engine.rb +2 -2
  70. data/lib/one_apm/support/rules_engine/replacement_rule.rb +4 -4
  71. data/lib/one_apm/support/rules_engine/segment_terms_rule.rb +8 -8
  72. data/lib/one_apm/support/supported_versions.rb +9 -13
  73. data/lib/one_apm/support/vm/rubinius_vm.rb +1 -1
  74. data/lib/one_apm/transaction.rb +8 -8
  75. data/lib/one_apm/transaction/class_methods.rb +8 -8
  76. data/lib/one_apm/transaction/instance_helpers.rb +1 -1
  77. data/lib/one_apm/transaction/metric_constants.rb +27 -27
  78. data/lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb +3 -3
  79. data/lib/one_apm/transaction/sample_buffer/force_persist_sample_buffer.rb +2 -2
  80. data/lib/one_apm/transaction/sample_buffer/slowest_sample_buffer.rb +2 -2
  81. data/lib/one_apm/transaction/sample_buffer/transaction_sample_buffer.rb +3 -3
  82. data/lib/one_apm/transaction/segment.rb +2 -2
  83. data/lib/one_apm/transaction/transaction_finish_append.rb +3 -3
  84. data/lib/one_apm/transaction/transaction_jruby_functions.rb +3 -3
  85. data/lib/one_apm/transaction/transaction_name.rb +3 -3
  86. data/lib/one_apm/transaction/transaction_namer.rb +7 -7
  87. data/lib/one_apm/transaction/transaction_sample_builder.rb +3 -3
  88. data/lib/one_apm/transaction/transaction_summary.rb +4 -4
  89. data/lib/one_apm/transaction/transaction_timings.rb +1 -1
  90. data/lib/one_apm/version.rb +3 -2
  91. metadata +3 -2
@@ -6,9 +6,9 @@ module OneApm
6
6
  module Mongo
7
7
  module Obfuscator
8
8
 
9
- WHITELIST = [:operation].freeze
9
+ OA_WHITELIST = [:operation].freeze
10
10
 
11
- def self.obfuscate_statement(source, whitelist=WHITELIST)
11
+ def self.obfuscate_statement(source, whitelist=OA_WHITELIST)
12
12
  obfuscated = {}
13
13
  source.each do |key, value|
14
14
  if whitelist.include?(key)
@@ -8,7 +8,7 @@ module OneApm
8
8
  module Mongo
9
9
  module StatementFormatter
10
10
 
11
- PLAINTEXT_KEYS = [
11
+ OA_PLAINTEXT_KEYS = [
12
12
  :database,
13
13
  :collection,
14
14
  :operation,
@@ -18,7 +18,7 @@ module OneApm
18
18
  :order
19
19
  ]
20
20
 
21
- OBFUSCATE_KEYS = [
21
+ OA_OBFUSCATE_KEYS = [
22
22
  :selector
23
23
  ]
24
24
 
@@ -27,11 +27,11 @@ module OneApm
27
27
 
28
28
  result = { :operation => operation }
29
29
 
30
- PLAINTEXT_KEYS.each do |key|
30
+ OA_PLAINTEXT_KEYS.each do |key|
31
31
  result[key] = statement[key] if statement.key?(key)
32
32
  end
33
33
 
34
- OBFUSCATE_KEYS.each do |key|
34
+ OA_OBFUSCATE_KEYS.each do |key|
35
35
  if statement.key?(key) && statement[key]
36
36
  obfuscated = obfuscate(statement[key])
37
37
  result[key] = obfuscated if obfuscated
@@ -9,7 +9,7 @@ module OneApm
9
9
  class JavascriptInstrumentor
10
10
  include OneApm::Coerce
11
11
 
12
- RUM_KEY_LENGTH = 13
12
+ OA_RUM_KEY_LENGTH = 13
13
13
 
14
14
  def initialize(event_listener)
15
15
  event_listener.subscribe(:finished_configuring, &method(:log_configuration))
@@ -30,7 +30,7 @@ module OneApm
30
30
  end
31
31
 
32
32
  def obfuscator
33
- @obfuscator ||= OneApm::Agent::Obfuscator.new(OneApm::Manager.config[:license_key], RUM_KEY_LENGTH)
33
+ @obfuscator ||= OneApm::Agent::Obfuscator.new(OneApm::Manager.config[:license_key], OA_RUM_KEY_LENGTH)
34
34
  end
35
35
 
36
36
  def js_enabled_and_ready?
@@ -121,30 +121,30 @@ module OneApm
121
121
  ''
122
122
  end
123
123
 
124
- BEACON_KEY = "beacon".freeze
125
- ERROR_BEACON_KEY = "errorBeacon".freeze
126
- LICENSE_KEY_KEY = "licenseKey".freeze
127
- APPLICATIONID_KEY = "applicationID".freeze
128
- TRANSACTION_NAME_KEY = "transactionName".freeze
129
- QUEUE_TIME_KEY = "queueTime".freeze
130
- APPLICATION_TIME_KEY = "applicationTime".freeze
131
- AGENT_KEY = "agent".freeze
132
- USER_ATTRIBUTES_KEY = "userAttributes".freeze
133
- SSL_FOR_HTTP_KEY = "sslForHttp".freeze
124
+ OA_BEACON_KEY = "beacon".freeze
125
+ OA_ERROR_BEACON_KEY = "errorBeacon".freeze
126
+ OA_LICENSE_KEY_KEY = "licenseKey".freeze
127
+ OA_APPLICATIONID_KEY = "applicationID".freeze
128
+ OA_TRANSACTION_NAME_KEY = "transactionName".freeze
129
+ OA_QUEUE_TIME_KEY = "queueTime".freeze
130
+ OA_APPLICATION_TIME_KEY = "applicationTime".freeze
131
+ OA_AGENT_KEY = "agent".freeze
132
+ OA_USER_ATTRIBUTES_KEY = "userAttributes".freeze
133
+ OA_SSL_FOR_HTTP_KEY = "sslForHttp".freeze
134
134
 
135
135
  # NOTE: Internal prototyping may override this, so leave name stable!
136
136
  def data_for_js_agent(state)
137
137
  timings = state.timings
138
138
 
139
139
  data = {
140
- BEACON_KEY => OneApm::Manager.config[:beacon],
141
- ERROR_BEACON_KEY => OneApm::Manager.config[:error_beacon],
142
- LICENSE_KEY_KEY => OneApm::Manager.config[:browser_key],
143
- APPLICATIONID_KEY => OneApm::Manager.config[:application_id],
144
- TRANSACTION_NAME_KEY => obfuscator.obfuscate(timings.transaction_name_or_unknown),
145
- QUEUE_TIME_KEY => timings.queue_time_in_millis,
146
- APPLICATION_TIME_KEY => timings.app_time_in_millis,
147
- AGENT_KEY => OneApm::Manager.config[:js_agent_file]
140
+ OA_BEACON_KEY => OneApm::Manager.config[:beacon],
141
+ OA_ERROR_BEACON_KEY => OneApm::Manager.config[:error_beacon],
142
+ OA_LICENSE_KEY_KEY => OneApm::Manager.config[:browser_key],
143
+ OA_APPLICATIONID_KEY => OneApm::Manager.config[:application_id],
144
+ OA_TRANSACTION_NAME_KEY => obfuscator.obfuscate(timings.transaction_name_or_unknown),
145
+ OA_QUEUE_TIME_KEY => timings.queue_time_in_millis,
146
+ OA_APPLICATION_TIME_KEY => timings.app_time_in_millis,
147
+ OA_AGENT_KEY => OneApm::Manager.config[:js_agent_file]
148
148
  }
149
149
 
150
150
  add_ssl_for_http(data)
@@ -156,7 +156,7 @@ module OneApm
156
156
  def add_ssl_for_http(data)
157
157
  ssl_for_http = OneApm::Manager.config[:'browser_monitoring.ssl_for_http']
158
158
  unless ssl_for_http.nil?
159
- data[SSL_FOR_HTTP_KEY] = ssl_for_http
159
+ data[OA_SSL_FOR_HTTP_KEY] = ssl_for_http
160
160
  end
161
161
  end
162
162
 
@@ -165,7 +165,7 @@ module OneApm
165
165
 
166
166
  params = event_params(txn.custom_parameters)
167
167
  json = OneApm::JSONWrapper.dump(params)
168
- data[USER_ATTRIBUTES_KEY] = obfuscator.obfuscate(json)
168
+ data[OA_USER_ATTRIBUTES_KEY] = obfuscator.obfuscate(json)
169
169
  end
170
170
 
171
171
  def include_custom_parameters?(txn)
@@ -5,20 +5,20 @@ require 'one_apm/agent/inbound_request_monitor'
5
5
  module OneApm
6
6
  module Agent
7
7
  class SyntheticsMonitor < InboundRequestMonitor
8
- SYNTHETICS_HEADER_KEY = 'HTTP_X_ONEAPM_SYNTHETICS'.freeze
8
+ OA_SYNTHETICS_HEADER_KEY = 'HTTP_X_ONEAPM_SYNTHETICS'.freeze
9
9
 
10
- SUPPORTED_VERSION = 1
11
- EXPECTED_PAYLOAD_LENGTH = 5
10
+ OA_SUPPORTED_VERSION = 1
11
+ OA_EXPECTED_PAYLOAD_LENGTH = 5
12
12
 
13
13
  def on_finished_configuring(events)
14
14
  events.subscribe(:before_call, &method(:on_before_call))
15
15
  end
16
16
 
17
17
  def on_before_call(request)
18
- encoded_header = request[SYNTHETICS_HEADER_KEY]
18
+ encoded_header = request[OA_SYNTHETICS_HEADER_KEY]
19
19
  return unless encoded_header
20
20
 
21
- incoming_payload = deserialize_header(encoded_header, SYNTHETICS_HEADER_KEY)
21
+ incoming_payload = deserialize_header(encoded_header, OA_SYNTHETICS_HEADER_KEY)
22
22
 
23
23
  return unless incoming_payload &&
24
24
  is_valid_payload?(incoming_payload) &&
@@ -32,7 +32,7 @@ module OneApm
32
32
  end
33
33
 
34
34
  def is_supported_version?(incoming_payload)
35
- incoming_payload.first == SUPPORTED_VERSION
35
+ incoming_payload.first == OA_SUPPORTED_VERSION
36
36
  end
37
37
 
38
38
  def is_trusted?(incoming_payload)
@@ -41,7 +41,7 @@ module OneApm
41
41
  end
42
42
 
43
43
  def is_valid_payload?(incoming_payload)
44
- incoming_payload.length == EXPECTED_PAYLOAD_LENGTH
44
+ incoming_payload.length == OA_EXPECTED_PAYLOAD_LENGTH
45
45
  end
46
46
  end
47
47
  end
@@ -106,12 +106,12 @@ module OneApm
106
106
  end
107
107
  end
108
108
 
109
- THREAD_PROFILER_NODES = 20_000
109
+ OA_THREAD_PROFILER_NODES = 20_000
110
110
 
111
111
  include OneApm::Coerce
112
112
 
113
113
  def generate_traces
114
- convert_N_trace_nodes_to_arrays(THREAD_PROFILER_NODES)
114
+ convert_N_trace_nodes_to_arrays(OA_THREAD_PROFILER_NODES)
115
115
 
116
116
  {
117
117
  "OTHER" => @traces[:other ].as_array,
@@ -5,7 +5,7 @@ module OneApm
5
5
 
6
6
  # These include Errno connection errors, and all indicate that the
7
7
  # underlying TCP connection may be in a bad state.
8
- CONNECTION_ERRORS = [Timeout::Error, EOFError, SystemCallError, SocketError].freeze
8
+ OA_CONNECTION_ERRORS = [Timeout::Error, EOFError, SystemCallError, SocketError].freeze
9
9
 
10
10
  def invoke_remote(method, payload = [], options = {})
11
11
  start_ts = Time.now
@@ -40,7 +40,7 @@ module OneApm
40
40
  # The path on the server that we should post our data to
41
41
  def remote_method_uri(method, format)
42
42
  params = {'run_id' => @agent_id, 'marshal_format' => format}
43
- uri = "/tpm/agent.do?PROTOCOL_VERSION=#{PROTOCOL_VERSION}&license_key=#{@license_key}&method=#{method}"
43
+ uri = "/tpm/agent.do?PROTOCOL_VERSION=#{OA_PROTOCOL_VERSION}&license_key=#{@license_key}&method=#{method}"
44
44
  uri << '&' + params.map do |k,v|
45
45
  next unless v
46
46
  "#{k}=#{v}"
@@ -75,7 +75,7 @@ module OneApm
75
75
  OneApm::TimerLib.timeout(@request_timeout) do
76
76
  response = conn.request(request)
77
77
  end
78
- rescue *CONNECTION_ERRORS => e
78
+ rescue *OA_CONNECTION_ERRORS => e
79
79
  close_shared_connection
80
80
  if attempts < max_attempts
81
81
  OneApm::Manager.logger.debug("Retrying request to #{opts[:collector]}#{opts[:uri]} after #{e}")
@@ -98,7 +98,7 @@ module OneApm
98
98
  else
99
99
  session_without_keepalive(&block)
100
100
  end
101
- rescue *CONNECTION_ERRORS => e
101
+ rescue *OA_CONNECTION_ERRORS => e
102
102
  elapsed = Time.now - t0
103
103
  raise OneApm::ServerConnectionException, "Recoverable error connecting to #{@collector} after #{elapsed} seconds: #{e}"
104
104
  ensure
@@ -16,7 +16,7 @@ module OneApm
16
16
  include OneApm::Collector::CollectorService::ServerMethods
17
17
  include OneApm::Collector::CollectorService::HttpConnection
18
18
 
19
- PROTOCOL_VERSION = 1
19
+ OA_PROTOCOL_VERSION = 1
20
20
 
21
21
  attr_accessor :request_timeout, :agent_id
22
22
  attr_reader :collector,:marshaller, :metric_id_cache
@@ -29,7 +29,7 @@ module OneApm
29
29
  def start(agent_command)
30
30
  OneApm::Manager.logger.debug("Starting Thread Profiler.")
31
31
  profile = @backtrace_service.subscribe(
32
- OneApm::Agent::Threading::BacktraceService::ALL_TRANSACTIONS,
32
+ OneApm::Agent::Threading::BacktraceService::OA_ALL_TRANSACTIONS,
33
33
  agent_command.arguments
34
34
  )
35
35
 
@@ -40,8 +40,8 @@ module OneApm
40
40
  def stop(report_data)
41
41
  return unless running?
42
42
  OneApm::Manager.logger.debug("Stopping Thread Profiler.")
43
- @finished_profile = @backtrace_service.harvest(OneApm::Agent::Threading::BacktraceService::ALL_TRANSACTIONS)
44
- @backtrace_service.unsubscribe(OneApm::Agent::Threading::BacktraceService::ALL_TRANSACTIONS)
43
+ @finished_profile = @backtrace_service.harvest(OneApm::Agent::Threading::BacktraceService::OA_ALL_TRANSACTIONS)
44
+ @backtrace_service.unsubscribe(OneApm::Agent::Threading::BacktraceService::OA_ALL_TRANSACTIONS)
45
45
  @finished_profile = nil if !report_data
46
46
  end
47
47
 
@@ -59,7 +59,7 @@ module OneApm
59
59
  end
60
60
 
61
61
  def running?
62
- @backtrace_service.subscribed?(OneApm::Agent::Threading::BacktraceService::ALL_TRANSACTIONS)
62
+ @backtrace_service.subscribed?(OneApm::Agent::Threading::BacktraceService::OA_ALL_TRANSACTIONS)
63
63
  end
64
64
 
65
65
  def ready_to_harvest?
@@ -126,15 +126,15 @@ module OneApm
126
126
  end
127
127
  end
128
128
 
129
- SUCCESS_RESULT = {}.freeze
130
- ERROR_KEY = "error"
129
+ OA_SUCCESS_RESULT = {}.freeze
130
+ OA_ERROR_KEY = "error"
131
131
 
132
132
  def success
133
- SUCCESS_RESULT
133
+ OA_SUCCESS_RESULT
134
134
  end
135
135
 
136
136
  def error(err)
137
- { ERROR_KEY => err.message }
137
+ { OA_ERROR_KEY => err.message }
138
138
  end
139
139
 
140
140
  def call_handler_for(agent_command)
@@ -7,22 +7,22 @@ module OneApm
7
7
  class CustomEventAggregator
8
8
  include OneApm::Coerce
9
9
 
10
- TYPE = 'type'.freeze
11
- TIMESTAMP = 'timestamp'.freeze
12
- EVENT_PARAMS_CTX = 'recording custom event'.freeze
13
- EVENT_TYPE_REGEX = /^[a-zA-Z0-9:_ ]+$/.freeze
10
+ OA_TYPE = 'type'.freeze
11
+ OA_TIMESTAMP = 'timestamp'.freeze
12
+ OA_EVENT_PARAMS_CTX = 'recording custom event'.freeze
13
+ OA_EVENT_TYPE_REGEX = /^[a-zA-Z0-9:_ ]+$/.freeze
14
14
 
15
- DEFAULT_CAPACITY_KEY = :'custom_insights_events.max_samples_stored'
15
+ OA_DEFAULT_CAPACITY_KEY = :'custom_insights_events.max_samples_stored'
16
16
 
17
17
  def initialize
18
18
  @lock = Mutex.new
19
- @buffer = OneApm::Agent::SampledBuffer.new(OneApm::Manager.config[DEFAULT_CAPACITY_KEY])
19
+ @buffer = OneApm::Agent::SampledBuffer.new(OneApm::Manager.config[OA_DEFAULT_CAPACITY_KEY])
20
20
  @type_strings = Hash.new { |hash, key| hash[key] = key.to_s.freeze }
21
21
  register_config_callbacks
22
22
  end
23
23
 
24
24
  def register_config_callbacks
25
- OneApm::Manager.config.register_callback(DEFAULT_CAPACITY_KEY) do |max_samples|
25
+ OneApm::Manager.config.register_callback(OA_DEFAULT_CAPACITY_KEY) do |max_samples|
26
26
  OneApm::Manager.logger.debug "CustomEventAggregator max_samples set to #{max_samples}"
27
27
  @lock.synchronize do
28
28
  @buffer.capacity = max_samples
@@ -32,14 +32,14 @@ module OneApm
32
32
 
33
33
  def record(type, attributes)
34
34
  type = @type_strings[type]
35
- unless type =~ EVENT_TYPE_REGEX
35
+ unless type =~ OA_EVENT_TYPE_REGEX
36
36
  note_dropped_event(type)
37
37
  return false
38
38
  end
39
39
 
40
40
  event = [
41
- { TYPE => type, TIMESTAMP => Time.now.to_i },
42
- event_params(attributes, EVENT_PARAMS_CTX)
41
+ { OA_TYPE => type, OA_TIMESTAMP => Time.now.to_i },
42
+ event_params(attributes, OA_EVENT_PARAMS_CTX)
43
43
  ]
44
44
 
45
45
  stored = @lock.synchronize do
@@ -13,7 +13,7 @@ module OneApm
13
13
  # Maximum possible length of the queue - defaults to 20, may be
14
14
  # made configurable in the future. This is a tradeoff between
15
15
  # memory and data retention
16
- MAX_ERROR_QUEUE_LENGTH = 20 unless defined? MAX_ERROR_QUEUE_LENGTH
16
+ OA_MAX_ERROR_QUEUE_LENGTH = 20 unless defined? OA_MAX_ERROR_QUEUE_LENGTH
17
17
 
18
18
  attr_accessor :errors
19
19
 
@@ -122,7 +122,7 @@ module OneApm
122
122
  end
123
123
 
124
124
  def blamed_metric_name(txn, options)
125
- if options[:metric] && options[:metric] != OneApm::Transaction::UNKNOWN_METRIC
125
+ if options[:metric] && options[:metric] != OneApm::Transaction::OA_UNKNOWN_METRIC
126
126
  "Errors/#{options[:metric]}"
127
127
  else
128
128
  "Errors/#{txn.best_name}" if txn
@@ -247,8 +247,8 @@ module OneApm
247
247
  # checks the size of the error queue to make sure we are under
248
248
  # the maximum limit, and logs a warning if we are over the limit.
249
249
  def over_queue_limit?(message)
250
- over_limit = (@errors.reject{|err| err.is_internal}.length >= MAX_ERROR_QUEUE_LENGTH)
251
- OneApm::Manager.logger.warn("The error reporting queue has reached #{MAX_ERROR_QUEUE_LENGTH}. The error detail for this and subsequent errors will not be transmitted to OneApm until the queued errors have been sent: #{message}") if over_limit
250
+ over_limit = (@errors.reject{|err| err.is_internal}.length >= OA_MAX_ERROR_QUEUE_LENGTH)
251
+ OneApm::Manager.logger.warn("The error reporting queue has reached #{OA_MAX_ERROR_QUEUE_LENGTH}. The error detail for this and subsequent errors will not be transmitted to OneApm until the queued errors have been sent: #{message}") if over_limit
252
252
  over_limit
253
253
  end
254
254
 
@@ -34,7 +34,7 @@ module OneApm
34
34
  # this is for unit tests only
35
35
  attr_reader :sql_traces
36
36
 
37
- MAX_SAMPLES = 10
37
+ OA_MAX_SAMPLES = 10
38
38
 
39
39
  def initialize
40
40
  @sql_traces = {}
@@ -119,7 +119,7 @@ module OneApm
119
119
 
120
120
  # this should always be called under the @samples_lock
121
121
  def has_room?
122
- @sql_traces.size < MAX_SAMPLES
122
+ @sql_traces.size < OA_MAX_SAMPLES
123
123
  end
124
124
 
125
125
  # this should always be called under the @samples_lock
@@ -6,24 +6,24 @@ class OneApm::Collector::TransactionEventAggregator
6
6
  include OneApm::Coerce, MonitorMixin
7
7
 
8
8
  # The type field of the sample
9
- SAMPLE_TYPE = 'Transaction'.freeze
9
+ OA_SAMPLE_TYPE = 'Transaction'.freeze
10
10
 
11
11
  # Strings for static keys of the sample structure
12
- TYPE_KEY = 'type'.freeze
13
- TIMESTAMP_KEY = 'timestamp'.freeze
14
- NAME_KEY = 'name'.freeze
15
- DURATION_KEY = 'duration'.freeze
16
- HTTP_RESPONSE_CODE_KEY = 'httpResponseCode'.freeze
17
- GUID_KEY = 'bw.guid'.freeze
18
- REFERRING_TRANSACTION_GUID_KEY = 'bw.referringTransactionGuid'.freeze
19
- CAT_TRIP_ID_KEY = 'bw.tripId'.freeze
20
- CAT_PATH_HASH_KEY = 'bw.pathHash'.freeze
21
- CAT_REFERRING_PATH_HASH_KEY = 'bw.referringPathHash'.freeze
22
- CAT_ALTERNATE_PATH_HASHES_KEY = 'bw.alternatePathHashes'.freeze
23
- APDEX_PERF_ZONE_KEY = 'bw.apdexPerfZone'.freeze
24
- SYNTHETICS_RESOURCE_ID_KEY = "bw.syntheticsResourceId".freeze
25
- SYNTHETICS_JOB_ID_KEY = "bw.syntheticsJobId".freeze
26
- SYNTHETICS_MONITOR_ID_KEY = "bw.syntheticsMonitorId".freeze
12
+ OA_TYPE_KEY = 'type'.freeze
13
+ OA_TIMESTAMP_KEY = 'timestamp'.freeze
14
+ OA_NAME_KEY = 'name'.freeze
15
+ OA_DURATION_KEY = 'duration'.freeze
16
+ OA_HTTP_RESPONSE_CODE_KEY = 'httpResponseCode'.freeze
17
+ OA_GUID_KEY = 'bw.guid'.freeze
18
+ OA_REFERRING_TRANSACTION_GUID_KEY = 'bw.referringTransactionGuid'.freeze
19
+ OA_CAT_TRIP_ID_KEY = 'bw.tripId'.freeze
20
+ OA_CAT_PATH_HASH_KEY = 'bw.pathHash'.freeze
21
+ OA_CAT_REFERRING_PATH_HASH_KEY = 'bw.referringPathHash'.freeze
22
+ OA_CAT_ALTERNATE_PATH_HASHES_KEY = 'bw.alternatePathHashes'.freeze
23
+ OA_APDEX_PERF_ZONE_KEY = 'bw.apdexPerfZone'.freeze
24
+ OA_SYNTHETICS_RESOURCE_ID_KEY = "bw.syntheticsResourceId".freeze
25
+ OA_SYNTHETICS_JOB_ID_KEY = "bw.syntheticsJobId".freeze
26
+ OA_SYNTHETICS_MONITOR_ID_KEY = "bw.syntheticsMonitorId".freeze
27
27
 
28
28
  def initialize(event_listener)
29
29
  super()
@@ -141,7 +141,7 @@ class OneApm::Collector::TransactionEventAggregator
141
141
  def append_event(event)
142
142
  main_event, _ = event
143
143
 
144
- if main_event.include?(SYNTHETICS_RESOURCE_ID_KEY)
144
+ if main_event.include?(OA_SYNTHETICS_RESOURCE_ID_KEY)
145
145
  # Try adding to synthetics buffer. If anything is rejected, give it a
146
146
  # shot in the main transaction events (where it may get sampled)
147
147
  result, rejected = @synthetics_samples.append_with_reject(event)
@@ -157,13 +157,13 @@ class OneApm::Collector::TransactionEventAggregator
157
157
  def self.map_metric(metric_name, to_add={})
158
158
  to_add.values.each(&:freeze)
159
159
 
160
- mappings = OVERVIEW_SPECS.fetch(metric_name, {})
160
+ mappings = OA_OVERVIEW_SPECS.fetch(metric_name, {})
161
161
  mappings.merge!(to_add)
162
162
 
163
- OVERVIEW_SPECS[metric_name] = mappings
163
+ OA_OVERVIEW_SPECS[metric_name] = mappings
164
164
  end
165
165
 
166
- OVERVIEW_SPECS = {}
166
+ OA_OVERVIEW_SPECS = {}
167
167
 
168
168
  # All Transactions
169
169
  # Don't need to use the transaction-type specific metrics since this is
@@ -187,7 +187,7 @@ class OneApm::Collector::TransactionEventAggregator
187
187
 
188
188
  def append_metrics(txn_metrics, sample)
189
189
  if txn_metrics
190
- OVERVIEW_SPECS.each do |(name, extracted_values)|
190
+ OA_OVERVIEW_SPECS.each do |(name, extracted_values)|
191
191
  if txn_metrics.has_key?(name)
192
192
  stat = txn_metrics[name]
193
193
  extracted_values.each do |value_name, key_name|
@@ -200,21 +200,21 @@ class OneApm::Collector::TransactionEventAggregator
200
200
 
201
201
  def create_main_event(payload)
202
202
  sample = {
203
- TIMESTAMP_KEY => float(payload[:start_timestamp]),
204
- NAME_KEY => string(payload[:name]),
205
- DURATION_KEY => float(payload[:duration]),
206
- TYPE_KEY => SAMPLE_TYPE,
203
+ OA_TIMESTAMP_KEY => float(payload[:start_timestamp]),
204
+ OA_NAME_KEY => string(payload[:name]),
205
+ OA_DURATION_KEY => float(payload[:duration]),
206
+ OA_TYPE_KEY => OA_SAMPLE_TYPE,
207
207
  }
208
208
  append_metrics(payload[:metrics], sample)
209
- optionally_append(GUID_KEY, :guid, sample, payload)
210
- optionally_append(REFERRING_TRANSACTION_GUID_KEY, :referring_transaction_guid, sample, payload)
211
- optionally_append(CAT_TRIP_ID_KEY, :cat_trip_id, sample, payload)
212
- optionally_append(CAT_PATH_HASH_KEY, :cat_path_hash, sample, payload)
213
- optionally_append(CAT_REFERRING_PATH_HASH_KEY, :cat_referring_path_hash, sample, payload)
214
- optionally_append(APDEX_PERF_ZONE_KEY, :apdex_perf_zone, sample, payload)
215
- optionally_append(SYNTHETICS_RESOURCE_ID_KEY, :synthetics_resource_id, sample, payload)
216
- optionally_append(SYNTHETICS_JOB_ID_KEY, :synthetics_job_id, sample, payload)
217
- optionally_append(SYNTHETICS_MONITOR_ID_KEY, :synthetics_monitor_id, sample, payload)
209
+ optionally_append(OA_GUID_KEY, :guid, sample, payload)
210
+ optionally_append(OA_REFERRING_TRANSACTION_GUID_KEY, :referring_transaction_guid, sample, payload)
211
+ optionally_append(OA_CAT_TRIP_ID_KEY, :cat_trip_id, sample, payload)
212
+ optionally_append(OA_CAT_PATH_HASH_KEY, :cat_path_hash, sample, payload)
213
+ optionally_append(OA_CAT_REFERRING_PATH_HASH_KEY, :cat_referring_path_hash, sample, payload)
214
+ optionally_append(OA_APDEX_PERF_ZONE_KEY, :apdex_perf_zone, sample, payload)
215
+ optionally_append(OA_SYNTHETICS_RESOURCE_ID_KEY, :synthetics_resource_id, sample, payload)
216
+ optionally_append(OA_SYNTHETICS_JOB_ID_KEY, :synthetics_job_id, sample, payload)
217
+ optionally_append(OA_SYNTHETICS_MONITOR_ID_KEY, :synthetics_monitor_id, sample, payload)
218
218
  append_http_response_code(sample, payload)
219
219
  append_cat_alternate_path_hashes(sample, payload)
220
220
  sample
@@ -222,13 +222,13 @@ class OneApm::Collector::TransactionEventAggregator
222
222
 
223
223
  def append_http_response_code(sample, payload)
224
224
  unless OneApm::Manager.config[:disable_rack_middleware]
225
- optionally_append(HTTP_RESPONSE_CODE_KEY, :http_response_code, sample, payload)
225
+ optionally_append(OA_HTTP_RESPONSE_CODE_KEY, :http_response_code, sample, payload)
226
226
  end
227
227
  end
228
228
 
229
229
  def append_cat_alternate_path_hashes(sample, payload)
230
230
  if payload.include?(:cat_alternate_path_hashes)
231
- sample[CAT_ALTERNATE_PATH_HASHES_KEY] = payload[:cat_alternate_path_hashes].sort.join(',')
231
+ sample[OA_CAT_ALTERNATE_PATH_HASHES_KEY] = payload[:cat_alternate_path_hashes].sort.join(',')
232
232
  end
233
233
  end
234
234