app_monit_rails 0.0.3 → 0.0.4

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: 03d5fafb91520a7cff4f077ca1e59529f9347b79
4
- data.tar.gz: 0ab9267e9d1763eca83c2f9dae22a5826a45b3eb
3
+ metadata.gz: 2e16e8914f679acb64fd2832699c439c6878eb0d
4
+ data.tar.gz: e0ed46dbce520e13f945b24fb2426a71845a6580
5
5
  SHA512:
6
- metadata.gz: 30a433805844c93c78e5ce0766c3268f75e3309ece3ade0be543919e6920eae2110c417127ef79324fc99796beecfc7ef30977278886d9a98aac9f694188c0db
7
- data.tar.gz: 845d116ad99b534847cd50f8e0c7ed1fe0cea176bd78e80b337c32f4804e74ff3cee89752941e1d86ac97b626a8d2457c9f20a8b4026e52538b62f72fae41e08
6
+ metadata.gz: 4a7bfcdbed0582d77d103bb9de8ac428b12bca2f6e93b5d89a22916d294a894c566824d63d8a6f8149070c20795763b2d3ed7d23cc1daa9a814a5edd70a10edb
7
+ data.tar.gz: 6e48300dd255c950dc2bef186e86afa67ffbbbdd42c2cff751b42df6492e0b4ff037db7a81bebd1881689057225d1ad85b9178bcaf52bfee8962f72843e78417
@@ -7,6 +7,10 @@ module AppMonit
7
7
  def enabled?
8
8
  @enabled.nil? ? ::Rails.env != "test" : @enabled
9
9
  end
10
+
11
+ def name
12
+ @name.nil? ? ::Rails.application.class.parent_name : @name
13
+ end
10
14
  end
11
15
  end
12
16
  end
@@ -1,5 +1,5 @@
1
1
  module AppMonit
2
2
  module Rails
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -98,8 +98,8 @@ module AppMonit
98
98
  def convert_requests_to_events
99
99
  @requests.flat_map do |minute, endpoints|
100
100
  endpoints.collect do |endpoint, durations|
101
- payload = { endpoint: endpoint }.merge(durations.delete(:total) || {}).merge(durations)
102
- { created_at: Time.at(minute), name: 'page_load', payload: payload }
101
+ payload = durations.merge(application: Config.name, endpoint: endpoint)
102
+ { application: Config.name, created_at: Time.at(minute), name: 'page_load', payload: payload }
103
103
  end
104
104
  end
105
105
  end
@@ -107,17 +107,19 @@ module AppMonit
107
107
  def convert_errors_to_events
108
108
  @errors.flat_map do |minute, endpoints|
109
109
  endpoints.collect do |endpoint, duration|
110
- payload = duration.merge(endpoint: endpoint)
110
+ payload = duration.merge(application: Config.name, endpoint: endpoint)
111
111
  { created_at: Time.at(minute), name: 'page_error', payload: payload }
112
112
  end
113
113
  end
114
114
  end
115
115
 
116
+ def events
117
+ convert_requests_to_events + convert_errors_to_events
118
+ end
119
+
116
120
  def send_to_collector
117
121
  AppMonit::Rails.logger.debug "Sending to collector"
118
122
 
119
- events = convert_requests_to_events + convert_errors_to_events
120
-
121
123
  if events.any?
122
124
  AppMonit::Http.post('/v1/events', event: events)
123
125
 
@@ -35,8 +35,9 @@ feature 'Triggered events' do
35
35
  }.to raise_error
36
36
 
37
37
  @worker = AppMonit::Rails::Worker.instance
38
+ @worker.push(:flush)
38
39
  end
39
40
 
40
- puts AppMonit::Rails::Worker.instance.requests.inspect
41
+ puts AppMonit::Rails::Worker.instance.events.inspect
41
42
  end
42
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_monit_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Redmar Kerkhoff