exception_handling 2.12.0 → 2.13.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: 1125ae1526cff9890e52497ac1a8b8d93a62a481afa49a74709c5f286f53b912
4
+ data.tar.gz: 3f882364adfb48ee837fc178cb3adcb85ab6c43b90bde5e04f96aea07559efc6
5
5
  SHA512:
6
- metadata.gz: 29b73b67171866400ce1f5a07e6654593f57cb24e1de9a07d37b8e4ac039c3c8faca4d004bec784b0810c984e8caec9e10ff2aa26357a4a76fbb18dd6ad49632
7
- data.tar.gz: 567d9ff144876f3fed8429a892e16f0a4e81440a2881c790bc3dc478ef9500050b0210fca71ed94e00f289a76a234898c46f45ba9de6738ffa351c41251cbdab
6
+ metadata.gz: efbe4b3c2843a4e07daf38a83606d504714b1bfa2dedc406070fc6a1e68a66ccf379cb459f5364c0c8c8ac43b9265474ab50d9dce7f31ec78de5791ff166c195
7
+ data.tar.gz: 1a69645d781332b9e7882921dbaded4d001c87ead47a40902b55e385c21e419ed48d9c3790cb38c38392a0fe2c872e05d003814bcd57b54e6cb27b38c3828772
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] - 2022-09-15
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)
5
5
  actionmailer (>= 5.2, < 7.0)
6
6
  actionpack (>= 5.2, < 7.0)
7
7
  activesupport (>= 5.2, < 7.0)
@@ -97,7 +97,7 @@ GEM
97
97
  pry-byebug (3.8.0)
98
98
  byebug (~> 11.0)
99
99
  pry (~> 0.10)
100
- psych (3.3.2)
100
+ psych (3.3.3)
101
101
  racc (1.6.0)
102
102
  rack (2.2.3)
103
103
  rack-test (1.1.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'
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
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-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer