app_monit 0.0.1 → 0.0.2

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: 4e1109ea294bf183a829e22b2dcb4629637deb5a
4
- data.tar.gz: 7fe39bad8e6db970a2355518bd8cfa049c28a4df
3
+ metadata.gz: 6dc9e44529d531ea68014aa8ae4a9e3db8b58606
4
+ data.tar.gz: 604fec1a5f824061397732fdde64f78b6e699eed
5
5
  SHA512:
6
- metadata.gz: 611e7fb651484d36800ffcda8d43554ecd0b0a656d5c51e26eb9011ef1e5d26c8a11e8136f615a88b49015a166c4d8f40e578084107ee770e603d345b7bfce6b
7
- data.tar.gz: cad200e2abd1d74c6d21be8f8358f88759d9b766b3bca67ae1730b6b7b7304e949d611fb4d46cc5754e9f70127c41c3bd00cdcaa6849ac41171c02c355f013c6
6
+ metadata.gz: 9171a668759d6fb693299ab8cc6c04f415e7ce8934bd0b35b36665005dd8e198a21f8790fa976fa6cd7f060a895f4b3bbf322089b4d2d2535943863ad24edf3e
7
+ data.tar.gz: f8eb9f13c51202064f09b0166fde7da9c97c6c107ed581b4a77b903f16d15d9db56e90660ea023d9aef6a90a9b2f291e00cbaf7a4e98f59a6c68018fb667ab96
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ app_monit_gem
data/README.md CHANGED
@@ -20,7 +20,108 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- TODO: Write usage instructions here
23
+ ### Configure the client
24
+
25
+ AppMonit::Config.api_key = '<YOUR_API_KEY>'
26
+ AppMonit::Config.end_point = 'https://api.appmon.it'
27
+ AppMonit::Config.env = Rails.env.to_s
28
+
29
+ ### Create an event
30
+
31
+ event_name = 'authentication'
32
+ payload_hash = {user: {id: 1, name: 'John'} }
33
+ AppMonit::Event.create(event_name, payload_hash)
34
+
35
+ ### Query
36
+
37
+ You can use the following metrics to query your data
38
+
39
+ * count
40
+ * count_unique
41
+ * minimum
42
+ * maximum
43
+ * average
44
+ * sum
45
+ * funnel
46
+
47
+ AppMonit::Event.create(:registered, user: {id: '1'})
48
+ AppMonit::Event.create(:registered, user: {id: '2'})
49
+ AppMonit::Event.create(:purchase, user: {id: '1'}, product: { price_in_cents: 100, name: 'water', alcoholic: false })
50
+ AppMonit::Event.create(:purchase, user: {id: '1'}, product: { price_in_cents: 150, name: 'soda', alcoholic: false })
51
+ AppMonit::Event.create(:purchase, user: {id: '1'}, product: { price_in_cents: 200, name: 'beer', alcoholic: true })
52
+
53
+ #### count
54
+ AppMonit::Query.count(:purchase) # { 'result' => 3 }
55
+
56
+ #### count
57
+ AppMonit::Query.count_unique(:purchase) # { 'result' => 2, target_property: 'product.name' }
58
+
59
+ #### minimum
60
+ AppMonit::Query.minimum(:purchase, target_property: 'product.price_in_cents') # { 'result' => 100 }
61
+
62
+ #### minimum
63
+ AppMonit::Query.maximum(:purchase, target_property: 'product.price_in_cents') # { 'result' => 200 }
64
+
65
+ #### average
66
+ AppMonit::Query.average(:purchase, target_property: 'product.price_in_cents') # { 'result' => 150 }
67
+
68
+ #### sum
69
+ AppMonit::Query.sum(:purchase, target_property: 'product.price_in_cents') # { 'result' => 450 }
70
+
71
+ #### funnel
72
+ AppMonit::Query.funnel(steps: [
73
+ { event_collection: 'registered', actor_property: 'user.id'},
74
+ { event_collection: 'purchase', actor_property: 'user.id'}
75
+ ] # { 'result' => { 'result' => [ 2, 1], 'steps' => [{ event_collection: 'registered', actor_property: 'user.id'},
76
+ { event_collection: 'purchase', actor_property: 'user.id'}]
77
+
78
+ #### Timeframe
79
+ AppMonit::Query.count('registered', timeframe: 'this_week')
80
+
81
+ Options
82
+
83
+ * this_minute
84
+ * this_hour
85
+ * this_day
86
+ * this_week
87
+ * this_month
88
+ * this_year
89
+
90
+ Or with n: this_n_minutes (n = 2 => this_2_minutes)
91
+
92
+ This can also be replaced with previous: previous_minute and previous_n_minutes
93
+
94
+ #### Interval
95
+ This can be used with timeframe
96
+ AppMonit::Query.count('registered', timeframe: 'this_week', interval: 'daily')
97
+
98
+ * minutely
99
+ * hourly
100
+ * daily
101
+ * monthly
102
+ * yearly
103
+ * weekly
104
+
105
+ Also with n: every_n_minutes (n = 2 => every_2_minutes)
106
+
107
+ #### Group by
108
+ AppMonit::Query.count('registered', group_by: 'alcoholic') # { 'result' => [ {'alcoholic' => true, result => 1 }
109
+ {'alcoholic' => false, result => 2 }]
110
+
111
+ #### Filter
112
+ AppMonit::Query.count('registered', filters: [{property_name: 'product.name', operator: 'eq', property_value: 'soda'}])
113
+
114
+ Allowed operators
115
+
116
+ * eq
117
+ * neq
118
+ * lt
119
+ * lte
120
+ * gt
121
+ * gte
122
+ * exists
123
+ * in
124
+ * nin
24
125
 
25
126
  ## Contributing
26
127
 
@@ -1,7 +1,7 @@
1
1
  module AppMonit
2
2
  class Config
3
3
  class << self
4
- attr_writer :api_key, :env, :end_point
4
+ attr_writer :api_key, :env, :end_point, :fail_silent
5
5
 
6
6
  def api_key
7
7
  @api_key || raise(ApiKeyNotSetError.new("Please set your API key"))
@@ -14,6 +14,10 @@ module AppMonit
14
14
  def end_point
15
15
  @end_point || "http://api.appmon.it"
16
16
  end
17
+
18
+ def fail_silent
19
+ @fail_silent || false
20
+ end
17
21
  end
18
22
  end
19
23
  end
@@ -6,12 +6,16 @@ module AppMonit
6
6
  create!(*args)
7
7
  rescue Http::Error
8
8
  false
9
+ rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse,
10
+ Net::HTTPHeaderSyntaxError, Net::ProtocolError => error
11
+ raise error unless AppMonit::Config.fail_silent
12
+ false
9
13
  end
10
14
 
11
15
  def self.create!(name, data_hash = {})
12
16
  created_at = data_hash.delete(:created_at) || Time.now.utc
13
17
 
14
- message = { created_at: created_at, name: name, payload: data_hash }
18
+ message = { created_at: created_at, name: name, payload: data_hash }
15
19
  client.post('/v1/events', message)
16
20
  end
17
21
 
@@ -1,3 +1,3 @@
1
1
  module AppMonit
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -31,6 +31,26 @@ describe AppMonit::Event do
31
31
  assert_equal false, subject.create
32
32
  end
33
33
  end
34
+
35
+ describe 'when the AppMonit::Config.fail_silent is set' do
36
+ it 'returns false if any Http related error is raised' do
37
+ AppMonit::Config.fail_silent = true
38
+
39
+ subject.stub(:create!, -> { raise Timeout::Error }) do
40
+ assert_equal false, subject.create
41
+ end
42
+ end
43
+ end
44
+
45
+ describe 'when the AppMonit::Config.fail_silent is NOT set' do
46
+ it 'raises the rescued Http related error again' do
47
+ AppMonit::Config.fail_silent = false
48
+
49
+ subject.stub(:create!, -> { raise Timeout::Error }) do
50
+ assert_raises(Timeout::Error) { subject.create }
51
+ end
52
+ end
53
+ end
34
54
  end
35
55
 
36
56
  describe '#create!' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_monit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Redmar Kerkhoff
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-29 00:00:00.000000000 Z
12
+ date: 2014-04-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -104,6 +104,7 @@ extensions: []
104
104
  extra_rdoc_files: []
105
105
  files:
106
106
  - ".gitignore"
107
+ - ".ruby-gemset"
107
108
  - ".ruby-version"
108
109
  - ".travis.yml"
109
110
  - Gemfile