exception_handling 2.12.0 → 2.13.0.pre.dc.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4e00da46ba75755214ab18ec1fa16bb9b230fbaf708031b97c1bb30f2c2f854
4
- data.tar.gz: 2cf79b0eec0a66c825b98062d2b50609c8821500003f36834bded3bc5fc7ea5d
3
+ metadata.gz: 313e1290b0b4cf43b2d3a89fb98475c4d2c47d874fdd998c3d87acc2e8c0292e
4
+ data.tar.gz: fcf448503b9ae39020404f38ecdbd397305f2a523baa056e76a710b084575f47
5
5
  SHA512:
6
- metadata.gz: 29b73b67171866400ce1f5a07e6654593f57cb24e1de9a07d37b8e4ac039c3c8faca4d004bec784b0810c984e8caec9e10ff2aa26357a4a76fbb18dd6ad49632
7
- data.tar.gz: 567d9ff144876f3fed8429a892e16f0a4e81440a2881c790bc3dc478ef9500050b0210fca71ed94e00f289a76a234898c46f45ba9de6738ffa351c41251cbdab
6
+ metadata.gz: bac7d8e5af5225c7a8836e29df43fc6acaba52ed71b04cb24a79302e7bc7527ab7e754f90d6f99814f588cb60ce97f75e53807c1871fc92e7bf450cd2169d851
7
+ data.tar.gz: a236751519a6515580e5f61d54b86a6e30e0cf84fbd14b3c68a6dcaccf583401aff4ac425f597e8d488aeb59a4b7010b409a0cb2130e0c5c61ce1176d5b6bf98
data/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
5
  Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [2.13.0] - Unreleased
8
+ ### Added
9
+ - Added an option for removing the 'exception_handling.' prefix from metric names in ExceptionHandling::default_metric_name
10
+
7
11
  ## [2.12.0] - 2022-08-04
8
12
  ### Added
9
13
  - Support for passing additional Honeybadger configuration parameters
@@ -95,6 +99,7 @@ Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0
95
99
  ### Changed
96
100
  - No longer depends on hobo_support. Uses invoca-utils 0.3 instead.
97
101
 
102
+ [2.13.0]: https://github.com/Invoca/exception_handling/compare/v2.12.0...v2.13.0
98
103
  [2.12.0]: https://github.com/Invoca/exception_handling/compare/v2.11.3...v2.12.0
99
104
  [2.11.3]: https://github.com/Invoca/exception_handling/compare/v2.11.2...v2.11.3
100
105
  [2.11.2]: https://github.com/Invoca/exception_handling/compare/v2.11.1...v2.11.2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- exception_handling (2.12.0)
4
+ exception_handling (2.13.0.pre.dc.0)
5
5
  actionmailer (>= 5.2, < 7.0)
6
6
  actionpack (>= 5.2, < 7.0)
7
7
  activesupport (>= 5.2, < 7.0)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ExceptionHandling
4
- VERSION = '2.12.0'
4
+ VERSION = '2.13.0.pre.dc.0'
5
5
  end
@@ -71,7 +71,10 @@ module ExceptionHandling # never included
71
71
  EscalateCallback.register_if_configured!
72
72
  end
73
73
 
74
- def default_metric_name(exception_data, exception, treat_like_warning)
74
+ def default_metric_name(exception_data, exception, treat_like_warning, include_prefix: true)
75
+ include_prefix and Deprecation3_0.deprecation_warning("the 'expection_handling.' prefix in ExceptionHandling::default_metric_name",
76
+ "do not rely on metric names including the 'exception_handling.' prefix.")
77
+
75
78
  metric_name = if exception_data['metric_name']
76
79
  exception_data['metric_name']
77
80
  elsif exception.is_a?(ExceptionHandling::Warning)
@@ -83,7 +86,7 @@ module ExceptionHandling # never included
83
86
  "exception"
84
87
  end
85
88
 
86
- "exception_handling.#{metric_name}"
89
+ "#{'exception_handling.' if include_prefix}#{metric_name}"
87
90
  end
88
91
 
89
92
  def default_honeybadger_metric_name(honeybadger_status)
@@ -307,42 +307,91 @@ describe ExceptionHandling do
307
307
 
308
308
  context "Exception Handling" do
309
309
  context "default_metric_name" do
310
- context "when metric_name is present in exception_data" do
311
- it "include metric_name in resulting metric name" do
312
- exception = StandardError.new('this is an exception')
313
- metric = ExceptionHandling.default_metric_name({ 'metric_name' => 'special_metric' }, exception, true)
314
- expect(metric).to eq('exception_handling.special_metric')
310
+ context "with include_prefix true" do
311
+ it "logs a deprecation warning" do
312
+ expect { ExceptionHandling.default_metric_name({}, StandardError.new('this is an exception'), false) }
313
+ .to output(/DEPRECATION WARNING: the 'expection_handling\.' prefix in ExceptionHandling::default_metric_name is deprecated/).to_stderr
315
314
  end
316
- end
317
315
 
318
- context "when metric_name is not present in exception_data" do
319
- it "return exception_handling.warning when using log warning" do
320
- warning = ExceptionHandling::Warning.new('this is a warning')
321
- metric = ExceptionHandling.default_metric_name({}, warning, false)
322
- expect(metric).to eq('exception_handling.warning')
316
+ context "when metric_name is present in exception_data" do
317
+ it "include metric_name in resulting metric name" do
318
+ exception = StandardError.new('this is an exception')
319
+ metric = ExceptionHandling.default_metric_name({ 'metric_name' => 'special_metric' }, exception, true, include_prefix: true)
320
+ expect(metric).to eq('exception_handling.special_metric')
321
+ end
323
322
  end
324
323
 
325
- it "return exception_handling.exception when using log error" do
326
- exception = StandardError.new('this is an exception')
327
- metric = ExceptionHandling.default_metric_name({}, exception, false)
328
- expect(metric).to eq('exception_handling.exception')
329
- end
324
+ context "when metric_name is not present in exception_data" do
325
+ it "return exception_handling.warning when using log warning" do
326
+ warning = ExceptionHandling::Warning.new('this is a warning')
327
+ metric = ExceptionHandling.default_metric_name({}, warning, false, include_prefix: true)
328
+ expect(metric).to eq('exception_handling.warning')
329
+ end
330
330
 
331
- context "when using log error with treat_like_warning" do
332
- it "return exception_handling.unforwarded_exception when exception not present" do
333
- metric = ExceptionHandling.default_metric_name({}, nil, true)
334
- expect(metric).to eq('exception_handling.unforwarded_exception')
331
+ it "return exception_handling.exception when using log error" do
332
+ exception = StandardError.new('this is an exception')
333
+ metric = ExceptionHandling.default_metric_name({}, exception, false, include_prefix: true)
334
+ expect(metric).to eq('exception_handling.exception')
335
335
  end
336
336
 
337
- it "return exception_handling.unforwarded_exception with exception classname when exception is present" do
338
- module SomeModule
339
- class SomeException < StandardError
337
+ context "when using log error with treat_like_warning" do
338
+ it "return exception_handling.unforwarded_exception when exception not present" do
339
+ metric = ExceptionHandling.default_metric_name({}, nil, true, include_prefix: true)
340
+ expect(metric).to eq('exception_handling.unforwarded_exception')
341
+ end
342
+
343
+ it "return exception_handling.unforwarded_exception with exception classname when exception is present" do
344
+ module SomeModule
345
+ class SomeException < StandardError
346
+ end
340
347
  end
348
+
349
+ exception = SomeModule::SomeException.new('this is an exception')
350
+ metric = ExceptionHandling.default_metric_name({}, exception, true, include_prefix: true)
351
+ expect(metric).to eq('exception_handling.unforwarded_exception_SomeException')
352
+ end
353
+ end
354
+ end
355
+ end
356
+
357
+ context "with include_prefix false" do
358
+ context "when metric_name is present in exception_data" do
359
+ it "include metric_name in resulting metric name" do
360
+ exception = StandardError.new('this is an exception')
361
+ metric = ExceptionHandling.default_metric_name({ 'metric_name' => 'special_metric' }, exception, true, include_prefix: false)
362
+ expect(metric).to eq('special_metric')
363
+ end
364
+ end
365
+
366
+ context "when metric_name is not present in exception_data" do
367
+ it "return exception_handling.warning when using log warning" do
368
+ warning = ExceptionHandling::Warning.new('this is a warning')
369
+ metric = ExceptionHandling.default_metric_name({}, warning, false, include_prefix: false)
370
+ expect(metric).to eq('warning')
371
+ end
372
+
373
+ it "return exception_handling.exception when using log error" do
374
+ exception = StandardError.new('this is an exception')
375
+ metric = ExceptionHandling.default_metric_name({}, exception, false, include_prefix: false)
376
+ expect(metric).to eq('exception')
377
+ end
378
+
379
+ context "when using log error with treat_like_warning" do
380
+ it "return exception_handling.unforwarded_exception when exception not present" do
381
+ metric = ExceptionHandling.default_metric_name({}, nil, true, include_prefix: false)
382
+ expect(metric).to eq('unforwarded_exception')
341
383
  end
342
384
 
343
- exception = SomeModule::SomeException.new('this is an exception')
344
- metric = ExceptionHandling.default_metric_name({}, exception, true)
345
- expect(metric).to eq('exception_handling.unforwarded_exception_SomeException')
385
+ it "return exception_handling.unforwarded_exception with exception classname when exception is present" do
386
+ module SomeModule
387
+ class SomeException < StandardError
388
+ end
389
+ end
390
+
391
+ exception = SomeModule::SomeException.new('this is an exception')
392
+ metric = ExceptionHandling.default_metric_name({}, exception, true, include_prefix: false)
393
+ expect(metric).to eq('unforwarded_exception_SomeException')
394
+ end
346
395
  end
347
396
  end
348
397
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exception_handling
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.12.0
4
+ version: 2.13.0.pre.dc.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Invoca
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-04 00:00:00.000000000 Z
11
+ date: 2022-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -222,9 +222,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
222
222
  version: '0'
223
223
  required_rubygems_version: !ruby/object:Gem::Requirement
224
224
  requirements:
225
- - - ">="
225
+ - - ">"
226
226
  - !ruby/object:Gem::Version
227
- version: '0'
227
+ version: 1.3.1
228
228
  requirements: []
229
229
  rubygems_version: 3.1.6
230
230
  signing_key: