appsignal 1.0.7 → 1.1.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/CHANGELOG.md +5 -21
  4. data/Rakefile +2 -0
  5. data/circle.yml +2 -1
  6. data/ext/agent.yml +7 -7
  7. data/ext/appsignal_extension.c +3 -5
  8. data/ext/extconf.rb +6 -15
  9. data/gemfiles/grape.gemfile +7 -0
  10. data/lib/appsignal/config.rb +2 -5
  11. data/lib/appsignal/event_formatter.rb +0 -2
  12. data/lib/appsignal/event_formatter/active_record/sql_formatter.rb +47 -1
  13. data/lib/appsignal/event_formatter/elastic_search/search_formatter.rb +29 -0
  14. data/lib/appsignal/event_formatter/moped/query_formatter.rb +7 -6
  15. data/lib/appsignal/hooks.rb +33 -0
  16. data/lib/appsignal/hooks/net_http.rb +1 -1
  17. data/lib/appsignal/hooks/sequel.rb +7 -4
  18. data/lib/appsignal/hooks/sidekiq.rb +10 -19
  19. data/lib/appsignal/integrations/capistrano/appsignal.cap +1 -1
  20. data/lib/appsignal/integrations/delayed_job_plugin.rb +20 -11
  21. data/lib/appsignal/integrations/grape.rb +44 -0
  22. data/lib/appsignal/integrations/mongo_ruby_driver.rb +5 -9
  23. data/lib/appsignal/integrations/railtie.rb +4 -0
  24. data/lib/appsignal/integrations/resque.rb +1 -1
  25. data/lib/appsignal/js_exception_transaction.rb +2 -3
  26. data/lib/appsignal/subscriber.rb +2 -3
  27. data/lib/appsignal/transaction.rb +2 -8
  28. data/lib/appsignal/transmitter.rb +1 -1
  29. data/lib/appsignal/utils.rb +7 -43
  30. data/lib/appsignal/version.rb +1 -1
  31. data/lib/tasks/diag.rake +75 -0
  32. data/spec/lib/appsignal/capistrano3_spec.rb +1 -21
  33. data/spec/lib/appsignal/config_spec.rb +0 -12
  34. data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +1 -1
  35. data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +186 -14
  36. data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +54 -0
  37. data/spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb +4 -4
  38. data/spec/lib/appsignal/extension_spec.rb +1 -1
  39. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +49 -14
  40. data/spec/lib/appsignal/hooks/sequel_spec.rb +1 -1
  41. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +29 -62
  42. data/spec/lib/appsignal/hooks_spec.rb +115 -0
  43. data/spec/lib/appsignal/integrations/grape_spec.rb +94 -0
  44. data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +5 -8
  45. data/spec/lib/appsignal/integrations/resque_spec.rb +0 -1
  46. data/spec/lib/appsignal/js_exception_transaction_spec.rb +0 -1
  47. data/spec/lib/appsignal/subscriber_spec.rb +5 -23
  48. data/spec/lib/appsignal/transaction_spec.rb +0 -21
  49. data/spec/lib/appsignal/utils_spec.rb +1 -68
  50. data/spec/spec_helper.rb +16 -0
  51. data/spec/support/helpers/env_helpers.rb +0 -1
  52. data/spec/support/stubs/delayed_job.rb +0 -0
  53. metadata +15 -11
  54. data/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter.rb +0 -88
  55. data/lib/appsignal/event_formatter/sequel/sql_formatter.rb +0 -13
  56. data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +0 -115
  57. data/spec/lib/appsignal/event_formatter/sequel/sql_formatter_spec.rb +0 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42b356ab377c00b79733935aa019790911ccf833
4
- data.tar.gz: a0cf25f397a828b9ad7ec98955e1d25f1b2369de
3
+ metadata.gz: 1b6829aaec5b482bbbce36c10e90369dc1d62c37
4
+ data.tar.gz: 4d339b3c07c604583c235f2d395812752c251073
5
5
  SHA512:
6
- metadata.gz: 0ac9406deb657285528ada31371db9ae94e8dc68e67fd5d884c26141682ceec78fbaa057a65e3f5dc6b608be8a7d1ea7417f08e3e4b411703df0be0482e58455
7
- data.tar.gz: a445c7e2e82c25abe89d2e9b12fe0783bc7a6702979c4e9293c352302c406cb6e4f4de929cdb319a8a8f95b76c44becc04779c3fa4c9b775154e088e172ad75b
6
+ metadata.gz: 8006649237b5e0e6d1c99ab039d90fe159f26c9e0dc7ff3c002f6cf778226ed6fab7eaabcb485073bf68bfdae793a5f7d5f4053248b2e8bec928045b553e699d
7
+ data.tar.gz: 6821cc4959da10f3f78bff97592cca2e9978b025e9ee4ef363b94476ce9936f7fd052f73d21c001b0b255457f05fa066011c5ff0abf556eb13478ac2b5911505
@@ -23,6 +23,7 @@ gemfile:
23
23
  - "gemfiles/resque.gemfile"
24
24
  - "gemfiles/sequel.gemfile"
25
25
  - "gemfiles/sinatra.gemfile"
26
+ - "gemfiles/grape.gemfile"
26
27
 
27
28
  matrix:
28
29
  exclude:
@@ -1,24 +1,8 @@
1
- # 1.0.7
2
- * Another multibyte bugfix in sql sanizitation
3
-
4
- # 1.0.6
5
- * Bugfix in sql sanitization when using multibyte utf-8 characters
6
-
7
- # 1.0.5
8
- * Improved sql sanitization
9
- * Improved mongoid/mongodb sanitization
10
- * Minor performance improvements
11
- * Better handling for non-utf8 convertable strings
12
- * Make gem installable (but not functional) on jRuby
13
-
14
- # 1.0.4
15
- * Make working dir configurable using `APPSIGNAL_WORKING_DIR_PATH` or `:working_dir_path`
16
-
17
- # 1.0.3
18
- * Fix bug in completing JS transactions
19
- * Make Resque integration robust for bigger payloads
20
- * Message in logs if agent logging cannot initialize
21
- * Call `to_s` on DJ id to see the id when using MongoDB
1
+ # 1.1
2
+ * Collect global metrics for GC durations
3
+ * Collect params from Delayed Job in a reliable way
4
+ * Collect perams for Delayed Job and Sidekiq when using ActiveJob
5
+ * Official Grape support
22
6
 
23
7
  # 1.0.2
24
8
  * Bug fix in format of process memory measurements
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'rspec/core/rake_task'
2
+ import 'lib/tasks/diag.rake'
2
3
 
3
4
  GEMFILES = %w(
4
5
  capistrano2
@@ -13,6 +14,7 @@ GEMFILES = %w(
13
14
  resque
14
15
  sequel
15
16
  sinatra
17
+ grape
16
18
  )
17
19
 
18
20
  RUBY_VERSIONS = %w(
data/circle.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  dependencies:
2
2
  override:
3
- - rake generate_bundle_and_spec_all
3
+ - bundle
4
+ - bundle exec rake generate_bundle_and_spec_all
4
5
 
5
6
  test:
6
7
  override:
@@ -1,15 +1,15 @@
1
1
  ---
2
- version: 8b9f469
2
+ version: 77ab5fd
3
3
  triples:
4
4
  x86_64-linux:
5
- checksum: 4477bd8083451e43e38f32bfecddacd5ae004b90ea834de201031c1f4b422fae
6
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/8b9f469/appsignal-agent-x86_64-linux-static.tar.gz
5
+ checksum: e8c9a38957a6d630b89f5588c256a160fd5be0b461a78bdca7d7d1f8b7b464ad
6
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/77ab5fd/appsignal-agent-x86_64-linux-static.tar.gz
7
7
  lib_filename: libappsignal.a
8
8
  i686-linux:
9
- checksum: a62e91f8e88d00abe028e9ed4b0c57e1e0d2c810aef9a9c830dc012b54b5e7d0
10
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/8b9f469/appsignal-agent-i686-linux-static.tar.gz
9
+ checksum: 0d1c14a89eddcf99e64dbda02863939f98b7be4d7c53aab4717fd0c08131edac
10
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/77ab5fd/appsignal-agent-i686-linux-static.tar.gz
11
11
  lib_filename: libappsignal.a
12
12
  x86_64-darwin:
13
- checksum: 8bd5b4bc3f884ae69fbe4759e01c33972f2d09b61b4008d0aae23fc68e617a9b
14
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/8b9f469/appsignal-agent-x86_64-darwin-static.tar.gz
13
+ checksum: 5f6c0056465a2c0a818d37326e1fe577618ae9dae2218d17496463dd6f176d37
14
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/77ab5fd/appsignal-agent-x86_64-darwin-static.tar.gz
15
15
  lib_filename: libappsignal.a
@@ -26,19 +26,17 @@ static VALUE start_event(VALUE self, VALUE transaction_index) {
26
26
  return Qnil;
27
27
  }
28
28
 
29
- static VALUE finish_event(VALUE self, VALUE transaction_index, VALUE name, VALUE title, VALUE body, VALUE body_format) {
29
+ static VALUE finish_event(VALUE self, VALUE transaction_index, VALUE name, VALUE title, VALUE body) {
30
30
  Check_Type(transaction_index, T_FIXNUM);
31
31
  Check_Type(name, T_STRING);
32
32
  Check_Type(title, T_STRING);
33
33
  Check_Type(body, T_STRING);
34
- Check_Type(body_format, T_FIXNUM);
35
34
 
36
35
  appsignal_finish_event(
37
36
  FIX2INT(transaction_index),
38
37
  StringValueCStr(name),
39
38
  StringValueCStr(title),
40
- StringValueCStr(body),
41
- FIX2INT(body_format)
39
+ StringValueCStr(body)
42
40
  );
43
41
  return Qnil;
44
42
  }
@@ -218,7 +216,7 @@ void Init_appsignal_extension(void) {
218
216
  rb_define_singleton_method(Extension, "stop", stop, 0);
219
217
  rb_define_singleton_method(Extension, "start_transaction", start_transaction, 2);
220
218
  rb_define_singleton_method(Extension, "start_event", start_event, 1);
221
- rb_define_singleton_method(Extension, "finish_event", finish_event, 5);
219
+ rb_define_singleton_method(Extension, "finish_event", finish_event, 4);
222
220
  rb_define_singleton_method(Extension, "set_transaction_error", set_transaction_error, 4);
223
221
  rb_define_singleton_method(Extension, "set_transaction_sample_data", set_transaction_sample_data, 3);
224
222
  rb_define_singleton_method(Extension, "set_transaction_action", set_transaction_action, 2);
@@ -1,5 +1,6 @@
1
1
  require 'digest'
2
2
  require 'logger'
3
+ require 'mkmf'
3
4
  require 'fileutils'
4
5
  require 'open-uri'
5
6
  require 'zlib'
@@ -29,13 +30,6 @@ end
29
30
  def install
30
31
  logger.info "Installing appsignal agent #{Appsignal::VERSION} for Ruby #{RUBY_VERSION} on #{RUBY_PLATFORM}"
31
32
 
32
- if RUBY_PLATFORM =~ /java/
33
- installation_failed(
34
- "We do not support jRuby at the moment, email support@appsignal.com if you want to join the beta"
35
- )
36
- return
37
- end
38
-
39
33
  unless AGENT_CONFIG['triples'].keys.include?(ARCH)
40
34
  installation_failed(
41
35
  "AppSignal currently does not support your system architecture (#{ARCH})." \
@@ -76,16 +70,13 @@ def install
76
70
  end
77
71
 
78
72
  logger.info "Creating makefile"
79
- require 'mkmf'
80
- if !find_library('appsignal', 'appsignal_start', EXT_PATH)
81
- installation_failed 'Aborting installation, libappsignal not found'
82
- elsif !find_executable('appsignal-agent', EXT_PATH)
83
- installation_failed 'Aborting installation, appsignal-agent not found'
84
- elsif !find_header('appsignal_extension.h', EXT_PATH)
85
- installation_failed 'Aborting installation, appsignal_extension.h not found'
86
- else
73
+ if find_library('appsignal', 'appsignal_start', EXT_PATH) &&
74
+ find_executable('appsignal-agent', EXT_PATH) &&
75
+ find_header('appsignal_extension.h', EXT_PATH)
87
76
  create_makefile 'appsignal_extension'
88
77
  logger.info 'Successfully installed appsignal extension'
78
+ else
79
+ installation_failed "Aborting installation, extension files were not present"
89
80
  end
90
81
  rescue => ex
91
82
  installation_failed "Exception while installing: #{ex}"
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'grape', '0.14.0'
4
+
5
+ gem 'generator_spec'
6
+
7
+ gemspec :path => '../'
@@ -42,8 +42,7 @@ module Appsignal
42
42
  'APPSIGNAL_HTTP_PROXY' => :http_proxy,
43
43
  'APPSIGNAL_ENABLE_ALLOCATION_TRACKING' => :enable_allocation_tracking,
44
44
  'APPSIGNAL_ENABLE_GC_INSTRUMENTATION' => :enable_gc_instrumentation,
45
- 'APPSIGNAL_RUNNING_IN_CONTAINER' => :running_in_container,
46
- 'APPSIGNAL_WORKING_DIR_PATH' => :working_dir_path
45
+ 'APPSIGNAL_RUNNING_IN_CONTAINER' => :running_in_container
47
46
  }.freeze
48
47
 
49
48
  attr_reader :root_path, :env, :initial_config, :config_hash
@@ -104,7 +103,6 @@ module Appsignal
104
103
  ENV['APPSIGNAL_HTTP_PROXY'] = config_hash[:http_proxy]
105
104
  ENV['APPSIGNAL_IGNORE_ACTIONS'] = config_hash[:ignore_actions].join(',')
106
105
  ENV['APPSIGNAL_RUNNING_IN_CONTAINER'] = config_hash[:running_in_container].to_s
107
- ENV['APPSIGNAL_WORKING_DIR_PATH'] = config_hash[:working_dir_path] if config_hash[:working_dir_path]
108
106
  end
109
107
 
110
108
  protected
@@ -152,8 +150,7 @@ module Appsignal
152
150
 
153
151
  # Configuration with string type
154
152
  %w(APPSIGNAL_PUSH_API_KEY APPSIGNAL_APP_NAME APPSIGNAL_PUSH_API_ENDPOINT
155
- APPSIGNAL_FRONTEND_ERROR_CATCHING_PATH APPSIGNAL_HTTP_PROXY APPSIGNAL_LOG_PATH
156
- APPSIGNAL_WORKING_DIR_PATH).each do |var|
153
+ APPSIGNAL_FRONTEND_ERROR_CATCHING_PATH APPSIGNAL_HTTP_PROXY APPSIGNAL_LOG_PATH).each do |var|
157
154
  if env_var = ENV[var]
158
155
  config[ENV_TO_KEY_MAPPING[var]] = env_var
159
156
  end
@@ -60,8 +60,6 @@ module Appsignal
60
60
  end
61
61
  end
62
62
  end
63
-
64
- SQL_BODY_FORMAT = 1
65
63
  end
66
64
 
67
65
  Dir.glob(File.expand_path('../event_formatter/**/*.rb', __FILE__)).each do |file|
@@ -4,9 +4,55 @@ module Appsignal
4
4
  class SqlFormatter < Appsignal::EventFormatter
5
5
  register 'sql.active_record'
6
6
 
7
+ SINGLE_QUOTED_STRING = /'(.?|[^']).*'/.freeze
8
+ DOUBLE_QUOTED_STRING = /"(.?|[^"]).*"/.freeze
9
+ IN_OPERATOR_CONTENT = /(IN \()[^SELECT][^\)]+(\))/.freeze
10
+ NUMERIC = /\d*\.?\d+/.freeze
11
+ REPLACEMENT = '?'.freeze
12
+ IN_REPLACEMENT = '\1?\2'.freeze
13
+ SCHEMA = 'SCHEMA'.freeze
14
+
15
+ attr_reader :adapter_uses_double_quoted_table_names
16
+
17
+ def initialize
18
+ @connection_config = connection_config
19
+ @adapter_uses_double_quoted_table_names = adapter_uses_double_quoted_table_names?
20
+ rescue ::ActiveRecord::ConnectionNotEstablished
21
+ Appsignal::EventFormatter.unregister('sql.active_record', self.class)
22
+ Appsignal.logger.error('Error while getting ActiveRecord connection info, unregistering sql.active_record event formatter')
23
+ end
24
+
7
25
  def format(payload)
8
- [payload[:name], payload[:sql], SQL_BODY_FORMAT]
26
+ return nil if schema_query?(payload) || !payload[:sql]
27
+ sql_string = payload[:sql].dup
28
+ unless adapter_uses_double_quoted_table_names
29
+ sql_string.gsub!(DOUBLE_QUOTED_STRING, REPLACEMENT)
30
+ end
31
+ sql_string.gsub!(SINGLE_QUOTED_STRING, REPLACEMENT)
32
+ sql_string.gsub!(IN_OPERATOR_CONTENT, IN_REPLACEMENT)
33
+ sql_string.gsub!(NUMERIC, REPLACEMENT)
34
+ [payload[:name], sql_string]
9
35
  end
36
+
37
+ protected
38
+
39
+ def schema_query?(payload)
40
+ payload[:name] == SCHEMA
41
+ end
42
+
43
+ def connection_config
44
+ # TODO handle ActiveRecord::ConnectionNotEstablished
45
+ if ::ActiveRecord::Base.respond_to?(:connection_config)
46
+ ::ActiveRecord::Base.connection_config
47
+ else
48
+ ::ActiveRecord::Base.connection_pool.spec.config
49
+ end
50
+ end
51
+
52
+ def adapter_uses_double_quoted_table_names?
53
+ adapter = @connection_config[:adapter]
54
+ adapter =~ /postgres/ || adapter =~ /sqlite/
55
+ end
10
56
  end
11
57
  end
12
58
  end
@@ -0,0 +1,29 @@
1
+ module Appsignal
2
+ class EventFormatter
3
+ module ElasticSearch
4
+ class SearchFormatter < Appsignal::EventFormatter
5
+ register 'search.elasticsearch'
6
+
7
+ def format(payload)
8
+ [
9
+ "#{payload[:name]}: #{payload[:klass]}",
10
+ sanitized_search(payload[:search]).inspect
11
+ ]
12
+ end
13
+
14
+ def sanitized_search(search)
15
+ return nil unless search.is_a?(Hash)
16
+ {}.tap do |hsh|
17
+ search.each do |key, val|
18
+ if [:index, :type].include?(key)
19
+ hsh[key] = val
20
+ else
21
+ hsh[key] = Appsignal::Utils.sanitize(val)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -11,12 +11,12 @@ module Appsignal
11
11
  when 'Moped::Protocol::Command'
12
12
  return ['Command', {
13
13
  :database => op.full_collection_name,
14
- :selector => Appsignal::Utils.sanitize(op.selector, true, :mongodb)
14
+ :selector => Appsignal::Utils.sanitize(op.selector)
15
15
  }.inspect]
16
16
  when 'Moped::Protocol::Query'
17
17
  return ['Query', {
18
18
  :database => op.full_collection_name,
19
- :selector => Appsignal::Utils.sanitize(op.selector, false, :mongodb),
19
+ :selector => Appsignal::Utils.sanitize(op.selector),
20
20
  :flags => op.flags,
21
21
  :limit => op.limit,
22
22
  :skip => op.skip,
@@ -25,21 +25,21 @@ module Appsignal
25
25
  when 'Moped::Protocol::Delete'
26
26
  return ['Delete', {
27
27
  :database => op.full_collection_name,
28
- :selector => Appsignal::Utils.sanitize(op.selector, false, :mongodb),
28
+ :selector => Appsignal::Utils.sanitize(op.selector),
29
29
  :flags => op.flags,
30
30
  }.inspect]
31
31
  when 'Moped::Protocol::Insert'
32
32
  return ['Insert', {
33
33
  :database => op.full_collection_name,
34
- :documents => Appsignal::Utils.sanitize(op.documents, true, :mongodb),
34
+ :documents => Appsignal::Utils.sanitize(op.documents, true),
35
35
  :count => op.documents.count,
36
36
  :flags => op.flags,
37
37
  }.inspect]
38
38
  when 'Moped::Protocol::Update'
39
39
  return ['Update', {
40
40
  :database => op.full_collection_name,
41
- :selector => Appsignal::Utils.sanitize(op.selector, false, :mongodb),
42
- :update => Appsignal::Utils.sanitize(op.update, true, :mongodb),
41
+ :selector => Appsignal::Utils.sanitize(op.selector),
42
+ :update => Appsignal::Utils.sanitize(op.update, true),
43
43
  :flags => op.flags,
44
44
  }.inspect]
45
45
  when 'Moped::Protocol::KillCursors'
@@ -53,6 +53,7 @@ module Appsignal
53
53
  end
54
54
  end
55
55
  end
56
+
56
57
  end
57
58
  end
58
59
  end
@@ -45,6 +45,39 @@ module Appsignal
45
45
  raise NotImplementedError
46
46
  end
47
47
  end
48
+
49
+ module Helpers
50
+ def string_or_inspect(string_or_other)
51
+ if string_or_other.is_a?(String)
52
+ string_or_other
53
+ else
54
+ string_or_other.inspect
55
+ end
56
+ end
57
+
58
+ def truncate(text)
59
+ text.size > 200 ? "#{text[0...197]}..." : text
60
+ end
61
+
62
+ def extract_value(object_or_hash, field, default_value=nil, convert_to_s=false)
63
+ value = if object_or_hash.respond_to?(:[])
64
+ object_or_hash[field]
65
+ elsif object_or_hash.respond_to?(field)
66
+ object_or_hash.send(field)
67
+ end || default_value
68
+ if convert_to_s
69
+ value.to_s
70
+ else
71
+ value
72
+ end
73
+ end
74
+
75
+ def format_args(args)
76
+ args.map do |arg|
77
+ truncate(string_or_inspect(arg))
78
+ end
79
+ end
80
+ end
48
81
  end
49
82
  end
50
83
 
@@ -6,7 +6,7 @@ module Appsignal
6
6
  register :net_http
7
7
 
8
8
  def dependencies_present?
9
- Appsignal.config[:instrument_net_http]
9
+ Appsignal.config && Appsignal.config[:instrument_net_http]
10
10
  end
11
11
 
12
12
  def install
@@ -3,10 +3,13 @@ module Appsignal
3
3
  module SequelExtension
4
4
  # Add query instrumentation
5
5
  def log_yield(sql, args = nil)
6
- ActiveSupport::Notifications.instrument(
7
- 'sql.sequel',
8
- :sql => sql
9
- ) do
6
+
7
+ # We'd like to get full sql queries in the payloads as well. To do
8
+ # that we need to find out a way to ask Sequel which quoting strategy
9
+ # is used by the adapter. We can then do something similar to the AR
10
+ # formatter.
11
+
12
+ ActiveSupport::Notifications.instrument('sql.sequel') do
10
13
  yield
11
14
  end
12
15
  end
@@ -1,21 +1,30 @@
1
1
  module Appsignal
2
2
  class Hooks
3
3
  class SidekiqPlugin
4
+ include Appsignal::Hooks::Helpers
5
+
4
6
  def job_keys
5
7
  @job_keys ||= Set.new(%w(
6
8
  class args retried_at failed_at
7
9
  error_message error_class backtrace
8
10
  error_backtrace enqueued_at retry
11
+ jid retry created_at wrapped
9
12
  ))
10
13
  end
11
14
 
12
15
  def call(worker, item, queue)
16
+ if item['class'] == 'ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper'
17
+ params = format_args(item['args'].first['arguments'])
18
+ else
19
+ params = format_args(item['args'])
20
+ end
21
+
13
22
  Appsignal.monitor_transaction(
14
23
  'perform_job.sidekiq',
15
24
  :class => item['wrapped'] || item['class'],
16
25
  :method => 'perform',
17
26
  :metadata => formatted_metadata(item),
18
- :params => format_args(item['args']),
27
+ :params => params,
19
28
  :queue_start => item['enqueued_at']
20
29
  ) do
21
30
  yield
@@ -29,24 +38,6 @@ module Appsignal
29
38
  end
30
39
  end
31
40
  end
32
-
33
- def string_or_inspect(string_or_other)
34
- if string_or_other.is_a?(String)
35
- string_or_other
36
- else
37
- string_or_other.inspect
38
- end
39
- end
40
-
41
- def format_args(args)
42
- args.map do |arg|
43
- truncate(string_or_inspect(arg))
44
- end
45
- end
46
-
47
- def truncate(text)
48
- text.size > 200 ? "#{text[0...197]}..." : text
49
- end
50
41
  end
51
42
 
52
43
  class SidekiqHook < Appsignal::Hooks::Hook