app_monit 0.0.4 → 0.0.5

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: 7592815c09ea9a8c41849e706fc4c0f890897dbd
4
- data.tar.gz: 182997dbbcf2280f9bb30305ef0038418493f464
3
+ metadata.gz: b45442d97743d84c104c4ff7d9f353e68f0c7d2f
4
+ data.tar.gz: 82ea6df8c1bf81b4702570735e65c07e6ecede16
5
5
  SHA512:
6
- metadata.gz: 793306265482872b9dd2fcf1c76ef1947ba0022a489da546f735462345e9dafce55957a22e80ab955369d84844c009025d226efaaf7428c159ed36c56fa30d21
7
- data.tar.gz: 79b57a659c3f19e8a8f145a82bdba3190cc8b56d6dc7c5f1cda3b23ab9695976c2c40af525b97213a9a9add711db6ff33798229996533c0efec36f33b5fe05c8
6
+ metadata.gz: 853143be5929ea5b6f8fc6bc00cce5a1b60ad42dff0c811d4764a26f12506f0447937ccafc693e764b8d9372830cf94c092ddd01b00dcf3052b1fdc8e7c38f24
7
+ data.tar.gz: 3c30b46d77e7fb013c629ac31521fe917ba0d1c3f95e5ef9aa051a06d07f89295f95a2535fceebb146cd81af432da3d890aa6e5c3fcaf1fd8ccc45acddf5aeb7
data/README.md CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  # AppMonit
4
4
 
5
- TODO: Write a gem description
6
-
7
5
  ## Installation
8
6
 
9
7
  Add this line to your application's Gemfile:
10
8
 
11
- gem 'app_monit'
9
+ ```ruby
10
+ gem 'app_monit'
11
+ ```
12
12
 
13
13
  And then execute:
14
14
 
@@ -22,63 +22,115 @@ Or install it yourself as:
22
22
 
23
23
  ### Configure the client
24
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
25
+ #### Basic configuration
26
+
27
+ ```ruby
28
+ AppMonit::Config.api_key = '<YOUR_API_KEY>'
29
+ AppMonit::Config.end_point = 'https://api.appmon.it'
30
+ AppMonit::Config.env = Rails.env.to_s
31
+ ```
32
+
33
+ #### Additional configuration
34
+
35
+ To ignore connection related errors when creating events, set the `.fail_silent` option in the configuration (default: `false`):
36
+
37
+ ```ruby
38
+ AppMonit::Config.fail_silent = true
39
+ ```
40
+
41
+ To disable creating events, set the `.enabled` option in the configuration (default: `true`):
42
+
43
+ ```ruby
44
+ AppMonit::Config.enabled = false
45
+ ```
28
46
 
29
47
  ### Create an event
30
48
 
31
- event_name = 'authentication'
32
- payload_hash = {user: {id: 1, name: 'John'} }
33
- AppMonit::Event.create(event_name, payload_hash)
49
+ ```ruby
50
+ event_name = 'authentication'
51
+ payload_hash = { user: { id: 1, name: 'John' } }
52
+
53
+ AppMonit::Event.create(event_name, payload_hash)
54
+ ```
34
55
 
35
56
  ### Query
36
57
 
37
- You can use the following metrics to query your data
58
+ You can use the following methods to query your data:
59
+
60
+ * `#count`
61
+ * `#count_unique`
62
+ * `#minimum`
63
+ * `#maximum`
64
+ * `#average`
65
+ * `#sum`
66
+ * `#funnel`
67
+
68
+ The examples are based on the following events:
69
+
70
+ ```ruby
71
+ AppMonit::Event.create(:registered, user: { id: '1' })
72
+ AppMonit::Event.create(:registered, user: { id: '2' })
73
+
74
+ AppMonit::Event.create(:purchase, user: { id: '1' }, product: { price_in_cents: 100, name: 'water', alcoholic: false })
75
+ AppMonit::Event.create(:purchase, user: { id: '1' }, product: { price_in_cents: 150, name: 'soda', alcoholic: false })
76
+ AppMonit::Event.create(:purchase, user: { id: '1' }, product: { price_in_cents: 200, name: 'beer', alcoholic: true })
77
+ ```
78
+
79
+ #### `#count`
80
+
81
+ ```ruby
82
+ AppMonit::Query.count(:purchase) #=> { 'result' => 3 }
83
+ ```
38
84
 
39
- * count
40
- * count_unique
41
- * minimum
42
- * maximum
43
- * average
44
- * sum
45
- * funnel
85
+ #### `#count_unique`
46
86
 
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 })
87
+ ```ruby
88
+ AppMonit::Query.count_unique(:purchase) #=> { 'result' => 2, target_property: 'product.name' }
89
+ ```
52
90
 
53
- #### count
54
- AppMonit::Query.count(:purchase) # { 'result' => 3 }
91
+ #### `#minimum`
55
92
 
56
- #### count
57
- AppMonit::Query.count_unique(:purchase) # { 'result' => 2, target_property: 'product.name' }
93
+ ```ruby
94
+ AppMonit::Query.minimum(:purchase, target_property: 'product.price_in_cents') #=> { 'result' => 100 }
95
+ ```
58
96
 
59
- #### minimum
60
- AppMonit::Query.minimum(:purchase, target_property: 'product.price_in_cents') # { 'result' => 100 }
97
+ #### `#maximum`
61
98
 
62
- #### minimum
63
- AppMonit::Query.maximum(:purchase, target_property: 'product.price_in_cents') # { 'result' => 200 }
99
+ ```ruby
100
+ AppMonit::Query.maximum(:purchase, target_property: 'product.price_in_cents') #=> { 'result' => 200 }
101
+ ```
64
102
 
65
- #### average
66
- AppMonit::Query.average(:purchase, target_property: 'product.price_in_cents') # { 'result' => 150 }
103
+ #### `#average`
67
104
 
68
- #### sum
69
- AppMonit::Query.sum(:purchase, target_property: 'product.price_in_cents') # { 'result' => 450 }
105
+ ```ruby
106
+ AppMonit::Query.average(:purchase, target_property: 'product.price_in_cents') #=> { 'result' => 150 }
107
+ ```
70
108
 
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'}]
109
+ #### `#sum`
110
+
111
+ ```ruby
112
+ AppMonit::Query.sum(:purchase, target_property: 'product.price_in_cents') #=> { 'result' => 450 }
113
+ ```
114
+
115
+ #### `#funnel`
116
+
117
+ ```ruby
118
+ AppMonit::Query.funnel(steps: [
119
+ { event_collection: 'registered', actor_property: 'user.id'},
120
+ { event_collection: 'purchase', actor_property: 'user.id'}
121
+ ]) #=> { 'result' => { 'result' => [ 2, 1], 'steps' => [{ event_collection: 'registered', actor_property: 'user.id'},
122
+ # { event_collection: 'purchase', actor_property: 'user.id'}]
123
+ ```
77
124
 
78
125
  #### Timeframe
79
- AppMonit::Query.count('registered', timeframe: 'this_week')
80
126
 
81
- Options
127
+ You can specify a timeframe when querying your data:
128
+
129
+ ```ruby
130
+ AppMonit::Query.count('registered', timeframe: 'this_week')
131
+ ```
132
+
133
+ Use the following options to specify the timeframe:
82
134
 
83
135
  * this_minute
84
136
  * this_hour
@@ -86,14 +138,18 @@ Options
86
138
  * this_week
87
139
  * this_month
88
140
  * this_year
141
+ * this_n_minutes (example: with n = 2 results this_2_minutes)
89
142
 
90
- Or with n: this_n_minutes (n = 2 => this_2_minutes)
143
+ In addition to using the word 'this' to specify the timeframe, you can also use the word 'previous' (example: previous_minute, previous_day and with n = 3 the previous_3_minutes).
91
144
 
92
- This can also be replaced with previous: previous_minute and previous_n_minutes
93
145
 
94
146
  #### Interval
