appsignal 3.9.3 → 3.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +22 -19
  3. data/.rubocop.yml +1 -1
  4. data/CHANGELOG.md +180 -0
  5. data/Gemfile +1 -0
  6. data/README.md +0 -1
  7. data/Rakefile +1 -1
  8. data/benchmark.rake +99 -42
  9. data/build_matrix.yml +10 -12
  10. data/gemfiles/webmachine1.gemfile +5 -4
  11. data/lib/appsignal/cli/demo.rb +0 -1
  12. data/lib/appsignal/config.rb +57 -97
  13. data/lib/appsignal/demo.rb +15 -20
  14. data/lib/appsignal/environment.rb +6 -1
  15. data/lib/appsignal/event_formatter/rom/sql_formatter.rb +1 -0
  16. data/lib/appsignal/event_formatter.rb +3 -2
  17. data/lib/appsignal/helpers/instrumentation.rb +490 -16
  18. data/lib/appsignal/hooks/action_cable.rb +21 -16
  19. data/lib/appsignal/hooks/active_job.rb +15 -14
  20. data/lib/appsignal/hooks/delayed_job.rb +1 -1
  21. data/lib/appsignal/hooks/shoryuken.rb +3 -63
  22. data/lib/appsignal/integrations/action_cable.rb +5 -7
  23. data/lib/appsignal/integrations/active_support_notifications.rb +1 -0
  24. data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +36 -35
  25. data/lib/appsignal/integrations/data_mapper.rb +1 -0
  26. data/lib/appsignal/integrations/delayed_job_plugin.rb +27 -33
  27. data/lib/appsignal/integrations/dry_monitor.rb +1 -0
  28. data/lib/appsignal/integrations/excon.rb +1 -0
  29. data/lib/appsignal/integrations/http.rb +1 -0
  30. data/lib/appsignal/integrations/net_http.rb +1 -0
  31. data/lib/appsignal/integrations/object.rb +6 -0
  32. data/lib/appsignal/integrations/padrino.rb +21 -25
  33. data/lib/appsignal/integrations/que.rb +13 -20
  34. data/lib/appsignal/integrations/railtie.rb +1 -1
  35. data/lib/appsignal/integrations/rake.rb +45 -15
  36. data/lib/appsignal/integrations/redis.rb +1 -0
  37. data/lib/appsignal/integrations/redis_client.rb +1 -0
  38. data/lib/appsignal/integrations/resque.rb +2 -5
  39. data/lib/appsignal/integrations/shoryuken.rb +75 -0
  40. data/lib/appsignal/integrations/sidekiq.rb +7 -25
  41. data/lib/appsignal/integrations/unicorn.rb +1 -0
  42. data/lib/appsignal/integrations/webmachine.rb +12 -9
  43. data/lib/appsignal/logger.rb +7 -3
  44. data/lib/appsignal/probes/helpers.rb +1 -0
  45. data/lib/appsignal/probes/mri.rb +1 -0
  46. data/lib/appsignal/probes/sidekiq.rb +1 -0
  47. data/lib/appsignal/probes.rb +3 -0
  48. data/lib/appsignal/rack/abstract_middleware.rb +67 -24
  49. data/lib/appsignal/rack/body_wrapper.rb +143 -0
  50. data/lib/appsignal/rack/event_handler.rb +39 -8
  51. data/lib/appsignal/rack/generic_instrumentation.rb +6 -4
  52. data/lib/appsignal/rack/grape_middleware.rb +3 -2
  53. data/lib/appsignal/rack/hanami_middleware.rb +1 -1
  54. data/lib/appsignal/rack/instrumentation_middleware.rb +62 -0
  55. data/lib/appsignal/rack/rails_instrumentation.rb +1 -3
  56. data/lib/appsignal/rack/sinatra_instrumentation.rb +1 -3
  57. data/lib/appsignal/rack/streaming_listener.rb +14 -59
  58. data/lib/appsignal/rack.rb +60 -0
  59. data/lib/appsignal/span.rb +1 -0
  60. data/lib/appsignal/transaction.rb +353 -104
  61. data/lib/appsignal/utils/data.rb +0 -1
  62. data/lib/appsignal/utils/hash_sanitizer.rb +0 -1
  63. data/lib/appsignal/utils/integration_logger.rb +0 -13
  64. data/lib/appsignal/utils/integration_memory_logger.rb +0 -13
  65. data/lib/appsignal/utils/json.rb +0 -1
  66. data/lib/appsignal/utils/query_params_sanitizer.rb +0 -1
  67. data/lib/appsignal/utils/stdout_and_logger_message.rb +0 -1
  68. data/lib/appsignal/utils.rb +6 -0
  69. data/lib/appsignal/version.rb +1 -1
  70. data/lib/appsignal.rb +9 -6
  71. data/spec/lib/appsignal/capistrano2_spec.rb +1 -1
  72. data/spec/lib/appsignal/config_spec.rb +139 -43
  73. data/spec/lib/appsignal/hooks/action_cable_spec.rb +43 -74
  74. data/spec/lib/appsignal/hooks/activejob_spec.rb +9 -0
  75. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +2 -443
  76. data/spec/lib/appsignal/hooks/rake_spec.rb +100 -17
  77. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +0 -171
  78. data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +459 -0
  79. data/spec/lib/appsignal/integrations/padrino_spec.rb +181 -131
  80. data/spec/lib/appsignal/integrations/que_spec.rb +3 -4
  81. data/spec/lib/appsignal/integrations/shoryuken_spec.rb +167 -0
  82. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +4 -4
  83. data/spec/lib/appsignal/integrations/sinatra_spec.rb +10 -2
  84. data/spec/lib/appsignal/integrations/webmachine_spec.rb +77 -17
  85. data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +144 -11
  86. data/spec/lib/appsignal/rack/body_wrapper_spec.rb +263 -0
  87. data/spec/lib/appsignal/rack/event_handler_spec.rb +81 -10
  88. data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +70 -17
  89. data/spec/lib/appsignal/rack/grape_middleware_spec.rb +1 -1
  90. data/spec/lib/appsignal/rack/instrumentation_middleware_spec.rb +38 -0
  91. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +4 -2
  92. data/spec/lib/appsignal/rack/streaming_listener_spec.rb +43 -120
  93. data/spec/lib/appsignal/rack_spec.rb +63 -0
  94. data/spec/lib/appsignal/transaction_spec.rb +1675 -953
  95. data/spec/lib/appsignal/utils/integration_logger_spec.rb +12 -16
  96. data/spec/lib/appsignal/utils/integration_memory_logger_spec.rb +0 -10
  97. data/spec/lib/appsignal_spec.rb +517 -13
  98. data/spec/support/helpers/transaction_helpers.rb +44 -20
  99. data/spec/support/matchers/transaction.rb +15 -1
  100. data/spec/support/mocks/dummy_app.rb +1 -1
  101. data/spec/support/testing.rb +1 -1
  102. metadata +12 -4
  103. data/support/check_versions +0 -22
@@ -10,6 +10,7 @@ module Appsignal
10
10
  class Config
11
11
  include Appsignal::Utils::StdoutAndLoggerMessage
12
12
 
13
+ # @api private
13
14
  DEFAULT_CONFIG = {
14
15
  :activejob_report_errors => "all",
15
16
  :ca_file_path => File.expand_path(File.join("../../../resources/cacert.pem"), __FILE__),
@@ -23,6 +24,7 @@ module Appsignal
23
24
  :enable_gvl_global_timer => true,
24
25
  :enable_gvl_waiting_threads => true,
25
26
  :enable_rails_error_reporter => true,
27
+ :enable_rake_performance_instrumentation => false,
26
28
  :endpoint => "https://push.appsignal.com",
27
29
  :files_world_accessible => true,
28
30
  :filter_metadata => [],
@@ -66,15 +68,31 @@ module Appsignal
66
68
  "trace" => ::Logger::DEBUG
67
69
  }.freeze
68
70
 
69
- ENV_TO_KEY_MAPPING = {
70
- "APPSIGNAL_ACTIVE" => :active,
71
+ # @api private
72
+ ENV_STRING_KEYS = {
71
73
  "APPSIGNAL_ACTIVEJOB_REPORT_ERRORS" => :activejob_report_errors,
72
74
  "APPSIGNAL_APP_NAME" => :name,
73
75
  "APPSIGNAL_BIND_ADDRESS" => :bind_address,
74
76
  "APPSIGNAL_CA_FILE_PATH" => :ca_file_path,
75
- "APPSIGNAL_CPU_COUNT" => :cpu_count,
77
+ "APPSIGNAL_HOSTNAME" => :hostname,
78
+ "APPSIGNAL_HOST_ROLE" => :host_role,
79
+ "APPSIGNAL_HTTP_PROXY" => :http_proxy,
80
+ "APPSIGNAL_LOG" => :log,
81
+ "APPSIGNAL_LOG_LEVEL" => :log_level,
82
+ "APPSIGNAL_LOG_PATH" => :log_path,
83
+ "APPSIGNAL_LOGGING_ENDPOINT" => :logging_endpoint,
84
+ "APPSIGNAL_PUSH_API_ENDPOINT" => :endpoint,
85
+ "APPSIGNAL_PUSH_API_KEY" => :push_api_key,
86
+ "APPSIGNAL_SIDEKIQ_REPORT_ERRORS" => :sidekiq_report_errors,
87
+ "APPSIGNAL_STATSD_PORT" => :statsd_port,
88
+ "APPSIGNAL_WORKING_DIRECTORY_PATH" => :working_directory_path,
89
+ "APPSIGNAL_WORKING_DIR_PATH" => :working_dir_path,
90
+ "APP_REVISION" => :revision
91
+ }.freeze
92
+ # @api private
93
+ ENV_BOOLEAN_KEYS = {
94
+ "APPSIGNAL_ACTIVE" => :active,
76
95
  "APPSIGNAL_DEBUG" => :debug,
77
- "APPSIGNAL_DNS_SERVERS" => :dns_servers,
78
96
  "APPSIGNAL_ENABLE_ALLOCATION_TRACKING" => :enable_allocation_tracking,
79
97
  "APPSIGNAL_ENABLE_HOST_METRICS" => :enable_host_metrics,
80
98
  "APPSIGNAL_ENABLE_MINUTELY_PROBES" => :enable_minutely_probes,
@@ -83,100 +101,36 @@ module Appsignal
83
101
  "APPSIGNAL_ENABLE_GVL_GLOBAL_TIMER" => :enable_gvl_global_timer,
84
102
  "APPSIGNAL_ENABLE_GVL_WAITING_THREADS" => :enable_gvl_waiting_threads,
85
103
  "APPSIGNAL_ENABLE_RAILS_ERROR_REPORTER" => :enable_rails_error_reporter,
104
+ "APPSIGNAL_ENABLE_RAKE_PERFORMANCE_INSTRUMENTATION" =>
105
+ :enable_rake_performance_instrumentation,
86
106
  "APPSIGNAL_FILES_WORLD_ACCESSIBLE" => :files_world_accessible,
87
- "APPSIGNAL_FILTER_METADATA" => :filter_metadata,
88
- "APPSIGNAL_FILTER_PARAMETERS" => :filter_parameters,
89
- "APPSIGNAL_FILTER_SESSION_DATA" => :filter_session_data,
90
- "APPSIGNAL_HOSTNAME" => :hostname,
91
- "APPSIGNAL_HOST_ROLE" => :host_role,
92
- "APPSIGNAL_HTTP_PROXY" => :http_proxy,
93
- "APPSIGNAL_IGNORE_ACTIONS" => :ignore_actions,
94
- "APPSIGNAL_IGNORE_ERRORS" => :ignore_errors,
95
- "APPSIGNAL_IGNORE_LOGS" => :ignore_logs,
96
- "APPSIGNAL_IGNORE_NAMESPACES" => :ignore_namespaces,
97
107
  "APPSIGNAL_INSTRUMENT_HTTP_RB" => :instrument_http_rb,
98
108
  "APPSIGNAL_INSTRUMENT_NET_HTTP" => :instrument_net_http,
99
109
  "APPSIGNAL_INSTRUMENT_REDIS" => :instrument_redis,
100
110
  "APPSIGNAL_INSTRUMENT_SEQUEL" => :instrument_sequel,
101
- "APPSIGNAL_LOG" => :log,
102
- "APPSIGNAL_LOG_LEVEL" => :log_level,
103
- "APPSIGNAL_LOG_PATH" => :log_path,
104
- "APPSIGNAL_LOGGING_ENDPOINT" => :logging_endpoint,
105
- "APPSIGNAL_PUSH_API_ENDPOINT" => :endpoint,
106
- "APPSIGNAL_PUSH_API_KEY" => :push_api_key,
107
- "APPSIGNAL_REQUEST_HEADERS" => :request_headers,
108
111
  "APPSIGNAL_RUNNING_IN_CONTAINER" => :running_in_container,
109
112
  "APPSIGNAL_SEND_ENVIRONMENT_METADATA" => :send_environment_metadata,
110
113
  "APPSIGNAL_SEND_PARAMS" => :send_params,
111
114
  "APPSIGNAL_SEND_SESSION_DATA" => :send_session_data,
112
- "APPSIGNAL_SIDEKIQ_REPORT_ERRORS" => :sidekiq_report_errors,
113
115
  "APPSIGNAL_SKIP_SESSION_DATA" => :skip_session_data,
114
- "APPSIGNAL_STATSD_PORT" => :statsd_port,
115
- "APPSIGNAL_TRANSACTION_DEBUG_MODE" => :transaction_debug_mode,
116
- "APPSIGNAL_WORKING_DIRECTORY_PATH" => :working_directory_path,
117
- "APPSIGNAL_WORKING_DIR_PATH" => :working_dir_path,
118
- "APP_REVISION" => :revision
116
+ "APPSIGNAL_TRANSACTION_DEBUG_MODE" => :transaction_debug_mode
119
117
  }.freeze
120
118
  # @api private
121
- ENV_STRING_KEYS = %w[
122
- APPSIGNAL_ACTIVEJOB_REPORT_ERRORS
123
- APPSIGNAL_APP_NAME
124
- APPSIGNAL_BIND_ADDRESS
125
- APPSIGNAL_CA_FILE_PATH
126
- APPSIGNAL_HOSTNAME
127
- APPSIGNAL_HOST_ROLE
128
- APPSIGNAL_HTTP_PROXY
129
- APPSIGNAL_LOG
130
- APPSIGNAL_LOG_LEVEL
131
- APPSIGNAL_LOG_PATH
132
- APPSIGNAL_LOGGING_ENDPOINT
133
- APPSIGNAL_PUSH_API_ENDPOINT
134
- APPSIGNAL_PUSH_API_KEY
135
- APPSIGNAL_SIDEKIQ_REPORT_ERRORS
136
- APPSIGNAL_STATSD_PORT
137
- APPSIGNAL_WORKING_DIRECTORY_PATH
138
- APPSIGNAL_WORKING_DIR_PATH
139
- APP_REVISION
140
- ].freeze
141
- # @api private
142
- ENV_BOOLEAN_KEYS = %w[
143
- APPSIGNAL_ACTIVE
144
- APPSIGNAL_DEBUG
145
- APPSIGNAL_ENABLE_ALLOCATION_TRACKING
146
- APPSIGNAL_ENABLE_HOST_METRICS
147
- APPSIGNAL_ENABLE_MINUTELY_PROBES
148
- APPSIGNAL_ENABLE_STATSD
149
- APPSIGNAL_ENABLE_NGINX_METRICS
150
- APPSIGNAL_ENABLE_GVL_GLOBAL_TIMER
151
- APPSIGNAL_ENABLE_GVL_WAITING_THREADS
152
- APPSIGNAL_ENABLE_RAILS_ERROR_REPORTER
153
- APPSIGNAL_FILES_WORLD_ACCESSIBLE
154
- APPSIGNAL_INSTRUMENT_HTTP_RB
155
- APPSIGNAL_INSTRUMENT_NET_HTTP
156
- APPSIGNAL_INSTRUMENT_REDIS
157
- APPSIGNAL_INSTRUMENT_SEQUEL
158
- APPSIGNAL_RUNNING_IN_CONTAINER
159
- APPSIGNAL_SEND_ENVIRONMENT_METADATA
160
- APPSIGNAL_SEND_PARAMS
161
- APPSIGNAL_SEND_SESSION_DATA
162
- APPSIGNAL_SKIP_SESSION_DATA
163
- APPSIGNAL_TRANSACTION_DEBUG_MODE
164
- ].freeze
119
+ ENV_ARRAY_KEYS = {
120
+ "APPSIGNAL_DNS_SERVERS" => :dns_servers,
121
+ "APPSIGNAL_FILTER_METADATA" => :filter_metadata,
122
+ "APPSIGNAL_FILTER_PARAMETERS" => :filter_parameters,
123
+ "APPSIGNAL_FILTER_SESSION_DATA" => :filter_session_data,
124
+ "APPSIGNAL_IGNORE_ACTIONS" => :ignore_actions,
125
+ "APPSIGNAL_IGNORE_ERRORS" => :ignore_errors,
126
+ "APPSIGNAL_IGNORE_LOGS" => :ignore_logs,
127
+ "APPSIGNAL_IGNORE_NAMESPACES" => :ignore_namespaces,
128
+ "APPSIGNAL_REQUEST_HEADERS" => :request_headers
129
+ }.freeze
165
130
  # @api private
166
- ENV_ARRAY_KEYS = %w[
167
- APPSIGNAL_DNS_SERVERS
168
- APPSIGNAL_FILTER_METADATA
169
- APPSIGNAL_FILTER_PARAMETERS
170
- APPSIGNAL_FILTER_SESSION_DATA
171
- APPSIGNAL_IGNORE_ACTIONS
172
- APPSIGNAL_IGNORE_ERRORS
173
- APPSIGNAL_IGNORE_LOGS
174
- APPSIGNAL_IGNORE_NAMESPACES
175
- APPSIGNAL_REQUEST_HEADERS
176
- ].freeze
177
- ENV_FLOAT_KEYS = %w[
178
- APPSIGNAL_CPU_COUNT
179
- ].freeze
131
+ ENV_FLOAT_KEYS = {
132
+ "APPSIGNAL_CPU_COUNT" => :cpu_count
133
+ }.freeze
180
134
 
181
135
  # @attribute [r] system_config
182
136
  # Config detected on the system level.
@@ -207,8 +161,10 @@ module Appsignal
207
161
  # @api private
208
162
  # @return [Hash]
209
163
 
164
+ # @api private
210
165
  attr_reader :root_path, :env, :config_hash, :system_config,
211
166
  :initial_config, :file_config, :env_config, :override_config
167
+ # @api private
212
168
  attr_accessor :logger
213
169
 
214
170
  # Initialize a new configuration object for AppSignal.
@@ -312,6 +268,7 @@ module Appsignal
312
268
  config_hash[key] = value
313
269
  end
314
270
 
271
+ # @api private
315
272
  def log_level
316
273
  level = ::Logger::DEBUG if config_hash[:debug] || config_hash[:transaction_debug_mode]
317
274
  option = config_hash[:log_level]
@@ -322,6 +279,7 @@ module Appsignal
322
279
  level.nil? ? Appsignal::Config::DEFAULT_LOG_LEVEL : level
323
280
  end
324
281
 
282
+ # @api private
325
283
  def log_file_path
326
284
  return @log_file_path if defined? @log_file_path
327
285
 
@@ -356,6 +314,7 @@ module Appsignal
356
314
  @valid && config_hash[:active]
357
315
  end
358
316
 
317
+ # @api private
359
318
  def write_to_environment # rubocop:disable Metrics/AbcSize
360
319
  ENV["_APPSIGNAL_ACTIVE"] = active?.to_s
361
320
  ENV["_APPSIGNAL_AGENT_PATH"] = File.expand_path("../../ext", __dir__).to_s
@@ -401,6 +360,7 @@ module Appsignal
401
360
  ENV["_APP_REVISION"] = config_hash[:revision].to_s
402
361
  end
403
362
 
363
+ # @api private
404
364
  def validate
405
365
  # Strip path from endpoint so we're backwards compatible with
406
366
  # earlier versions of the gem.
@@ -499,35 +459,35 @@ module Appsignal
499
459
  config = {}
500
460
 
501
461
  # Configuration with string type
502
- ENV_STRING_KEYS.each do |var|
503
- env_var = ENV.fetch(var, nil)
462
+ ENV_STRING_KEYS.each do |env_key, option|
463
+ env_var = ENV.fetch(env_key, nil)
504
464
  next unless env_var
505
465
 
506
- config[ENV_TO_KEY_MAPPING[var]] = env_var
466
+ config[option] = env_var
507
467
  end
508
468
 
509
469
  # Configuration with boolean type
510
- ENV_BOOLEAN_KEYS.each do |var|
511
- env_var = ENV.fetch(var, nil)
470
+ ENV_BOOLEAN_KEYS.each do |env_key, option|
471
+ env_var = ENV.fetch(env_key, nil)
512
472
  next unless env_var
513
473
 
514
- config[ENV_TO_KEY_MAPPING[var]] = env_var.casecmp("true").zero?
474
+ config[option] = env_var.casecmp("true").zero?
515
475
  end
516
476
 
517
477
  # Configuration with array of strings type
518
- ENV_ARRAY_KEYS.each do |var|
519
- env_var = ENV.fetch(var, nil)
478
+ ENV_ARRAY_KEYS.each do |env_key, option|
479
+ env_var = ENV.fetch(env_key, nil)
520
480
  next unless env_var
521
481
 
522
- config[ENV_TO_KEY_MAPPING[var]] = env_var.split(",")
482
+ config[option] = env_var.split(",")
523
483
  end
524
484
 
525
485
  # Configuration with float type
526
- ENV_FLOAT_KEYS.each do |var|
527
- env_var = ENV.fetch(var, nil)
486
+ ENV_FLOAT_KEYS.each do |env_key, option|
487
+ env_var = ENV.fetch(env_key, nil)
528
488
  next unless env_var
529
489
 
530
- config[ENV_TO_KEY_MAPPING[var]] = env_var.to_f
490
+ config[option] = env_var.to_f
531
491
  end
532
492
 
533
493
  config
@@ -39,18 +39,15 @@ module Appsignal
39
39
  private
40
40
 
41
41
  def create_example_error_request
42
- transaction = Appsignal::Transaction.create(
43
- SecureRandom.uuid,
44
- Appsignal::Transaction::HTTP_REQUEST,
45
- rack_request
46
- )
42
+ transaction = Appsignal::Transaction.create(Appsignal::Transaction::HTTP_REQUEST)
47
43
  begin
48
44
  raise TestError,
49
45
  "Hello world! This is an error used for demonstration purposes."
50
46
  rescue => error
51
47
  Appsignal.set_error(error)
52
48
  end
53
- transaction.set_http_or_background_queue_start
49
+ add_params_to(transaction)
50
+ add_headers_to(transaction)
54
51
  transaction.set_metadata("path", "/hello")
55
52
  transaction.set_metadata("method", "GET")
56
53
  transaction.set_action("DemoController#hello")
@@ -59,16 +56,13 @@ module Appsignal
59
56
  end
60
57
 
61
58
  def create_example_performance_request
62
- transaction = Appsignal::Transaction.create(
63
- SecureRandom.uuid,
64
- Appsignal::Transaction::HTTP_REQUEST,
65
- rack_request
66
- )
59
+ transaction = Appsignal::Transaction.create(Appsignal::Transaction::HTTP_REQUEST)
67
60
  Appsignal.instrument "action_view.render", "Render hello.html.erb",
68
61
  "<h1>Hello world!</h1>" do
69
62
  sleep 2
70
63
  end
71
- transaction.set_http_or_background_queue_start
64
+ add_params_to(transaction)
65
+ add_headers_to(transaction)
72
66
  transaction.set_metadata("path", "/hello")
73
67
  transaction.set_metadata("method", "GET")
74
68
  transaction.set_action("DemoController#hello")
@@ -80,13 +74,15 @@ module Appsignal
80
74
  transaction.set_metadata("demo_sample", "true")
81
75
  end
82
76
 
83
- def rack_request
84
- env = ::Rack::MockRequest.env_for(
85
- "/demo",
86
- :params => {
87
- "controller" => "demo",
88
- "action" => "hello"
89
- },
77
+ def add_params_to(transaction)
78
+ transaction.set_params(
79
+ "controller" => "demo",
80
+ "action" => "hello"
81
+ )
82
+ end
83
+
84
+ def add_headers_to(transaction)
85
+ transaction.set_headers(
90
86
  "REMOTE_ADDR" => "127.0.0.1",
91
87
  "REQUEST_METHOD" => "GET",
92
88
  "SERVER_NAME" => "localhost",
@@ -102,7 +98,6 @@ module Appsignal
102
98
  "HTTP_USER_AGENT" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0)",
103
99
  "HTTP_REFERER" => "http://appsignal.com/accounts"
104
100
  )
105
- ::Rack::Request.new(env)
106
101
  end
107
102
  end
108
103
  end
@@ -121,7 +121,12 @@ module Appsignal
121
121
  def self.report_supported_gems
122
122
  return unless defined?(Bundler) # Do nothing if Bundler is not present
123
123
 
124
- bundle_gem_specs = ::Bundler.rubygems.all_specs
124
+ bundle_gem_specs =
125
+ if ::Bundler.rubygems.respond_to?(:installed_specs)
126
+ ::Bundler.rubygems.installed_specs
127
+ else
128
+ ::Bundler.rubygems.all_specs
129
+ end
125
130
  SUPPORTED_GEMS.each do |gem_name|
126
131
  gem_spec = bundle_gem_specs.find { |spec| spec.name == gem_name }
127
132
  next unless gem_spec
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Appsignal
4
4
  class EventFormatter
5
+ # @api private
5
6
  module Rom
6
7
  class SqlFormatter
7
8
  def format(payload)
@@ -10,14 +10,14 @@ module Appsignal
10
10
  # event, the same object will be called intermittently in a threaded environment.
11
11
  # So only keep global configuration as state and pass the payload around as an
12
12
  # argument if you need to use helper methods.
13
- #
14
- # @api private
15
13
  class EventFormatter
16
14
  class << self
15
+ # @api private
17
16
  def formatters
18
17
  @formatters ||= {}
19
18
  end
20
19
 
20
+ # @api private
21
21
  def formatter_classes
22
22
  @formatter_classes ||= {}
23
23
  end
@@ -49,6 +49,7 @@ module Appsignal
49
49
  end
50
50
  end
51
51
 
52
+ # @api private
52
53
  def format(name, payload)
53
54
  formatter = formatters[name]
54
55
  formatter&.format(payload)