oneapm_rpm 1.2.2 → 1.2.3.rc2

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZWFmNjc4Yjk5MzM5ZjI0YmVmYmM3ZmMxNDg3YWMwZjk4OTBlNWQ2Mg==
4
+ NzA4OTY1M2MxYjA2NTc0OGMwYzg1NzVjN2ZlYjUxMzBiYTVmZjI0NA==
5
5
  data.tar.gz: !binary |-
6
- NWI5Y2M3Mzg5ZDJkZTI1MWFmZTk3MTRjYTRkNWIyMjU2YjM2NDBlYQ==
6
+ MzcyNjE0NGI5OGJkNDE3ODEzZGEyODFhNTM5MTgxNjNkMWI2Y2JlMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjI3MzM2ZTJhMzQ1NzUyNTg5OTk3ZGQ3MmI5MWQwMmFmN2EzZGQxMjI5NjUy
10
- Yzc2MzIxN2YxYmMyZGNmMDA0ZjQwNGJmY2JhNWRmYTgwMTYxYWQ2MjRkZGRl
11
- NDg0M2I2Y2VhODg5OWE4MDcwMWQ3ZTViZThjMjBiZGIxOGQ1ZWQ=
9
+ YzlkN2IwZDFmZDJmMGY1MGNkM2IxNDk1ZjE2Y2VkNGUxODk4MzBiYmNjNjkz
10
+ MjgzMWZjNTVmYWQ4ZDg3Y2E4M2MyODBmMDZkYmFiMjYxMmRhZjhkYjJhM2Q1
11
+ ZjgxMmI5MTljYzUyMzM0NTQ5MmM0NGM2NzEyYzYxM2YwYjk4ZjE=
12
12
  data.tar.gz: !binary |-
13
- MjA5Y2FlM2FmNmFmYjk3NjFmZDk2MTUyZTJkZTFkN2E0MGU4Yzc0ZTQzNTZl
14
- OGUxNDdhMTE2M2E2YzNmODA2Mjg0OGQ3YjYyOWRjYWVmZjBlOGQ3YmZlMjE2
15
- OTEzNTQ1NTQxODhkNmNjNzA0ZjEzNTBjNWU4ODY3YjU1NGZkYjM=
13
+ MDU5MmUzYjRjYjVjZjhlMzRmMTNmZTI4MjVlODEzOTkzZDYzZDE1YzhjNDg3
14
+ Y2M5NDljYjAzN2I0ZTVlZGZjZTQ2MDA1YTdkOTc0NzEwMDdlMzIzNzYyNmIw
15
+ NGQ0ZDc3ODliZDg5NzQ5ODg2ZWIyNTM3ZDM3MGRlYWE0ZDU3MDM=
data/lib/one_apm/agent.rb CHANGED
@@ -38,6 +38,8 @@ require 'one_apm/agent/agent/connect'
38
38
  require 'one_apm/agent/agent/helpers'
39
39
  require 'one_apm/agent/agent/container_data_manager'
40
40
  require 'one_apm/agent/agent/forkable_dispatcher_functions'
41
+ require 'one_apm/agent/agent/restart_monitor'
42
+ require 'one_apm/agent/agent/restart'
41
43
 
42
44
  module OneApm
43
45
  module Agent
@@ -83,12 +85,14 @@ module OneApm
83
85
 
84
86
  init_containers @events
85
87
  OneApm::Agent::SyntheticsMonitor.new @events
88
+ OneApm::Agent::RestartMonitor.new
86
89
 
87
90
  @cross_app_monitor = OneApm::Agent::CrossAppMonitor.new(@events)
88
91
  @transaction_rules = OneApm::Support::RulesEngine.new
89
92
  @harvest_samplers = OneApm::Collector::SamplerCollection.new(@events)
90
93
  @monotonic_gc_profiler = OneApm::Support::VM::MonotonicGCProfiler.new
91
94
  @javascript_instrumentor = OneApm::Agent::JavascriptInstrumentor.new(@events)
95
+ @restart = OneApm::Agent::Restart.new(@events)
92
96
 
93
97
  @harvester = OneApm::Agent::Harvester.new(@events)
94
98
  @after_fork_lock = Mutex.new
@@ -141,6 +141,10 @@ module OneApm
141
141
  end
142
142
  end
143
143
 
144
+ def detect_config
145
+ @events.notify(:agent_restart) if OneApm::Agent::RestartMonitor.need_restart?
146
+ end
147
+
144
148
  def transmit_event_data
145
149
  transmit_single_data_type(:harvest_and_send_analytic_event_data, "TransactionEvent")
146
150
  end
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+
3
+ module OneApm
4
+ module Agent
5
+ class Restart
6
+
7
+ def initialize(events)
8
+ events.subscribe(:agent_restart, &method(:restart))
9
+ end
10
+
11
+ def restart
12
+ OneApm::Manager.logger.info "Restarting Agent..."
13
+ OneApm::Manager.restart
14
+ OneApm::Manager.logger.info "Restarted Agent done."
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,75 @@
1
+ # encoding: utf-8
2
+
3
+ module OneApm
4
+ module Agent
5
+ class RestartMonitor
6
+
7
+ def initialize
8
+ @lock = Mutex.new
9
+ create_restart_file
10
+ end
11
+
12
+ def create_restart_file
13
+ @lock.synchronize do
14
+ begin
15
+ file_path = OneApm::Agent::RestartMonitor.file_path
16
+ return if file_path.nil?
17
+ if !File.exist?(file_path) && system("touch #{file_path}")
18
+ OneApm::Manager.logger.info "create #{file_path} successful."
19
+ else
20
+ OneApm::Manager.logger.debug "#{file_path} has exist."
21
+ end
22
+ OneApm::Agent::RestartMonitor.timestamp = File.mtime(file_path).to_i
23
+ rescue => e
24
+ OneApm::Manager.logger.warn("create #{file_path} fail.", e)
25
+ end
26
+ end
27
+ end
28
+
29
+ def self.need_restart?
30
+ @result = timestamp == restart_file_timestamp
31
+ self.timestamp = restart_file_timestamp unless @result
32
+ !@result
33
+ end
34
+
35
+ def self.touch
36
+ !file_path.nil? && system("touch #{file_path}")
37
+ end
38
+
39
+ private
40
+
41
+ def self.timestamp
42
+ @timestamp || 0
43
+ end
44
+
45
+ def self.timestamp= timestamp
46
+ @timestamp = timestamp
47
+ end
48
+
49
+ def self.restart_file_timestamp
50
+ return 0 unless File.exist?(file_path)
51
+ File.mtime(file_path).to_i
52
+ end
53
+
54
+ def self.file_path
55
+ return nil if path.nil?
56
+ @file_path ||= "#{path}/#{OneApm::Manager.config[:agent_restart_file_name]}"
57
+ end
58
+
59
+ def self.path
60
+ @path ||= find_or_create_path(OneApm::Manager.config[:agent_restart_file_path], OneApm::Probe.instance.root)
61
+ end
62
+
63
+ def self.find_or_create_path(path_setting, root)
64
+ for abs_path in [ File.expand_path(path_setting),
65
+ File.expand_path(File.join(root, path_setting)) ] do
66
+ if File.directory?(abs_path) || (Dir.mkdir(abs_path) rescue nil)
67
+ return abs_path[%r{^(.*?)/?$}]
68
+ end
69
+ end
70
+ nil
71
+ end
72
+
73
+ end
74
+ end
75
+ end
@@ -40,10 +40,12 @@ module OneApm
40
40
  @event_loop.on(:report_data) { transmit_data }
41
41
  @event_loop.on(:report_event_data) { transmit_event_data }
42
42
  @event_loop.on(:reset_log_once_keys) { OneApm::Manager.logger.clear_already_logged }
43
+ @event_loop.on(:detect_config) { detect_config }
43
44
 
44
45
  @event_loop.fire_every(Manager.config[:data_report_period], :report_data)
45
46
  @event_loop.fire_every(report_period_for(:analytic_event_data), :report_event_data)
46
47
  @event_loop.fire_every(LOG_ONCE_KEYS_RESET_PERIOD, :reset_log_once_keys)
48
+ @event_loop.fire_every(Manager.config[:data_report_period], :detect_config)
47
49
 
48
50
  if OneApm::Manager.config[:collect_utilization] && !in_resque_child_process?
49
51
  @event_loop.on(:report_utilization_data) { transmit_utilization_data }
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+
3
+ require 'one_apm/agent/agent/restart_monitor'
4
+
5
+ module OneApm
6
+ module Collector
7
+ module Commands
8
+ class RestartAgent
9
+
10
+ def initialize
11
+ OneApm::Agent::RestartMonitor.touch
12
+ end
13
+
14
+ end
15
+ end
16
+ end
17
+ end
@@ -3,6 +3,7 @@
3
3
  require 'one_apm/collector/commands/agent_command'
4
4
  require 'one_apm/collector/commands/xray_session_collection'
5
5
  require 'one_apm/collector/commands/thread_profiler_session'
6
+ require 'one_apm/collector/commands/restart_agent'
6
7
  require 'one_apm/support/backtrace/backtrace_service'
7
8
 
8
9
  module OneApm
@@ -22,7 +23,7 @@ module OneApm
22
23
  @thread_profiler_session = OneApm::Collector::Commands::ThreadProfilerSession.new(@backtrace_service)
23
24
  @xray_session_collection = OneApm::Collector::Commands::XraySessionCollection.new(@backtrace_service, event_listener)
24
25
 
25
- @handlers['restart'] = Proc.new { OneApm::Manager.restart }
26
+ @handlers['restart'] = Proc.new { OneApm::Collector::Commands::RestartAgent.new }
26
27
  @handlers['start_profiler'] = Proc.new { |cmd| thread_profiler_session.handle_start_command(cmd) }
27
28
  @handlers['stop_profiler'] = Proc.new { |cmd| thread_profiler_session.handle_stop_command(cmd) }
28
29
  @handlers['active_xray_sessions'] = Proc.new { |cmd| xray_session_collection.handle_active_xray_sessions(cmd) }
@@ -1050,6 +1050,18 @@ module OneApm
1050
1050
  :public => true,
1051
1051
  :type => Boolean,
1052
1052
  :description => 'Defines whether the agent will wrap middlewares which are installed Rails.'
1053
+ },
1054
+ :agent_restart_file_name => {
1055
+ :default => 'oneapm_restart.txt',
1056
+ :public => true,
1057
+ :type => String,
1058
+ :description => 'Defines name of the agent restart file.'
1059
+ },
1060
+ :agent_restart_file_path => {
1061
+ :default => 'tmp/',
1062
+ :public => true,
1063
+ :type => String,
1064
+ :description => 'Defines a path to the agent restart file, excluding the filename.'
1053
1065
  }
1054
1066
  }.freeze
1055
1067
  end
@@ -50,9 +50,17 @@ module OneApm
50
50
  end
51
51
  end
52
52
 
53
+ def agent_hooks_installed
54
+ @@agent_hooks_installed ||= false
55
+ end
56
+
57
+ def browser_monitoring_installed
58
+ @@browser_monitoring_installed ||= false
59
+ end
60
+
53
61
  def install_agent_hooks(config)
54
- return if @agent_hooks_installed
55
- @agent_hooks_installed = true
62
+ return if agent_hooks_installed
63
+ @@agent_hooks_installed = true
56
64
  return if config.nil? || !config.respond_to?(:middleware)
57
65
  begin
58
66
  require 'one_apm/rack/middleware_hooks'
@@ -65,8 +73,8 @@ module OneApm
65
73
  end
66
74
 
67
75
  def install_browser_monitoring(config)
68
- return if @browser_monitoring_installed
69
- @browser_monitoring_installed = true
76
+ return if browser_monitoring_installed
77
+ @@browser_monitoring_installed = true
70
78
  return if config.nil? || !config.respond_to?(:middleware) || !Manager.config[:'browser_monitoring.auto_instrument']
71
79
  begin
72
80
  require 'one_apm/rack/browser_monitoring'
@@ -82,7 +82,7 @@ LibraryDetection.defer do
82
82
  def filter command
83
83
  need_filtered = OneApm::Manager.config[:'redis.ignore_commands'].map(&:to_s).include?(command.to_s)
84
84
  if need_filtered
85
- OneApm::Manager.logger.debug "filter command: #{command}"
85
+ OneApm::Manager.logger.debug "Redis filter command: #{command}"
86
86
  nil
87
87
  else
88
88
  command
@@ -74,9 +74,9 @@ module OneApm
74
74
  def restart
75
75
  shutdown
76
76
  agent.harvest_samplers.clear
77
- agent.agent_variable_set(:@connect_state, :pending)
78
- agent.agent_variable_set(:@worker_thread, nil)
79
- agent.harvester.agent_variable_set(:@starting_pid, nil)
77
+ agent.instance_variable_set(:@connect_state, :pending)
78
+ agent.instance_variable_set(:@worker_thread, nil)
79
+ agent.harvester.instance_variable_set(:@starting_pid, nil)
80
80
  OneApm::Probe.init({:agent_enabled => true, :sync_startup => true})
81
81
  end
82
82
 
@@ -5,9 +5,10 @@ module OneApm
5
5
 
6
6
  MAJOR = 1
7
7
  MINOR = 2
8
- TINY = 2
8
+ TINY = 3
9
+ TAG = 'rc2'
9
10
 
10
- STRING = [MAJOR, MINOR, TINY].compact.join('.')
11
+ STRING = [MAJOR, MINOR, TINY, TAG].compact.join('.')
11
12
 
12
13
  end
13
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oneapm_rpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - oneapm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-22 00:00:00.000000000 Z
11
+ date: 2015-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -243,6 +243,8 @@ files:
243
243
  - lib/one_apm/agent/agent/container_data_manager.rb
244
244
  - lib/one_apm/agent/agent/forkable_dispatcher_functions.rb
245
245
  - lib/one_apm/agent/agent/helpers.rb
246
+ - lib/one_apm/agent/agent/restart.rb
247
+ - lib/one_apm/agent/agent/restart_monitor.rb
246
248
  - lib/one_apm/agent/agent/start.rb
247
249
  - lib/one_apm/agent/agent/start_worker_thread.rb
248
250
  - lib/one_apm/agent/busy_calculator.rb
@@ -270,6 +272,7 @@ files:
270
272
  - lib/one_apm/collector/collector/server_methods.rb
271
273
  - lib/one_apm/collector/collector_service.rb
272
274
  - lib/one_apm/collector/commands/agent_command.rb
275
+ - lib/one_apm/collector/commands/restart_agent.rb
273
276
  - lib/one_apm/collector/commands/thread_profiler_session.rb
274
277
  - lib/one_apm/collector/commands/xray_session.rb
275
278
  - lib/one_apm/collector/commands/xray_session_collection.rb