appsignal 2.5.3 → 2.6.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +10 -1
- data/.rubocop_todo.yml +1 -1
- data/.travis.yml +8 -1
- data/CHANGELOG.md +12 -0
- data/appsignal.gemspec +2 -2
- data/benchmark.rake +6 -0
- data/ext/agent.yml +35 -35
- data/ext/appsignal_extension.c +27 -9
- data/lib/appsignal.rb +15 -19
- data/lib/appsignal/auth_check.rb +2 -0
- data/lib/appsignal/capistrano.rb +2 -0
- data/lib/appsignal/cli.rb +2 -0
- data/lib/appsignal/cli/demo.rb +2 -0
- data/lib/appsignal/cli/diagnose.rb +2 -0
- data/lib/appsignal/cli/helpers.rb +2 -0
- data/lib/appsignal/cli/install.rb +15 -1
- data/lib/appsignal/cli/notify_of_deploy.rb +8 -0
- data/lib/appsignal/config.rb +44 -5
- data/lib/appsignal/demo.rb +2 -0
- data/lib/appsignal/event_formatter.rb +2 -0
- data/lib/appsignal/event_formatter/action_view/render_formatter.rb +2 -0
- data/lib/appsignal/event_formatter/active_record/instantiation_formatter.rb +2 -0
- data/lib/appsignal/event_formatter/active_record/sql_formatter.rb +2 -0
- data/lib/appsignal/event_formatter/elastic_search/search_formatter.rb +2 -0
- data/lib/appsignal/event_formatter/faraday/request_formatter.rb +2 -0
- data/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter.rb +2 -0
- data/lib/appsignal/event_formatter/moped/query_formatter.rb +2 -0
- data/lib/appsignal/extension.rb +2 -0
- data/lib/appsignal/extension/jruby.rb +15 -13
- data/lib/appsignal/garbage_collection_profiler.rb +2 -0
- data/lib/appsignal/hooks.rb +2 -0
- data/lib/appsignal/hooks/action_cable.rb +2 -0
- data/lib/appsignal/hooks/active_support_notifications.rb +2 -0
- data/lib/appsignal/hooks/celluloid.rb +2 -0
- data/lib/appsignal/hooks/data_mapper.rb +2 -0
- data/lib/appsignal/hooks/delayed_job.rb +2 -0
- data/lib/appsignal/hooks/mongo_ruby_driver.rb +2 -0
- data/lib/appsignal/hooks/net_http.rb +2 -0
- data/lib/appsignal/hooks/passenger.rb +2 -0
- data/lib/appsignal/hooks/puma.rb +2 -0
- data/lib/appsignal/hooks/que.rb +2 -0
- data/lib/appsignal/hooks/rake.rb +2 -0
- data/lib/appsignal/hooks/redis.rb +2 -0
- data/lib/appsignal/hooks/sequel.rb +2 -0
- data/lib/appsignal/hooks/shoryuken.rb +6 -2
- data/lib/appsignal/hooks/sidekiq.rb +4 -2
- data/lib/appsignal/hooks/unicorn.rb +2 -0
- data/lib/appsignal/hooks/webmachine.rb +2 -0
- data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +2 -0
- data/lib/appsignal/integrations/data_mapper.rb +2 -0
- data/lib/appsignal/integrations/delayed_job_plugin.rb +6 -2
- data/lib/appsignal/integrations/grape.rb +2 -0
- data/lib/appsignal/integrations/mongo_ruby_driver.rb +2 -0
- data/lib/appsignal/integrations/object.rb +2 -0
- data/lib/appsignal/integrations/padrino.rb +3 -4
- data/lib/appsignal/integrations/que.rb +2 -0
- data/lib/appsignal/integrations/railtie.rb +2 -0
- data/lib/appsignal/integrations/rake.rb +2 -0
- data/lib/appsignal/integrations/resque.rb +2 -0
- data/lib/appsignal/integrations/resque_active_job.rb +6 -2
- data/lib/appsignal/integrations/sinatra.rb +2 -0
- data/lib/appsignal/integrations/webmachine.rb +2 -0
- data/lib/appsignal/js_exception_transaction.rb +2 -0
- data/lib/appsignal/marker.rb +2 -0
- data/lib/appsignal/minutely.rb +2 -0
- data/lib/appsignal/rack/generic_instrumentation.rb +2 -0
- data/lib/appsignal/rack/js_exception_catcher.rb +2 -0
- data/lib/appsignal/rack/rails_instrumentation.rb +2 -0
- data/lib/appsignal/rack/sinatra_instrumentation.rb +2 -0
- data/lib/appsignal/rack/streaming_listener.rb +2 -0
- data/lib/appsignal/system.rb +2 -0
- data/lib/appsignal/transaction.rb +13 -10
- data/lib/appsignal/transmitter.rb +2 -0
- data/lib/appsignal/utils.rb +3 -1
- data/lib/appsignal/utils/{params_sanitizer.rb → hash_sanitizer.rb} +12 -11
- data/lib/appsignal/utils/query_params_sanitizer.rb +2 -0
- data/lib/appsignal/version.rb +3 -1
- data/lib/sequel/extensions/appsignal_integration.rb +2 -0
- data/resources/appsignal.yml.erb +5 -0
- data/spec/lib/appsignal/auth_check_spec.rb +11 -2
- data/spec/lib/appsignal/cli/install_spec.rb +33 -0
- data/spec/lib/appsignal/config_spec.rb +76 -18
- data/spec/lib/appsignal/extension_spec.rb +3 -3
- data/spec/lib/appsignal/integrations/padrino_spec.rb +8 -28
- data/spec/lib/appsignal/transaction_spec.rb +63 -30
- data/spec/lib/appsignal/utils/{params_sanitizer_spec.rb → hash_sanitizer_spec.rb} +6 -6
- data/spec/lib/appsignal_spec.rb +180 -158
- data/spec/support/helpers/std_streams_helper.rb +19 -12
- data/spec/support/project_fixture/config/appsignal.yml +21 -0
- metadata +11 -11
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Appsignal
|
2
4
|
class CLI
|
3
5
|
# Command line tool to send a "Deploy Marker" for an application to
|
@@ -44,6 +46,12 @@ module Appsignal
|
|
44
46
|
# @example help command
|
45
47
|
# appsignal notify_of_deploy --help
|
46
48
|
#
|
49
|
+
# @deprecated This method of sending AppSignal deploy markers is
|
50
|
+
# deprecated. Use the [`revision` config option]
|
51
|
+
# (https://docs.appsignal.com/ruby/configuration/options.html#app_revision-revision)
|
52
|
+
# instead. For more information, please read the [deploy markers]
|
53
|
+
# (https://docs.appsignal.com/application/markers/deploy-markers.html)
|
54
|
+
# documentation.
|
47
55
|
# @since 0.2.5
|
48
56
|
# @see Appsignal::Marker Appsignal::Marker
|
49
57
|
# @see http://docs.appsignal.com/ruby/command-line/notify_of_deploy.html
|
data/lib/appsignal/config.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "erb"
|
2
4
|
require "yaml"
|
3
5
|
require "uri"
|
@@ -13,6 +15,7 @@ module Appsignal
|
|
13
15
|
:ignore_errors => [],
|
14
16
|
:ignore_namespaces => [],
|
15
17
|
:filter_parameters => [],
|
18
|
+
:filter_session_data => [],
|
16
19
|
:send_params => true,
|
17
20
|
:endpoint => "https://push.appsignal.com",
|
18
21
|
:instrument_net_http => true,
|
@@ -25,7 +28,6 @@ module Appsignal
|
|
25
28
|
:enable_gc_instrumentation => false,
|
26
29
|
:enable_host_metrics => true,
|
27
30
|
:enable_minutely_probes => false,
|
28
|
-
:hostname => ::Socket.gethostname,
|
29
31
|
:ca_file_path => File.expand_path(File.join("../../../resources/cacert.pem"), __FILE__),
|
30
32
|
:dns_servers => [],
|
31
33
|
:files_world_accessible => true
|
@@ -49,6 +51,7 @@ module Appsignal
|
|
49
51
|
"APPSIGNAL_IGNORE_ERRORS" => :ignore_errors,
|
50
52
|
"APPSIGNAL_IGNORE_NAMESPACES" => :ignore_namespaces,
|
51
53
|
"APPSIGNAL_FILTER_PARAMETERS" => :filter_parameters,
|
54
|
+
"APPSIGNAL_FILTER_SESSION_DATA" => :filter_session_data,
|
52
55
|
"APPSIGNAL_SEND_PARAMS" => :send_params,
|
53
56
|
"APPSIGNAL_HTTP_PROXY" => :http_proxy,
|
54
57
|
"APPSIGNAL_ENABLE_ALLOCATION_TRACKING" => :enable_allocation_tracking,
|
@@ -60,8 +63,18 @@ module Appsignal
|
|
60
63
|
"APPSIGNAL_HOSTNAME" => :hostname,
|
61
64
|
"APPSIGNAL_CA_FILE_PATH" => :ca_file_path,
|
62
65
|
"APPSIGNAL_DNS_SERVERS" => :dns_servers,
|
63
|
-
"APPSIGNAL_FILES_WORLD_ACCESSIBLE" => :files_world_accessible
|
66
|
+
"APPSIGNAL_FILES_WORLD_ACCESSIBLE" => :files_world_accessible,
|
67
|
+
"APPSIGNAL_REQUEST_HEADERS" => :request_headers,
|
68
|
+
"APP_REVISION" => :revision
|
64
69
|
}.freeze
|
70
|
+
# Formatted in two-dimensional array for easy printing
|
71
|
+
SUGGESTED_REQUEST_HEADERS = [
|
72
|
+
%w[HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING],
|
73
|
+
%w[HTTP_ACCEPT_LANGUAGE HTTP_CACHE_CONTROL HTTP_CONNECTION],
|
74
|
+
%w[CONTENT_LENGTH PATH_INFO HTTP_RANGE],
|
75
|
+
%w[REQUEST_METHOD REQUEST_URI SERVER_NAME SERVER_PORT],
|
76
|
+
%w[SERVER_PROTOCOL]
|
77
|
+
].freeze
|
65
78
|
|
66
79
|
# Mapping of old and deprecated AppSignal configuration keys
|
67
80
|
DEPRECATED_CONFIG_KEY_MAPPING = {
|
@@ -153,7 +166,6 @@ module Appsignal
|
|
153
166
|
ENV["_APPSIGNAL_IGNORE_ACTIONS"] = config_hash[:ignore_actions].join(",")
|
154
167
|
ENV["_APPSIGNAL_IGNORE_ERRORS"] = config_hash[:ignore_errors].join(",")
|
155
168
|
ENV["_APPSIGNAL_IGNORE_NAMESPACES"] = config_hash[:ignore_namespaces].join(",")
|
156
|
-
ENV["_APPSIGNAL_FILTER_PARAMETERS"] = config_hash[:filter_parameters].join(",")
|
157
169
|
ENV["_APPSIGNAL_SEND_PARAMS"] = config_hash[:send_params].to_s
|
158
170
|
ENV["_APPSIGNAL_RUNNING_IN_CONTAINER"] = config_hash[:running_in_container].to_s
|
159
171
|
ENV["_APPSIGNAL_WORKING_DIR_PATH"] = config_hash[:working_dir_path] if config_hash[:working_dir_path]
|
@@ -164,6 +176,7 @@ module Appsignal
|
|
164
176
|
ENV["_APPSIGNAL_CA_FILE_PATH"] = config_hash[:ca_file_path].to_s
|
165
177
|
ENV["_APPSIGNAL_DNS_SERVERS"] = config_hash[:dns_servers].join(",")
|
166
178
|
ENV["_APPSIGNAL_FILES_WORLD_ACCESSIBLE"] = config_hash[:files_world_accessible].to_s
|
179
|
+
ENV["_APP_REVISION"] = config_hash[:revision].to_s
|
167
180
|
end
|
168
181
|
|
169
182
|
def validate
|
@@ -184,10 +197,35 @@ module Appsignal
|
|
184
197
|
@valid = false
|
185
198
|
@logger.error "Push api key not set after loading config"
|
186
199
|
end
|
200
|
+
|
201
|
+
check_if_request_headers_option_is_set
|
187
202
|
end
|
188
203
|
|
189
204
|
private
|
190
205
|
|
206
|
+
def check_if_request_headers_option_is_set
|
207
|
+
return unless valid?
|
208
|
+
return if config_hash.key?(:request_headers) || env == "test"
|
209
|
+
|
210
|
+
multi_line_request_headers = SUGGESTED_REQUEST_HEADERS.map do |row|
|
211
|
+
row.map(&:inspect).join(", ")
|
212
|
+
end.join(",\n ")
|
213
|
+
single_line_request_headers = SUGGESTED_REQUEST_HEADERS.flatten.join(",")
|
214
|
+
|
215
|
+
puts "Warning: The `request_headers` config option was not set " \
|
216
|
+
" in the AppSignal configuration, falling back to the default list. " \
|
217
|
+
"Please explicitly list response headers to send to AppSignal in " \
|
218
|
+
"config/appsignal.yml:\n\n" \
|
219
|
+
" request_headers: [\n" \
|
220
|
+
" #{multi_line_request_headers}\n" \
|
221
|
+
"]\n\n" \
|
222
|
+
"Or set the APPSIGNAL_REQUEST_HEADERS environment variable:\n\n"\
|
223
|
+
" $ export APPSIGNAL_REQUEST_HEADERS=" \
|
224
|
+
"\"#{single_line_request_headers}\"\n\n" \
|
225
|
+
"Please check https://github.com/appsignal/appsignal-ruby/pull/406 " \
|
226
|
+
"for more information on this change."
|
227
|
+
end
|
228
|
+
|
191
229
|
def config_file
|
192
230
|
@config_file ||=
|
193
231
|
root_path.nil? ? nil : File.join(root_path, "config", "appsignal.yml")
|
@@ -244,7 +282,7 @@ module Appsignal
|
|
244
282
|
%w[APPSIGNAL_PUSH_API_KEY APPSIGNAL_APP_NAME APPSIGNAL_PUSH_API_ENDPOINT
|
245
283
|
APPSIGNAL_FRONTEND_ERROR_CATCHING_PATH APPSIGNAL_HTTP_PROXY
|
246
284
|
APPSIGNAL_LOG APPSIGNAL_LOG_PATH APPSIGNAL_WORKING_DIR_PATH
|
247
|
-
APPSIGNAL_HOSTNAME APPSIGNAL_CA_FILE_PATH].each do |var|
|
285
|
+
APPSIGNAL_HOSTNAME APPSIGNAL_CA_FILE_PATH APP_REVISION].each do |var|
|
248
286
|
env_var = ENV[var]
|
249
287
|
next unless env_var
|
250
288
|
config[ENV_TO_KEY_MAPPING[var]] = env_var
|
@@ -265,7 +303,8 @@ module Appsignal
|
|
265
303
|
|
266
304
|
# Configuration with array of strings type
|
267
305
|
%w[APPSIGNAL_IGNORE_ACTIONS APPSIGNAL_IGNORE_ERRORS
|
268
|
-
APPSIGNAL_IGNORE_NAMESPACES APPSIGNAL_FILTER_PARAMETERS
|
306
|
+
APPSIGNAL_IGNORE_NAMESPACES APPSIGNAL_FILTER_PARAMETERS
|
307
|
+
APPSIGNAL_FILTER_SESSION_DATA APPSIGNAL_REQUEST_HEADERS].each do |var|
|
269
308
|
env_var = ENV[var]
|
270
309
|
next unless env_var
|
271
310
|
config[ENV_TO_KEY_MAPPING[var]] = env_var.split(",")
|
data/lib/appsignal/demo.rb
CHANGED
data/lib/appsignal/extension.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "ffi"
|
2
4
|
|
3
5
|
module Appsignal
|
@@ -61,7 +63,7 @@ module Appsignal
|
|
61
63
|
|
62
64
|
# Metrics methods
|
63
65
|
attach_function :appsignal_set_gauge,
|
64
|
-
[:appsignal_string, :double],
|
66
|
+
[:appsignal_string, :double, :pointer],
|
65
67
|
:void
|
66
68
|
attach_function :appsignal_set_host_gauge,
|
67
69
|
[:appsignal_string, :double],
|
@@ -70,10 +72,10 @@ module Appsignal
|
|
70
72
|
[:appsignal_string, :double],
|
71
73
|
:void
|
72
74
|
attach_function :appsignal_increment_counter,
|
73
|
-
[:appsignal_string, :int64],
|
75
|
+
[:appsignal_string, :int64, :pointer],
|
74
76
|
:void
|
75
77
|
attach_function :appsignal_add_distribution_value,
|
76
|
-
[:appsignal_string, :double],
|
78
|
+
[:appsignal_string, :double, :pointer],
|
77
79
|
:void
|
78
80
|
|
79
81
|
# Transaction methods
|
@@ -222,8 +224,8 @@ module Appsignal
|
|
222
224
|
appsignal_running_in_container
|
223
225
|
end
|
224
226
|
|
225
|
-
def set_gauge(key, value)
|
226
|
-
appsignal_set_gauge(make_appsignal_string(key), value)
|
227
|
+
def set_gauge(key, value, tags)
|
228
|
+
appsignal_set_gauge(make_appsignal_string(key), value, tags.pointer)
|
227
229
|
end
|
228
230
|
|
229
231
|
def set_host_gauge(key, value)
|
@@ -234,12 +236,12 @@ module Appsignal
|
|
234
236
|
appsignal_set_process_gauge(make_appsignal_string(key), value)
|
235
237
|
end
|
236
238
|
|
237
|
-
def increment_counter(key, value)
|
238
|
-
appsignal_increment_counter(make_appsignal_string(key), value)
|
239
|
+
def increment_counter(key, value, tags)
|
240
|
+
appsignal_increment_counter(make_appsignal_string(key), value, tags.pointer)
|
239
241
|
end
|
240
242
|
|
241
|
-
def add_distribution_value(key, value)
|
242
|
-
appsignal_add_distribution_value(make_appsignal_string(key), value)
|
243
|
+
def add_distribution_value(key, value, tags)
|
244
|
+
appsignal_add_distribution_value(make_appsignal_string(key), value, tags.pointer)
|
243
245
|
end
|
244
246
|
|
245
247
|
class Transaction # rubocop:disable Metrics/ClassLength
|
@@ -314,14 +316,14 @@ module Appsignal
|
|
314
316
|
)
|
315
317
|
end
|
316
318
|
|
317
|
-
def set_action(action_name) # rubocop:disable
|
319
|
+
def set_action(action_name) # rubocop:disable Naming/AccessorMethodName
|
318
320
|
Extension.appsignal_set_transaction_action(
|
319
321
|
pointer,
|
320
322
|
make_appsignal_string(action_name)
|
321
323
|
)
|
322
324
|
end
|
323
325
|
|
324
|
-
def set_namespace(namespace) # rubocop:disable
|
326
|
+
def set_namespace(namespace) # rubocop:disable Naming/AccessorMethodName
|
325
327
|
Extension.appsignal_set_transaction_namespace(
|
326
328
|
pointer,
|
327
329
|
make_appsignal_string(namespace)
|
@@ -336,7 +338,7 @@ module Appsignal
|
|
336
338
|
)
|
337
339
|
end
|
338
340
|
|
339
|
-
def set_queue_start(time) # rubocop:disable
|
341
|
+
def set_queue_start(time) # rubocop:disable Naming/AccessorMethodName
|
340
342
|
Extension.appsignal_set_transaction_queue_start(pointer, time)
|
341
343
|
end
|
342
344
|
|
@@ -405,7 +407,7 @@ module Appsignal
|
|
405
407
|
)
|
406
408
|
end
|
407
409
|
|
408
|
-
def set_nil(key) # rubocop:disable
|
410
|
+
def set_nil(key) # rubocop:disable Naming/AccessorMethodName
|
409
411
|
Extension.appsignal_data_map_set_null(
|
410
412
|
pointer,
|
411
413
|
make_appsignal_string(key)
|
data/lib/appsignal/hooks.rb
CHANGED
data/lib/appsignal/hooks/puma.rb
CHANGED
data/lib/appsignal/hooks/que.rb
CHANGED
data/lib/appsignal/hooks/rake.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Appsignal
|
2
4
|
class Hooks
|
3
5
|
# @api private
|
@@ -11,8 +13,10 @@ module Appsignal
|
|
11
13
|
}
|
12
14
|
|
13
15
|
args = body.is_a?(Hash) ? body : { :params => body }
|
14
|
-
options[:params] = Appsignal::Utils::
|
15
|
-
|
16
|
+
options[:params] = Appsignal::Utils::HashSanitizer.sanitize(
|
17
|
+
args,
|
18
|
+
Appsignal.config[:filter_parameters]
|
19
|
+
)
|
16
20
|
|
17
21
|
if sqs_msg.attributes.key?("SentTimestamp")
|
18
22
|
options[:queue_start] = Time.at(sqs_msg.attributes["SentTimestamp"].to_i / 1000)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "yaml"
|
2
4
|
|
3
5
|
module Appsignal
|
@@ -69,9 +71,9 @@ module Appsignal
|
|
69
71
|
end
|
70
72
|
|
71
73
|
def filtered_arguments(job)
|
72
|
-
Appsignal::Utils::
|
74
|
+
Appsignal::Utils::HashSanitizer.sanitize(
|
73
75
|
parse_arguments(job),
|
74
|
-
|
76
|
+
Appsignal.config[:filter_parameters]
|
75
77
|
)
|
76
78
|
end
|
77
79
|
|