meter 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/meter/rails/controller_instrumentation.rb +42 -0
- data/lib/meter/rails/middleware.rb +2 -2
- data/lib/meter/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d92202ec3c138c26b1735b6ff29e9d225b779f3
|
4
|
+
data.tar.gz: 3caff126ac19e40757e39c741062e5d694d453cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1176186d018a71e4cf6f0317c87da626b2993e4d106f5869faf00c41039bff4580feae626c4afd1696de9483a1179f6354992f6eec82ddb86ecec5d3fbf5e48
|
7
|
+
data.tar.gz: c5f8b6738c1a7b61f04e957465fe2f3d382e9adf0fc320ed480fef3727ba731a926639eea83d73cb0f2dd49711a31e83e490eafc77c0a5d76eb8ce2c5291cb13
|
@@ -0,0 +1,42 @@
|
|
1
|
+
ActiveSupport::Notifications.subscribe /process_action.action_controller/ do |*args|
|
2
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
3
|
+
payload = event.payload
|
4
|
+
controller = payload[:controller]
|
5
|
+
action = payload[:action]
|
6
|
+
format = payload[:format] || 'all'
|
7
|
+
format = "all" if format == "*/*"
|
8
|
+
http_status = payload[:status]
|
9
|
+
|
10
|
+
total_duration = event.duration.to_i
|
11
|
+
|
12
|
+
meter_tags = {
|
13
|
+
controller: controller,
|
14
|
+
format: format,
|
15
|
+
method: payload[:method],
|
16
|
+
http_status: http_status
|
17
|
+
}
|
18
|
+
|
19
|
+
meter_data = {
|
20
|
+
action: action,
|
21
|
+
path: payload[:path],
|
22
|
+
params: payload[:params].to_query,
|
23
|
+
user_id: payload[:user].to_s,
|
24
|
+
duration: total_duration
|
25
|
+
}
|
26
|
+
|
27
|
+
instrumented_layers = {
|
28
|
+
db_runtime: :db_duration,
|
29
|
+
view_runtime: :view_duration,
|
30
|
+
elasticsearch_runtime: :elasticsearch_duration
|
31
|
+
}
|
32
|
+
|
33
|
+
instrumented_layers.each do |layer, tag_value|
|
34
|
+
next unless payload.has_key? layer
|
35
|
+
duration = payload[layer].to_i
|
36
|
+
meter_data[tag_value] = duration
|
37
|
+
Meter.timing("request.layer_duration", duration, tags: meter_tags.merge(layer: tag_value))
|
38
|
+
end
|
39
|
+
|
40
|
+
Meter.timing "request.total_duration", total_duration, tags: meter_tags
|
41
|
+
Meter.track "requests", tags: meter_tags, data: meter_data
|
42
|
+
end
|
@@ -32,8 +32,8 @@ module Meter
|
|
32
32
|
|
33
33
|
def store_geoip_data(request)
|
34
34
|
lookup = Locality::IP.new request.ip
|
35
|
-
Meter::MDC.tags['geoip_country'] = lookup.country_name
|
36
|
-
Meter::MDC.data['geoip_city'] = lookup.city_name
|
35
|
+
Meter::MDC.tags['geoip_country'] = lookup.country_name if lookup.country_name
|
36
|
+
Meter::MDC.data['geoip_city'] = lookup.city_name if lookup.city_name
|
37
37
|
Meter::MDC.data['geoip_coords'] = "#{lookup.latitude},#{lookup.longitude}" if lookup.latitude && lookup.longitude
|
38
38
|
end
|
39
39
|
end
|
data/lib/meter/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bukowskis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: useragent
|
@@ -117,6 +117,7 @@ files:
|
|
117
117
|
- lib/meter/metric/gauge.rb
|
118
118
|
- lib/meter/metric/histogram.rb
|
119
119
|
- lib/meter/metric/timing.rb
|
120
|
+
- lib/meter/rails/controller_instrumentation.rb
|
120
121
|
- lib/meter/rails/middleware.rb
|
121
122
|
- lib/meter/rails/railtie.rb
|
122
123
|
- lib/meter/version.rb
|