tcell_agent 0.2.7 → 0.2.8

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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/bin/tcell_agent +22 -0
  3. data/lib/tcell_agent/agent/event_processor.rb +7 -0
  4. data/lib/tcell_agent/agent/fork_pipe_manager.rb +29 -29
  5. data/lib/tcell_agent/agent/policy_manager.rb +2 -1
  6. data/lib/tcell_agent/agent/route_manager.rb +35 -15
  7. data/lib/tcell_agent/configuration.rb +42 -2
  8. data/lib/tcell_agent/instrumentation.rb +4 -1
  9. data/lib/tcell_agent/logger.rb +1 -1
  10. data/lib/tcell_agent/rails.rb +12 -18
  11. data/lib/tcell_agent/rails/auth/authlogic.rb +2 -2
  12. data/lib/tcell_agent/rails/auth/devise.rb +1 -1
  13. data/lib/tcell_agent/rails/dlp.rb +133 -123
  14. data/lib/tcell_agent/rails/middleware/body_filter_middleware.rb +2 -1
  15. data/lib/tcell_agent/rails/on_start.rb +67 -69
  16. data/lib/tcell_agent/rails/routes.rb +91 -86
  17. data/lib/tcell_agent/rails/settings_reporter.rb +10 -0
  18. data/lib/tcell_agent/routes/table.rb +2 -0
  19. data/lib/tcell_agent/sensor_events/server_agent.rb +10 -0
  20. data/lib/tcell_agent/servers/thin.rb +1 -0
  21. data/lib/tcell_agent/servers/webrick.rb +0 -1
  22. data/lib/tcell_agent/start_background_thread.rb +44 -45
  23. data/lib/tcell_agent/system_info.rb +10 -0
  24. data/lib/tcell_agent/version.rb +1 -1
  25. data/spec/lib/tcell_agent/agent/fork_pipe_manager_spec.rb +99 -0
  26. data/spec/lib/tcell_agent/api/api_spec.rb +2 -2
  27. data/spec/lib/tcell_agent/instrumentation_spec.rb +176 -176
  28. data/spec/lib/tcell_agent/policies/appsensor_policy_spec.rb +32 -32
  29. data/spec/lib/tcell_agent/policies/clickjacking_policy_spec.rb +63 -63
  30. data/spec/lib/tcell_agent/policies/content_security_policy_spec.rb +93 -93
  31. data/spec/lib/tcell_agent/policies/dataloss_policy_spec.rb +222 -222
  32. data/spec/lib/tcell_agent/policies/honeytokens_policy_spec.rb +17 -17
  33. data/spec/lib/tcell_agent/policies/http_redirect_policy_spec.rb +57 -57
  34. data/spec/lib/tcell_agent/policies/http_tx_policy_spec.rb +17 -17
  35. data/spec/lib/tcell_agent/policies/login_policy_spec.rb +3 -3
  36. data/spec/lib/tcell_agent/policies/secure_headers_policy_spec.rb +59 -59
  37. data/spec/lib/tcell_agent/rails/logger_spec.rb +148 -0
  38. data/spec/lib/tcell_agent/rails/middleware/global_middleware_spec.rb +7 -7
  39. data/spec/lib/tcell_agent/rails_spec.rb +2 -2
  40. data/spec/lib/tcell_agent/sensor_events/dlp_spec.rb +9 -9
  41. data/spec/lib/tcell_agent/sensor_events/util/redirect_utils_spec.rb +20 -20
  42. data/spec/lib/tcell_agent/sensor_events/util/sanitizer_utilities_spec.rb +52 -52
  43. data/spec/lib/tcell_agent_spec.rb +17 -17
  44. data/spec/spec_helper.rb +1 -0
  45. data/spec/support/resources/normal_config.json +5 -5
  46. data/tcell_agent.gemspec +4 -4
  47. metadata +31 -26
@@ -74,7 +74,8 @@ module TCellAgent
74
74
  script_tag_policy.js_agent_api_key)
75
75
  newbody = []
76
76
  rack_body.each { |str|
77
- newbody << self.replace_in_body(script_tag_policy, str)
77
+ newbody_part = self.replace_in_body(script_tag_policy, str) || str
78
+ newbody << newbody_part
78
79
  }
79
80
  response = [status, headers, newbody]
80
81
  end
@@ -1,101 +1,99 @@
1
1
  # See the file "LICENSE" for the full license governing this code.
2
2
 
3
3
  #require 'tcell_agent/authlogic' if defined?(Authlogic)
4
- #require 'tcell_agent/devise' if defined?(Devise)
4
+ require 'tcell_agent/configuration'
5
5
 
6
6
  require 'rails/all'
7
+ require 'rails'
7
8
 
8
- module TCellAgent
9
- module Instrumentation
10
- module Rails
11
- METHODS = ['GET','POST','PUT','DELETE','HEAD',
12
- 'PATCH','TRACE','CONNECT','OPTIONS']
13
-
14
- def self.instrument_route(route)
15
- if (route.constraints.has_key? :request_method)
16
- route_path = "#{route.path.spec}"
17
- if (route_path.end_with?("(.:format)"))
18
- route_path = route_path.chomp("(.:format)")
19
- end
9
+ TCellAgent::Instrumentation::Rails.send_language_info
10
+ TCellAgent::Instrumentation::Rails.send_framework_info
11
+ if TCellAgent.configuration.enabled && TCellAgent.configuration.should_instrument?
12
+ module TCellAgent
13
+ module Instrumentation
14
+ module Rails
15
+ METHODS = ['GET','POST','PUT','DELETE','HEAD',
16
+ 'PATCH','TRACE','CONNECT','OPTIONS']
17
+
18
+ def self.instrument_route(route)
19
+ if (route.constraints.has_key? :request_method)
20
+ route_path = "#{route.path.spec}"
21
+ if (route_path.end_with?("(.:format)"))
22
+ route_path = route_path.chomp("(.:format)")
23
+ end
20
24
 
21
- route_destination = route.defaults.to_json.to_s
25
+ route_destination = route.defaults.to_json.to_s
22
26
 
23
- route_methods = METHODS.select { |x| route.verb.match(x) }
24
- route_methods.each { |route_method|
25
- route_id = TCellAgent::SensorEvents::Util.calculateRouteId(route_method.downcase, route.path.spec)
26
- TCellAgent.send_event(
27
- TCellAgent::SensorEvents::AppRoutesSensorEvent.new(
28
- route_path, route_method, route_id, nil, route_destination
27
+ route_methods = METHODS.select { |x| route.verb.match(x) }
28
+ route_methods.each { |route_method|
29
+ route_id = TCellAgent::SensorEvents::Util.calculateRouteId(route_method.downcase, route.path.spec)
30
+ TCellAgent.send_event(
31
+ TCellAgent::SensorEvents::AppRoutesSensorEvent.new(
32
+ route_path, route_method, route_id, nil, route_destination
33
+ )
29
34
  )
30
- )
31
- }
35
+ }
36
+ end
32
37
  end
33
- end
34
38
 
35
- def self.instrument_routes
36
- if ::Rails.application
37
- ::Rails.application.routes.routes.each do |route|
38
- self.instrument_route(route)
39
+ def self.instrument_routes
40
+ if ::Rails.application
41
+ ::Rails.application.routes.routes.each do |route|
42
+ self.instrument_route(route)
43
+ end
39
44
  end
40
45
  end
41
- end
42
46
 
43
- if (::Rails::VERSION::MAJOR == 3)
44
- ActionDispatch::Routing::RouteSet.class_eval do
45
- alias_method :original_add_route, :add_route
46
- def add_route(app, conditions = {}, requirements = {}, defaults = {}, name = nil, anchor = true)
47
- route = original_add_route(app, conditions, requirements, defaults, name, anchor)
47
+ if (::Rails::VERSION::MAJOR == 3)
48
+ ActionDispatch::Routing::RouteSet.class_eval do
49
+ alias_method :original_add_route, :add_route
50
+ def add_route(app, conditions = {}, requirements = {}, defaults = {}, name = nil, anchor = true)
51
+ route = original_add_route(app, conditions, requirements, defaults, name, anchor)
48
52
 
49
- TCellAgent::Instrumentation::Rails.instrument_route(route)
53
+ TCellAgent::Instrumentation::Rails.instrument_route(route)
50
54
 
51
- route
52
- end
55
+ route
56
+ end
57
+ end
53
58
  end
54
- end
55
59
 
56
- if (::Rails::VERSION::MAJOR == 4)
57
- ActionDispatch::Journey::Routes.class_eval do
58
- alias_method :original_add_route, :add_route
59
- def add_route(app, path, conditions, defaults, name = nil)
60
- route = original_add_route(app, path, conditions, defaults, name)
60
+ if (::Rails::VERSION::MAJOR == 4)
61
+ ActionDispatch::Journey::Routes.class_eval do
62
+ alias_method :original_add_route, :add_route
63
+ def add_route(app, path, conditions, defaults, name = nil)
64
+ route = original_add_route(app, path, conditions, defaults, name)
61
65
 
62
- TCellAgent::Instrumentation::Rails.instrument_route(route)
66
+ TCellAgent::Instrumentation::Rails.instrument_route(route)
63
67
 
64
- route
68
+ route
69
+ end
65
70
  end
66
71
  end
67
- end
68
72
 
73
+ end
69
74
  end
70
75
  end
71
- end
72
76
 
77
+ if (Rails.application)
78
+ TCellAgent::Instrumentation::Rails.send_settings(Rails.application)
79
+ else
80
+ module TCellAgent
81
+ class MyRailtie < Rails::Railtie
82
+ initializer 'activeservice.autoload', :after => :set_autoload_paths do |app|
83
+ if (TCellAgent.configuration.enabled)
84
+ Rails.application.config.to_prepare do
85
+ require 'tcell_agent/devise' if defined?(Devise)
86
+ require 'tcell_agent/rails/auth/devise' if defined?(Devise)
87
+ require 'tcell_agent/authlogic' if defined?(Authlogic)
88
+ require 'tcell_agent/rails/auth/authlogic' if defined?(Authlogic)
89
+ end
73
90
 
74
- TCellAgent::Instrumentation::Rails.send_framework_info
75
- if (Rails.application)
76
- TCellAgent::Instrumentation::Rails.send_settings(Rails.application)
77
- require 'tcell_agent/devise' if defined?(Devise)
78
- require 'tcell_agent/rails/auth/devise' if defined?(Devise)
79
- require 'tcell_agent/authlogic' if defined?(Authlogic)
80
- require 'tcell_agent/rails/auth/authlogic' if defined?(Authlogic)
81
-
82
- else
83
- module TCellAgent
84
- class MyRailtie < Rails::Railtie
85
- initializer 'activeservice.autoload', :after => :set_autoload_paths do |app|
86
- if (TCellAgent.configuration.enabled)
87
- Rails.application.config.to_prepare do
88
- require 'tcell_agent/devise' if defined?(Devise)
89
- require 'tcell_agent/rails/auth/devise' if defined?(Devise)
90
- require 'tcell_agent/authlogic' if defined?(Authlogic)
91
- require 'tcell_agent/rails/auth/authlogic' if defined?(Authlogic)
92
- end
93
-
94
- Rails.application.config.after_initialize do
95
- TCellAgent::Instrumentation::Rails.send_settings(Rails.application)
91
+ Rails.application.config.after_initialize do
92
+ TCellAgent::Instrumentation::Rails.send_settings(Rails.application)
93
+ end
96
94
  end
97
95
  end
98
96
  end
99
97
  end
100
98
  end
101
- end
99
+ end
@@ -1,99 +1,104 @@
1
- module TCellAgent
2
- ActiveSupport.on_load(:action_controller) do
3
- ActionController::Base.class_eval do
1
+ require 'tcell_agent/configuration'
4
2
 
5
- prepend_around_filter :tell_around_filter_routes
6
- def tell_around_filter_routes
7
- begin
8
- TCellAgent::Instrumentation.safe_block("Determining Rails Route ID") {
9
- route = Rails.application.routes.router.recognize(request) { |r, _| r }.first
10
- if route
11
- route_path = route[2].path.spec
12
- tcell_context = request.env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID]
13
- if tcell_context
14
- tcell_context.route_id = TCellAgent::SensorEvents::Util.calculateRouteId(request.method.downcase, route_path)
3
+ if TCellAgent.configuration.enabled && TCellAgent.configuration.should_instrument? && TCellAgent.configuration.should_intercept_requests?
4
+
5
+ module TCellAgent
6
+ ActiveSupport.on_load(:action_controller) do
7
+ ActionController::Base.class_eval do
8
+
9
+ prepend_around_filter :tell_around_filter_routes
10
+ def tell_around_filter_routes
11
+ begin
12
+ TCellAgent::Instrumentation.safe_block("Determining Rails Route ID") {
13
+ route = Rails.application.routes.router.recognize(request) { |r, _| r }.first
14
+ if route
15
+ route_path = route[2].path.spec
16
+ tcell_context = request.env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID]
17
+ if tcell_context
18
+ tcell_context.route_id = TCellAgent::SensorEvents::Util.calculateRouteId(request.method.downcase, route_path)
19
+ end
15
20
  end
16
- end
17
- }
18
- def loop_params_hash(method, param_hash, prefix, &block)
19
- param_hash.each do |param_name, param_value|
20
- if param_value && param_value.is_a?(Hash)
21
- loop_params_hash(method, param_value, 'hash', &block)
22
- elsif !param_value || !param_value.instance_of?(String) || param_value == ""
23
- next
24
- else
25
- block.call(method, param_name, param_value)
21
+ }
22
+ def loop_params_hash(method, param_hash, prefix, &block)
23
+ param_hash.each do |param_name, param_value|
24
+ if param_value && param_value.is_a?(Hash)
25
+ loop_params_hash(method, param_value, 'hash', &block)
26
+ elsif !param_value || !param_value.instance_of?(String) || param_value == ""
27
+ next
28
+ else
29
+ block.call(method, param_name, param_value)
30
+ end
31
+ end
32
+ end
33
+ def for_params(request, &block)
34
+ get_params = request.GET
35
+ if get_params
36
+ self.loop_params_hash('get', get_params, nil, &block)
37
+ end
38
+ post_params = request.POST
39
+ if post_params
40
+ self.loop_params_hash('post', post_params, nil, &block)
41
+ end
42
+ end
43
+ def _handle_dataexpsure_forms(request)
44
+ dataex_policy = TCellAgent.policy(TCellAgent::PolicyTypes::DataLoss)
45
+ tcell_context = request.env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID]
46
+ if tcell_context && dataex_policy && dataex_policy.has_actions_for_form_parameter?
47
+ for_params(request) { |method, param_name, param_value|
48
+ actions = dataex_policy.get_actions_for_request("form",param_name)
49
+ if actions
50
+ actions.each { |action|
51
+ tcell_context.add_filter_for_request_parameter(param_value, action, param_name)
52
+ }
26
53
  end
54
+ }
27
55
  end
28
- end
29
- def for_params(request, &block)
30
- get_params = request.GET
31
- if get_params
32
- self.loop_params_hash('get', get_params, nil, &block)
33
- end
34
- post_params = request.POST
35
- if post_params
36
- self.loop_params_hash('post', post_params, nil, &block)
37
- end
38
- end
39
- def _handle_dataexpsure_forms(request)
40
- dataex_policy = TCellAgent.policy(TCellAgent::PolicyTypes::DataLoss)
41
- tcell_context = request.env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID]
42
- if tcell_context && dataex_policy && dataex_policy.has_actions_for_form_parameter?
43
- for_params(request) { |method, param_name, param_value|
44
- actions = dataex_policy.get_actions_for_request("form",param_name)
45
- if actions
46
- actions.each { |action|
47
- tcell_context.add_filter_for_request_parameter(param_value, action, param_name)
48
- }
49
- end
50
- }
51
56
  end
52
- end
53
- TCellAgent::Instrumentation.safe_block("Handling Dataexposure (request forms)") {
54
- _handle_dataexpsure_forms(request)
55
- }
57
+ TCellAgent::Instrumentation.safe_block("Handling Dataexposure (request forms)") {
58
+ _handle_dataexpsure_forms(request)
59
+ }
56
60
 
57
- def _handle_dataexpsure_headers(request)
58
- dataex_policy = TCellAgent.policy(TCellAgent::PolicyTypes::DataLoss)
59
- tcell_context = request.env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID]
60
- if tcell_context && dataex_policy && dataex_policy.has_actions_for_headers?
61
- headers = request.env.select {|k,v| k.start_with? 'HTTP_'}
62
- headers.each { |header_name, header_value|
63
- header_name = header_name.sub(/^HTTP_/, '').gsub('_','-')
64
- actions = dataex_policy.get_actions_for_header(header_name)
65
- if actions
66
- actions.each { |action|
67
- tcell_context.add_filter_for_header_value(header_value, action, header_name)
68
- }
69
- end
70
- }
61
+ def _handle_dataexpsure_headers(request)
62
+ dataex_policy = TCellAgent.policy(TCellAgent::PolicyTypes::DataLoss)
63
+ tcell_context = request.env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID]
64
+ if tcell_context && dataex_policy && dataex_policy.has_actions_for_headers?
65
+ headers = request.env.select {|k,v| k.start_with? 'HTTP_'}
66
+ headers.each { |header_name, header_value|
67
+ header_name = header_name.sub(/^HTTP_/, '').gsub('_','-')
68
+ actions = dataex_policy.get_actions_for_header(header_name)
69
+ if actions
70
+ actions.each { |action|
71
+ tcell_context.add_filter_for_header_value(header_value, action, header_name)
72
+ }
73
+ end
74
+ }
75
+ end
71
76
  end
