raygun-apm 1.1.14-x86_64-linux → 1.1.15.pre2-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,106 +1,106 @@
1
- module Raygun
2
- module Apm
3
- class Config
4
- LOGLEVELS = {
5
- "None" => Tracer::LOG_NONE,
6
- "Info" => Tracer::LOG_INFO,
7
- "Warning" => Tracer::LOG_WARNING,
8
- "Error" => Tracer::LOG_ERROR,
9
- "Verbose" => Tracer::LOG_VERBOSE,
10
- "Debug" => Tracer::LOG_DEBUG,
11
- "Everything" => Tracer::LOG_EVERYTHING,
12
- # ruby profiler specific
13
- "Blacklist" => Tracer::LOG_BLACKLIST
14
- }
15
-
16
- ENVIRONMENTS = {
17
- "development" => Tracer::ENV_DEVELOPMENT,
18
- "production" => Tracer::ENV_PRODUCTION
19
- }
20
-
21
- DEFAULT_BLACKLIST_PATH_UNIX = "/usr/share/Raygun/Blacklist"
22
- DEFAULT_BLACKLIST_PATH_WINDOWS = "C:\\ProgramData\\Raygun\\Blacklist"
23
-
24
- attr_accessor :env
25
- def initialize(env=ENV)
26
- @env = env
27
- end
28
-
29
- def self.cast_to_boolean(x)
30
- case x
31
- when true, 'true', 'True', 1, '1' then true
32
- else
33
- false
34
- end
35
- end
36
-
37
- def self.config_var(attr, opts={}, &blk)
38
- define_method attr.downcase do
39
- val = if x = env[attr]
40
- if opts[:as] == Integer
41
- Integer(x)
42
- elsif opts[:as] == String
43
- x.to_s
44
- elsif opts[:as] == :boolean
45
- self.class.cast_to_boolean(x)
46
- end
47
- else
48
- opts[:default]
49
- end
50
- blk ? blk.call(val) : val
51
- end
52
- end
53
-
54
- # Initial constants for ProtonAgentTail.exe
55
- UDP_SINK_HOST = TCP_SINK_HOST = TCP_MANAGEMENT_HOST = '127.0.0.1'
56
- UDP_SINK_MULTICAST_HOST = '239.100.15.215'
57
- UDP_SINK_PORT = TCP_SINK_PORT = 2799
58
- TCP_MANAGEMENT_PORT = 2790
59
-
60
- ## Enumerate all PROTON_ constants
61
- config_var 'PROTON_API_KEY', as: String, default: ''
62
- config_var 'PROTON_DEBUG_LOGLEVEL', as: String, default: 'None'
63
- config_var 'PROTON_USER_OVERRIDES_FILE', as: String
64
- config_var 'PROTON_NETWORK_MODE', as: String, default: 'Udp'
65
- config_var 'PROTON_FILE_IPC_FOLDER', as: String
66
- config_var 'PROTON_USE_MULTICAST', as: String, default: 'False'
67
- config_var 'PROTON_BATCH_IDLE_COUNTER', as: Integer, default: 500
68
- ## New - Ruby profiler
69
- config_var 'PROTON_UDP_HOST', as: String, default: UDP_SINK_HOST
70
- config_var 'PROTON_UDP_PORT', as: Integer, default: UDP_SINK_PORT
71
- config_var 'PROTON_TCP_HOST', as: String, default: TCP_SINK_HOST
72
- config_var 'PROTON_TCP_PORT', as: Integer, default: TCP_SINK_PORT
73
- ## Conditional hooks
74
- config_var 'PROTON_HOOK_REDIS', as: :boolean, default: 'True'
75
- config_var 'PROTON_HOOK_INTERNALS', as: :boolean, default: 'True'
76
-
77
- def proton_udp_host
78
- if proton_use_multicast == 'True'
79
- UDP_SINK_MULTICAST_HOST
80
- else
81
- env['PROTON_UDP_HOST'] ? env['PROTON_UDP_HOST'].to_s : UDP_SINK_HOST
82
- end
83
- end
84
-
85
- def proton_tcp_host
86
- env['PROTON_TCP_HOST'] ? env['PROTON_TCP_HOST'].to_s : TCP_SINK_HOST
87
- end
88
-
89
- def loglevel
90
- LOGLEVELS[proton_debug_loglevel] || raise(ArgumentError, "invalid log level")
91
- end
92
-
93
- def environment
94
- environment = env['RACK_ENV'] || env['RAILS_ENV'] || 'production'
95
- ENVIRONMENTS[environment] || Tracer::ENV_PRODUCTION
96
- end
97
-
98
- # Prefer what is set by PROTON_USER_OVERRIDES_FILE env
99
- def blacklist_file
100
- return proton_user_overrides_file if proton_user_overrides_file
101
- path = Gem.win_platform? ? DEFAULT_BLACKLIST_PATH_WINDOWS : DEFAULT_BLACKLIST_PATH_UNIX
102
- "#{File.join(path, proton_api_key)}.txt"
103
- end
104
- end
105
- end
106
- end
1
+ module Raygun
2
+ module Apm
3
+ class Config
4
+ LOGLEVELS = {
5
+ "None" => Tracer::LOG_NONE,
6
+ "Info" => Tracer::LOG_INFO,
7
+ "Warning" => Tracer::LOG_WARNING,
8
+ "Error" => Tracer::LOG_ERROR,
9
+ "Verbose" => Tracer::LOG_VERBOSE,
10
+ "Debug" => Tracer::LOG_DEBUG,
11
+ "Everything" => Tracer::LOG_EVERYTHING,
12
+ # ruby profiler specific
13
+ "Blacklist" => Tracer::LOG_BLACKLIST
14
+ }
15
+
16
+ ENVIRONMENTS = {
17
+ "development" => Tracer::ENV_DEVELOPMENT,
18
+ "production" => Tracer::ENV_PRODUCTION
19
+ }
20
+
21
+ DEFAULT_BLACKLIST_PATH_UNIX = "/usr/share/Raygun/Blacklist"
22
+ DEFAULT_BLACKLIST_PATH_WINDOWS = "C:\\ProgramData\\Raygun\\Blacklist"
23
+
24
+ attr_accessor :env
25
+ def initialize(env=ENV)
26
+ @env = env
27
+ end
28
+
29
+ def self.cast_to_boolean(x)
30
+ case x
31
+ when true, 'true', 'True', 1, '1' then true
32
+ else
33
+ false
34
+ end
35
+ end
36
+
37
+ def self.config_var(attr, opts={}, &blk)
38
+ define_method attr.downcase do
39
+ val = if x = env[attr]
40
+ if opts[:as] == Integer
41
+ Integer(x)
42
+ elsif opts[:as] == String
43
+ x.to_s
44
+ elsif opts[:as] == :boolean
45
+ self.class.cast_to_boolean(x)
46
+ end
47
+ else
48
+ opts[:default]
49
+ end
50
+ blk ? blk.call(val) : val
51
+ end
52
+ end
53
+
54
+ # Initial constants for ProtonAgentTail.exe
55
+ UDP_SINK_HOST = TCP_SINK_HOST = TCP_MANAGEMENT_HOST = '127.0.0.1'
56
+ UDP_SINK_MULTICAST_HOST = '239.100.15.215'
57
+ UDP_SINK_PORT = TCP_SINK_PORT = 2799
58
+ TCP_MANAGEMENT_PORT = 2790
59
+
60
+ ## Enumerate all PROTON_ constants
61
+ config_var 'PROTON_API_KEY', as: String, default: ''
62
+ config_var 'PROTON_DEBUG_LOGLEVEL', as: String, default: 'None'
63
+ config_var 'PROTON_USER_OVERRIDES_FILE', as: String
64
+ config_var 'PROTON_NETWORK_MODE', as: String, default: 'Udp'
65
+ config_var 'PROTON_FILE_IPC_FOLDER', as: String
66
+ config_var 'PROTON_USE_MULTICAST', as: String, default: 'False'
67
+ config_var 'PROTON_BATCH_IDLE_COUNTER', as: Integer, default: 500
68
+ ## New - Ruby profiler
69
+ config_var 'PROTON_UDP_HOST', as: String, default: UDP_SINK_HOST
70
+ config_var 'PROTON_UDP_PORT', as: Integer, default: UDP_SINK_PORT
71
+ config_var 'PROTON_TCP_HOST', as: String, default: TCP_SINK_HOST
72
+ config_var 'PROTON_TCP_PORT', as: Integer, default: TCP_SINK_PORT
73
+ ## Conditional hooks
74
+ config_var 'PROTON_HOOK_REDIS', as: :boolean, default: 'True'
75
+ config_var 'PROTON_HOOK_INTERNALS', as: :boolean, default: 'True'
76
+
77
+ def proton_udp_host
78
+ if proton_use_multicast == 'True'
79
+ UDP_SINK_MULTICAST_HOST
80
+ else
81
+ env['PROTON_UDP_HOST'] ? env['PROTON_UDP_HOST'].to_s : UDP_SINK_HOST
82
+ end
83
+ end
84
+
85
+ def proton_tcp_host
86
+ env['PROTON_TCP_HOST'] ? env['PROTON_TCP_HOST'].to_s : TCP_SINK_HOST
87
+ end
88
+
89
+ def loglevel
90
+ LOGLEVELS[proton_debug_loglevel] || raise(ArgumentError, "invalid log level")
91
+ end
92
+
93
+ def environment
94
+ environment = env['RACK_ENV'] || env['RAILS_ENV'] || 'production'
95
+ ENVIRONMENTS[environment] || Tracer::ENV_PRODUCTION
96
+ end
97
+
98
+ # Prefer what is set by PROTON_USER_OVERRIDES_FILE env
99
+ def blacklist_file
100
+ return proton_user_overrides_file if proton_user_overrides_file
101
+ path = Gem.win_platform? ? DEFAULT_BLACKLIST_PATH_WINDOWS : DEFAULT_BLACKLIST_PATH_UNIX
102
+ "#{File.join(path, proton_api_key)}.txt"
103
+ end
104
+ end
105
+ end
106
+ end
@@ -1,54 +1,54 @@
1
- require "socket"
2
- require "json"
3
-
4
- module Raygun
5
- module Apm
6
- class Diagnostics
7
- AGENT_STATE_DOWN = "\nThe Raygun APM Agent appears to not be running on the current host.\nIf not already installed, please consult https://raygun.com/documentation/product-guides/apm/agent/downloads/\nOtherwise refer to https://raygun.com/documentation/product-guides/apm/agent/installation/ for starting the Agent."
8
- AGENT_STATE_UNKNOWN = "\nThe Raygun APM Agent is reachable, but Unable to determine the state of the Agent at the moment."
9
- AGENT_STATE_UP_MISCONFIGURED = "\nThe Raygun APM Agent is running, but misconfigured.\nThe API Key needs to be set through the Raygun_ApiKey environment variable.\nThe API key can be found under 'Application Settings' in the Raygun UI"
10
- AGENT_STATE_UP_CONFIGURED = "\nThe Raygun APM Agent is configured properly!"
11
- AGENT_MINIMUM_VERSION_NOT_MET = "\nVersion #{Raygun::Apm::VERSION} of the Raygun APM Profiler requires a minimum Agent version #{Raygun::Apm::MINIMUM_AGENT_VERSION}\nPlease download the latest Agent from https://raygun.com/documentation/product-guides/apm/agent/downloads/"
12
- PROFILER_NOOPED = "Profiler loaded in noop mode and will be disabled due to the minimum Agent version not met"
13
-
14
- def initialize(host: Apm::Config::TCP_MANAGEMENT_HOST, port: Apm::Config::TCP_MANAGEMENT_PORT)
15
- @host = host
16
- @port = port
17
- end
18
-
19
- def verify_agent(tracer)
20
- socket.write "GetAgentInfo"
21
- response = JSON.parse(socket.gets)
22
- if minimum_agent_version_not_met?(response['Version'])
23
- puts AGENT_MINIMUM_VERSION_NOT_MET
24
- tracer.noop!
25
- puts PROFILER_NOOPED
26
- else
27
- if response['Status'] == 1
28
- puts AGENT_STATE_UP_CONFIGURED
29
- elsif response['Status'] == 0
30
- puts AGENT_STATE_UP_MISCONFIGURED
31
- end
32
- end
33
- rescue Errno::ECONNREFUSED
34
- puts AGENT_STATE_DOWN
35
- rescue
36
- puts AGENT_STATE_UNKNOWN
37
- end
38
-
39
- private
40
- def socket
41
- @socket ||= s = TCPSocket.new(@host, @port)
42
- end
43
-
44
- def minimum_agent_version_not_met?(version)
45
- # Legacy path
46
- if String === version
47
- version < Raygun::Apm::MINIMUM_AGENT_VERSION
48
- else
49
- "#{version['Major']}.#{version['Minor']}.#{version['Build']}.#{version['Revision']}" < Raygun::Apm::MINIMUM_AGENT_VERSION
50
- end
51
- end
52
- end
53
- end
54
- end
1
+ require "socket"
2
+ require "json"
3
+
4
+ module Raygun
5
+ module Apm
6
+ class Diagnostics
7
+ AGENT_STATE_DOWN = "\nThe Raygun APM Agent appears to not be running on the current host.\nIf not already installed, please consult https://raygun.com/documentation/product-guides/apm/agent/downloads/\nOtherwise refer to https://raygun.com/documentation/product-guides/apm/agent/installation/ for starting the Agent."
8
+ AGENT_STATE_UNKNOWN = "\nThe Raygun APM Agent is reachable, but Unable to determine the state of the Agent at the moment."
9
+ AGENT_STATE_UP_MISCONFIGURED = "\nThe Raygun APM Agent is running, but misconfigured.\nThe API Key needs to be set through the Raygun_ApiKey environment variable.\nThe API key can be found under 'Application Settings' in the Raygun UI"
10
+ AGENT_STATE_UP_CONFIGURED = "\nThe Raygun APM Agent is configured properly!"
11
+ AGENT_MINIMUM_VERSION_NOT_MET = "\nVersion #{Raygun::Apm::VERSION} of the Raygun APM Profiler requires a minimum Agent version #{Raygun::Apm::MINIMUM_AGENT_VERSION}\nPlease download the latest Agent from https://raygun.com/documentation/product-guides/apm/agent/downloads/"
12
+ PROFILER_NOOPED = "Profiler loaded in noop mode and will be disabled due to the minimum Agent version not met"
13
+
14
+ def initialize(host: Apm::Config::TCP_MANAGEMENT_HOST, port: Apm::Config::TCP_MANAGEMENT_PORT)
15
+ @host = host
16
+ @port = port
17
+ end
18
+
19
+ def verify_agent(tracer)
20
+ socket.write "GetAgentInfo"
21
+ response = JSON.parse(socket.gets)
22
+ if minimum_agent_version_not_met?(response['Version'])
23
+ puts AGENT_MINIMUM_VERSION_NOT_MET
24
+ tracer.noop!
25
+ puts PROFILER_NOOPED
26
+ else
27
+ if response['Status'] == 1
28
+ puts AGENT_STATE_UP_CONFIGURED
29
+ elsif response['Status'] == 0
30
+ puts AGENT_STATE_UP_MISCONFIGURED
31
+ end
32
+ end
33
+ rescue Errno::ECONNREFUSED
34
+ puts AGENT_STATE_DOWN
35
+ rescue
36
+ puts AGENT_STATE_UNKNOWN
37
+ end
38
+
39
+ private
40
+ def socket
41
+ @socket ||= s = TCPSocket.new(@host, @port)
42
+ end
43
+
44
+ def minimum_agent_version_not_met?(version)
45
+ # Legacy path
46
+ if String === version
47
+ version < Raygun::Apm::MINIMUM_AGENT_VERSION
48
+ else
49
+ "#{version['Major']}.#{version['Minor']}.#{version['Build']}.#{version['Revision']}" < Raygun::Apm::MINIMUM_AGENT_VERSION
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -1,49 +1,49 @@
1
- module Raygun
2
- module Apm
3
- class Event
4
- def inspect
5
- "#<#{self.class.name}:#{self.object_id}> length:#{self.length} pid:#{self[:pid]} tid:#{self[:tid]} timestamp:#{self[:timestamp]}"
6
- end
7
- class ExceptionThrown < Event
8
- def inspect
9
- super + " class:#{self[:class_name]}"
10
- end
11
- end
12
- class ThreadStarted < Event
13
- def inspect
14
- super + " parent_tid:#{self[:parent_tid]}"
15
- end
16
- end
17
- class Begin < Event
18
- def inspect
19
- super + " function_id:#{self[:function_id]} instance_id:#{self[:instance_id]}"
20
- end
21
- end
22
- class End < Event
23
- def inspect
24
- super + " function_id:#{self[:function_id]}"
25
- end
26
- end
27
- class Methodinfo < Event
28
- def inspect
29
- super + " function_id:#{self[:function_id]} class_name:#{self[:class_name]} method_name:#{self[:method_name]} method_source:#{self[:method_source]}"
30
- end
31
- end
32
- class HttpOut < Event
33
- def inspect
34
- super + " url:#{self[:url]} verb:#{self[:verb]} status:#{self[:status]} duration:#{self[:duration]}"
35
- end
36
- end
37
- class Sql < Event
38
- def inspect
39
- super + " provider:#{self[:provider]} host:#{self[:host]} query:#{self[:query]} database:#{self[:database]} duration:#{self[:duration]}"
40
- end
41
- end
42
- class BeginTransaction < Event
43
- def inspect
44
- super + " api_key:#{self[:api_key]} technology_type:#{self[:technology_type]} process_type:#{self[:process_type]}"
45
- end
46
- end
47
- end
48
- end
1
+ module Raygun
2
+ module Apm
3
+ class Event
4
+ def inspect
5
+ "#<#{self.class.name}:#{self.object_id}> length:#{self.length} pid:#{self[:pid]} tid:#{self[:tid]} timestamp:#{self[:timestamp]}"
6
+ end
7
+ class ExceptionThrown < Event
8
+ def inspect
9
+ super + " class:#{self[:class_name]}"
10
+ end
11
+ end
12
+ class ThreadStarted < Event
13
+ def inspect
14
+ super + " parent_tid:#{self[:parent_tid]}"
15
+ end
16
+ end
17
+ class Begin < Event
18
+ def inspect
19
+ super + " function_id:#{self[:function_id]} instance_id:#{self[:instance_id]}"
20
+ end
21
+ end
22
+ class End < Event
23
+ def inspect
24
+ super + " function_id:#{self[:function_id]}"
25
+ end
26
+ end
27
+ class Methodinfo < Event
28
+ def inspect
29
+ super + " function_id:#{self[:function_id]} class_name:#{self[:class_name]} method_name:#{self[:method_name]} method_source:#{self[:method_source]}"
30
+ end
31
+ end
32
+ class HttpOut < Event
33
+ def inspect
34
+ super + " url:#{self[:url]} verb:#{self[:verb]} status:#{self[:status]} duration:#{self[:duration]}"
35
+ end
36
+ end
37
+ class Sql < Event
38
+ def inspect
39
+ super + " provider:#{self[:provider]} host:#{self[:host]} query:#{self[:query]} database:#{self[:database]} duration:#{self[:duration]}"
40
+ end
41
+ end
42
+ class BeginTransaction < Event
43
+ def inspect
44
+ super + " api_key:#{self[:api_key]} technology_type:#{self[:technology_type]} process_type:#{self[:process_type]}"
45
+ end
46
+ end
47
+ end
48
+ end
49
49
  end
@@ -1,36 +1,36 @@
1
- require 'excon'
2
-
3
- module Raygun
4
- module Apm
5
- module Hooks
6
- module Excon
7
- def request(params={}, &block)
8
- if tracer = Raygun::Apm::Tracer.instance
9
- started = tracer.now
10
- response = super
11
- ended = tracer.now
12
- event = raygun_apm_http_out_event
13
- event[:pid] = Process.pid
14
- event[:url] = "#{@data[:scheme]}://#{@data[:host]}/#{params[:path]}"
15
- event[:verb] = params[:method].to_s.upcase
16
- event[:status] = response.status
17
- event[:duration] = ended - started
18
- event[:timestamp] = started
19
- event[:tid] = tracer.get_thread_id(Thread.current)
20
- tracer.emit(event)
21
- response
22
- else
23
- super
24
- end
25
- end
26
-
27
- private
28
- def raygun_apm_http_out_event
29
- @_raygun_apm_http_out_event ||= Raygun::Apm::Event::HttpOut.new
30
- end
31
- end
32
- end
33
- end
34
- end
35
-
36
- Raygun::Apm::Tracer.patch(Excon::Connection, Raygun::Apm::Hooks::Excon)
1
+ require 'excon'
2
+
3
+ module Raygun
4
+ module Apm
5
+ module Hooks
6
+ module Excon
7
+ def request(params={}, &block)
8
+ if tracer = Raygun::Apm::Tracer.instance
9
+ started = tracer.now
10
+ response = super
11
+ ended = tracer.now
12
+ event = raygun_apm_http_out_event
13
+ event[:pid] = Process.pid
14
+ event[:url] = "#{@data[:scheme]}://#{@data[:host]}/#{params[:path]}"
15
+ event[:verb] = params[:method].to_s.upcase
16
+ event[:status] = response.status
17
+ event[:duration] = ended - started
18
+ event[:timestamp] = started
19
+ event[:tid] = tracer.get_thread_id(Thread.current)
20
+ tracer.emit(event)
21
+ response
22
+ else
23
+ super
24
+ end
25
+ end
26
+
27
+ private
28
+ def raygun_apm_http_out_event
29
+ @_raygun_apm_http_out_event ||= Raygun::Apm::Event::HttpOut.new
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ Raygun::Apm::Tracer.patch(Excon::Connection, Raygun::Apm::Hooks::Excon)
@@ -1,43 +1,43 @@
1
- require 'httpclient'
2
-
3
- module Raygun
4
- module Apm
5
- module Hooks
6
- module HTTPClient
7
- private
8
-
9
- def do_request(method, uri, query, body, header, &filtered_block)
10
- if tracer = Raygun::Apm::Tracer.instance
11
- started = tracer.now
12
- response = super
13
- ended = tracer.now
14
- event = raygun_apm_http_out_event
15
- event[:pid] = Process.pid
16
- event[:url] = raygun_apm_url(uri, query)
17
- event[:verb] = method.to_s.upcase
18
- event[:status] = response.code.to_i
19
- event[:duration] = ended - started
20
- event[:timestamp] = started
21
- event[:tid] = tracer.get_thread_id(Thread.current)
22
- tracer.emit(event)
23
- response
24
- else
25
- super
26
- end
27
- end
28
-
29
- def raygun_apm_url(uri, query)
30
- uri = uri.to_param if uri.respond_to?(:to_param)
31
- query = query.to_param if query.respond_to?(:to_param)
32
- query && uri ? URI.join(uri, query).to_s : uri.to_s
33
- end
34
-
35
- def raygun_apm_http_out_event
36
- @_raygun_apm_http_out_event ||= Raygun::Apm::Event::HttpOut.new
37
- end
38
- end
39
- end
40
- end
41
- end
42
-
43
- Raygun::Apm::Tracer.patch(HTTPClient, Raygun::Apm::Hooks::HTTPClient)
1
+ require 'httpclient'
2
+
3
+ module Raygun
4
+ module Apm
5
+ module Hooks
6
+ module HTTPClient
7
+ private
8
+
9
+ def do_request(method, uri, query, body, header, &filtered_block)
10
+ if tracer = Raygun::Apm::Tracer.instance
11
+ started = tracer.now
12
+ response = super
13
+ ended = tracer.now
14
+ event = raygun_apm_http_out_event
15
+ event[:pid] = Process.pid
16
+ event[:url] = raygun_apm_url(uri, query)
17
+ event[:verb] = method.to_s.upcase
18
+ event[:status] = response.code.to_i
19
+ event[:duration] = ended - started
20
+ event[:timestamp] = started
21
+ event[:tid] = tracer.get_thread_id(Thread.current)
22
+ tracer.emit(event)
23
+ response
24
+ else
25
+ super
26
+ end
27
+ end
28
+
29
+ def raygun_apm_url(uri, query)
30
+ uri = uri.to_param if uri.respond_to?(:to_param)
31
+ query = query.to_param if query.respond_to?(:to_param)
32
+ query && uri ? URI.join(uri, query).to_s : uri.to_s
33
+ end
34
+
35
+ def raygun_apm_http_out_event
36
+ @_raygun_apm_http_out_event ||= Raygun::Apm::Event::HttpOut.new
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ Raygun::Apm::Tracer.patch(HTTPClient, Raygun::Apm::Hooks::HTTPClient)