95
- This can be used with timeframe
96
- AppMonit::Query.count('registered', timeframe: 'this_week', interval: 'daily')
147
+ You can specify an interval when querying your data in combination with a timeframe:
148
+
149
+ ```ruby
150
+ AppMonit::Query.count('registered', timeframe: 'this_week', interval: 'daily')
151
+ ```
152
+ Use the following options to specify the interval:
97
153
 
98
154
  * minutely
99
155
  * hourly
@@ -101,27 +157,40 @@ This can be used with timeframe
101
157
  * monthly
102
158
  * yearly
103
159
  * weekly
160
+ * every_n_minutes (example: with n = 3 results every_3_minutes)
104
161
 
105
- Also with n: every_n_minutes (n = 2 => every_2_minutes)
106
162
 
107
163
  #### Group by
108
- AppMonit::Query.count('registered', group_by: 'alcoholic') # { 'result' => [ {'alcoholic' => true, result => 1 }
109
- {'alcoholic' => false, result => 2 }]
164
+
165
+ You can specify a group when querying your data:
166
+
167
+ ```ruby
168
+ AppMonit::Query.count('registered', group_by: 'alcoholic') #=> { 'result' => [{ 'alcoholic' => true, result => 1 }
169
+ # { 'alcoholic' => false, result => 2 }]
170
+ ```
110
171
 
111
172
  #### 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
173
+
174
+ You can specify a filter when querying your data:
175
+
176
+ ```ruby
177
+ AppMonit::Query.count('registered', filters: [{ property_name: 'product.name', operator: 'eq', property_value: 'soda' }]) #=> { 'result' => 1 }
178
+ ```
179
+
180
+ Use the following operators:
181
+
182
+ | Operator | Matcher
183
+ | -------- | --------------------------- |
184
+ | eq | equal |
185
+ | neq | not equal |
186
+ | lt | less than |
187
+ | lte | less than or equal to |
188
+ | gt | greater than |
189
+ | gte | greater than or equal to |
190
+ | exists | exists |
191
+ | in | in |
192
+ | nin | not in |
193
+
125
194
 
126
195
  ## Contributing
127
196
 
@@ -1,7 +1,7 @@
1
1
  module AppMonit
2
2
  class Config
3
3
  class << self
4
- attr_writer :api_key, :env, :end_point, :fail_silent, :enabled
4
+ attr_writer :api_key, :env, :end_point, :fail_silent, :enabled, :timeout
5
5
 
6
6
  def api_key
7
7
  @api_key || raise(ApiKeyNotSetError.new("Please set your API key"))
@@ -22,6 +22,10 @@ module AppMonit
22
22
  def enabled?
23
23
  @enabled.nil? ? env != "test" : @enabled
24
24
  end
25
+
26
+ def timeout
27
+ @timeout || 1
28
+ end
25
29
  end
26
30
  end
27
31
  end
@@ -14,7 +14,7 @@ module AppMonit
14
14
  @client.verify_mode = OpenSSL::SSL::VERIFY_PEER
15
15
  end
16
16
 
17
- @client.read_timeout = 1
17
+ @client.read_timeout = AppMonit::Config.timeout if AppMonit::Config.timeout > 0
18
18
  end
19
19
 
20
20
  def self.post(path, data_hash)
@@ -1,3 +1,3 @@
1
1
  module AppMonit
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -40,8 +40,14 @@ describe AppMonit::Http do
40
40
  assert_requested :post, /.*/, :headers => { 'Appmonit-Api-Key' => 'FUBAR123' }
41
41
  end
42
42
 
43
- it 'sets the read timeout to 1 second' do
44
- assert_equal 1, subject.client.read_timeout
43
+ it 'sets the read timeout to AppMonit::Config.timeout' do
44
+ AppMonit::Config.timeout = 10
45
+ assert_equal 10, subject.client.read_timeout
46
+ end
47
+
48
+ it 'sets the read timeout to the default' do
49
+ AppMonit::Config.timeout = 0
50
+ assert_equal 60, subject.client.read_timeout
45
51
  end
46
52
 
47
53
  describe 'when using ssl' 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.4
4
+ version: 0.0.5
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-05-29 00:00:00.000000000 Z
12
+ date: 2014-10-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler