event_tracer 0.4.6 → 0.5.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: 64dde68b086b57c4b676d62613a5a36be4fa5c754ccb4acd167aa5e69b4247d8
4
- data.tar.gz: '083bca3d0a990b4d0ac49a20935c6d160b4880604fdeb48bb050720f1713820f'
3
+ metadata.gz: f84ff22349c762a429e58f5913884a3eff066c983881ed16d9f846785c27184f
4
+ data.tar.gz: ccb8508e0eba3e08f2312248618d2fff80ff5bab70c08c5c9754b04ee000088e
5
5
  SHA512:
6
- metadata.gz: 68f56c5bab8b095372ee8dbbe993eb08d9c1692acf7774e3c003abcebb8ac07093eddabb79012c9a6abbb42662da626d4b69ad11221616a6dcebd012c56fb868
7
- data.tar.gz: ec619f4d64f70a81371063a0ac3ec2fa6666db0030b3af45b364b01de6664757c9824ac010179eeb3af147eb9b2fbd48acc53a3094926891199613ba31d2826a
6
+ metadata.gz: 588eb7e39ca26221be2c15a986d5862a6f102713a8be329e245ae086c0503daa0c2e1d54d5996a008c1a6a93855f5f16b33eea551902438926fb1e29dcd29720
7
+ data.tar.gz: 43d3d079f656213b87f8666bca064dd83910282a4f7ffe3bb9dc1106f25ceea8c6b2e6dafbb8181c20c1377e515a6a37311cb495d4b9cab7c48016f2a79124ea
@@ -46,6 +46,8 @@ module EventTracer
46
46
  )
47
47
 
48
48
  worker.perform_async(filtered_payloads) if filtered_payloads.any?
49
+ rescue StandardError => error
50
+ raise EventTracer::ErrorWithPayload.new(error, payloads)
49
51
  end
50
52
 
51
53
  def filter_invalid_data(payloads)
@@ -12,6 +12,7 @@ module EventTracer
12
12
  setting :dynamo_db_table_name, default: 'logs'
13
13
  setting :dynamo_db_client
14
14
  setting :dynamo_db_queue_name, default: 'low'
15
+ setting :error_handler, default: ->(error, _payload) { raise error }
15
16
  else
16
17
  setting :app_name, 'app_name'
17
18
 
@@ -19,6 +20,7 @@ module EventTracer
19
20
  setting :dynamo_db_table_name, 'logs'
20
21
  setting :dynamo_db_client
21
22
  setting :dynamo_db_queue_name, 'low'
23
+ setting :error_handler, ->(error, _payload) { raise error }
22
24
  end
23
25
  end
24
26
  end
@@ -0,0 +1,10 @@
1
+ module EventTracer
2
+ class ErrorWithPayload < StandardError
3
+ attr_reader :payload
4
+
5
+ def initialize(error, payload)
6
+ super(error)
7
+ @payload = payload
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module EventTracer
2
- VERSION = '0.4.6'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
data/lib/event_tracer.rb CHANGED
@@ -32,7 +32,15 @@ module EventTracer
32
32
 
33
33
  loggers.each do |code, logger|
34
34
  if args[:action] && args[:message]
35
- result.record code, logger.send(log_type, **args)
35
+ begin
36
+ result.record code, logger.send(log_type, **args)
37
+ rescue EventTracer::ErrorWithPayload => error
38
+ EventTracer::Config.config.error_handler.call(error.cause || error, error.payload)
39
+ result.record code, LogResult.new(false, error.message)
40
+ rescue StandardError => error
41
+ EventTracer::Config.config.error_handler.call(error, args)
42
+ result.record code, LogResult.new(false, error.message)
43
+ end
36
44
  else
37
45
  result.record code, LogResult.new(false, 'Fields action & message need to be populated')
38
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event_tracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - melvrickgoh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-23 00:00:00.000000000 Z
11
+ date: 2022-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -100,6 +100,7 @@ files:
100
100
  - lib/event_tracer/dynamo_db/default_processor.rb
101
101
  - lib/event_tracer/dynamo_db/logger.rb
102
102
  - lib/event_tracer/dynamo_db/worker.rb
103
+ - lib/event_tracer/error_with_payload.rb
103
104
  - lib/event_tracer/log_result.rb
104
105
  - lib/event_tracer/version.rb
105
106
  homepage: https://github.com/melvrickgoh/event_tracer