ffwd 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ffwd/event.rb +30 -6
- data/lib/ffwd/event_emitter.rb +8 -8
- data/lib/ffwd/metric.rb +30 -6
- data/lib/ffwd/metric_emitter.rb +7 -7
- data/lib/ffwd/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0eaf467d00c75edea35139ab207a456cbd37b78d
|
4
|
+
data.tar.gz: 4e8a5de41839bfc8f5460b8d70f085f969082635
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b44d46575fcedd217b4ebdd76ffef9a40eabf272edf393eb92a646e4e89764f03f1147b7087462f3a4e9df0784347e7f611aeb64166d2740dd8c42cd3830ffdb
|
7
|
+
data.tar.gz: 14b0775875d1b1d658cccbe021832291755c09273a9fa8bae4b4f34e5ee563042a3bcff69b3fc80a9c58ee0c0296f48f01e0b26a3adff728a47c8f3017e57016
|
data/lib/ffwd/event.rb
CHANGED
@@ -13,6 +13,8 @@
|
|
13
13
|
# License for the specific language governing permissions and limitations under
|
14
14
|
# the License.
|
15
15
|
|
16
|
+
require_relative 'utils'
|
17
|
+
|
16
18
|
module FFWD
|
17
19
|
# Struct used to define all fields related to an event.
|
18
20
|
EventStruct = Struct.new(
|
@@ -33,17 +35,32 @@ module FFWD
|
|
33
35
|
# A time to live associated with the event.
|
34
36
|
:ttl,
|
35
37
|
# Tags associated with the event.
|
36
|
-
:
|
38
|
+
:external_tags,
|
39
|
+
# Tags which are statically provided by the internal implementation.
|
40
|
+
:fixed_tags,
|
37
41
|
# Attributes (extra fields) associated with the event.
|
38
|
-
:
|
42
|
+
:external_attr,
|
43
|
+
# Attributes which are statically provided by the internal implementation.
|
44
|
+
:fixed_attr
|
39
45
|
)
|
40
46
|
|
41
47
|
# A convenience class for each individual event.
|
42
48
|
class Event < EventStruct
|
43
49
|
def self.make opts = {}
|
44
50
|
new(opts[:time], opts[:key], opts[:value], opts[:host], opts[:source],
|
45
|
-
opts[:state], opts[:description], opts[:ttl],
|
46
|
-
opts[:
|
51
|
+
opts[:state], opts[:description], opts[:ttl],
|
52
|
+
opts[:tags], opts[:fixed_tags],
|
53
|
+
opts[:attributes], opts[:fixed_attr])
|
54
|
+
end
|
55
|
+
|
56
|
+
# maintained for backwards compatibility, but implementors are encouraged
|
57
|
+
# to use internal/external attributes directly.
|
58
|
+
def attributes
|
59
|
+
FFWD.merge_hashes fixed_attr, external_attr
|
60
|
+
end
|
61
|
+
|
62
|
+
def tags
|
63
|
+
FFWD.merge_sets fixed_tags, external_tags
|
47
64
|
end
|
48
65
|
|
49
66
|
# Convert event to a sparse hash.
|
@@ -57,8 +74,15 @@ module FFWD
|
|
57
74
|
d[:state] = state if state
|
58
75
|
d[:description] = description if description
|
59
76
|
d[:ttl] = ttl if ttl
|
60
|
-
|
61
|
-
|
77
|
+
|
78
|
+
if t = tags and not t.empty?
|
79
|
+
d[:tags] = t
|
80
|
+
end
|
81
|
+
|
82
|
+
if a = attributes and not a.empty?
|
83
|
+
d[:attributes] = a
|
84
|
+
end
|
85
|
+
|
62
86
|
d
|
63
87
|
end
|
64
88
|
end
|
data/lib/ffwd/event_emitter.rb
CHANGED
@@ -42,15 +42,15 @@ module FFWD
|
|
42
42
|
@attributes = attributes
|
43
43
|
end
|
44
44
|
|
45
|
-
def emit
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
45
|
+
def emit d
|
46
|
+
d[:time] ||= Time.now
|
47
|
+
d[:host] ||= @host if @host
|
48
|
+
d[:ttl] ||= @ttl if @ttl
|
49
|
+
d[:value] = nil if (v = d[:value] and v.is_a?(Float) and v.nan?)
|
50
|
+
d[:fixed_tags] = @tags
|
51
|
+
d[:fixed_attr] = @attributes
|
52
52
|
|
53
|
-
@output.event Event.make(
|
53
|
+
@output.event Event.make(d)
|
54
54
|
rescue => e
|
55
55
|
log.error "Failed to emit event", e
|
56
56
|
end
|
data/lib/ffwd/metric.rb
CHANGED
@@ -13,6 +13,8 @@
|
|
13
13
|
# License for the specific language governing permissions and limitations under
|
14
14
|
# the License.
|
15
15
|
|
16
|
+
require_relative 'utils'
|
17
|
+
|
16
18
|
module FFWD
|
17
19
|
# Struct used to define all fields related to a metric.
|
18
20
|
MetricStruct = Struct.new(
|
@@ -26,17 +28,32 @@ module FFWD
|
|
26
28
|
:host,
|
27
29
|
# The source metric this metric was derived from (if any).
|
28
30
|
:source,
|
29
|
-
# Tags associated
|
30
|
-
:
|
31
|
+
# Tags associated with the event.
|
32
|
+
:external_tags,
|
33
|
+
# Tags which are statically provided by the internal implementation.
|
34
|
+
:fixed_tags,
|
31
35
|
# Attributes (extra fields) associated to the metric.
|
32
|
-
:
|
36
|
+
:external_attr,
|
37
|
+
# Attributes which are statically provided by the internal implementation.
|
38
|
+
:fixed_attr
|
33
39
|
)
|
34
40
|
|
35
41
|
# A convenience class for each individual metric.
|
36
42
|
class Metric < MetricStruct
|
37
43
|
def self.make opts={}
|
38
44
|
new(opts[:time], opts[:key], opts[:value], opts[:host], opts[:source],
|
39
|
-
opts[:tags], opts[:
|
45
|
+
opts[:tags], opts[:fixed_tags],
|
46
|
+
opts[:attributes], opts[:fixed_attr])
|
47
|
+
end
|
48
|
+
|
49
|
+
# maintained for backwards compatibility, but implementors are encouraged
|
50
|
+
# to use internal/external attributes directly.
|
51
|
+
def attributes
|
52
|
+
FFWD.merge_hashes fixed_attr, external_attr
|
53
|
+
end
|
54
|
+
|
55
|
+
def tags
|
56
|
+
FFWD.merge_sets fixed_tags, external_tags
|
40
57
|
end
|
41
58
|
|
42
59
|
# Convert metric to a sparse hash.
|
@@ -47,8 +64,15 @@ module FFWD
|
|
47
64
|
d[:value] = value if value
|
48
65
|
d[:host] = host if host
|
49
66
|
d[:source] = source if source
|
50
|
-
|
51
|
-
|
67
|
+
|
68
|
+
if t = tags and not t.empty?
|
69
|
+
d[:tags] = t
|
70
|
+
end
|
71
|
+
|
72
|
+
if a = attributes and not a.empty?
|
73
|
+
d[:attributes] = a
|
74
|
+
end
|
75
|
+
|
52
76
|
d
|
53
77
|
end
|
54
78
|
end
|
data/lib/ffwd/metric_emitter.rb
CHANGED
@@ -36,14 +36,14 @@ module FFWD
|
|
36
36
|
@attributes = attributes
|
37
37
|
end
|
38
38
|
|
39
|
-
def emit
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
def emit d
|
40
|
+
d[:time] ||= Time.now
|
41
|
+
d[:host] ||= @host if @host
|
42
|
+
d[:fixed_tags] = @tags
|
43
|
+
d[:fixed_attr] = @attributes
|
44
|
+
d[:value] = nil if (v = d[:value] and v.is_a?(Float) and v.nan?)
|
45
45
|
|
46
|
-
@output.metric Metric.make(
|
46
|
+
@output.metric Metric.make(d)
|
47
47
|
rescue => e
|
48
48
|
log.error "Failed to emit metric", e
|
49
49
|
end
|
data/lib/ffwd/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffwd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John-John Tedro
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-03-
|
12
|
+
date: 2015-03-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|