alephant-logger 0.1.0 → 0.2.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
  SHA1:
3
- metadata.gz: 2d605d1b63ad9aba8fa73757565282ab99da4315
4
- data.tar.gz: 8c5aaba175a66c483b007996b565e1bd33b47eac
3
+ metadata.gz: de780cad17918478c874e67e2b92f664e4be91ee
4
+ data.tar.gz: aaa9ae2aca771d382386706ada2cceb59171249e
5
5
  SHA512:
6
- metadata.gz: c32c78d2569da9febbf690ede022a1f455bd06d6a58300985d94c2210008b89b170166752df5366a1a8ac9a8ea2134d5263476041635fc8bc245bb2ef3a506a5
7
- data.tar.gz: b481bd868cd2a352f5e020412120d4254c399bfa7879e6a76c220eea464fd65e0d65b8feed6e273a5f24708a2914e3245cc2c0c9a4f99a140298ce316f705758
6
+ metadata.gz: 2dee305aad70a33dc38ac5f64e9ba51851298bb16e42d3be030b6827d14546bb951a492fcb0b93c98d342150b848a952191ce2019f9cd5f645c42e69c59d06cc
7
+ data.tar.gz: 41753b2edd992d33a8c330e75035deb733b514c16760bd7dd95b00f952230c3ff40a5d47d1975f185d48424dd93504977c8695d3e2197fee31cf643e4b5ce684
data/README.md CHANGED
@@ -75,13 +75,9 @@ class Foo
75
75
  logger.error "great error"
76
76
  logger.warn "so warn"
77
77
  logger.fatal "ooh fatal"
78
-
79
- # We set the value of the metric to 123
80
- logger.metric({:name => "SomeMetricName", :unit => "Count", :value => 123})
81
-
82
- # Notice that no :value key is specified, meaning we'll increment the last seen value
83
- # If this metric hasn't been set within the last hour then we'll reset the value back to zero
84
- logger.metric({:name => "SomeMetricName", :unit => "Count"})
78
+
79
+ # Without the CloudWatchDecorator the `metric` call is a no-op
80
+ logger.metric({:name => "SomeMetricName", :unit => "Count", :value => 1})
85
81
  end
86
82
  end
87
83
 
@@ -14,15 +14,17 @@ module Alephant
14
14
  def metric(opts)
15
15
  name, value, unit, dimensions = opts.values_at(:name, :value, :unit, :dimensions)
16
16
 
17
- cloudwatch.put_metric_data(
18
- :namespace => namespace,
19
- :metric_data => [{
20
- :metric_name => name,
21
- :value => determine(name, value),
22
- :unit => unit || "None",
23
- :dimensions => parse(dimensions || {})
24
- }]
25
- )
17
+ Thread.new do
18
+ cloudwatch.put_metric_data(
19
+ :namespace => namespace,
20
+ :metric_data => [{
21
+ :metric_name => name,
22
+ :value => value,
23
+ :unit => unit || "None",
24
+ :dimensions => parse(dimensions || {})
25
+ }]
26
+ )
27
+ end
26
28
  end
27
29
 
28
30
  # Ruby's Kernel implements a `warn` method
@@ -50,41 +52,6 @@ module Alephant
50
52
  }
51
53
  end
52
54
  end
53
-
54
- def determine(name, value)
55
- value ? value : increment_metric_value(name)
56
- end
57
-
58
- def increment_metric_value(name)
59
- stats = get_stats name
60
- stats.datapoints.size == 0 ? 0 : stats.datapoints.last[:sum] += 1
61
- end
62
-
63
- def get_stats(name)
64
- stats_for(filter_metric name).tap do |stats|
65
- sort stats.datapoints if stats.datapoints.size > 0
66
- end
67
- end
68
-
69
- def filter_metric(name)
70
- filter_namespace.filter("metric_name", name)
71
- end
72
-
73
- def filter_namespace
74
- cloudwatch.metrics.filter("namespace", namespace)
75
- end
76
-
77
- def stats_for(metric)
78
- metric.first.statistics({
79
- :statistics => ["Sum"],
80
- :start_time => Time.now - ONE_HOUR,
81
- :end_time => Time.now
82
- })
83
- end
84
-
85
- def sort(stats)
86
- stats.sort! { |a, b| a[:timestamp] <=> b[:timestamp] }
87
- end
88
55
  end
89
56
  end
90
57
  end
@@ -1,5 +1,5 @@
1
1
  module Alephant
2
2
  module Logger
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alephant-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Kenny
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-05 00:00:00.000000000 Z
11
+ date: 2014-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk