event_tracer 0.4.4 → 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: 1eb75aebdf04e2a3797b9cb77780ab1f1960846b9332899d466ef67e269f599d
4
- data.tar.gz: 9ffcabba2a3435bab02a8e6e2929250ee5aa659069b1d006d29c3df084923a45
3
+ metadata.gz: f84ff22349c762a429e58f5913884a3eff066c983881ed16d9f846785c27184f
4
+ data.tar.gz: ccb8508e0eba3e08f2312248618d2fff80ff5bab70c08c5c9754b04ee000088e
5
5
  SHA512:
6
- metadata.gz: fa666b368a2a7cdb565a850b460e0f763b195550cfdd640d9d7970709370cdc531eda7b48caab30b4687c00002bed32540511f3df4d83606ff1a33f6885b4698
7
- data.tar.gz: 94dfdbc766ba5dcc02fac74d81ced3ed516d9a29ad578a8472810955aa66ffe0f92db1507593d2846951ff613e1524cb07fb37e8d8f2f4e7ae43b9db4c05161b
6
+ metadata.gz: 588eb7e39ca26221be2c15a986d5862a6f102713a8be329e245ae086c0503daa0c2e1d54d5996a008c1a6a93855f5f16b33eea551902438926fb1e29dcd29720
7
+ data.tar.gz: 43d3d079f656213b87f8666bca064dd83910282a4f7ffe3bb9dc1106f25ceea8c6b2e6dafbb8181c20c1377e515a6a37311cb495d4b9cab7c48016f2a79124ea
@@ -43,8 +43,9 @@ module EventTracer
43
43
  end
44
44
  when Hash
45
45
  metrics.each do |metric_name, metric_payload|
46
- metric_type = SUPPORTED_METRIC_TYPES[metric_payload.fetch(:type).to_sym]
47
- appsignal.public_send(metric_type, metric_name, metric_payload.fetch(:value), tags) if metric_type
46
+ payload = metric_payload.transform_keys(&:to_sym)
47
+ metric_type = SUPPORTED_METRIC_TYPES[payload.fetch(:type).to_sym]
48
+ appsignal.public_send(metric_type, metric_name, payload.fetch(:value), tags) if metric_type
48
49
  end
49
50
  end
50
51
 
@@ -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
@@ -45,8 +45,9 @@ module EventTracer
45
45
  end
46
46
  when Hash
47
47
  metrics.each do |metric_name, metric_payload|
48
- metric_type = SUPPORTED_METRIC_TYPES[metric_payload.fetch(:type).to_sym]
49
- datadog.public_send(metric_type, metric_name, metric_payload.fetch(:value), tags: tags) if metric_type
48
+ payload = metric_payload.transform_keys(&:to_sym)
49
+ metric_type = SUPPORTED_METRIC_TYPES[payload.fetch(:type).to_sym]
50
+ datadog.public_send(metric_type, metric_name, payload.fetch(:value), tags: tags) if metric_type
50
51
  end
51
52
  end
52
53
 
@@ -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.4'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
data/lib/event_tracer.rb CHANGED
@@ -3,7 +3,7 @@ require 'event_tracer/log_result'
3
3
 
4
4
  module EventTracer
5
5
 
6
- LOG_TYPES = %i(info warn error)
6
+ LOG_TYPES = %i(debug info warn error)
7
7
 
8
8
  @loggers = {}
9
9
 
@@ -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.4
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-11 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