appsignal 3.1.4-java → 3.1.6-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11a83cde5a5fd83b9e14f1429d5a9f695d080ffc2ac729a02f83f3b891b812c3
4
- data.tar.gz: 53743646f5cf821ab45559817cf65c2bf9ed483184725fca2413b3606fad6e1e
3
+ metadata.gz: b0739a45917b16eb1bc1a3d181f6c7d247faca2cd4cc095aae13a186e71a3817
4
+ data.tar.gz: a5e646a6124dd3a9173d3a30ec19463076a50b96e8b4320ef54c909fdc2aad22
5
5
  SHA512:
6
- metadata.gz: 3e56000d21fc9cb56edc28ef15ad22d8ab493d081e8e88d8e112c592b7a8bf93c3ac2d0a24b2ea97b7cc85f26fe2fdbdf751894c4fb156f3189bc962504f93d5
7
- data.tar.gz: b03a309a6c8649397e6f5d9b62a65324e4b4e39a3a1eee77b6cb60280758838212e2de7ca3eb28c8f10b3b59cb5b02ca7d88347cc9f3995be0308bf5249cae70
6
+ metadata.gz: 464672760abe3fed2b7e36a8812b19377ed5596bbaadd34bcdc22775a0696ff8fc2698a002c0fce8113f3215a594943ee7e15ef8e9dfdae609ce847b9b45b8da
7
+ data.tar.gz: 3761cf3f55137ac16e63a740d917e0f83a75d8d72ad93cbd52aa1de09a61bd3631dc8e6f537ada82d36c7e8a0395b1e05f5d76084508dd00169a2ef67c77a83d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # AppSignal for Ruby gem Changelog
2
2
 
3
+ ## 3.1.6
4
+
5
+ ### Fixed
6
+
7
+ - [a03b7246](https://github.com/appsignal/appsignal-ruby/commit/a03b72461f5f3b047ca81368cf2bdbeadf078e08) patch - Support Sidekiq 7 in the Sidekiq minutely probe. It will now report metrics to Sidekiq magic dashboard for Sidekiq version 7 and newer.
8
+
9
+ ## 3.1.5
10
+
11
+ ### Changed
12
+
13
+ - [4035c3c2](https://github.com/appsignal/appsignal-ruby/commit/4035c3c2d5c0b002119054014daddd193bd820f0) patch - Bump agent to version 813a59b
14
+
15
+ - Fix http proxy config option parsing for port 80.
16
+ - Fix the return value for appsignal_import_opentelemetry_span extension
17
+ function in `appsignal.h`.
18
+
19
+ ### Fixed
20
+
21
+ - [feb60fb8](https://github.com/appsignal/appsignal-ruby/commit/feb60fb877a2b264e587fe3d5d546e40d86c9c38) patch - Fix NoMethodError for AppSignal Puma plugin for Puma 6. Puma 5 is also still supported.
22
+
3
23
  ## 3.1.4
4
24
 
5
25
  ### Added
data/ext/agent.yml CHANGED
@@ -3,99 +3,99 @@
3
3
  # appsignal-agent repository.
4
4
  # Modifications to this file will be overwritten with the next agent release.
5
5
  ---
6
- version: '06391fb'
6
+ version: 813a59b
7
7
  mirrors:
8
8
  - https://appsignal-agent-releases.global.ssl.fastly.net
9
9
  - https://d135dj0rjqvssy.cloudfront.net
10
10
  triples:
11
11
  x86_64-darwin:
12
12
  static:
13
- checksum: 9bf41c183d94c80e980f57ea2e29d08bae97e8097b5284a2b91a5484bf866f8c
13
+ checksum: c8919a19a28950f726221829ea4d2b3312f1595a5e28ea134f8c41ed0814d7cd
14
14
  filename: appsignal-x86_64-darwin-all-static.tar.gz
15
15
  dynamic:
16
- checksum: 4d3789e65cf00e446600e883d95d097323ebb3835703c67c8d09f434f09ab496
16
+ checksum: 1c10139bc4df56048a71766b64eba76462ee38d3cc814dc230e0fdb3c7e4fba3
17
17
  filename: appsignal-x86_64-darwin-all-dynamic.tar.gz
18
18
  universal-darwin:
19
19
  static:
20
- checksum: 9bf41c183d94c80e980f57ea2e29d08bae97e8097b5284a2b91a5484bf866f8c
20
+ checksum: c8919a19a28950f726221829ea4d2b3312f1595a5e28ea134f8c41ed0814d7cd
21
21
  filename: appsignal-x86_64-darwin-all-static.tar.gz
22
22
  dynamic:
23
- checksum: 4d3789e65cf00e446600e883d95d097323ebb3835703c67c8d09f434f09ab496
23
+ checksum: 1c10139bc4df56048a71766b64eba76462ee38d3cc814dc230e0fdb3c7e4fba3
24
24
  filename: appsignal-x86_64-darwin-all-dynamic.tar.gz
25
25
  aarch64-darwin:
26
26
  static:
27
- checksum: 74edd7b97995f3314c10e3d84fc832c1b842c236c331ed4f2f77146ad004d179
27
+ checksum: 40a38896132f418362af9fb2e9796eb4479e13cc0691b61f0f0b81b77e66ded6
28
28
  filename: appsignal-aarch64-darwin-all-static.tar.gz
29
29
  dynamic:
30
- checksum: 7165bb164a9cd7a2a5f97897d954390412f7034c667e5826b3307ffbd848bff9
30
+ checksum: 40ec0c7db246cfc9b8eeebc882b07ba625948f376a53d8e24add7148d0f8c067
31
31
  filename: appsignal-aarch64-darwin-all-dynamic.tar.gz
32
32
  arm64-darwin:
33
33
  static:
34
- checksum: 74edd7b97995f3314c10e3d84fc832c1b842c236c331ed4f2f77146ad004d179
34
+ checksum: 40a38896132f418362af9fb2e9796eb4479e13cc0691b61f0f0b81b77e66ded6
35
35
  filename: appsignal-aarch64-darwin-all-static.tar.gz
36
36
  dynamic:
37
- checksum: 7165bb164a9cd7a2a5f97897d954390412f7034c667e5826b3307ffbd848bff9
37
+ checksum: 40ec0c7db246cfc9b8eeebc882b07ba625948f376a53d8e24add7148d0f8c067
38
38
  filename: appsignal-aarch64-darwin-all-dynamic.tar.gz
39
39
  arm-darwin:
40
40
  static:
41
- checksum: 74edd7b97995f3314c10e3d84fc832c1b842c236c331ed4f2f77146ad004d179
41
+ checksum: 40a38896132f418362af9fb2e9796eb4479e13cc0691b61f0f0b81b77e66ded6
42
42
  filename: appsignal-aarch64-darwin-all-static.tar.gz
43
43
  dynamic:
44
- checksum: 7165bb164a9cd7a2a5f97897d954390412f7034c667e5826b3307ffbd848bff9
44
+ checksum: 40ec0c7db246cfc9b8eeebc882b07ba625948f376a53d8e24add7148d0f8c067
45
45
  filename: appsignal-aarch64-darwin-all-dynamic.tar.gz
46
46
  aarch64-linux:
47
47
  static:
48
- checksum: 0f2430e637eb77ce2093f021777087e87cb1e7be7c86a53771172696791c4879
48
+ checksum: c73b6e9de849a40290a0d90eaad43ea41a9a0293ba4b8bf99f69965c45c85514
49
49
  filename: appsignal-aarch64-linux-all-static.tar.gz
50
50
  dynamic:
51
- checksum: 0e4f9305aeaaa2d7847e83be04227b865723a0591574108d78040b5921a677a7
51
+ checksum: 90226eefe2e2f66833ca3e31c69ce70763ed57916bd0b5c1809bd99d61ff3429
52
52
  filename: appsignal-aarch64-linux-all-dynamic.tar.gz
53
53
  i686-linux:
54
54
  static:
55
- checksum: 449ba623aaa1853c2d211bf1e2d3a14e5ae09225a62457cbdbcc0983a5713a52
55
+ checksum: 6741b9a068dc405b3d6d07953fab7fc876c21b4add1cbb2b4c4c4dfdeca5d387
56
56
  filename: appsignal-i686-linux-all-static.tar.gz
57
57
  dynamic:
58
- checksum: dae994292d602eaf0910bd2ce53f0163e19767a4cbb8e5d0db99c0010d6df486
58
+ checksum: 1af902b37af378a06251365fb637f86298380d3627c54f2945a85c1b7f075fda
59
59
  filename: appsignal-i686-linux-all-dynamic.tar.gz
60
60
  x86-linux:
61
61
  static:
62
- checksum: 449ba623aaa1853c2d211bf1e2d3a14e5ae09225a62457cbdbcc0983a5713a52
62
+ checksum: 6741b9a068dc405b3d6d07953fab7fc876c21b4add1cbb2b4c4c4dfdeca5d387
63
63
  filename: appsignal-i686-linux-all-static.tar.gz
64
64
  dynamic:
65
- checksum: dae994292d602eaf0910bd2ce53f0163e19767a4cbb8e5d0db99c0010d6df486
65
+ checksum: 1af902b37af378a06251365fb637f86298380d3627c54f2945a85c1b7f075fda
66
66
  filename: appsignal-i686-linux-all-dynamic.tar.gz
67
67
  x86_64-linux:
68
68
  static:
69
- checksum: 394796c0ddeb4881c9f2e6ce82f840e66bcb69e027324f6c04f6671067445fbb
69
+ checksum: 8355b017093db606014023cc617d84d6375d503d7ffa54f62c7b3dc56fb64ead
70
70
  filename: appsignal-x86_64-linux-all-static.tar.gz
71
71
  dynamic:
72
- checksum: 9ca4762c464482b0a5a89898a839388597dd57a17a21527a67f3e3db0e540a03
72
+ checksum: 7c239a7ffe18cb173120bd67fb96563f4a81f0744bbbb47082f077a38ccbe5f1
73
73
  filename: appsignal-x86_64-linux-all-dynamic.tar.gz
74
74
  x86_64-linux-musl:
75
75
  static:
76
- checksum: 673271c8c5fd55053d8a719bcd307f787db4ca4633baf8cf961c442bf1805614
76
+ checksum: e9d98ed23b872dbf1e67a081473918cf88c4af775b1caadbfd93deda2635d9f8
77
77
  filename: appsignal-x86_64-linux-musl-all-static.tar.gz
78
78
  dynamic:
79
- checksum: 609d59376d6633652015e838eb649229fe2523d443a5471232b869f48eb99640
79
+ checksum: 5538172a95dfca1a4cf8e111ba61eab5e9c16314fa902259711cb9e8e0d2f85e
80
80
  filename: appsignal-x86_64-linux-musl-all-dynamic.tar.gz
81
81
  aarch64-linux-musl:
82
82
  static:
83
- checksum: e90ca19bf61596be022ba04897e8902b3401add58f351a40a3d3a7af241d0bbb
83
+ checksum: 0fb3eacfb8c8bc01c4acc8916327626720de376bcdd95104be71bb11a4ff9215
84
84
  filename: appsignal-aarch64-linux-musl-all-static.tar.gz
85
85
  dynamic:
86
- checksum: afb66c65fb82b672887bc6b6e82d82f09d9855a5497a7abb06b438dadea97aca
86
+ checksum: b87bcedaa2aa886acf3a93ce6e32762a843f3bee1ca7a8f9e0d17ca32f7a7d39
87
87
  filename: appsignal-aarch64-linux-musl-all-dynamic.tar.gz
88
88
  x86_64-freebsd:
89
89
  static:
90
- checksum: cb45da91c51123859e5ef5cea850460c28d6e77dfa08b90375178d9017162ba8
90
+ checksum: b7d3c244b7068213840f5970df2e318d98f7909eb3b2b4ab42441d064ffb19ee
91
91
  filename: appsignal-x86_64-freebsd-all-static.tar.gz
92
92
  dynamic:
93
- checksum: 6a03e02c2526e05edaa7fa932b2e764318c63ec93d517c6c00f6b7541bfe71f3
93
+ checksum: 0a739134f11d50318d14f247df1f8cc0f8aec1fbcb70a8bc48d5e1f22dc4aaba
94
94
  filename: appsignal-x86_64-freebsd-all-dynamic.tar.gz
95
95
  amd64-freebsd:
96
96
  static:
97
- checksum: cb45da91c51123859e5ef5cea850460c28d6e77dfa08b90375178d9017162ba8
97
+ checksum: b7d3c244b7068213840f5970df2e318d98f7909eb3b2b4ab42441d064ffb19ee
98
98
  filename: appsignal-x86_64-freebsd-all-static.tar.gz
99
99
  dynamic:
100
- checksum: 6a03e02c2526e05edaa7fa932b2e764318c63ec93d517c6c00f6b7541bfe71f3
100
+ checksum: 0a739134f11d50318d14f247df1f8cc0f8aec1fbcb70a8bc48d5e1f22dc4aaba
101
101
  filename: appsignal-x86_64-freebsd-all-dynamic.tar.gz
@@ -1,6 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'padrino', "~> 0.15"
4
- gem 'rack'
4
+ gem 'rack', "~> 2"
5
+ gem 'sinatra', "~> 2"
5
6
 
6
7
  gemspec :path => '../'
data/gemfiles/que.gemfile CHANGED
@@ -1,5 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'que'
3
+ gem 'que', "~> 1.0"
4
4
 
5
5
  gemspec :path => '../'
@@ -3,17 +3,59 @@ module Appsignal
3
3
  class SidekiqProbe
4
4
  include Helpers
5
5
 
6
+ class Sidekiq7Adapter
7
+ def self.redis_info
8
+ redis_info = nil
9
+ ::Sidekiq.redis { |c| redis_info = c.info }
10
+ redis_info
11
+ end
12
+
13
+ def self.hostname
14
+ host = nil
15
+ ::Sidekiq.redis do |c|
16
+ host = c.config.host
17
+ end
18
+ host
19
+ end
20
+ end
21
+
22
+ class Sidekiq6Adapter
23
+ def self.redis_info
24
+ return unless ::Sidekiq.respond_to?(:redis_info)
25
+
26
+ ::Sidekiq.redis_info
27
+ end
28
+
29
+ def self.hostname
30
+ host = nil
31
+ ::Sidekiq.redis do |c|
32
+ host = c.connection[:host] if c.respond_to? :connection
33
+ end
34
+ host
35
+ end
36
+ end
37
+
6
38
  # @api private
7
39
  attr_reader :config
8
40
 
41
+ def self.sidekiq7_and_greater?
42
+ Gem::Version.new(::Sidekiq::VERSION) >= Gem::Version.new("7.0.0")
43
+ end
44
+
9
45
  # @api private
10
46
  def self.dependencies_present?
47
+ return true if sidekiq7_and_greater?
48
+ return unless defined?(::Redis::VERSION) # Sidekiq <= 6
49
+
11
50
  Gem::Version.new(::Redis::VERSION) >= Gem::Version.new("3.3.5")
12
51
  end
13
52
 
14
53
  def initialize(config = {})
15
54
  @config = config
16
55
  @cache = {}
56
+ is_sidekiq7 = self.class.sidekiq7_and_greater?
57
+ @adapter = is_sidekiq7 ? Sidekiq7Adapter : Sidekiq6Adapter
58
+
17
59
  config_string = " with config: #{config}" unless config.empty?
18
60
  Appsignal.logger.debug("Initializing Sidekiq probe#{config_string}")
19
61
  require "sidekiq/api"
@@ -28,11 +70,11 @@ module Appsignal
28
70
 
29
71
  private
30
72
 
31
- attr_reader :cache
73
+ attr_reader :adapter, :cache
32
74
 
33
75
  def track_redis_info
34
- return unless ::Sidekiq.respond_to?(:redis_info)
35
- redis_info = ::Sidekiq.redis_info
76
+ redis_info = adapter.redis_info
77
+ return unless redis_info
36
78
 
37
79
  gauge "connection_count", redis_info.fetch("connected_clients")
38
80
  gauge "memory_usage", redis_info.fetch("used_memory")
@@ -81,8 +123,7 @@ module Appsignal
81
123
  return @hostname
82
124
  end
83
125
 
84
- host = nil
85
- ::Sidekiq.redis { |c| host = c.connection[:host] }
126
+ host = adapter.hostname
86
127
  Appsignal.logger.debug "Sidekiq probe: Using Redis server hostname " \
87
128
  "#{host.inspect} as hostname"
88
129
  @hostname = host
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "3.1.4".freeze
4
+ VERSION = "3.1.6".freeze
5
5
  end
@@ -11,9 +11,9 @@ require "json"
11
11
  Puma::Plugin.create do # rubocop:disable Metrics/BlockLength
12
12
  def start(launcher)
13
13
  @launcher = launcher
14
- @launcher.events.debug "AppSignal: Puma plugin start."
14
+ log_debug "AppSignal: Puma plugin start."
15
15
  in_background do
16
- @launcher.events.debug "AppSignal: Start Puma stats collection loop."
16
+ log_debug "AppSignal: Start Puma stats collection loop."
17
17
  plugin = AppsignalPumaPlugin.new
18
18
 
19
19
  loop do
@@ -24,12 +24,12 @@ Puma::Plugin.create do # rubocop:disable Metrics/BlockLength
24
24
  # metrics.
25
25
  sleep sleep_time
26
26
 
27
- @launcher.events.debug "AppSignal: Collecting Puma stats."
27
+ log_debug "AppSignal: Collecting Puma stats."
28
28
  stats = fetch_puma_stats
29
29
  if stats
30
30
  plugin.call(stats)
31
31
  else
32
- @launcher.events.log "AppSignal: No Puma stats to report."
32
+ log_debug "AppSignal: No Puma stats to report."
33
33
  end
34
34
  rescue StandardError => error
35
35
  log_error "Error while processing metrics.", error
@@ -44,8 +44,20 @@ Puma::Plugin.create do # rubocop:disable Metrics/BlockLength
44
44
  60 # seconds
45
45
  end
46
46
 
47
+ def logger
48
+ if @launcher.respond_to? :log_writer
49
+ @launcher.log_writer
50
+ else
51
+ @launcher.events
52
+ end
53
+ end
54
+
55
+ def log_debug(message)
56
+ logger.debug message
57
+ end
58
+
47
59
  def log_error(message, error)
48
- @launcher.events.log "AppSignal: #{message}\n" \
60
+ logger.error "AppSignal: #{message}\n" \
49
61
  "#{error.class}: #{error.message}\n#{error.backtrace.join("\n")}"
50
62
  end
51
63
 
@@ -7,114 +7,177 @@ describe Appsignal::Probes::SidekiqProbe do
7
7
  let(:expected_default_tags) { { :hostname => "localhost" } }
8
8
  before do
9
9
  Appsignal.config = project_fixture_config
10
- module SidekiqMock
11
- def self.redis_info
12
- {
13
- "connected_clients" => 2,
14
- "used_memory" => 1024,
15
- "used_memory_rss" => 512
16
- }
10
+
11
+ class SidekiqStats
12
+ class << self
13
+ attr_reader :calls
14
+
15
+ def count_call
16
+ @calls ||= -1
17
+ @calls += 1
18
+ end
17
19
  end
18
20
 
19
- def self.redis
20
- yield Client.new
21
+ def workers_size
22
+ # First method called, so count it towards a call
23
+ self.class.count_call
24
+ 24
21
25
  end
22
26
 
23
- class Client
24
- def connection
25
- { :host => "localhost" }
26
- end
27
+ def processes_size
28
+ 25
27
29
  end
28
30
 
29
- class Stats
30
- class << self
31
- attr_reader :calls
31
+ # Return two different values for two separate calls.
32
+ # This allows us to test the delta of the value send as a gauge.
33
+ def processed
34
+ [10, 15][self.class.calls]
35
+ end
32
36
 
33
- def count_call
34
- @calls ||= -1
35
- @calls += 1
36
- end
37
- end
37
+ # Return two different values for two separate calls.
38
+ # This allows us to test the delta of the value send as a gauge.
39
+ def failed
40
+ [10, 13][self.class.calls]
41
+ end
38
42
 
39
- def workers_size
40
- # First method called, so count it towards a call
41
- self.class.count_call
42
- 24
43
- end
43
+ def retry_size
44
+ 12
45
+ end
44
46
 
45
- def processes_size
46
- 25
47
- end
47
+ # Return two different values for two separate calls.
48
+ # This allows us to test the delta of the value send as a gauge.
49
+ def dead_size
50
+ [10, 12][self.class.calls]
51
+ end
48
52
 
49
- # Return two different values for two separate calls.
50
- # This allows us to test the delta of the value send as a gauge.
51
- def processed
52
- [10, 15][self.class.calls]
53
- end
53
+ def scheduled_size
54
+ 14
55
+ end
54
56
 
55
- # Return two different values for two separate calls.
56
- # This allows us to test the delta of the value send as a gauge.
57
- def failed
58
- [10, 13][self.class.calls]
59
- end
57
+ def enqueued
58
+ 15
59
+ end
60
+ end
60
61
 
61
- def retry_size
62
- 12
63
- end
62
+ class SidekiqQueue
63
+ Queue = Struct.new(:name, :size, :latency)
64
+
65
+ def self.all
66
+ [
67
+ Queue.new("default", 10, 12),
68
+ Queue.new("critical", 1, 2)
69
+ ]
70
+ end
71
+ end
72
+
73
+ module Sidekiq7Mock
74
+ VERSION = "7.0.0".freeze
75
+
76
+ def self.redis
77
+ yield Client.new
78
+ end
64
79
 
65
- # Return two different values for two separate calls.
66
- # This allows us to test the delta of the value send as a gauge.
67
- def dead_size
68
- [10, 12][self.class.calls]
80
+ class Client
81
+ def config
82
+ Config.new
69
83
  end
70
84
 
71
- def scheduled_size
72
- 14
85
+ def info
86
+ {
87
+ "connected_clients" => 2,
88
+ "used_memory" => 1024,
89
+ "used_memory_rss" => 512
90
+ }
73
91
  end
92
+ end
74
93
 
75
- def enqueued
76
- 15
94
+ class Config
95
+ def host
96
+ "localhost"
77
97
  end
78
98
  end
79
99
 
80
- class Queue
81
- Queue = Struct.new(:name, :size, :latency)
100
+ Stats = ::SidekiqStats
101
+ Queue = ::SidekiqQueue
102
+ end
103
+
104
+ module Sidekiq6Mock
105
+ VERSION = "6.9.9".freeze
106
+
107
+ def self.redis_info
108
+ {
109
+ "connected_clients" => 2,
110
+ "used_memory" => 1024,
111
+ "used_memory_rss" => 512
112
+ }
113
+ end
114
+
115
+ def self.redis
116
+ yield Client.new
117
+ end
82
118
 
83
- def self.all
84
- [
85
- Queue.new("default", 10, 12),
86
- Queue.new("critical", 1, 2)
87
- ]
119
+ class Client
120
+ def connection
121
+ { :host => "localhost" }
88
122
  end
89
123
  end
124
+
125
+ Stats = ::SidekiqStats
126
+ Queue = ::SidekiqQueue
90
127
  end
91
- stub_const("Sidekiq", SidekiqMock)
92
128
  end
93
- after { Object.send(:remove_const, :SidekiqMock) }
129
+ after do
130
+ Object.send(:remove_const, :SidekiqStats)
131
+ Object.send(:remove_const, :SidekiqQueue)
132
+ Object.send(:remove_const, :Sidekiq6Mock)
133
+ Object.send(:remove_const, :Sidekiq7Mock)
134
+ end
135
+
136
+ def with_sidekiq7!
137
+ stub_const("Sidekiq", Sidekiq7Mock)
138
+ end
139
+ # Version not relevant, but requires any version for tests
140
+ alias_method :with_sidekiq!, :with_sidekiq7!
141
+
142
+ def with_sidekiq6!
143
+ stub_const("Sidekiq", Sidekiq6Mock)
144
+ end
94
145
 
95
146
  describe ".dependencies_present?" do
96
- before do
97
- stub_const("Redis::VERSION", version)
147
+ context "when Sidekiq 7" do
148
+ before { with_sidekiq7! }
149
+
150
+ it "starts the probe" do
151
+ expect(described_class.dependencies_present?).to be_truthy
152
+ end
98
153
  end
99
154
 
100
- context "when Redis version is < 3.3.5" do
101
- let(:version) { "3.3.4" }
155
+ context "when Sidekiq 6" do
156
+ before do
157
+ with_sidekiq6!
158
+ stub_const("Redis::VERSION", version)
159
+ end
160
+
161
+ context "when Redis version is < 3.3.5" do
162
+ let(:version) { "3.3.4" }
102
163
 
103
- it "does not start probe" do
104
- expect(described_class.dependencies_present?).to be_falsy
164
+ it "does not start probe" do
165
+ expect(described_class.dependencies_present?).to be_falsy
166
+ end
105
167
  end
106
- end
107
168
 
108
- context "when Redis version is >= 3.3.5" do
109
- let(:version) { "3.3.5" }
169
+ context "when Redis version is >= 3.3.5" do
170
+ let(:version) { "3.3.5" }
110
171
 
111
- it "does not start probe" do
112
- expect(described_class.dependencies_present?).to be_truthy
172
+ it "starts the probe" do
173
+ expect(described_class.dependencies_present?).to be_truthy
174
+ end
113
175
  end
114
176
  end
115
177
  end
116
178
 
117
179
  it "loads Sidekiq::API" do
180
+ with_sidekiq!
118
181
  # Hide the Sidekiq constant if it was already loaded. It will be
119
182
  # redefined by loading "sidekiq/api" in the probe.
120
183
  hide_const "Sidekiq::Stats"
@@ -125,53 +188,94 @@ describe Appsignal::Probes::SidekiqProbe do
125
188
  end
126
189
 
127
190
  it "logs config on initialize" do
191
+ with_sidekiq!
128
192
  log = capture_logs { probe }
129
193
  expect(log).to contains_log(:debug, "Initializing Sidekiq probe\n")
130
194
  end
131
195
 
132
- it "logs used hostname on call once" do
133
- log = capture_logs { probe.call }
134
- expect(log).to contains_log(
135
- :debug,
136
- %(Sidekiq probe: Using Redis server hostname "localhost" as hostname)
137
- )
138
- log = capture_logs { probe.call }
139
- # Match more logs with incompelete message
140
- expect(log).to_not contains_log(:debug, %(Sidekiq probe: ))
141
- end
196
+ context "with Sidekiq 7" do
197
+ before { with_sidekiq7! }
142
198
 
143
- it "collects custom metrics" do
144
- expect_gauge("worker_count", 24).twice
145
- expect_gauge("process_count", 25).twice
146
- expect_gauge("connection_count", 2).twice
147
- expect_gauge("memory_usage", 1024).twice
148
- expect_gauge("memory_usage_rss", 512).twice
149
- expect_gauge("job_count", 5, :status => :processed) # Gauge delta
150
- expect_gauge("job_count", 3, :status => :failed) # Gauge delta
151
- expect_gauge("job_count", 12, :status => :retry_queue).twice
152
- expect_gauge("job_count", 2, :status => :died) # Gauge delta
153
- expect_gauge("job_count", 14, :status => :scheduled).twice
154
- expect_gauge("job_count", 15, :status => :enqueued).twice
155
- expect_gauge("queue_length", 10, :queue => "default").twice
156
- expect_gauge("queue_latency", 12_000, :queue => "default").twice
157
- expect_gauge("queue_length", 1, :queue => "critical").twice
158
- expect_gauge("queue_latency", 2_000, :queue => "critical").twice
159
- # Call probe twice so we can calculate the delta for some gauge values
160
- probe.call
161
- probe.call
199
+ it "logs used hostname on call once" do
200
+ log = capture_logs { probe.call }
201
+ expect(log).to contains_log(
202
+ :debug,
203
+ %(Sidekiq probe: Using Redis server hostname "localhost" as hostname)
204
+ )
205
+ log = capture_logs { probe.call }
206
+ # Match more logs with incompelete message
207
+ expect(log).to_not contains_log(:debug, %(Sidekiq probe: ))
208
+ end
209
+
210
+ it "collects custom metrics" do
211
+ expect_gauge("worker_count", 24).twice
212
+ expect_gauge("process_count", 25).twice
213
+ expect_gauge("connection_count", 2).twice
214
+ expect_gauge("memory_usage", 1024).twice
215
+ expect_gauge("memory_usage_rss", 512).twice
216
+ expect_gauge("job_count", 5, :status => :processed) # Gauge delta
217
+ expect_gauge("job_count", 3, :status => :failed) # Gauge delta
218
+ expect_gauge("job_count", 12, :status => :retry_queue).twice
219
+ expect_gauge("job_count", 2, :status => :died) # Gauge delta
220
+ expect_gauge("job_count", 14, :status => :scheduled).twice
221
+ expect_gauge("job_count", 15, :status => :enqueued).twice
222
+ expect_gauge("queue_length", 10, :queue => "default").twice
223
+ expect_gauge("queue_latency", 12_000, :queue => "default").twice
224
+ expect_gauge("queue_length", 1, :queue => "critical").twice
225
+ expect_gauge("queue_latency", 2_000, :queue => "critical").twice
226
+ # Call probe twice so we can calculate the delta for some gauge values
227
+ probe.call
228
+ probe.call
229
+ end
162
230
  end
163
231
 
164
- context "when `redis_info` is not defined" do
165
- before do
166
- allow(Sidekiq).to receive(:respond_to?).with(:redis_info).and_return(false)
232
+ context "with Sidekiq 6" do
233
+ before { with_sidekiq6! }
234
+
235
+ it "logs used hostname on call once" do
236
+ log = capture_logs { probe.call }
237
+ expect(log).to contains_log(
238
+ :debug,
239
+ %(Sidekiq probe: Using Redis server hostname "localhost" as hostname)
240
+ )
241
+ log = capture_logs { probe.call }
242
+ # Match more logs with incompelete message
243
+ expect(log).to_not contains_log(:debug, %(Sidekiq probe: ))
167
244
  end
168
245
 
169
- it "does not collect redis metrics" do
170
- expect_gauge("connection_count", 2).never
171
- expect_gauge("memory_usage", 1024).never
172
- expect_gauge("memory_usage_rss", 512).never
246
+ it "collects custom metrics" do
247
+ expect_gauge("worker_count", 24).twice
248
+ expect_gauge("process_count", 25).twice
249
+ expect_gauge("connection_count", 2).twice
250
+ expect_gauge("memory_usage", 1024).twice
251
+ expect_gauge("memory_usage_rss", 512).twice
252
+ expect_gauge("job_count", 5, :status => :processed) # Gauge delta
253
+ expect_gauge("job_count", 3, :status => :failed) # Gauge delta
254
+ expect_gauge("job_count", 12, :status => :retry_queue).twice
255
+ expect_gauge("job_count", 2, :status => :died) # Gauge delta
256
+ expect_gauge("job_count", 14, :status => :scheduled).twice
257
+ expect_gauge("job_count", 15, :status => :enqueued).twice
258
+ expect_gauge("queue_length", 10, :queue => "default").twice
259
+ expect_gauge("queue_latency", 12_000, :queue => "default").twice
260
+ expect_gauge("queue_length", 1, :queue => "critical").twice
261
+ expect_gauge("queue_latency", 2_000, :queue => "critical").twice
262
+ # Call probe twice so we can calculate the delta for some gauge values
263
+ probe.call
173
264
  probe.call
174
265
  end
266
+
267
+ context "when Sidekiq `redis_info` is not defined" do
268
+ before do
269
+ allow(Sidekiq).to receive(:respond_to?).with(:redis_info).and_return(false)
270
+ end
271
+
272
+ it "does not collect redis metrics" do
273
+ expect_gauge("connection_count", 2).never
274
+ expect_gauge("memory_usage", 1024).never
275
+ expect_gauge("memory_usage_rss", 512).never
276
+ probe.call
277
+ end
278
+ end
175
279
  end
176
280
 
177
281
  context "when hostname is configured for probe" do
@@ -179,6 +283,8 @@ describe Appsignal::Probes::SidekiqProbe do
179
283
  let(:probe) { described_class.new(:hostname => redis_hostname) }
180
284
 
181
285
  it "uses the redis hostname for the hostname tag" do
286
+ with_sidekiq!
287
+
182
288
  allow(Appsignal).to receive(:set_gauge).and_call_original
183
289
  log = capture_logs { probe }
184
290
  expect(log).to contains_log(
@@ -683,43 +683,36 @@ describe Appsignal::Transaction do
683
683
  end
684
684
 
685
685
  describe "#sample_data" do
686
- it "should sample data" do
687
- expect(transaction.ext).to receive(:set_sample_data).with(
688
- "environment",
689
- Appsignal::Utils::Data.generate(
690
- "CONTENT_LENGTH" => "0",
691
- "REQUEST_METHOD" => "GET",
692
- "SERVER_NAME" => "example.org",
693
- "SERVER_PORT" => "80",
694
- "PATH_INFO" => "/blog"
695
- )
696
- ).once
697
- expect(transaction.ext).to receive(:set_sample_data).with(
698
- "session_data",
699
- Appsignal::Utils::Data.generate({})
700
- ).once
701
- expect(transaction.ext).to receive(:set_sample_data).with(
702
- "params",
703
- Appsignal::Utils::Data.generate(
704
- "controller" => "blog_posts",
705
- "action" => "show",
706
- "id" => "1"
707
- )
708
- ).once
709
- expect(transaction.ext).to receive(:set_sample_data).with(
710
- "metadata",
711
- Appsignal::Utils::Data.generate("key" => "value")
712
- ).once
713
- expect(transaction.ext).to receive(:set_sample_data).with(
714
- "tags",
715
- Appsignal::Utils::Data.generate({})
716
- ).once
717
- expect(transaction.ext).to receive(:set_sample_data).with(
718
- "breadcrumbs",
719
- Appsignal::Utils::Data.generate([])
720
- ).once
686
+ let(:env) { { "rack.session" => { "session" => "value" } } }
721
687
 
688
+ it "sets sample data" do
689
+ transaction.set_tags "tag" => "value"
690
+ transaction.add_breadcrumb "category", "action", "message", "key" => "value"
722
691
  transaction.sample_data
692
+
693
+ sample_data = transaction.to_h["sample_data"]
694
+ expect(sample_data["environment"]).to include(
695
+ "CONTENT_LENGTH" => "0",
696
+ "REQUEST_METHOD" => "GET",
697
+ "SERVER_NAME" => "example.org",
698
+ "SERVER_PORT" => "80",
699
+ "PATH_INFO" => "/blog"
700
+ )
701
+ expect(sample_data["session_data"]).to eq("session" => "value")
702
+ expect(sample_data["params"]).to eq(
703
+ "controller" => "blog_posts",
704
+ "action" => "show",
705
+ "id" => "1"
706
+ )
707
+ expect(sample_data["metadata"]).to eq("key" => "value")
708
+ expect(sample_data["tags"]).to eq("tag" => "value")
709
+ expect(sample_data["breadcrumbs"]).to contain_exactly(
710
+ "action" => "action",
711
+ "category" => "category",
712
+ "message" => "message",
713
+ "metadata" => { "key" => "value" },
714
+ "time" => kind_of(Integer)
715
+ )
723
716
  end
724
717
  end
725
718
 
@@ -77,7 +77,7 @@ describe Appsignal do
77
77
  end
78
78
 
79
79
  it "should not install the allocation event hook" do
80
- expect(Appsignal::Minutely).not_to receive(:install_allocation_event_hook)
80
+ expect(Appsignal::Extension).not_to receive(:install_allocation_event_hook)
81
81
  Appsignal.start
82
82
  expect_not_environment_metadata("ruby_allocation_tracking_enabled")
83
83
  end
@@ -2,14 +2,14 @@ RSpec.describe "Puma plugin" do
2
2
  include WaitForHelper
3
3
 
4
4
  class MockPumaLauncher
5
- def events
6
- return @events if defined?(@events)
5
+ def log_writer
6
+ return @log_writer if defined?(@log_writer)
7
7
 
8
- @events = MockPumaEvents.new
8
+ @log_writer = MockPumaLogWriter.new
9
9
  end
10
10
  end
11
11
 
12
- class MockPumaEvents
12
+ class MockPumaLogWriter
13
13
  attr_reader :logs
14
14
 
15
15
  def initialize
@@ -153,7 +153,7 @@ RSpec.describe "Puma plugin" do
153
153
  end
154
154
 
155
155
  def logs
156
- launcher.events.logs
156
+ launcher.log_writer.logs
157
157
  end
158
158
 
159
159
  def messages
@@ -281,7 +281,7 @@ RSpec.describe "Puma plugin" do
281
281
  it "does not fetch metrics" do
282
282
  run_plugin(appsignal_plugin) do
283
283
  expect(logs).to_not include([:error, kind_of(String)])
284
- expect(logs).to include([:log, "AppSignal: No Puma stats to report."])
284
+ expect(logs).to include([:debug, "AppSignal: No Puma stats to report."])
285
285
  expect(messages).to be_empty
286
286
  end
287
287
  end
@@ -296,4 +296,43 @@ RSpec.describe "Puma plugin" do
296
296
  end
297
297
  end
298
298
  end
299
+
300
+ context "with Puma < 6 Events class" do
301
+ class MockPumaEvents
302
+ attr_reader :logs
303
+
304
+ def initialize
305
+ @logs = []
306
+ end
307
+
308
+ def log(message)
309
+ @logs << [:log, message]
310
+ end
311
+
312
+ def debug(message)
313
+ @logs << [:debug, message]
314
+ end
315
+
316
+ def error(message)
317
+ @logs << [:error, message]
318
+ end
319
+ end
320
+
321
+ let(:launcher) do
322
+ Class.new do
323
+ def events
324
+ return @events if defined?(@events)
325
+
326
+ @events = MockPumaEvents.new
327
+ end
328
+ end.new
329
+ end
330
+ let(:stats_data) { { :max_threads => 5 } }
331
+
332
+ it "logs messages to the events class" do
333
+ run_plugin(appsignal_plugin) do
334
+ expect(launcher.events.logs).to_not be_empty
335
+ end
336
+ end
337
+ end
299
338
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appsignal
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.4
4
+ version: 3.1.6
5
5
  platform: java
6
6
  authors:
7
7
  - Robert Beekman
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-08-15 00:00:00.000000000 Z
13
+ date: 2022-11-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
@@ -441,7 +441,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
441
441
  - !ruby/object:Gem::Version
442
442
  version: '0'
443
443
  requirements: []
444
- rubygems_version: 3.3.12
444
+ rubygems_version: 3.3.7
445
445
  signing_key:
446
446
  specification_version: 4
447
447
  summary: Logs performance and exception data from your app to appsignal.com