meter 1.2.3 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/meter.rb +1 -0
- data/lib/meter/backends/datadog.rb +2 -2
- data/lib/meter/backends/logger.rb +21 -0
- data/lib/meter/rails/controller_instrumentation.rb +4 -21
- data/lib/meter/rails/middleware.rb +4 -4
- data/lib/meter/version.rb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c623ec75b3dbafa90e381faf47007b7cedf897ab9713ff45b4b7d274280054a2
|
4
|
+
data.tar.gz: 4acb548008b84b1c5019a33534fa5320c96a0b942b043f0a8ed6bf57c41dfc1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caa06fd4a0e6afded4227c7c159fa411137db1d2a2a08895688f0dd5a471411a987efb56187af62e3ab122f109cb23db31cf348cd9aa0c5434076b5d2506c53d
|
7
|
+
data.tar.gz: a3403fc15edd7e29205cf905d6d6d69f4fa47965df3d72a92ecad96fb98bfb50f39c06cf4894c6d38bb260b88658690ec928e41dca3a811d7891da389b5c2387
|
data/lib/meter.rb
CHANGED
@@ -5,7 +5,7 @@ module Meter
|
|
5
5
|
class Datadog < ::Meter::Backends::Statsd
|
6
6
|
|
7
7
|
def self.supported_metrics
|
8
|
-
[:
|
8
|
+
[:counter, :gauge, :timing, :histogram]
|
9
9
|
end
|
10
10
|
|
11
11
|
def convert_to_backend_format(metric)
|
@@ -19,7 +19,7 @@ module Meter
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def statsd_type(metric)
|
22
|
-
types = {
|
22
|
+
types = {counter: 'c', gauge: 'g', timing: 'ms', histogram: 'h'}
|
23
23
|
types[metric.type]
|
24
24
|
end
|
25
25
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Meter
|
2
|
+
module Backends
|
3
|
+
class Logger < ::Meter::Backends::Base
|
4
|
+
def self.supported_metrics
|
5
|
+
[:log]
|
6
|
+
end
|
7
|
+
|
8
|
+
def convert_to_backend_format(metric)
|
9
|
+
{
|
10
|
+
statname: metric.name,
|
11
|
+
metric_type: metric.type,
|
12
|
+
metric_value: metric.value
|
13
|
+
}.merge(metric.data).merge(metric.tags)
|
14
|
+
end
|
15
|
+
|
16
|
+
def output_data(data)
|
17
|
+
::Meter.config.logger.info payload: data
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -4,38 +4,21 @@ ActiveSupport::Notifications.subscribe /process_action.action_controller/ do |*a
|
|
4
4
|
controller = payload[:controller]
|
5
5
|
action = payload[:action]
|
6
6
|
format = payload[:format] || 'all'
|
7
|
-
format =
|
7
|
+
format = 'all' if format == '*/*'
|
8
8
|
http_status = payload[:status]
|
9
9
|
|
10
10
|
total_duration = event.duration.to_i
|
11
11
|
|
12
|
-
|
12
|
+
meter_data = {
|
13
13
|
controller: controller,
|
14
14
|
format: format,
|
15
15
|
method: payload[:method],
|
16
|
-
http_status: http_status
|
17
|
-
}
|
18
|
-
|
19
|
-
meter_data = {
|
16
|
+
http_status: http_status,
|
20
17
|
action: action,
|
21
18
|
path: payload[:path],
|
22
19
|
params: payload[:params].to_query,
|
23
20
|
duration: total_duration
|
24
21
|
}
|
25
22
|
|
26
|
-
|
27
|
-
db_runtime: :db_duration,
|
28
|
-
view_runtime: :view_duration,
|
29
|
-
elasticsearch_runtime: :elasticsearch_duration
|
30
|
-
}
|
31
|
-
|
32
|
-
instrumented_layers.each do |layer, tag_value|
|
33
|
-
next unless payload.has_key? layer
|
34
|
-
duration = payload[layer].to_i
|
35
|
-
meter_data[tag_value] = duration
|
36
|
-
Meter.timing("request.layer_duration", duration, tags: meter_tags.merge(layer: tag_value))
|
37
|
-
end
|
38
|
-
|
39
|
-
Meter.timing "request.total_duration", total_duration, tags: meter_tags
|
40
|
-
Meter.track "requests", tags: meter_tags, data: meter_data
|
23
|
+
Meter.log 'requests', data: meter_data
|
41
24
|
end
|
@@ -27,9 +27,9 @@ module Meter
|
|
27
27
|
|
28
28
|
def store_user_agent_data(request)
|
29
29
|
user_agent = UserAgent.parse(request.user_agent)
|
30
|
-
Meter::MDC.
|
31
|
-
Meter::MDC.
|
32
|
-
Meter::MDC.
|
30
|
+
Meter::MDC.data['user_agent_name'] = user_agent.browser
|
31
|
+
Meter::MDC.data['user_agent_platform'] = user_agent.platform
|
32
|
+
Meter::MDC.data['user_agent_bot'] = user_agent.bot?
|
33
33
|
Meter::MDC.data['user_agent_version'] = "#{user_agent.browser}_#{user_agent.version}"
|
34
34
|
|
35
35
|
Meter::MDC.data['user_agent'] = user_agent.to_s
|
@@ -37,7 +37,7 @@ module Meter
|
|
37
37
|
|
38
38
|
def store_geoip_data(request)
|
39
39
|
lookup = Locality::IP.new request.ip
|
40
|
-
Meter::MDC.
|
40
|
+
Meter::MDC.data['geoip_country'] = lookup.country_name if lookup.country_name
|
41
41
|
Meter::MDC.data['geoip_city'] = lookup.city_name if lookup.city_name
|
42
42
|
Meter::MDC.data['geoip_coords'] = "#{lookup.latitude},#{lookup.longitude}" if lookup.latitude && lookup.longitude
|
43
43
|
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.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bukowskis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: useragent
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- lib/meter/backends/base.rb
|
108
108
|
- lib/meter/backends/datadog.rb
|
109
109
|
- lib/meter/backends/json_log.rb
|
110
|
+
- lib/meter/backends/logger.rb
|
110
111
|
- lib/meter/backends/statsd.rb
|
111
112
|
- lib/meter/backends/udp.rb
|
112
113
|
- lib/meter/configuration.rb
|
@@ -143,8 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
144
|
- !ruby/object:Gem::Version
|
144
145
|
version: '0'
|
145
146
|
requirements: []
|
146
|
-
|
147
|
-
rubygems_version: 2.5.1
|
147
|
+
rubygems_version: 3.0.3
|
148
148
|
signing_key:
|
149
149
|
specification_version: 4
|
150
150
|
summary: A generic abstraction layer for fire and forgetting measurements via UDP.
|