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 +4 -4
- data/README.md +131 -62
- data/lib/app_monit/config.rb +5 -1
- data/lib/app_monit/http.rb +1 -1
- data/lib/app_monit/version.rb +1 -1
- data/spec/app_monit/http_spec.rb +8 -2
- 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: b45442d97743d84c104c4ff7d9f353e68f0c7d2f
|
4
|
+
data.tar.gz: 82ea6df8c1bf81b4702570735e65c07e6ecede16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
32
|
-
|
33
|
-
|
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
|
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
|
-
|
40
|
-
* count_unique
|
41
|
-
* minimum
|
42
|
-
* maximum
|
43
|
-
* average
|
44
|
-
* sum
|
45
|
-
* funnel
|
85
|
+
#### `#count_unique`
|
46
86
|
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
-
####
|
54
|
-
AppMonit::Query.count(:purchase) # { 'result' => 3 }
|
91
|
+
#### `#minimum`
|
55
92
|
|
56
|
-
|
57
|
-
|
93
|
+
```ruby
|
94
|
+
AppMonit::Query.minimum(:purchase, target_property: 'product.price_in_cents') #=> { 'result' => 100 }
|
95
|
+
```
|
58
96
|
|
59
|
-
####
|
60
|
-
AppMonit::Query.minimum(:purchase, target_property: 'product.price_in_cents') # { 'result' => 100 }
|
97
|
+
#### `#maximum`
|
61
98
|
|
62
|
-
|
63
|
-
|
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
|
-
|
69
|
-
|
105
|
+
```ruby
|
106
|
+
AppMonit::Query.average(:purchase, target_property: 'product.price_in_cents') #=> { 'result' => 150 }
|
107
|
+
```
|
70
108
|
|
71
|
-
####
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
96
|
-
|
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
|
-
|
109
|
-
|
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
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
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
|
|
data/lib/app_monit/config.rb
CHANGED
@@ -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
|
data/lib/app_monit/http.rb
CHANGED
data/lib/app_monit/version.rb
CHANGED
data/spec/app_monit/http_spec.rb
CHANGED
@@ -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
|
44
|
-
|
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
|
+
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-
|
12
|
+
date: 2014-10-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|