stackify-ruby-apm 1.6.1 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8ec4ca9ae4465f5108ab76f8759bdd94702f0b46c7a44a2c510314cff8e7f44
4
- data.tar.gz: 4b95a706746da817c8aab319fadb72392f6806e9795c23cfe4b4558bd9660b56
3
+ metadata.gz: ca22a5a75e1ae02e39bea7fa1330da6530c522cf33f3e82f4aec4aec2515ef79
4
+ data.tar.gz: 3ce816108dfed9e9abdd268b127b5795a41be911da28d16afcc0262e369847f7
5
5
  SHA512:
6
- metadata.gz: 5ba374e64587fc878524e7e47a003099e24cb444ca6fea2fdfed114339d2c64ed241b02abfbf2bd0c5f69cb87fdb50a37e456350b719d2c402b50a7d8cc874f0
7
- data.tar.gz: e58a7a2206c39b3c15c896267f64aa3c91a6775c0fee17267012724a184c41f6486d295f3f50bfa82821075f95b72c754f5986b48ab84ba8da3e1b78bf0fbc65
6
+ metadata.gz: e9a115fe042f1f9b3021af173ba229ba2bfab15c5685bf57cf851e6292089252f321966c7cf85622942ef853750961641980a38db8452b07e79a17c17a5bc79d
7
+ data.tar.gz: 2ce4459279a1661b6ef016ccc33ddf5d9b01d9e2a1eea94e732be98101699920e5ba068d226d2711ac0c754014b6c0607c4b5c441ac476aa72edf8ff39c67ea0
@@ -19,6 +19,10 @@ module StackifyRubyAPM
19
19
  environment_name: ENV['RAILS_ENV'] || ENV['RACK_ENV'],
20
20
  already_instrumented_flag: false,
21
21
  rum_auto_injection: false,
22
+ rum_enabled: false,
23
+ rum_cookie_max_age: 0,
24
+ rum_cookie_path: '/',
25
+ rum_cookie_name: '.Stackify.Rum',
22
26
  instrument: true,
23
27
  debug_logging: false,
24
28
  log_path: StackifyRubyAPM::Util.host_os == 'WINDOWS' ? 'C:\ProgramData\Stackify\Ruby\log\stackify-ruby-apm-1.log' : '/usr/local/stackify/stackify-ruby-apm/log/stackify-ruby-apm-1.log',
@@ -58,6 +62,7 @@ module StackifyRubyAPM
58
62
  'STACKIFY_APM_ENVIRONMENT_NAME' => 'environment_name',
59
63
  'STACKIFY_APM_RUM_SCRIPT_SRC' => 'rum_script_src',
60
64
  'STACKIFY_APM_RUM_AUTO_INJECTION' => 'rum_auto_injection',
65
+ 'STACKIFY_APM_RUM_ENABLED' => 'rum_enabled',
61
66
  'STACKIFY_ALREADY_INSTRUMENTED_FLAG' => 'already_instrumented_flag',
62
67
  'STACKIFY_APM_DEBUG_LOGGING' => 'debug_logging',
63
68
  'STACKIFY_APM_INSTRUMENT' => [:bool, 'instrument'],
@@ -77,13 +82,12 @@ module StackifyRubyAPM
77
82
 
78
83
  def initialize(options = {})
79
84
  set_defaults
80
-
81
85
  set_from_args(options)
82
86
  set_from_config_file
83
87
  set_from_env
84
88
 
85
89
  yield self if block_given?
86
- build_logger if ENV['STACKIFY_RUBY_ENV'] == 'rspec'
90
+ debug_logger
87
91
  StackifyRubyAPM::Util.host_os == 'WINDOWS' ? load_stackify_props_windows : load_stackify_props
88
92
  end
89
93
 
@@ -92,6 +96,10 @@ module StackifyRubyAPM
92
96
  attr_accessor :environment_name
93
97
  attr_accessor :rum_script_src
94
98
  attr_accessor :rum_auto_injection
99
+ attr_accessor :rum_enabled
100
+ attr_accessor :rum_cookie_max_age
101
+ attr_accessor :rum_cookie_path
102
+ attr_accessor :rum_cookie_name
95
103
  attr_accessor :already_instrumented_flag
96
104
  attr_accessor :rum_script_injected
97
105
  attr_accessor :instrument
@@ -203,8 +211,8 @@ module StackifyRubyAPM
203
211
  end
204
212
 
205
213
  def debug_logger
206
- debuger_logpath = log_path == '-' ? $stdout : log_path
207
- logger = StackifyLogger.new(debuger_logpath, debugger_filenum_rotate, debugger_byte_size)
214
+ debugger_logpath = log_path == '-' ? $stdout : log_path
215
+ logger = StackifyLogger.new(debugger_logpath, debugger_filenum_rotate, debugger_byte_size)
208
216
  logger.level = log_level
209
217
  self.logger = logger
210
218
  end
@@ -265,8 +273,8 @@ module StackifyRubyAPM
265
273
  # rubocop:enable Naming/AccessorMethodName
266
274
 
267
275
  def build_logger
268
- debuger_logpath = log_path == '-' ? $stdout : log_path
269
- logger = StackifyLogger.new(debuger_logpath, debugger_filenum_rotate, debugger_byte_size)
276
+ debugger_logpath = log_path == '-' ? $stdout : log_path
277
+ logger = StackifyLogger.new(debugger_logpath, debugger_filenum_rotate, debugger_byte_size)
270
278
  logger.level = log_level
271
279
  self.logger = logger
272
280
  end
@@ -50,18 +50,19 @@ module StackifyRubyAPM
50
50
 
51
51
  if okay_to_modify?
52
52
  @configuration.already_instrumented_flag = true
53
- if StackifyRubyAPM.rum_script_inject
54
- resp
53
+ if @configuration.rum_auto_injection
54
+ response_string = response_manupulate.adjust_pagehtml_response
55
+ end
56
+ if response_string
57
+ response = Rack::Response.new(response_string, @rack_status, @rack_headers)
58
+ response.set_cookie(@configuration.rum_cookie_name, value: transaction.id, path: @configuration.rum_cookie_path, max_age: @configuration.rum_cookie_max_age) if @configuration.rum_enabled
59
+ resp = response.finish
60
+ elsif @configuration.rum_enabled
61
+ response = Rack::Response.new @rack_body, @rack_status, @rack_headers
62
+ response.set_cookie(@configuration.rum_cookie_name, value: transaction.id, path: @configuration.rum_cookie_path, max_age: @configuration.rum_cookie_max_age)
63
+ resp = response.finish
55
64
  else
56
- if @configuration.rum_auto_injection
57
- response_string = response_manupulate.call_manipulate
58
- end
59
- if response_string
60
- response = Rack::Response.new(response_string, @rack_status, @rack_headers)
61
- resp = response.finish
62
- else
63
- resp
64
- end
65
+ resp
65
66
  end
66
67
  else
67
68
  resp
@@ -4,9 +4,11 @@
4
4
  # This class will manupulate the html page d: e.g., call(env)
5
5
  #
6
6
  #
7
+
7
8
  module StackifyRubyAPM
8
9
  # an abstraction for manipulating the HTML we capture in the middleware
9
10
  class ResponseManipulator
11
+ include Log
10
12
  attr_reader :rack_response, :jsfile_to_inject
11
13
  attr_reader :rack_status, :rack_headers, :rack_body, :Rack_flagger
12
14
  attr_reader :env
@@ -32,31 +34,13 @@ module StackifyRubyAPM
32
34
  @config = config
33
35
  end
34
36
 
35
- def call_manipulate
36
- if check_rumscript_variable
37
- adjust_pagehtml_response(true)
38
- else
39
- adjust_pagehtml_response
40
- end
41
- end
42
-
43
- def check_rumscript_variable
44
- response = @rack_body
45
- source = gather_source(response)
46
- close_old_response(response)
47
- return false unless source
48
-
49
- return true if source.include?(RUM_SCRIPT_VARIABLE)
50
- false
51
- end
52
-
53
37
  def rebuild_rack_response
54
38
  [rack_status, rack_headers, rack_body]
55
39
  end
56
40
 
57
41
  # rubocop:disable Metrics/CyclomaticComplexity
58
42
  # rubocop:disable Metrics/PerceivedComplexity
59
- def adjust_pagehtml_response(rum_variable_script = false)
43
+ def adjust_pagehtml_response
60
44
  response = @rack_body
61
45
  source = gather_source(response)
62
46
  close_old_response(response)
@@ -71,8 +55,10 @@ module StackifyRubyAPM
71
55
  if StackifyRubyAPM.check_isdomain(client_rundomain)
72
56
  inject_flag = true
73
57
  else
74
- info 'Error: Stackify Client RUM Domain is invalid.'
58
+ info 'RUM Injection Error: Client RUM Domain is invalid.'
75
59
  end
60
+ else
61
+ info 'RUM Injection Error: No Device ID and/or Client ID found.'
76
62
  end
77
63
 
78
64
  return unless inject_flag
@@ -96,7 +82,6 @@ module StackifyRubyAPM
96
82
  source = source[0...insertion_index] <<
97
83
  jsfile_to_inject <<
98
84
  source[insertion_index..-1]
99
- source = source.sub('[RUM_SCRIPT_VARIABLE]', '') if rum_variable_script
100
85
  end
101
86
  source
102
87
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Sets the version of the APM
4
4
  module StackifyRubyAPM
5
- VERSION = '1.6.1'.freeze
5
+ VERSION = '1.7.1'.freeze
6
6
  end
@@ -25,7 +25,7 @@ require 'stackify_apm/config'
25
25
  require 'stackify_apm/context'
26
26
  require 'stackify_apm/instrumenter'
27
27
  require 'stackify_apm/internal_error'
28
- # require 'stackify_apm/util'
28
+ require 'stackify_apm/response_manipulator'
29
29
  require 'stackify_apm/middleware'
30
30
  require 'stackify_apm/instrumenter_helper'
31
31
 
@@ -34,6 +34,7 @@ require 'stackify_apm/railtie' if defined?(::Rails::Railtie)
34
34
 
35
35
  # Start medoule for StackifyRubyAPM Agent
36
36
  module StackifyRubyAPM
37
+ include Log
37
38
  # Starts the StackifyRubyAPM Agent
38
39
  #
39
40
  # @param config [Config] An instance of Config
@@ -48,15 +49,10 @@ module StackifyRubyAPM
48
49
  device_id = config.device_id
49
50
  client_rundomain = config.client_run_domain
50
51
  transaction_id = defined?(StackifyRubyAPM.current_transaction.id) ? StackifyRubyAPM.current_transaction.id : nil
51
-
52
52
  inject_flag = false
53
53
 
54
54
  if client_id && device_id
55
- if check_isdomain(client_rundomain)
56
- inject_flag = true
57
- else
58
- info 'Error: Stackify Client RUM Domain is invalid.'
59
- end
55
+ inject_flag = true if check_isdomain(client_rundomain)
60
56
  end
61
57
 
62
58
  return unless inject_flag
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackify-ruby-apm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stackify
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-06 00:00:00.000000000 Z
11
+ date: 2019-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler