event_tracer 0.2.0 → 0.2.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 +20 -3
- data/lib/event_tracer/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77058f3fa969027f3d51399425d8885c60037ae6250db1cfa686fbafb8524467
|
4
|
+
data.tar.gz: 40b98f105722939c88bb364a04bfbd708c9fcfc2c76815d41d5b2318994aa9bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31fb42ad32f68d2efd4b78dbfb9d55f16563bc897eaa4c4602c5855eb092bf0f03c4308c22a91ed011663c095548029155a7a795de638405588bb162a93d723b
|
7
|
+
data.tar.gz: 58c9ec65b708b9b44fb141c9da778fbc6d56fea371a8edc9e0aaf9ef4d4a2b89855e0a88afbafd0a61312c2b8023bd7c13325bc0f7c86be13ee7d87e534dc6ad
|
@@ -7,6 +7,7 @@ require_relative './basic_decorator'
|
|
7
7
|
#
|
8
8
|
# Usage: EventTracer.register :appsignal, EventTracer::AppsignalLogger.new(Appsignal)
|
9
9
|
# appsignal_logger.info appsignal: { increment_counter: { counter_1: 1, counter_2: 2 }, set_gauge: { gauge_1: 1 } }
|
10
|
+
# appsignal_logger.info appsignal: { set_gauge: { gauge_1: { value: 1, tags: { region: 'eu' } } } }
|
10
11
|
module EventTracer
|
11
12
|
class AppsignalLogger < BasicDecorator
|
12
13
|
|
@@ -21,6 +22,8 @@ module EventTracer
|
|
21
22
|
return LogResult.new(false, "Appsignal metric #{metric} invalid") unless metric_args && metric_args.is_a?(Hash)
|
22
23
|
|
23
24
|
send_metric metric, metric_args
|
25
|
+
rescue InvalidTagError => e
|
26
|
+
return LogResult.new(false, e.message)
|
24
27
|
end
|
25
28
|
|
26
29
|
LogResult.new(true)
|
@@ -37,10 +40,24 @@ module EventTracer
|
|
37
40
|
end
|
38
41
|
|
39
42
|
def send_metric(metric, payload)
|
40
|
-
payload.each do |increment,
|
41
|
-
|
43
|
+
payload.each do |increment, attribute|
|
44
|
+
if attribute.is_a?(Hash)
|
45
|
+
begin
|
46
|
+
appsignal.send(
|
47
|
+
metric,
|
48
|
+
increment,
|
49
|
+
attribute.fetch(:value),
|
50
|
+
attribute.fetch(:tags)
|
51
|
+
)
|
52
|
+
rescue KeyError
|
53
|
+
raise InvalidTagError, "Appsignal payload { #{increment}: #{attribute} } invalid"
|
54
|
+
end
|
55
|
+
else
|
56
|
+
appsignal.send(metric, increment, attribute)
|
57
|
+
end
|
42
58
|
end
|
43
59
|
end
|
44
|
-
|
45
60
|
end
|
61
|
+
|
62
|
+
class InvalidTagError < StandardError; end
|
46
63
|
end
|
data/lib/event_tracer/version.rb
CHANGED
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.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- melvrickgoh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.1.4
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.1.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
89
|
requirements: []
|
90
|
-
rubygems_version: 3.
|
90
|
+
rubygems_version: 3.0.8
|
91
91
|
signing_key:
|
92
92
|
specification_version: 4
|
93
93
|
summary: Thin wrapper for formatted logging/ metric services to be used as a single
|