event_tracer 0.4.5 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/event_tracer/appsignal_logger.rb +3 -2
- data/lib/event_tracer/buffered_logger.rb +2 -0
- data/lib/event_tracer/config.rb +2 -0
- data/lib/event_tracer/datadog_logger.rb +9 -5
- data/lib/event_tracer/error_with_payload.rb +10 -0
- data/lib/event_tracer/version.rb +1 -1
- data/lib/event_tracer.rb +9 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c2e5bbf4d4546e3ece6589508e00fc01eb30ca41b572ff2afbb4185b73c93d5
|
4
|
+
data.tar.gz: e3fe3b13cf8fc1e43732a75386502618427cab7a449fe95b8d2c69789383947b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17cd02fe83f7725b8e2a9d495979f5b183e2a63fc071b1b58795adfb910ed0c9048f1692b608d78d0348377b4c9216c1601481234ff60791206b2c1797e7d51f
|
7
|
+
data.tar.gz: ba23fdd140689fa467671a1f28024f38ea6b5c9e1ddd911c4980cbb91d57faf7a5ad2ce028aaffcead4f75d06ac4d5e30b0728525a3dac074ac366b8318f2797
|
@@ -43,8 +43,9 @@ module EventTracer
|
|
43
43
|
end
|
44
44
|
when Hash
|
45
45
|
metrics.each do |metric_name, metric_payload|
|
46
|
-
|
47
|
-
|
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
|
|
data/lib/event_tracer/config.rb
CHANGED
@@ -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
|
@@ -18,15 +18,16 @@ module EventTracer
|
|
18
18
|
gauge: :gauge,
|
19
19
|
set: :set,
|
20
20
|
histogram: :histogram
|
21
|
-
}
|
21
|
+
}.freeze
|
22
22
|
DEFAULT_METRIC_TYPE = :count
|
23
23
|
DEFAULT_COUNTER = 1
|
24
24
|
|
25
25
|
attr_reader :allowed_tags
|
26
26
|
|
27
|
-
def initialize(decoratee, allowed_tags: [])
|
27
|
+
def initialize(decoratee, allowed_tags: [], default_tags: {})
|
28
28
|
super(decoratee)
|
29
29
|
@allowed_tags = allowed_tags.freeze
|
30
|
+
@default_tags = default_tags.freeze
|
30
31
|
end
|
31
32
|
|
32
33
|
LOG_TYPES.each do |log_type|
|
@@ -45,8 +46,9 @@ module EventTracer
|
|
45
46
|
end
|
46
47
|
when Hash
|
47
48
|
metrics.each do |metric_name, metric_payload|
|
48
|
-
|
49
|
-
|
49
|
+
payload = metric_payload.transform_keys(&:to_sym)
|
50
|
+
metric_type = SUPPORTED_METRIC_TYPES[payload.fetch(:type).to_sym]
|
51
|
+
datadog.public_send(metric_type, metric_name, payload.fetch(:value), tags: tags) if metric_type
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
@@ -58,12 +60,14 @@ module EventTracer
|
|
58
60
|
|
59
61
|
alias_method :datadog, :decoratee
|
60
62
|
|
63
|
+
attr_reader :default_tags
|
64
|
+
|
61
65
|
def valid_args?(metrics)
|
62
66
|
metrics && (metrics.is_a?(Hash) || metrics.is_a?(Array))
|
63
67
|
end
|
64
68
|
|
65
69
|
def build_tags(args)
|
66
|
-
args.slice(*allowed_tags).map do |tag, value|
|
70
|
+
@default_tags.merge(args.slice(*allowed_tags)).map do |tag, value|
|
67
71
|
"#{tag}:#{value}"
|
68
72
|
end
|
69
73
|
end
|
data/lib/event_tracer/version.rb
CHANGED
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
|
-
|
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
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- melvrickgoh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-18 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
|