appsignal 3.5.3 → 3.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.semaphore/semaphore.yml +180 -14
  3. data/CHANGELOG.md +36 -0
  4. data/README.md +2 -0
  5. data/Rakefile +3 -1
  6. data/build_matrix.yml +7 -13
  7. data/ext/Rakefile +8 -1
  8. data/ext/agent.rb +27 -27
  9. data/ext/appsignal_extension.c +0 -24
  10. data/ext/base.rb +4 -1
  11. data/gemfiles/redis-4.gemfile +5 -0
  12. data/gemfiles/redis-5.gemfile +6 -0
  13. data/lib/appsignal/cli/diagnose/paths.rb +25 -6
  14. data/lib/appsignal/cli/diagnose.rb +1 -1
  15. data/lib/appsignal/config.rb +9 -4
  16. data/lib/appsignal/environment.rb +24 -13
  17. data/lib/appsignal/event_formatter.rb +1 -1
  18. data/lib/appsignal/extension/jruby.rb +4 -17
  19. data/lib/appsignal/extension.rb +1 -1
  20. data/lib/appsignal/helpers/instrumentation.rb +7 -7
  21. data/lib/appsignal/helpers/metrics.rb +15 -13
  22. data/lib/appsignal/hooks/redis.rb +1 -0
  23. data/lib/appsignal/hooks/redis_client.rb +27 -0
  24. data/lib/appsignal/hooks.rb +3 -2
  25. data/lib/appsignal/integrations/hanami.rb +1 -1
  26. data/lib/appsignal/integrations/padrino.rb +1 -1
  27. data/lib/appsignal/integrations/railtie.rb +1 -1
  28. data/lib/appsignal/integrations/redis_client.rb +20 -0
  29. data/lib/appsignal/integrations/sidekiq.rb +1 -1
  30. data/lib/appsignal/integrations/sinatra.rb +1 -1
  31. data/lib/appsignal/minutely.rb +4 -4
  32. data/lib/appsignal/probes/gvl.rb +1 -1
  33. data/lib/appsignal/probes/helpers.rb +1 -1
  34. data/lib/appsignal/probes/mri.rb +1 -1
  35. data/lib/appsignal/probes/sidekiq.rb +5 -5
  36. data/lib/appsignal/rack/generic_instrumentation.rb +1 -1
  37. data/lib/appsignal/rack/rails_instrumentation.rb +2 -2
  38. data/lib/appsignal/rack/sinatra_instrumentation.rb +2 -2
  39. data/lib/appsignal/rack/streaming_listener.rb +1 -1
  40. data/lib/appsignal/span.rb +2 -2
  41. data/lib/appsignal/transaction.rb +11 -11
  42. data/lib/appsignal/utils/deprecation_message.rb +2 -2
  43. data/lib/appsignal/version.rb +1 -1
  44. data/lib/appsignal.rb +37 -31
  45. data/spec/lib/appsignal/cli/diagnose_spec.rb +17 -12
  46. data/spec/lib/appsignal/config_spec.rb +2 -2
  47. data/spec/lib/appsignal/hooks/activejob_spec.rb +1 -1
  48. data/spec/lib/appsignal/hooks/redis_client_spec.rb +222 -0
  49. data/spec/lib/appsignal/hooks/redis_spec.rb +98 -76
  50. data/spec/lib/appsignal/hooks_spec.rb +4 -4
  51. data/spec/lib/appsignal/integrations/railtie_spec.rb +2 -2
  52. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +3 -3
  53. data/spec/lib/appsignal/integrations/sinatra_spec.rb +2 -2
  54. data/spec/lib/appsignal/minutely_spec.rb +2 -2
  55. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +1 -1
  56. data/spec/lib/appsignal/transaction_spec.rb +4 -4
  57. data/spec/lib/appsignal_spec.rb +62 -60
  58. data/spec/spec_helper.rb +1 -1
  59. data/spec/support/helpers/config_helpers.rb +6 -2
  60. data/spec/support/helpers/dependency_helper.rb +9 -1
  61. data/spec/support/helpers/log_helpers.rb +2 -2
  62. metadata +7 -2
@@ -759,28 +759,6 @@ static VALUE set_gauge(VALUE self, VALUE key, VALUE value, VALUE tags) {
759
759
  return Qnil;
760
760
  }
761
761
 
762
- static VALUE set_host_gauge(VALUE self, VALUE key, VALUE value) {
763
- Check_Type(key, T_STRING);
764
- Check_Type(value, T_FLOAT);
765
-
766
- appsignal_set_host_gauge(
767
- make_appsignal_string(key),
768
- NUM2DBL(value)
769
- );
770
- return Qnil;
771
- }
772
-
773
- static VALUE set_process_gauge(VALUE self, VALUE key, VALUE value) {
774
- Check_Type(key, T_STRING);
775
- Check_Type(value, T_FLOAT);
776
-
777
- appsignal_set_process_gauge(
778
- make_appsignal_string(key),
779
- NUM2DBL(value)
780
- );
781
- return Qnil;
782
- }
783
-
784
762
  static VALUE increment_counter(VALUE self, VALUE key, VALUE count, VALUE tags) {
785
763
  appsignal_data_t* tags_data;
786
764
 
@@ -941,8 +919,6 @@ void Init_appsignal_extension(void) {
941
919
 
942
920
  // Metrics
943
921
  rb_define_singleton_method(Extension, "set_gauge", set_gauge, 3);
944
- rb_define_singleton_method(Extension, "set_host_gauge", set_host_gauge, 2);
945
- rb_define_singleton_method(Extension, "set_process_gauge", set_process_gauge, 2);
946
922
  rb_define_singleton_method(Extension, "increment_counter", increment_counter, 3);
947
923
  rb_define_singleton_method(Extension, "add_distribution_value", add_distribution_value, 3);
948
924
  }
data/ext/base.rb CHANGED
@@ -26,13 +26,16 @@ def report
26
26
  @report ||=
27
27
  begin
28
28
  rbconfig = RbConfig::CONFIG
29
+ patchlevel = rbconfig["PATCHLEVEL"]
30
+ patchlevel_label = "-p#{patchlevel}" if patchlevel
31
+ ruby_version = "#{RUBY_VERSION}#{patchlevel_label}"
29
32
  {
30
33
  "result" => {
31
34
  "status" => "incomplete"
32
35
  },
33
36
  "language" => {
34
37
  "name" => "ruby",
35
- "version" => "#{rbconfig["RUBY_PROGRAM_VERSION"]}-p#{rbconfig["PATCHLEVEL"]}"
38
+ "version" => ruby_version
36
39
  },
37
40
  "download" => {
38
41
  "checksum" => "unverified"
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'redis', "~> 4.0"
4
+
5
+ gemspec :path => '../'
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'redis', '~> 5.0'
4
+ gem 'hiredis-client'
5
+
6
+ gemspec :path => '../'
@@ -19,7 +19,6 @@ module Appsignal
19
19
  begin
20
20
  config = Appsignal.config
21
21
  log_file_path = config.log_file_path
22
- makefile_log_path = File.join("ext", "mkmf.log")
23
22
  {
24
23
  :package_install_path => {
25
24
  :label => "AppSignal gem path",
@@ -37,9 +36,9 @@ module Appsignal
37
36
  :label => "Log directory",
38
37
  :path => log_file_path ? File.dirname(log_file_path) : ""
39
38
  },
40
- makefile_log_path => {
39
+ "ext/mkmf.log" => {
41
40
  :label => "Makefile install log",
42
- :path => File.join(gem_path, makefile_log_path)
41
+ :path => makefile_install_log_path
43
42
  },
44
43
  "appsignal.log" => {
45
44
  :label => "AppSignal log",
@@ -54,8 +53,11 @@ module Appsignal
54
53
  def path_stat(path)
55
54
  {
56
55
  :path => path,
57
- :exists => File.exist?(path)
56
+ :exists => false
58
57
  }.tap do |info|
58
+ next unless info[:path]
59
+
60
+ info[:exists] = File.exist?(path)
59
61
  next unless info[:exists]
60
62
 
61
63
  stat = File.stat(path)
@@ -84,9 +86,26 @@ module Appsignal
84
86
  end
85
87
 
86
88
  # Returns the AppSignal gem installation path. The root directory of
87
- # this gem.
89
+ # this gem when installed.
88
90
  def gem_path
89
- File.expand_path("../../../..", __dir__)
91
+ gemspec.full_gem_path
92
+ end
93
+
94
+ # Returns the AppSignal gem's Makefile log path, if it exists.
95
+ def makefile_install_log_path
96
+ possible_locations = [
97
+ # Installed gem location
98
+ File.join(gemspec.extension_dir, "mkmf.log"),
99
+ # Local development location
100
+ File.join(gem_path, "ext", "mkmf.log")
101
+ ]
102
+ possible_locations.find do |location|
103
+ File.exist?(location)
104
+ end || possible_locations.first
105
+ end
106
+
107
+ def gemspec
108
+ Gem.loaded_specs["appsignal"]
90
109
  end
91
110
  end
92
111
  end
@@ -201,7 +201,7 @@ module Appsignal
201
201
  )
202
202
  Appsignal.config.write_to_environment
203
203
  Appsignal.start_logger
204
- Appsignal.logger.info("Starting AppSignal diagnose")
204
+ Appsignal.internal_logger.info("Starting AppSignal diagnose")
205
205
  end
206
206
 
207
207
  def run_agent_diagnose_mode
@@ -219,8 +219,8 @@ module Appsignal
219
219
  # use. This will be overwritten by the file config and environment
220
220
  # variables config.
221
221
  # @param logger [Logger] The logger to use for the AppSignal gem. This is
222
- # used by the configuration class only. Default: {Appsignal.logger}. See
223
- # also {Appsignal.start_logger}.
222
+ # used by the configuration class only. Default:
223
+ # {Appsignal.internal_logger}. See also {Appsignal.start_logger}.
224
224
  # @param config_file [String] Custom config file location. Default
225
225
  # `config/appsignal.yml`.
226
226
  #
@@ -230,8 +230,13 @@ module Appsignal
230
230
  # Configuration load order
231
231
  # @see https://docs.appsignal.com/ruby/instrumentation/integrating-appsignal.html
232
232
  # How to integrate AppSignal manually
233
- def initialize(root_path, env, initial_config = {}, logger = Appsignal.logger,
234
- config_file = nil)
233
+ def initialize(
234
+ root_path,
235
+ env,
236
+ initial_config = {},
237
+ logger = Appsignal.internal_logger,
238
+ config_file = nil
239
+ )
235
240
  @config_file_error = false
236
241
  @root_path = root_path
237
242
  @config_file = config_file
@@ -10,9 +10,9 @@ module Appsignal
10
10
  #
11
11
  # The value of the environment metadata is given as a block that captures
12
12
  # errors that might be raised while fetching the value. It will not
13
- # re-raise errors, but instead log them using the {Appsignal.logger}. This
14
- # ensures AppSignal will not cause an error in the application when
15
- # collecting this metadata.
13
+ # re-raise errors, but instead log them using the
14
+ # {Appsignal.internal_logger}. This ensures AppSignal will not cause an
15
+ # error in the application when collecting this metadata.
16
16
  #
17
17
  # @example Reporting a key and value
18
18
  # Appsignal::Environment.report("ruby_version") { RUBY_VERSION }
@@ -34,8 +34,8 @@ module Appsignal
34
34
  when String
35
35
  key
36
36
  else
37
- Appsignal.logger.error "Unable to report on environment metadata: " \
38
- "Unsupported value type for #{key.inspect}"
37
+ Appsignal.internal_logger.error "Unable to report on environment " \
38
+ "metadata: Unsupported value type for #{key.inspect}"
39
39
  return
40
40
  end
41
41
 
@@ -43,7 +43,7 @@ module Appsignal
43
43
  begin
44
44
  yield
45
45
  rescue => e
46
- Appsignal.logger.error \
46
+ Appsignal.internal_logger.error \
47
47
  "Unable to report on environment metadata #{key.inspect}:\n" \
48
48
  "#{e.class}: #{e}"
49
49
  return
@@ -56,26 +56,35 @@ module Appsignal
56
56
  when String
57
57
  yielded_value
58
58
  else
59
- Appsignal.logger.error "Unable to report on environment metadata " \
60
- "#{key.inspect}: Unsupported value type for " \
59
+ Appsignal.internal_logger.error "Unable to report on environment " \
60
+ "metadata #{key.inspect}: Unsupported value type for " \
61
61
  "#{yielded_value.inspect}"
62
62
  return
63
63
  end
64
64
 
65
65
  Appsignal::Extension.set_environment_metadata(key, value)
66
66
  rescue => e
67
- Appsignal.logger.error "Unable to report on environment metadata:\n" \
68
- "#{e.class}: #{e}"
67
+ Appsignal.internal_logger.error "Unable to report on environment " \
68
+ "metadata:\n#{e.class}: #{e}"
69
69
  end
70
70
 
71
71
  # @see report_supported_gems
72
72
  SUPPORTED_GEMS = %w[
73
73
  actioncable
74
+ actionmailer
74
75
  activejob
76
+ activerecord
75
77
  capistrano
76
78
  celluloid
77
79
  data_mapper
78
80
  delayed_job
81
+ dry-monitor
82
+ elasticsearch
83
+ excon
84
+ faraday
85
+ gvltools
86
+ hanami
87
+ hiredis
79
88
  mongo_ruby_driver
80
89
  padrino
81
90
  passenger
@@ -85,7 +94,9 @@ module Appsignal
85
94
  rails
86
95
  rake
87
96
  redis
97
+ redis-client
88
98
  resque
99
+ rom
89
100
  sequel
90
101
  shoryuken
91
102
  sidekiq
@@ -114,15 +125,15 @@ module Appsignal
114
125
  report("ruby_#{gem_name}_version") { gem_spec.version.to_s }
115
126
  end
116
127
  rescue => e
117
- Appsignal.logger.error "Unable to report supported gems:\n" \
128
+ Appsignal.internal_logger.error "Unable to report supported gems:\n" \
118
129
  "#{e.class}: #{e}"
119
130
  end
120
131
 
121
132
  def self.report_enabled(feature)
122
133
  Appsignal::Environment.report("ruby_#{feature}_enabled") { true }
123
134
  rescue => e
124
- Appsignal.logger.error "Unable to report integration enabled:\n" \
125
- "#{e.class}: #{e}"
135
+ Appsignal.internal_logger.error "Unable to report integration " \
136
+ "enabled:\n#{e.class}: #{e}"
126
137
  end
127
138
  end
128
139
  end
@@ -73,7 +73,7 @@ module Appsignal
73
73
  end
74
74
 
75
75
  def logger
76
- Appsignal.logger
76
+ Appsignal.internal_logger
77
77
  end
78
78
  end
79
79
 
@@ -71,12 +71,6 @@ module Appsignal
71
71
  attach_function :appsignal_set_gauge,
72
72
  [:appsignal_string, :double, :pointer],
73
73
  :void
74
- attach_function :appsignal_set_host_gauge,
75
- [:appsignal_string, :double],
76
- :void
77
- attach_function :appsignal_set_process_gauge,
78
- [:appsignal_string, :double],
79
- :void
80
74
  attach_function :appsignal_increment_counter,
81
75
  [:appsignal_string, :double, :pointer],
82
76
  :void
@@ -248,14 +242,15 @@ module Appsignal
248
242
  [:pointer],
249
243
  :appsignal_string
250
244
 
251
- Appsignal.extension_loaded = true
245
+ Appsignal.extension_loaded = true if Appsignal.respond_to? :extension_loaded=
252
246
  rescue LoadError => error
253
247
  error_message = "ERROR: AppSignal failed to load extension. " \
254
248
  "Please run `appsignal diagnose` and email us at support@appsignal.com\n" \
255
249
  "#{error.class}: #{error.message}"
256
- Appsignal.logger.error(error_message)
250
+ Appsignal.internal_logger.error(error_message) if Appsignal.respond_to? :internal_logger
257
251
  Kernel.warn error_message
258
- Appsignal.extension_loaded = false
252
+ Appsignal.extension_loaded = false if Appsignal.respond_to? :extension_loaded=
253
+ raise error if ENV["_APPSIGNAL_EXTENSION_INSTALL"] == "true"
259
254
  end
260
255
 
261
256
  def start
@@ -319,14 +314,6 @@ module Appsignal
319
314
  appsignal_set_gauge(make_appsignal_string(key), value, tags.pointer)
320
315
  end
321
316
 
322
- def set_host_gauge(key, value)
323
- appsignal_set_host_gauge(make_appsignal_string(key), value)
324
- end
325
-
326
- def set_process_gauge(key, value)
327
- appsignal_set_process_gauge(make_appsignal_string(key), value)
328
- end
329
-
330
317
  def increment_counter(key, value, tags)
331
318
  appsignal_increment_counter(make_appsignal_string(key), value, tags.pointer)
332
319
  end
@@ -12,7 +12,7 @@ rescue LoadError => error
12
12
  error_message = "ERROR: AppSignal failed to load extension. " \
13
13
  "Please run `appsignal diagnose` and email us at support@appsignal.com\n" \
14
14
  "#{error.class}: #{error.message}"
15
- Appsignal.logger.error(error_message)
15
+ Appsignal.internal_logger.error(error_message)
16
16
  Kernel.warn error_message
17
17
  Appsignal.extension_loaded = false
18
18
  end
@@ -68,9 +68,9 @@ module Appsignal
68
68
  namespace = Appsignal::Transaction::HTTP_REQUEST
69
69
  request = ::Rack::Request.new(env)
70
70
  else
71
- logger.error "Unrecognized name '#{name}': names must start with " \
72
- "either 'perform_job' (for jobs and tasks) or 'process_action' " \
73
- "(for HTTP requests)"
71
+ internal_logger.error "Unrecognized name '#{name}': names must " \
72
+ "start with either 'perform_job' (for jobs and tasks) or " \
73
+ "'process_action' (for HTTP requests)"
74
74
  return yield
75
75
  end
76
76
 
@@ -228,8 +228,8 @@ module Appsignal
228
228
  return unless active?
229
229
 
230
230
  unless error.is_a?(Exception)
231
- logger.error "Appsignal.send_error: Cannot send error. The given " \
232
- "value is not an exception: #{error.inspect}"
231
+ internal_logger.error "Appsignal.send_error: Cannot send error. " \
232
+ "The given value is not an exception: #{error.inspect}"
233
233
  return
234
234
  end
235
235
  transaction = Appsignal::Transaction.new(
@@ -319,8 +319,8 @@ module Appsignal
319
319
  "Appsignal.set_error called on location: #{call_location}"
320
320
  end
321
321
  unless exception.is_a?(Exception)
322
- logger.error "Appsignal.set_error: Cannot set error. The given " \
323
- "value is not an exception: #{exception.inspect}"
322
+ internal_logger.error "Appsignal.set_error: Cannot set error. " \
323
+ "The given value is not an exception: #{exception.inspect}"
324
324
  return
325
325
  end
326
326
  return if !active? || !Appsignal::Transaction.current?
@@ -10,22 +10,24 @@ module Appsignal
10
10
  Appsignal::Utils::Data.generate(tags)
11
11
  )
12
12
  rescue RangeError
13
- Appsignal.logger
13
+ Appsignal.internal_logger
14
14
  .warn("Gauge value #{value} for key '#{key}' is too big")
15
15
  end
16
16
 
17
- def set_host_gauge(key, value)
18
- Appsignal::Extension.set_host_gauge(key.to_s, value.to_f)
19
- rescue RangeError
20
- Appsignal.logger
21
- .warn("Host gauge value #{value} for key '#{key}' is too big")
17
+ def set_host_gauge(_key, _value)
18
+ Appsignal::Utils::DeprecationMessage.message \
19
+ "The `set_host_gauge` method has been deprecated. " \
20
+ "Calling this method has no effect. " \
21
+ "Please remove method call in the following file to remove " \
22
+ "this message.\n#{caller.first}"
22
23
  end
23
24
 
24
- def set_process_gauge(key, value)
25
- Appsignal::Extension.set_process_gauge(key.to_s, value.to_f)
26
- rescue RangeError
27
- Appsignal.logger
28
- .warn("Process gauge value #{value} for key '#{key}' is too big")
25
+ def set_process_gauge(_key, _value)
26
+ Appsignal::Utils::DeprecationMessage.message \
27
+ "The `set_process_gauge` method has been deprecated. " \
28
+ "Calling this method has no effect. " \
29
+ "Please remove method call in the following file to remove " \
30
+ "this message.\n#{caller.first}"
29
31
  end
30
32
 
31
33
  def increment_counter(key, value = 1.0, tags = {})
@@ -35,7 +37,7 @@ module Appsignal
35
37
  Appsignal::Utils::Data.generate(tags)
36
38
  )
37
39
  rescue RangeError
38
- Appsignal.logger
40
+ Appsignal.internal_logger
39
41
  .warn("Counter value #{value} for key '#{key}' is too big")
40
42
  end
41
43
 
@@ -46,7 +48,7 @@ module Appsignal
46
48
  Appsignal::Utils::Data.generate(tags)
47
49
  )
48
50
  rescue RangeError
49
- Appsignal.logger
51
+ Appsignal.internal_logger
50
52
  .warn("Distribution value #{value} for key '#{key}' is too big")
51
53
  end
52
54
  end
@@ -8,6 +8,7 @@ module Appsignal
8
8
 
9
9
  def dependencies_present?
10
10
  defined?(::Redis) &&
11
+ !defined?(::RedisClient) &&
11
12
  Appsignal.config &&
12
13
  Appsignal.config[:instrument_redis]
13
14
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appsignal
4
+ class Hooks
5
+ # @api private
6
+ class RedisClientHook < Appsignal::Hooks::Hook
7
+ register :redis_client
8
+
9
+ def dependencies_present?
10
+ defined?(::RedisClient) &&
11
+ Appsignal.config &&
12
+ Appsignal.config[:instrument_redis]
13
+ end
14
+
15
+ def install
16
+ require "appsignal/integrations/redis_client"
17
+ ::RedisClient::RubyConnection.prepend Appsignal::Integrations::RedisClientIntegration
18
+ Appsignal::Environment.report_enabled("redis")
19
+
20
+ return unless defined?(::RedisClient::HiredisConnection)
21
+
22
+ ::RedisClient::HiredisConnection.prepend Appsignal::Integrations::RedisClientIntegration
23
+ Appsignal::Environment.report_enabled("hiredis")
24
+ end
25
+ end
26
+ end
27
+ end
@@ -32,12 +32,12 @@ module Appsignal
32
32
  return unless dependencies_present?
33
33
  return if installed?
34
34
 
35
- Appsignal.logger.debug("Installing #{name} hook")
35
+ Appsignal.internal_logger.debug("Installing #{name} hook")
36
36
  begin
37
37
  install
38
38
  @installed = true
39
39
  rescue => ex
40
- logger = Appsignal.logger
40
+ logger = Appsignal.internal_logger
41
41
  logger.error("Error while installing #{name} hook: #{ex}")
42
42
  logger.debug ex.backtrace.join("\n")
43
43
  end
@@ -103,6 +103,7 @@ require "appsignal/hooks/passenger"
103
103
  require "appsignal/hooks/puma"
104
104
  require "appsignal/hooks/rake"
105
105
  require "appsignal/hooks/redis"
106
+ require "appsignal/hooks/redis_client"
106
107
  require "appsignal/hooks/resque"
107
108
  require "appsignal/hooks/sequel"
108
109
  require "appsignal/hooks/shoryuken"
@@ -6,7 +6,7 @@ module Appsignal
6
6
  module Integrations
7
7
  module HanamiPlugin
8
8
  def self.init
9
- Appsignal.logger.debug("Loading Hanami integration")
9
+ Appsignal.internal_logger.debug("Loading Hanami integration")
10
10
 
11
11
  hanami_app_config = ::Hanami.app.config
12
12
  Appsignal.config = Appsignal::Config.new(
@@ -7,7 +7,7 @@ module Appsignal
7
7
  # @api private
8
8
  module PadrinoPlugin
9
9
  def self.init
10
- Appsignal.logger.debug("Loading Padrino (#{Padrino::VERSION}) integration")
10
+ Appsignal.internal_logger.debug("Loading Padrino (#{Padrino::VERSION}) integration")
11
11
 
12
12
  root = Padrino.mounted_root
13
13
  Appsignal.config = Appsignal::Config.new(root, Padrino.env)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Appsignal.logger.debug("Loading Rails (#{Rails.version}) integration")
3
+ Appsignal.internal_logger.debug("Loading Rails (#{Rails.version}) integration")
4
4
 
5
5
  require "appsignal/utils/rails_helper"
6
6
  require "appsignal/rack/rails_instrumentation"
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appsignal
4
+ module Integrations
5
+ module RedisClientIntegration
6
+ def write(command)
7
+ sanitized_command =
8
+ if command[0] == :eval
9
+ "#{command[1]}#{" ?" * (command.size - 3)}"
10
+ else
11
+ "#{command[0]}#{" ?" * (command.size - 1)}"
12
+ end
13
+
14
+ Appsignal.instrument "query.redis", @config.id, sanitized_command do
15
+ super
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -168,7 +168,7 @@ module Appsignal
168
168
  # Sidekiq issue #1761: in dev mode, it's possible to have jobs enqueued
169
169
  # which haven't been loaded into memory yet so the YAML can't be
170
170
  # loaded.
171
- Appsignal.logger.warn "Unable to load YAML: #{error.message}"
171
+ Appsignal.internal_logger.warn "Unable to load YAML: #{error.message}"
172
172
  default
173
173
  end
174
174
  end
@@ -3,7 +3,7 @@
3
3
  require "appsignal"
4
4
  require "appsignal/rack/sinatra_instrumentation"
5
5
 
6
- Appsignal.logger.debug("Loading Sinatra (#{Sinatra::VERSION}) integration")
6
+ Appsignal.internal_logger.debug("Loading Sinatra (#{Sinatra::VERSION}) integration")
7
7
 
8
8
  app_settings = ::Sinatra::Application.settings
9
9
  Appsignal.config = Appsignal::Config.new(
@@ -108,7 +108,7 @@ module Appsignal
108
108
  attr_reader :probes
109
109
 
110
110
  def logger
111
- Appsignal.logger
111
+ Appsignal.internal_logger
112
112
  end
113
113
  end
114
114
 
@@ -132,7 +132,7 @@ module Appsignal
132
132
  sleep initial_wait_time
133
133
  initialize_probes
134
134
  loop do
135
- logger = Appsignal.logger
135
+ logger = Appsignal.internal_logger
136
136
  logger.debug("Gathering minutely metrics with #{probe_instances.count} probes")
137
137
  probe_instances.each do |name, probe|
138
138
  logger.debug("Gathering minutely metrics with '#{name}' probe")
@@ -181,13 +181,13 @@ module Appsignal
181
181
  klass = instance.class
182
182
  end
183
183
  unless dependencies_present?(klass)
184
- Appsignal.logger.debug "Skipping '#{name}' probe, " \
184
+ Appsignal.internal_logger.debug "Skipping '#{name}' probe, " \
185
185
  "#{klass}.dependency_present? returned falsy"
186
186
  return
187
187
  end
188
188
  probe_instances[name] = instance
189
189
  rescue => error
190
- logger = Appsignal.logger
190
+ logger = Appsignal.internal_logger
191
191
  logger.error "Error while initializing minutely probe '#{name}': #{error}"
192
192
  logger.debug error.backtrace.join("\n")
193
193
  end
@@ -22,7 +22,7 @@ module Appsignal
22
22
  end
23
23
 
24
24
  def initialize(appsignal: Appsignal, gvl_tools: ::GVLTools)
25
- Appsignal.logger.debug("Initializing GVL probe")
25
+ Appsignal.internal_logger.debug("Initializing GVL probe")
26
26
  @appsignal = appsignal
27
27
  @gvl_tools = gvl_tools
28
28
  end
@@ -47,7 +47,7 @@ module Appsignal
47
47
  # Auto detect hostname as fallback. May be inaccurate.
48
48
  @hostname =
49
49
  config[:hostname] || Socket.gethostname
50
- Appsignal.logger.debug "Probe helper: Using hostname config " \
50
+ Appsignal.internal_logger.debug "Probe helper: Using hostname config " \
51
51
  "option '#{@hostname.inspect}' as hostname"
52
52
 
53
53
  @hostname
@@ -11,7 +11,7 @@ module Appsignal
11
11
  end
12
12
 
13
13
  def initialize(appsignal: Appsignal, gc_profiler: Appsignal::GarbageCollection.profiler)
14
- Appsignal.logger.debug("Initializing VM probe")
14
+ Appsignal.internal_logger.debug("Initializing VM probe")
15
15
  @appsignal = appsignal
16
16
  @gc_profiler = gc_profiler
17
17
  end
@@ -59,7 +59,7 @@ module Appsignal
59
59
  @adapter = is_sidekiq7 ? Sidekiq7Adapter : Sidekiq6Adapter
60
60
 
61
61
  config_string = " with config: #{config}" unless config.empty?
62
- Appsignal.logger.debug("Initializing Sidekiq probe#{config_string}")
62
+ Appsignal.internal_logger.debug("Initializing Sidekiq probe#{config_string}")
63
63
  require "sidekiq/api"
64
64
  end
65
65
 
@@ -123,14 +123,14 @@ module Appsignal
123
123
 
124
124
  if config.key?(:hostname)
125
125
  @hostname = config[:hostname]
126
- Appsignal.logger.debug "Sidekiq probe: Using hostname config " \
127
- "option #{@hostname.inspect} as hostname"
126
+ Appsignal.internal_logger.debug "Sidekiq probe: Using hostname " \
127
+ "config option #{@hostname.inspect} as hostname"
128
128
  return @hostname
129
129
  end
130
130
 
131
131
  host = adapter.hostname
132
- Appsignal.logger.debug "Sidekiq probe: Using Redis server hostname " \
133
- "#{host.inspect} as hostname"
132
+ Appsignal.internal_logger.debug "Sidekiq probe: Using Redis server " \
133
+ "hostname #{host.inspect} as hostname"
134
134
  @hostname = host
135
135
  end
136
136
  end