appsignal 3.2.1-java → 3.2.2-java

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # AppSignal for Ruby gem Changelog
2
2
 
3
+ ## 3.2.2
4
+
5
+ ### Changed
6
+
7
+ - [2b1964d9](https://github.com/appsignal/appsignal-ruby/commit/2b1964d94eee0b20c12f5c602c427643057e787b) patch - Track new Ruby 3.2 VM cache metrics. In Ruby 3.2 the `class_serial` and `global_constant_state` metrics are no longer reported for the "Ruby (VM) metrics" magic dashboard, because Ruby 3.2 removed these metrics. Instead we will now report the new `constant_cache_invalidations` and `constant_cache_misses` metrics reported by Ruby 3.2.
8
+ - [6804e898](https://github.com/appsignal/appsignal-ruby/commit/6804e89817234c88105d2376687b5574bfc8e8c9) patch - Use log formatter if set in logger
9
+
3
10
  ## 3.2.1
4
11
 
5
12
  ### Fixed
data/build_matrix.yml CHANGED
@@ -25,6 +25,12 @@ semaphore: # Default `.semaphore/semaphore.yml` contents
25
25
  commands:
26
26
  - checkout
27
27
  - rm -f $HOME/.rbenv/plugins/rbenv-gem-rehash/etc/rbenv.d/exec/~gem-rehash.bash
28
+ - |
29
+ if [ -n "$_LIBYAML" ]; then
30
+ install-package --update libyaml-dev
31
+ else
32
+ echo Skipping libyaml-dev install
33
+ fi
28
34
  - |
29
35
  if [ -n "$_C_VERSION" ]; then
30
36
  sem-version c $_C_VERSION
@@ -54,8 +60,8 @@ semaphore: # Default `.semaphore/semaphore.yml` contents
54
60
  task:
55
61
  prologue:
56
62
  commands:
57
- - cache restore $_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)
58
- - cache restore $_GEMS_CACHE-gems-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)
63
+ - cache restore $_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec)
64
+ - cache restore $_GEMS_CACHE-gems-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec)
59
65
  - ./support/bundler_wrapper install --jobs=3 --retry=3
60
66
  jobs:
61
67
  - name: Validate CI setup
@@ -71,15 +77,15 @@ semaphore: # Default `.semaphore/semaphore.yml` contents
71
77
  epilogue:
72
78
  on_pass:
73
79
  commands:
74
- - cache store $_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE) .bundle
75
- - cache store $_GEMS_CACHE-gems-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE) $HOME/.gem
80
+ - cache store $_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec) .bundle
81
+ - cache store $_GEMS_CACHE-gems-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec) $HOME/.gem
76
82
  - name: Ruby linters
77
83
  dependencies: []
78
84
  task:
79
85
  prologue:
80
86
  commands:
81
- - cache restore $_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)
82
- - cache restore $_GEMS_CACHE-gems-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)
87
+ - cache restore $_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec)
88
+ - cache restore $_GEMS_CACHE-gems-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec)
83
89
  - ./support/bundler_wrapper install --jobs=3 --retry=3
84
90
  jobs:
85
91
  - name: RuboCop
@@ -95,8 +101,8 @@ semaphore: # Default `.semaphore/semaphore.yml` contents
95
101
  epilogue:
96
102
  on_pass:
97
103
  commands:
98
- - cache store $_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE) .bundle
99
- - cache store $_GEMS_CACHE-gems-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE) $HOME/.gem
104
+ - cache store $_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec) .bundle
105
+ - cache store $_GEMS_CACHE-gems-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec) $HOME/.gem
100
106
  - name: Other linters
101
107
  dependencies: []
102
108
  task:
@@ -143,16 +149,16 @@ matrix:
143
149
  value: "1"
144
150
  prologue: # Shared for all jobs in the build matrix
145
151
  commands:
146
- - cache restore $_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)
147
- - cache restore $_GEMS_CACHE-gems-$RUBY_VERSION-$(checksum $BUNDLE_GEMFILE)
152
+ - cache restore $_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec)
153
+ - cache restore $_GEMS_CACHE-gems-$RUBY_VERSION-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec)
148
154
  - ./support/install_deps
149
155
  - bundle config set clean 'true'
150
156
  - ./support/bundler_wrapper install --jobs=3 --retry=3
151
157
  epilogue: # Shared for all jobs in the build matrix
152
158
  on_pass:
153
159
  commands:
154
- - cache store $_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE) .bundle
155
- - cache store $_GEMS_CACHE-gems-$RUBY_VERSION-$(checksum $BUNDLE_GEMFILE) $HOME/.gem
160
+ - cache store $_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec) .bundle
161
+ - cache store $_GEMS_CACHE-gems-$RUBY_VERSION-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec) $HOME/.gem
156
162
  on_fail:
157
163
  commands:
158
164
  - "[ -e ext/install.report ] && cat ext/install.report || echo 'No ext/install.report file found'"
@@ -196,16 +202,16 @@ matrix:
196
202
  - ruby: "2.5.8"
197
203
  gems: "minimal"
198
204
  - ruby: "2.6.9"
199
- - ruby: "2.7.5"
200
- - ruby: "3.0.3"
201
- - ruby: "3.1.1"
202
- - ruby: "3.2.0-preview1"
203
- - ruby: "jruby-9.2.19.0"
204
- gems: "minimal"
205
+ - ruby: "2.7.7"
206
+ - ruby: "3.0.4"
207
+ - ruby: "3.1.2"
208
+ - ruby: "3.2.0-preview3"
205
209
  env_vars:
206
- - name: "_C_VERSION"
207
- value: "8"
208
- - ruby: "jruby-9.3.6.0"
210
+ - name: "_LIBYAML"
211
+ value: "1"
212
+ - ruby: "jruby-9.3.9.0"
213
+ gems: "minimal"
214
+ - ruby: "jruby-9.4.0.0"
209
215
  gems: "minimal"
210
216
  gems:
211
217
  - gem: "no_dependencies"
@@ -217,15 +223,15 @@ matrix:
217
223
  - gem: "psych-3"
218
224
  only:
219
225
  ruby:
220
- - "3.0.3"
221
- - "3.1.1"
222
- - "3.2.0-preview1"
226
+ - "3.0.4"
227
+ - "3.1.2"
228
+ - "3.2.0-preview3"
223
229
  - gem: "psych-4"
224
230
  only:
225
231
  ruby:
226
- - "3.0.3"
227
- - "3.1.1"
228
- - "3.2.0-preview1"
232
+ - "3.0.4"
233
+ - "3.1.2"
234
+ - "3.2.0-preview3"
229
235
  - gem: "que"
230
236
  - gem: "que_beta"
231
237
  - gem: "rails-3.2"
@@ -258,7 +264,7 @@ matrix:
258
264
  - "2.4.10"
259
265
  - "2.5.8"
260
266
  - "2.6.9"
261
- - "2.7.5"
267
+ - "2.7.7"
262
268
  - gem: "rails-5.1"
263
269
  only:
264
270
  ruby:
@@ -269,7 +275,7 @@ matrix:
269
275
  - "2.4.10"
270
276
  - "2.5.8"
271
277
  - "2.6.9"
272
- - "2.7.5"
278
+ - "2.7.7"
273
279
  - gem: "rails-5.2"
274
280
  only:
275
281
  ruby:
@@ -280,34 +286,34 @@ matrix:
280
286
  - "2.4.10"
281
287
  - "2.5.8"
282
288
  - "2.6.9"
283
- - "2.7.5"
284
- - "jruby-9.2.19.0"
289
+ - "2.7.7"
290
+ - "jruby-9.3.9.0"
285
291
  - gem: "rails-6.0"
286
292
  only:
287
293
  ruby:
288
294
  - "2.5.8"
289
295
  - "2.6.9"
290
- - "2.7.5"
291
- - "3.0.3"
292
- - "jruby-9.2.19.0"
296
+ - "2.7.7"
297
+ - "3.0.4"
298
+ - "jruby-9.4.0.0"
293
299
  - gem: "rails-6.1"
294
300
  only:
295
301
  ruby:
296
302
  - "2.5.8"
297
303
  - "2.6.9"
298
- - "2.7.5"
299
- - "3.0.3"
300
- - "3.1.1"
301
- - "3.2.0-preview1"
302
- - "jruby-9.2.19.0"
303
- - "jruby-9.3.6.0"
304
+ - "2.7.7"
305
+ - "3.0.4"
306
+ - "3.1.2"
307
+ - "3.2.0-preview3"
308
+ - "jruby-9.4.0.0"
304
309
  - gem: "rails-7.0"
305
310
  only:
306
311
  ruby:
307
- - "2.7.5"
308
- - "3.0.3"
309
- - "3.1.1"
310
- - "3.2.0-preview1"
312
+ - "2.7.7"
313
+ - "3.0.4"
314
+ - "3.1.2"
315
+ - "3.2.0-preview3"
316
+ - "jruby-9.4.0.0"
311
317
  - gem: "resque-1"
312
318
  bundler: "1.17.3"
313
319
  only:
@@ -319,7 +325,7 @@ matrix:
319
325
  - "2.4.10"
320
326
  - "2.5.8"
321
327
  - "2.6.9"
322
- - "2.7.5"
328
+ - "2.7.7"
323
329
  - gem: "resque-2"
324
330
  - gem: "sequel"
325
331
  - gem: "sequel-435"
@@ -332,6 +338,6 @@ matrix:
332
338
  - "2.4.10"
333
339
  - "2.5.8"
334
340
  - "2.6.9"
335
- - "2.7.5"
341
+ - "2.7.7"
336
342
  - gem: "sinatra"
337
343
  - gem: "webmachine"
@@ -5,7 +5,7 @@ require "set"
5
5
 
6
6
  module Appsignal
7
7
  # Logger that flushes logs to the AppSignal logging service
8
- class Logger < ::Logger
8
+ class Logger < ::Logger # rubocop:disable Metrics/ClassLength
9
9
  # Create a new logger instance
10
10
  #
11
11
  # @param group Name of the group for this logger.
@@ -20,7 +20,7 @@ module Appsignal
20
20
  # We support the various methods in the Ruby
21
21
  # logger class by supplying this method.
22
22
  # @api private
23
- def add(severity, message = nil, group = nil)
23
+ def add(severity, message = nil, group = nil) # rubocop:disable Metrics/CyclomaticComplexity
24
24
  severity ||= UNKNOWN
25
25
  return true if severity < level
26
26
  group = @group if group.nil?
@@ -33,6 +33,7 @@ module Appsignal
33
33
  end
34
34
  end
35
35
  return if message.nil?
36
+ message = formatter.call(severity, 0, group, message) if formatter
36
37
  severity_number = case severity
37
38
  when DEBUG
38
39
  2
@@ -64,6 +65,7 @@ module Appsignal
64
65
  return if DEBUG < level
65
66
  message = yield if message.nil? && block_given?
66
67
  return if message.nil?
68
+ message = formatter.call(DEBUG, 0, @group, message) if formatter
67
69
  Appsignal::Extension.log(
68
70
  @group,
69
71
  2,
@@ -80,6 +82,7 @@ module Appsignal
80
82
  return if INFO < level
81
83
  message = yield if message.nil? && block_given?
82
84
  return if message.nil?
85
+ message = formatter.call(INFO, 0, @group, message) if formatter
83
86
  Appsignal::Extension.log(
84
87
  @group,
85
88
  3,
@@ -96,6 +99,7 @@ module Appsignal
96
99
  return if WARN < level
97
100
  message = yield if message.nil? && block_given?
98
101
  return if message.nil?
102
+ message = formatter.call(WARN, 0, @group, message) if formatter
99
103
  Appsignal::Extension.log(
100
104
  @group,
101
105
  5,
@@ -112,6 +116,7 @@ module Appsignal
112
116
  return if ERROR < level
113
117
  message = yield if message.nil? && block_given?
114
118
  return if message.nil?
119
+ message = formatter.call(ERROR, 0, @group, message) if formatter
115
120
  Appsignal::Extension.log(
116
121
  @group,
117
122
  6,
@@ -128,6 +133,7 @@ module Appsignal
128
133
  return if FATAL < level
129
134
  message = yield if message.nil? && block_given?
130
135
  return if message.nil?
136
+ message = formatter.call(FATAL, 0, @group, message) if formatter
131
137
  Appsignal::Extension.log(
132
138
  @group,
133
139
  7,
@@ -18,17 +18,38 @@ module Appsignal
18
18
  def call
19
19
  stat = RubyVM.stat
20
20
 
21
- set_gauge(
22
- "ruby_vm",
23
- stat[:class_serial],
24
- :metric => :class_serial
25
- )
26
-
27
- set_gauge(
28
- "ruby_vm",
29
- stat[:constant_cache] ? stat[:constant_cache].values.sum : stat[:global_constant_state],
30
- :metric => :global_constant_state
31
- )
21
+ constant_cache_invalidations = stat[:constant_cache_invalidations]
22
+ if constant_cache_invalidations
23
+ set_gauge(
24
+ "ruby_vm",
25
+ constant_cache_invalidations,
26
+ :metric => :constant_cache_invalidations
27
+ )
28
+ end
29
+
30
+ constant_cache_misses = stat[:constant_cache_misses]
31
+ if constant_cache_misses
32
+ set_gauge(
33
+ "ruby_vm",
34
+ constant_cache_misses,
35
+ :metric => :constant_cache_misses
36
+ )
37
+ end
38
+
39
+ class_serial = stat[:class_serial]
40
+ if class_serial
41
+ set_gauge("ruby_vm", class_serial, :metric => :class_serial)
42
+ end
43
+
44
+ global_constant_state =
45
+ stat[:constant_cache] ? stat[:constant_cache].values.sum : stat[:global_constant_state]
46
+ if global_constant_state
47
+ set_gauge(
48
+ "ruby_vm",
49
+ global_constant_state,
50
+ :metric => :global_constant_state
51
+ )
52
+ end
32
53
 
33
54
  set_gauge("thread_count", Thread.list.size)
34
55
  if Appsignal::GarbageCollection.enabled?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "3.2.1".freeze
4
+ VERSION = "3.2.2".freeze
5
5
  end
@@ -20,12 +20,7 @@ describe Appsignal::AuthCheck do
20
20
  end
21
21
 
22
22
  def build_uri_query_string(hash)
23
- hash.map do |k, v|
24
- k.to_s.tap do |s|
25
- next unless v
26
- s << "=#{v}"
27
- end
28
- end.join("&")
23
+ URI.encode_www_form(hash)
29
24
  end
30
25
 
31
26
  describe "#perform" do
@@ -42,6 +42,20 @@ describe Appsignal::Logger do
42
42
  logger.add(::Logger::DEBUG, "Log message")
43
43
  end
44
44
  end
45
+
46
+ context "with a formatter set" do
47
+ before do
48
+ logger.formatter = proc do |_level, _timestamp, _appname, message|
49
+ "formatted: '#{message}'"
50
+ end
51
+ end
52
+
53
+ it "should log with a level, message and group" do
54
+ expect(Appsignal::Extension).to receive(:log)
55
+ .with("other_group", 3, "formatted: 'Log message'", instance_of(Appsignal::Extension::Data))
56
+ logger.add(::Logger::INFO, "Log message", "other_group")
57
+ end
58
+ end
45
59
  end
46
60
 
47
61
  [
@@ -89,6 +103,20 @@ describe Appsignal::Logger do
89
103
  end
90
104
  end
91
105
  end
106
+
107
+ context "with a formatter set" do
108
+ before do
109
+ logger.formatter = proc do |_level, _timestamp, _appname, message|
110
+ "formatted: '#{message}'"
111
+ end
112
+ end
113
+
114
+ it "should log with a level, message and group" do
115
+ expect(Appsignal::Extension).to receive(:log)
116
+ .with("group", method[1], "formatted: 'Log message'", instance_of(Appsignal::Extension::Data))
117
+ logger.send(method[0], "Log message")
118
+ end
119
+ end
92
120
  end
93
121
  end
94
122
  end
@@ -42,10 +42,15 @@ describe Appsignal::Probes::MriProbe do
42
42
  allow(GC::Profiler).to receive(:enabled?).and_return(true)
43
43
  end
44
44
 
45
- it "should track vm metrics" do
45
+ it "should track vm cache metrics" do
46
46
  probe.call
47
- expect_gauge_value("ruby_vm", :tags => { :metric => :class_serial })
48
- expect_gauge_value("ruby_vm", :tags => { :metric => :global_constant_state })
47
+ if DependencyHelper.ruby_3_2_or_newer?
48
+ expect_gauge_value("ruby_vm", :tags => { :metric => :constant_cache_invalidations })
49
+ expect_gauge_value("ruby_vm", :tags => { :metric => :constant_cache_misses })
50
+ else
51
+ expect_gauge_value("ruby_vm", :tags => { :metric => :class_serial })
52
+ expect_gauge_value("ruby_vm", :tags => { :metric => :global_constant_state })
53
+ end
49
54
  end
50
55
 
51
56
  it "tracks thread counts" do
@@ -13,6 +13,10 @@ module DependencyHelper
13
13
  ruby_version >= Gem::Version.new("3.1.0")
14
14
  end
15
15
 
16
+ def ruby_3_2_or_newer?
17
+ ruby_version >= Gem::Version.new("3.2.0")
18
+ end
19
+
16
20
  def running_jruby?
17
21
  Appsignal::System.jruby?
18
22
  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.2.1
4
+ version: 3.2.2
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-11-21 00:00:00.000000000 Z
13
+ date: 2022-12-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
@@ -448,7 +448,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
448
448
  - !ruby/object:Gem::Version
449
449
  version: '0'
450
450
  requirements: []
451
- rubygems_version: 3.3.7
451
+ rubygems_version: 3.3.26
452
452
  signing_key:
453
453
  specification_version: 4
454
454
  summary: Logs performance and exception data from your app to appsignal.com