72
- end
73
- TCellAgent::Instrumentation.safe_block("Handling Dataexposure (request headers)") {
74
- _handle_dataexpsure_headers(request)
75
- }
77
+ TCellAgent::Instrumentation.safe_block("Handling Dataexposure (request headers)") {
78
+ _handle_dataexpsure_headers(request)
79
+ }
76
80
 
77
- def _handler_dataexposure_cookies(request)
78
- dataex_policy = TCellAgent.policy(TCellAgent::PolicyTypes::DataLoss)
79
- tcell_context = request.env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID]
80
- if tcell_context && dataex_policy && dataex_policy.has_actions_for_cookie?
81
- request.cookies.each { |cookie_name, cookie_value|
82
- actions = dataex_policy.get_actions_for_cookie(cookie_name)
83
- if actions
84
- actions.each { |action|
85
- tcell_context.add_filter_for_cookie_value(cookie_value, action, cookie_name)
86
- }
87
- end
88
- }
81
+ def _handler_dataexposure_cookies(request)
82
+ dataex_policy = TCellAgent.policy(TCellAgent::PolicyTypes::DataLoss)
83
+ tcell_context = request.env[TCellAgent::Instrumentation::Rails::Middleware::TCELL_ID]
84
+ if tcell_context && dataex_policy && dataex_policy.has_actions_for_cookie?
85
+ request.cookies.each { |cookie_name, cookie_value|
86
+ actions = dataex_policy.get_actions_for_cookie(cookie_name)
87
+ if actions
88
+ actions.each { |action|
89
+ tcell_context.add_filter_for_cookie_value(cookie_value, action, cookie_name)
90
+ }
91
+ end
92
+ }
93
+ end
89
94
  end
90
- end
91
- TCellAgent::Instrumentation.safe_block("Handling Dataexposure (request cookies)") {
92
- _handler_dataexposure_cookies(request)
93
- }
94
- yield
95
+ TCellAgent::Instrumentation.safe_block("Handling Dataexposure (request cookies)") {
96
+ _handler_dataexposure_cookies(request)
97
+ }
98
+ yield
99
+ end
95
100
  end
96
101
  end
97
102
  end
98
103
  end
99
- end
104
+ end
@@ -2,6 +2,7 @@ require 'rails'
2
2
  require 'tcell_agent'
3
3
  require 'tcell_agent/sensor_events/app_config'
4
4
  require 'tcell_agent/sensor_events/server_agent'
5
+ require 'tcell_agent/system_info'
5
6
 
6
7
  module TCellAgent
7
8
  module Instrumentation
@@ -14,6 +15,15 @@ module TCellAgent
14
15
  ))
15
16
  end
16
17
  end
18
+ def self.send_language_info
19
+ if (TCellAgent.configuration.exp_config_settings)
20
+ language = TCellAgent::SystemInfo.get_language
21
+ language_version = TCellAgent::SystemInfo.get_language_version
22
+ TCellAgent.send_event(TCellAgent::SensorEvents::ServerAgentDetailsLanguageEvent.new(
23
+ language, language_version
24
+ ))
25
+ end
26
+ end
17
27
  def self.send_settings(application)
18
28
  if (TCellAgent.configuration.exp_config_settings)
19
29
  # Defaults to true
@@ -10,7 +10,9 @@ module TCellAgent
10
10
 
11
11
  class RouteEndpoint
12
12
  attr_accessor :database
13
+ attr_accessor :database_queries_discovered
13
14
  def initialize
15
+ @database_queries_discovered = {}
14
16
  @database = Hash.new {|h,k| # Database
15
17
  h[k] = Hash.new {|h,k| # Schema
16
18
  h[k] = Hash.new {|h,k| # Table
@@ -41,6 +41,16 @@ module TCellAgent
41
41
  end
42
42
  end
43
43
  end
44
+ class ServerAgentDetailsLanguageEvent < TCellSensorEvent
45
+ def initialize(language, language_version)
46
+ super("server_agent_details")
47
+ @flush = true
48
+ @ensure = true
49
+ self["language"] = language
50
+ self["language_version"] = language_version
51
+ end
52
+ end
53
+
44
54
  class ServerAgentAppFrameworkEvent < TCellSensorEvent
45
55
  def initialize(framework_name, framework_version)
46
56
  super("server_agent_details")
@@ -1,3 +1,4 @@
1
+
1
2
  Thin::Server.class_eval do
2
3
 
3
4
  alias_method :original_start, :start
@@ -10,4 +10,3 @@ Rack::Handler::WEBrick.class_eval do
10
10
  end
11
11
 
12
12
  end
13
-
@@ -5,74 +5,73 @@ require 'tcell_agent/agent'
5
5
  require 'tcell_agent/configuration'
6
6
  require 'thread'
7
7
 
8
-
9
- module TCellAgent
10
-
11
- if (TCellAgent.configuration.enabled && TCellAgent.configuration.instrument_for_events)
12
- require 'tcell_agent/sinatra' if defined?(Sinatra)
8
+ if TCellAgent.configuration.enabled
9
+ module TCellAgent
10
+ #require 'tcell_agent/sinatra' if defined?(Sinatra)
13
11
  require 'tcell_agent/rails' if defined?(Rails)
14
- end
15
12
 
16
- def self.run_instrumentation(server_name)
17
- require 'tcell_agent/rails/on_start' if defined?(Rails)
13
+ def self.run_instrumentation(server_name)
18
14
 
19
- begin
20
- TCellAgent.logger.debug("Instrumenting: #{server_name}")
21
- TCellAgent.thread_agent.start
22
- rescue Exception => e
23
- TCellAgent.logger.error("Could not start thread agent. #{e.message}")
24
- end
15
+ require 'tcell_agent/rails/on_start' if defined?(Rails)
25
16
 
26
- Thread.abort_on_exception = TCellAgent.configuration.raise_exceptions
27
- Thread.new do
28
-
29
- TCellAgent::Instrumentation.safe_block("Instrumenting Agent Details") do
30
- event = TCellAgent::SensorEvents::ServerAgentDetailsSensorEvent.new
31
- TCellAgent.send_event(event)
17
+ begin
18
+ TCellAgent.logger.debug("Instrumenting: #{server_name}")
19
+ TCellAgent.thread_agent.start
20
+ rescue Exception => e
21
+ TCellAgent.logger.error("Could not start thread agent. #{e.message}")
32
22
  end
33
23
 
34
- TCellAgent::Instrumentation.safe_block("Instrumenting Server Packages") do
35
- event = TCellAgent::SensorEvents::ServerAgentPackagesSensorEvent.new
36
- TCellAgent.send_event(event)
37
- end
24
+ Thread.abort_on_exception = TCellAgent.configuration.raise_exceptions
25
+ Thread.new do
26
+
27
+ TCellAgent::Instrumentation.safe_block("Instrumenting Agent Details") do
28
+ event = TCellAgent::SensorEvents::ServerAgentDetailsSensorEvent.new
29
+ TCellAgent.send_event(event)
30
+ end
31
+
32
+ TCellAgent::Instrumentation.safe_block("Instrumenting Server Packages") do
33
+ event = TCellAgent::SensorEvents::ServerAgentPackagesSensorEvent.new
34
+ TCellAgent.send_event(event)
35
+ end
38
36
 
39
- if (TCellAgent.configuration.enabled && TCellAgent.configuration.instrument_for_events && defined?(Rails))
40
- TCellAgent::Instrumentation.safe_block("Instrumenting routes") do
41
- TCellAgent::Instrumentation::Rails.instrument_routes
37
+ if (TCellAgent.configuration.enabled && TCellAgent.configuration.should_instrument? && defined?(Rails))
38
+ TCellAgent::Instrumentation.safe_block("Instrumenting routes") do
39
+ TCellAgent::Instrumentation::Rails.instrument_routes
40
+ end
42
41
  end
42
+
43
43
  end
44
44
 
45
45
  end
46
46
 
47
47
  end
48
48
 
49
- end
50
-
51
- tcell_server = ENV["TCELL_AGENT_SERVER"]
49
+ tcell_server = ENV["TCELL_AGENT_SERVER"]
52
50
 
53
- if (!(tcell_server && tcell_server == "mock"))
51
+ if (!(tcell_server && tcell_server == "mock"))
54
52
 
55
- if (tcell_server && tcell_server == "webrick") || defined?(Rails::Server)
53
+ if (tcell_server && tcell_server == "webrick") || defined?(Rails::Server)
56
54
 
57
- require("tcell_agent/servers/rails_server")
55
+ require("tcell_agent/servers/rails_server")
58
56
 
59
- elsif (tcell_server && tcell_server == "thin") || defined?(Thin)
57
+ elsif (tcell_server && tcell_server == "thin") || defined?(Thin)
60
58
 
61
- require("tcell_agent/servers/thin")
59
+ require("tcell_agent/servers/thin")
62
60
 
63
- elsif (tcell_server && tcell_server == "puma") || defined?(Puma)
61
+ elsif (tcell_server && tcell_server == "puma") || defined?(Puma)
64
62
 
65
- require("tcell_agent/servers/puma")
63
+ require("tcell_agent/servers/puma")
66
64
 
67
- elsif (tcell_server && tcell_server == "unicorn") || defined?(Unicorn)
65
+ elsif (tcell_server && tcell_server == "unicorn") || defined?(Unicorn)
68
66
 
69
- require("tcell_agent/servers/unicorn")
67
+ require("tcell_agent/servers/unicorn")
70
68
 
71
- else
72
- puts "[tCell.io] **********************************************************************"
73
- puts "[tCell.io] Server used to launch rails not recognized."
74
- puts "[tCell.io] You can override this with the env variable"
75
- puts "[tCell.io] TCELL_AGENT_SERVER=thin|puma|unicorn"
76
- puts "[tCell.io] **********************************************************************"
69
+ else
70
+ puts "[tCell.io] **********************************************************************"
71
+ puts "[tCell.io] Server used to launch rails not recognized."
72
+ puts "[tCell.io] You can override this with the env variable"
73
+ puts "[tCell.io] TCELL_AGENT_SERVER=thin|puma|unicorn"
74
+ puts "[tCell.io] **********************************************************************"
75
+ end
77
76
  end
78
77
  end