graphite-metric 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
data/lib/graphite-metric/raw.rb
CHANGED
@@ -36,18 +36,24 @@ module GraphiteMetric
|
|
36
36
|
raw_headers, raw_metrics = raw.split("|")
|
37
37
|
|
38
38
|
metric_name, from, to, step = raw_headers.split(",")
|
39
|
-
|
39
|
+
|
40
40
|
current_step = 0
|
41
41
|
raw_metrics.split(",").each do |raw_metric|
|
42
42
|
@metrics << {
|
43
43
|
:key => metric_name,
|
44
44
|
:timestamp => from.to_i + current_step,
|
45
|
-
:value =>
|
45
|
+
:value => float(raw_metric)
|
46
46
|
}
|
47
47
|
current_step += step.to_i
|
48
48
|
end
|
49
49
|
end
|
50
50
|
self
|
51
51
|
end
|
52
|
+
|
53
|
+
def float(raw_metric)
|
54
|
+
Float(raw_metric)
|
55
|
+
rescue
|
56
|
+
0
|
57
|
+
end
|
52
58
|
end
|
53
59
|
end
|
@@ -1,2 +1,2 @@
|
|
1
|
-
my.first.metric,1336559725,1336559845,60|
|
1
|
+
my.first.metric,1336559725,1336559845,60|None,9.21,8.333
|
2
2
|
my.second.metric,1336559725,1336559845,60|1.1,2.999,3.50
|
@@ -1 +1 @@
|
|
1
|
-
my.metric,1336559725,1336559845,60|34.999,35.10,
|
1
|
+
my.metric,1336559725,1336559845,60|34.999,35.10,None
|
data/test/test_helper.rb
CHANGED
@@ -27,7 +27,7 @@ module TestHelpers
|
|
27
27
|
{
|
28
28
|
:key => "my.metric",
|
29
29
|
:timestamp => 1336559845,
|
30
|
-
:value =>
|
30
|
+
:value => 0
|
31
31
|
}
|
32
32
|
]
|
33
33
|
end
|
@@ -41,7 +41,7 @@ module TestHelpers
|
|
41
41
|
{
|
42
42
|
:key => "my.first.metric",
|
43
43
|
:timestamp => 1336559725,
|
44
|
-
:value =>
|
44
|
+
:value => 0
|
45
45
|
},
|
46
46
|
{
|
47
47
|
:key => "my.first.metric",
|
@@ -76,7 +76,7 @@ module TestHelpers
|
|
76
76
|
"my.first.metric" => [
|
77
77
|
{
|
78
78
|
:timestamp => 1336559725,
|
79
|
-
:value =>
|
79
|
+
:value => 0
|
80
80
|
},
|
81
81
|
{
|
82
82
|
:timestamp => 1336559785,
|