oneapm_rpm 1.1.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/lib/one_apm/agent.rb +4 -4
  3. data/lib/one_apm/agent/agent/connect.rb +3 -49
  4. data/lib/one_apm/agent/agent/container_data_manager.rb +2 -10
  5. data/lib/one_apm/agent/agent/forkable_dispatcher_functions.rb +4 -2
  6. data/lib/one_apm/agent/agent/helpers.rb +2 -0
  7. data/lib/one_apm/agent/agent/start.rb +3 -3
  8. data/lib/one_apm/agent/agent/start_worker_thread.rb +2 -0
  9. data/lib/one_apm/agent/database/active_record_helper.rb +1 -0
  10. data/lib/one_apm/agent/{datastores.rb → datastore.rb} +2 -2
  11. data/lib/one_apm/agent/{datastores → datastore}/metric_helper.rb +1 -1
  12. data/lib/one_apm/agent/{datastores → datastore}/mongo.rb +1 -1
  13. data/lib/one_apm/agent/{datastores → datastore}/mongo/metric_translator.rb +4 -4
  14. data/lib/one_apm/agent/{datastores → datastore}/mongo/obfuscator.rb +1 -1
  15. data/lib/one_apm/agent/{datastores → datastore}/mongo/statement_formatter.rb +2 -2
  16. data/lib/one_apm/agent/threading/agent_thread.rb +50 -50
  17. data/lib/one_apm/agent/threading/thread_profile.rb +1 -4
  18. data/lib/one_apm/collector/commands/thread_profiler_session.rb +1 -1
  19. data/lib/one_apm/collector/containers/agent_command_router.rb +1 -1
  20. data/lib/one_apm/collector/containers/transaction_sampler.rb +7 -1
  21. data/lib/one_apm/collector/containers/utilization_data.rb +3 -4
  22. data/lib/one_apm/{agent → collector}/sampler.rb +1 -1
  23. data/lib/one_apm/{agent → collector}/samplers/cpu_sampler.rb +4 -4
  24. data/lib/one_apm/{agent → collector}/samplers/delayed_job_sampler.rb +3 -14
  25. data/lib/one_apm/{agent → collector}/samplers/memory_sampler.rb +13 -15
  26. data/lib/one_apm/{agent → collector}/samplers/object_sampler.rb +3 -3
  27. data/lib/one_apm/{agent → collector}/samplers/vm_sampler.rb +2 -2
  28. data/lib/one_apm/collector/{forked_process_service.rb → support/forked_process_service.rb} +1 -1
  29. data/lib/one_apm/{agent → collector/support}/sampler_collection.rb +2 -2
  30. data/lib/one_apm/configuration/default_source.rb +7 -2
  31. data/lib/one_apm/frameworks/rails.rb +18 -0
  32. data/lib/one_apm/inst/nosql/memcache.rb +2 -2
  33. data/lib/one_apm/inst/nosql/mongo.rb +6 -6
  34. data/lib/one_apm/inst/nosql/mongo_moped.rb +3 -3
  35. data/lib/one_apm/inst/nosql/redis.rb +4 -4
  36. data/lib/one_apm/manager.rb +38 -6
  37. data/lib/one_apm/metrics/metric_spec.rb +1 -4
  38. data/lib/one_apm/probe/instrumentation.rb +2 -5
  39. data/lib/one_apm/rack/developer_mode.rb +221 -0
  40. data/lib/one_apm/rack/developer_mode/helper.rb +299 -0
  41. data/lib/one_apm/rack/developer_mode/views/oneapm/_explain_plans.html.erb +25 -0
  42. data/lib/one_apm/rack/developer_mode/views/oneapm/_home_right.html.erb +18 -0
  43. data/lib/one_apm/rack/developer_mode/views/oneapm/_sample.html.erb +20 -0
  44. data/lib/one_apm/rack/developer_mode/views/oneapm/_segment.html.erb +24 -0
  45. data/lib/one_apm/rack/developer_mode/views/oneapm/_segment_limit_message.html.erb +1 -0
  46. data/lib/one_apm/rack/developer_mode/views/oneapm/_segment_row.html.erb +11 -0
  47. data/lib/one_apm/rack/developer_mode/views/oneapm/_show_sample_detail.html.erb +30 -0
  48. data/lib/one_apm/rack/developer_mode/views/oneapm/_show_sample_sql.html.erb +19 -0
  49. data/lib/one_apm/rack/developer_mode/views/oneapm/_show_sample_summary.html.erb +25 -0
  50. data/lib/one_apm/rack/developer_mode/views/oneapm/_sql_row.html.erb +15 -0
  51. data/lib/one_apm/rack/developer_mode/views/oneapm/_stack_trace.html.erb +14 -0
  52. data/lib/one_apm/rack/developer_mode/views/oneapm/_summary_table.html.erb +12 -0
  53. data/lib/one_apm/rack/developer_mode/views/oneapm/assets/images/arrow-close.png +0 -0
  54. data/lib/one_apm/rack/developer_mode/views/oneapm/assets/images/arrow-open.png +0 -0
  55. data/lib/one_apm/rack/developer_mode/views/oneapm/assets/images/oneapm_logo.png +0 -0
  56. data/lib/one_apm/rack/developer_mode/views/oneapm/assets/javascript/c3.min.js +5 -0
  57. data/lib/one_apm/rack/developer_mode/views/oneapm/assets/javascript/d3.min.js +5 -0
  58. data/lib/one_apm/rack/developer_mode/views/oneapm/assets/javascript/jquery.min.js +4 -0
  59. data/lib/one_apm/rack/developer_mode/views/oneapm/assets/javascript/transaction_sample.js +120 -0
  60. data/lib/one_apm/rack/developer_mode/views/oneapm/assets/stylesheets/bootstrap.min.css +5 -0
  61. data/lib/one_apm/rack/developer_mode/views/oneapm/assets/stylesheets/c3.css +158 -0
  62. data/lib/one_apm/rack/developer_mode/views/oneapm/assets/stylesheets/style.css +149 -0
  63. data/lib/one_apm/rack/developer_mode/views/oneapm/explain_sql.html.erb +53 -0
  64. data/lib/one_apm/rack/developer_mode/views/oneapm/index.html.erb +33 -0
  65. data/lib/one_apm/rack/developer_mode/views/oneapm/layout.html.erb +46 -0
  66. data/lib/one_apm/rack/developer_mode/views/oneapm/sample_not_found.html.erb +2 -0
  67. data/lib/one_apm/rack/developer_mode/views/oneapm/show_sample.html.erb +61 -0
  68. data/lib/one_apm/rack/developer_mode/views/oneapm/threads.html.erb +53 -0
  69. data/lib/one_apm/{agent/threading → support/backtrace}/backtrace_node.rb +0 -0
  70. data/lib/one_apm/{agent/threading → support/backtrace}/backtrace_service.rb +0 -0
  71. data/lib/one_apm/support/environment_report.rb +6 -38
  72. data/lib/one_apm/support/system_info.rb +1 -6
  73. data/lib/one_apm/transaction/composite_segment.rb +30 -0
  74. data/lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb +58 -0
  75. data/lib/one_apm/transaction/segment_summary.rb +0 -5
  76. data/lib/one_apm/transaction/summary_segment.rb +24 -0
  77. data/lib/one_apm/transaction/transaction_sample.rb +2 -0
  78. data/lib/one_apm/version.rb +2 -2
  79. metadata +51 -19
  80. data/lib/one_apm/configuration/autostart.rb +0 -41
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2549e99a228ebc5192a1fa035a985afc7bac2ace
4
- data.tar.gz: d52a272c4e52693f21c973c51f8fa3cdd72081c3
3
+ metadata.gz: 9637faf70e8254363cc5ef872cff5be2107b0e18
4
+ data.tar.gz: ce1569b659d17bb3cb59b050f5c764ad30a8b4ce
5
5
  SHA512:
6
- metadata.gz: 786db6b474c198e117000456a33c46538d7a0cf343082556361b04a2b1db2f442f65e2e5f4cbaa7d88772741ee10989f9193bb90ad5c7e2a4493a01a571c380e
7
- data.tar.gz: 1d3c27a588fa01c9606cb79ac4120b862b1e453be7e1422eda17fef366fe84362c4f8e92a05312be7e40a9d0cd90bfb05c717303d708c688f89c313ff6653126
6
+ metadata.gz: a082645eea917ba25880dabec86c54b7576b42d9b04c7479eada3af10cc4c0853154dc54376eb01eee36b0aa9732287ff1428d7e64244d70e82de5d258069305
7
+ data.tar.gz: 7bd556b3e93f61b72485b36d6bd4a56489662738fc42b4878da3884814d7e26ad65f0f8ae71d429b5d603cdcb1be6b1543ea3d4ff23a5d01a1ff843b3eebee5c
data/lib/one_apm/agent.rb CHANGED
@@ -8,7 +8,6 @@ require 'zlib'
8
8
  require 'stringio'
9
9
 
10
10
  require 'one_apm/support/event_buffer/sampled_buffer'
11
- require 'one_apm/configuration/autostart'
12
11
  require 'one_apm/agent/harvester'
13
12
 
14
13
  require 'one_apm/support/hostname'
@@ -22,13 +21,14 @@ require 'one_apm/collector/containers/transaction_event_aggregator'
22
21
  require 'one_apm/collector/containers/custom_event_aggregator'
23
22
  require 'one_apm/collector/containers/utilization_data'
24
23
 
25
- require 'one_apm/collector/forked_process_service'
24
+ require 'one_apm/collector/support/forked_process_service'
25
+ require 'one_apm/collector/support/sampler_collection'
26
+
26
27
  require 'one_apm/agent/database'
27
28
  require 'one_apm/support/event/event_listener'
28
29
  require 'one_apm/agent/cross_app/cross_app_monitor'
29
30
  require 'one_apm/agent/synthetics_monitor'
30
31
  require 'one_apm/support/event_buffer/synthetics_event_buffer'
31
- require 'one_apm/agent/sampler_collection'
32
32
  require 'one_apm/agent/javascript_instrumentor'
33
33
  require 'one_apm/support/vm/monotonic_gc_profiler'
34
34
 
@@ -86,7 +86,7 @@ module OneApm
86
86
 
87
87
  @cross_app_monitor = OneApm::Agent::CrossAppMonitor.new(@events)
88
88
  @transaction_rules = OneApm::Support::RulesEngine.new
89
- @harvest_samplers = OneApm::Agent::SamplerCollection.new(@events)
89
+ @harvest_samplers = OneApm::Collector::SamplerCollection.new(@events)
90
90
  @monotonic_gc_profiler = OneApm::Support::VM::MonotonicGCProfiler.new
91
91
  @javascript_instrumentor = OneApm::Agent::JavascriptInstrumentor.new(@events)
92
92
 
@@ -1,15 +1,12 @@
1
+ # encoding: utf-8
2
+
1
3
  module OneApm
2
4
  module Agent
3
5
  class Agent
4
- # This module is an artifact of a refactoring of the connect
5
- # method - all of its methods are used in that context, so it
6
- # can be refactored at will. It should be fully tested
7
6
  module Connect
8
- # number of attempts we've made to contact the server
7
+
9
8
  attr_accessor :connect_attempts
10
9
 
11
- # Disconnect just sets connected to false, which prevents
12
- # the agent from trying to connect again
13
10
  def disconnect
14
11
  @connect_state = :disconnected
15
12
  true
@@ -23,17 +20,10 @@ module OneApm
23
20
  @connect_state == :disconnected
24
21
  end
25
22
 
26
- # Don't connect if we're already connected, or if we tried to connect
27
- # and were rejected with prejudice because of a license issue, unless
28
- # we're forced to by force_reconnect.
29
23
  def should_connect?(force = false)
30
24
  force || (!connected? && !disconnected?)
31
25
  end
32
26
 
33
- # Retry period is a minute for each failed attempt that
34
- # we've made. This should probably do some sort of sane TCP
35
- # backoff to prevent hammering the server, but a minute for
36
- # each attempt seems to work reasonably well.
37
27
  def connect_retry_period
38
28
  [600, connect_attempts * 60].min
39
29
  end
@@ -42,20 +32,10 @@ module OneApm
42
32
  self.connect_attempts += 1
43
33
  end
44
34
 
45
- # When we have a problem connecting to the server, we need
46
- # to tell the user what happened, since this is not an error
47
- # we can handle gracefully.
48
35
  def log_error(error)
49
36
  OneApm::Manager.logger.error "Error establishing connection with OneApm Service at #{@service.server}:", error
50
37
  end
51
38
 
52
- # When the server sends us an error with the license key, we
53
- # want to tell the user that something went wrong, and let
54
- # them know where to go to get a valid license key
55
- #
56
- # After this runs, it disconnects the agent so that it will
57
- # no longer try to connect to the server, saving the
58
- # application and the server load
59
39
  def handle_license_error(error)
60
40
  OneApm::Manager.logger.error( \
61
41
  error.message, \
@@ -73,26 +53,16 @@ module OneApm
73
53
  @environment_report = environment_for_connect
74
54
  end
75
55
 
76
- # Checks whether we should send environment info, and if so,
77
- # returns the snapshot from the local environment.
78
- # Generating the EnvironmentReport has the potential to trigger
79
- # require calls in Rails environments, so this method should only
80
- # be called synchronously from on the main thread.
81
56
  def environment_for_connect
82
57
  OneApm::Manager.config[:send_environment_info] ? Array(EnvironmentReport.new) : []
83
58
  end
84
59
 
85
- # We've seen objects in the environment report (Rails.env in
86
- # particular) that can't seralize to JSON. Cope with that here and
87
- # clear out so downstream code doesn't have to check again.
88
60
  def sanitize_environment_report
89
61
  if !@service.valid_to_marshal?(@environment_report)
90
62
  @environment_report = []
91
63
  end
92
64
  end
93
65
 
94
- # Initializes the hash of settings that we send to the
95
- # server. Returns a literal hash containing the options
96
66
  def connect_settings
97
67
  sanitize_environment_report
98
68
  {
@@ -109,29 +79,18 @@ module OneApm
109
79
  }
110
80
  end
111
81
 
112
- # apdex_f is always 4 times the apdex_t
113
82
  def apdex_f
114
83
  (4 * OneApm::Manager.config[:apdex_t]).to_f
115
84
  end
116
85
 
117
- # Sets the collector host and connects to the server, then
118
- # invokes the final configuration with the returned data
119
86
  def query_server_for_configuration
120
87
  finish_setup(connect_to_server)
121
88
  end
122
89
 
123
- # Returns connect data passed back from the server
124
90
  def connect_to_server
125
91
  @service.connect(connect_settings)
126
92
  end
127
93
 
128
- # Takes a hash of configuration data returned from the
129
- # server and uses it to set local variables and to
130
- # initialize various parts of the agent that are configured
131
- # separately.
132
- #
133
- # Can accommodate most arbitrary data - anything extra is
134
- # ignored unless we say to do something with it here.
135
94
  def finish_setup(config_data)
136
95
  return if config_data == nil
137
96
 
@@ -144,17 +103,12 @@ module OneApm
144
103
 
145
104
  @transaction_rules = OneApm::Support::RulesEngine.create_transaction_rules(config_data)
146
105
  @stats_engine.metric_rules = OneApm::Support::RulesEngine.create_metric_rules(config_data)
147
-
148
- # If you're adding something else here to respond to the server-side config,
149
- # use OneApm::Manager.agent.events.subscribe(:finished_configuring) callback instead!
150
106
  end
151
107
 
152
108
  def local_host
153
109
  @local_host ||= OneApm::Agent::Hostname.get
154
110
  end
155
111
 
156
- # Logs when we connect to the server, for debugging purposes
157
- # - makes sure we know if an agent has not connected
158
112
  def log_connection!(config_data)
159
113
  OneApm::Manager.logger.debug "Connected to OneApm Service at #{@service.collector.name}"
160
114
  OneApm::Manager.logger.debug "Agent Run = #{@service.agent_id}."
@@ -1,16 +1,14 @@
1
+ # encoding: utf-8
2
+
1
3
  module OneApm
2
4
  module Agent
3
5
  class Agent
4
6
  module ContainerDataManager
5
7
 
6
- # the statistics engine that holds all the timeslice data
7
8
  attr_reader :stats_engine
8
- # the transaction sampler that handles recording transactions
9
9
  attr_reader :transaction_sampler
10
10
  attr_reader :sql_sampler
11
- # manages agent commands we receive from the collector, and the handlers
12
11
  attr_reader :agent_command_router
13
- # error collector is a simple collection of recorded errors
14
12
  attr_reader :error_collector
15
13
  attr_reader :custom_event_aggregator
16
14
 
@@ -22,7 +20,6 @@ module OneApm
22
20
  OneApm::Manager.logger.error("Error while merging #{endpoint} data from child: ", e)
23
21
  end
24
22
 
25
- # Clear out the metric data, errors, and transaction traces, etc.
26
23
  def drop_buffered_data
27
24
  @stats_engine.reset!
28
25
  @error_collector.reset!
@@ -117,11 +114,6 @@ module OneApm
117
114
  harvest_and_send_from_container(@sql_sampler, :sql_trace_data)
118
115
  end
119
116
 
120
- # This handles getting the transaction traces and then sending
121
- # them across the wire. This includes gathering SQL
122
- # explanations, stripping out stack traces, and normalizing
123
- # SQL. note that we explain only the sql statements whose
124
- # segments' execution times exceed our threshold.
125
117
  def harvest_and_send_transaction_traces
126
118
  harvest_and_send_from_container(@transaction_sampler, :transaction_sample_data)
127
119
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module OneApm
2
4
  module Agent
3
5
  class Agent
@@ -27,7 +29,7 @@ module OneApm
27
29
  end
28
30
 
29
31
  def install_pipe_service(channel_id)
30
- @service = OneApm::Agent::ForkedProcessService.new(channel_id)
32
+ @service = OneApm::Collector::ForkedProcessService.new(channel_id)
31
33
  if connected?
32
34
  @connected_pid = Process.pid
33
35
  else
@@ -55,7 +57,7 @@ module OneApm
55
57
  end
56
58
 
57
59
  def flush_pipe_data
58
- if connected? && @service.is_a?(::OneApm::Agent::ForkedProcessService)
60
+ if connected? && @service.is_a?(::OneApm::Collector::ForkedProcessService)
59
61
  transmit_data
60
62
  transmit_event_data
61
63
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module OneApm
2
4
  module Agent
3
5
  class Agent
@@ -1,8 +1,8 @@
1
+ # encoding: utf-8
2
+
1
3
  module OneApm
2
4
  module Agent
3
5
  class Agent
4
- # Herein lies the corpse of the former 'start' method. May
5
- # its unmatched flog score rest in pieces.
6
6
  module Start
7
7
 
8
8
  # Sanity-check the agent configuration and start the agent,
@@ -173,7 +173,7 @@ module OneApm
173
173
  end
174
174
 
175
175
  def in_resque_child_process?
176
- @service.is_a?(OneApm::Agent::ForkedProcessService)
176
+ @service.is_a?(OneApm::Collector::ForkedProcessService)
177
177
  end
178
178
 
179
179
  # Log startup information that we almost always want to know
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module OneApm
2
4
  module Agent
3
5
  class Agent
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  module OneApm
3
4
  module Agent
4
5
  module Instrumentation
@@ -1,10 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'one_apm/agent/datastores/metric_helper'
3
+ require 'one_apm/agent/datastore/metric_helper'
4
4
 
5
5
  module OneApm
6
6
  module Agent
7
- module Datastores
7
+ module Datastore
8
8
 
9
9
  def self.trace(clazz, method_name, product, operation = method_name)
10
10
  clazz.class_eval do
@@ -2,7 +2,7 @@
2
2
 
3
3
  module OneApm
4
4
  module Agent
5
- module Datastores
5
+ module Datastore
6
6
  module MetricHelper
7
7
  ROLLUP_METRIC = "Datastore/all".freeze
8
8
  WEB_ROLLUP_METRIC = "Datastore/allWeb".freeze
@@ -2,7 +2,7 @@
2
2
 
3
3
  module OneApm
4
4
  module Agent
5
- module Datastores
5
+ module Datastore
6
6
  module Mongo
7
7
  def self.is_supported_version?
8
8
  # No version constant in < 2.0 versions of Mongo :(
@@ -1,11 +1,11 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'one_apm/agent/datastores/mongo/obfuscator'
4
- require 'one_apm/agent/datastores/metric_helper'
3
+ require 'one_apm/agent/datastore/mongo/obfuscator'
4
+ require 'one_apm/agent/datastore/metric_helper'
5
5
 
6
6
  module OneApm
7
7
  module Agent
8
- module Datastores
8
+ module Datastore
9
9
  module Mongo
10
10
  module MetricTranslator
11
11
  def self.metrics_for(name, payload)
@@ -58,7 +58,7 @@ module OneApm
58
58
  MONGO_PRODUCT_NAME = "MongoDB".freeze
59
59
 
60
60
  def self.build_metrics(name, collection)
61
- OneApm::Agent::Datastores::MetricHelper.metrics_for(MONGO_PRODUCT_NAME,
61
+ OneApm::Agent::Datastore::MetricHelper.metrics_for(MONGO_PRODUCT_NAME,
62
62
  name,
63
63
  collection)
64
64
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module OneApm
4
4
  module Agent
5
- module Datastores
5
+ module Datastore
6
6
  module Mongo
7
7
  module Obfuscator
8
8
 
@@ -1,10 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'one_apm/agent/datastores/mongo/obfuscator'
3
+ require 'one_apm/agent/datastore/mongo/obfuscator'
4
4
 
5
5
  module OneApm
6
6
  module Agent
7
- module Datastores
7
+ module Datastore
8
8
  module Mongo
9
9
  module StatementFormatter
10
10
 
@@ -5,68 +5,68 @@ module OneApm
5
5
  module Threading
6
6
  class AgentThread
7
7
 
8
- def self.create(label, &blk)
9
- OneApm::Manager.logger.debug("Creating OneApm thread: #{label}")
10
- wrapped_blk = Proc.new do
11
- begin
12
- blk.call
13
- rescue => e
14
- OneApm::Manager.logger.error("Thread #{label} exited with error", e)
15
- rescue Exception => e
16
- OneApm::Manager.logger.error("Thread #{label} exited with exception. Re-raising in case of interupt.", e)
17
- raise
18
- ensure
19
- OneApm::Manager.logger.debug("Exiting OneApm thread: #{label}")
8
+ @backing_thread_class = ::Thread
9
+
10
+ class << self
11
+
12
+ def create(label, &blk)
13
+ OneApm::Manager.logger.debug("Creating OneApm thread: #{label}")
14
+ wrapped_blk = Proc.new do
15
+ begin
16
+ blk.call
17
+ rescue => e
18
+ OneApm::Manager.logger.error("Thread #{label} exited with error", e)
19
+ rescue Exception => e
20
+ OneApm::Manager.logger.error("Thread #{label} exited with exception. Re-raising in case of interupt.", e)
21
+ raise
22
+ ensure
23
+ OneApm::Manager.logger.debug("Exiting OneApm thread: #{label}")
24
+ end
20
25
  end
21
- end
22
26
 
23
- thread = backing_thread_class.new(&wrapped_blk)
24
- thread[:oneapm_label] = label
25
- thread
26
- end
27
+ thread = backing_thread_class.new(&wrapped_blk)
28
+ thread[:oneapm_label] = label
29
+ thread
30
+ end
27
31
 
28
- # Simplifies testing if we don't directly use ::Thread.list, so keep
29
- # the accessor for it here on AgentThread to use and stub.
30
- def self.list
31
- backing_thread_class.list
32
- end
32
+ def list
33
+ backing_thread_class.list
34
+ end
33
35
 
34
- def self.bucket_thread(thread, profile_agent_code)
35
- if thread.key?(:oneapm_label)
36
- profile_agent_code ? :agent : :ignore
37
- else
38
- state = TransactionState.tl_state_for(thread)
39
- if state.in_background_transaction?
40
- :background
41
- elsif state.in_web_transaction?
42
- :request
36
+ def bucket_thread(thread, profile_agent_code)
37
+ if thread.key?(:oneapm_label)
38
+ profile_agent_code ? :agent : :ignore
43
39
  else
44
- :other
40
+ state = TransactionState.tl_state_for(thread)
41
+ if state.in_background_transaction?
42
+ :background
43
+ elsif state.in_web_transaction?
44
+ :request
45
+ else
46
+ :other
47
+ end
45
48
  end
46
49
  end
47
- end
48
50
 
49
- def self.scrub_backtrace(thread, profile_agent_code)
50
- begin
51
- bt = thread.backtrace
52
- rescue Exception => e
53
- OneApm::Manager.logger.debug("Failed to backtrace #{thread.inspect}: #{e.class.name}: #{e.to_s}")
51
+ def scrub_backtrace(thread, profile_agent_code)
52
+ begin
53
+ bt = thread.backtrace
54
+ rescue Exception => e
55
+ OneApm::Manager.logger.debug("Failed to backtrace #{thread.inspect}: #{e.class.name}: #{e.to_s}")
56
+ end
57
+ return nil unless bt
58
+ bt.reject! { |t| t.include?('one_apm') } unless profile_agent_code
59
+ bt
54
60
  end
55
- return nil unless bt
56
- bt.reject! { |t| t.include?('one_apm') } unless profile_agent_code
57
- bt
58
- end
59
61
 
60
- # To allow tests to swap out Thread for a synchronous alternative,
61
- # surface the backing class we'll use from the class level.
62
- @backing_thread_class = ::Thread
62
+ def backing_thread_class
63
+ @backing_thread_class
64
+ end
63
65
 
64
- def self.backing_thread_class
65
- @backing_thread_class
66
- end
66
+ def backing_thread_class=(clazz)
67
+ @backing_thread_class = clazz
68
+ end
67
69
 
68
- def self.backing_thread_class=(clazz)
69
- @backing_thread_class = clazz
70
70
  end
71
71
  end
72
72
  end