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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: aa7c2dcd6179f6f90438097a4b5e4c0ffd6ee900
4
- data.tar.gz: d18165ffd183652093b2e2cab2c9267780f92a0f
2
+ SHA256:
3
+ metadata.gz: c623ec75b3dbafa90e381faf47007b7cedf897ab9713ff45b4b7d274280054a2
4
+ data.tar.gz: 4acb548008b84b1c5019a33534fa5320c96a0b942b043f0a8ed6bf57c41dfc1a
5
5
  SHA512:
6
- metadata.gz: 375aa514949f39ec0628622c347e1aae8c6c47dbfd0c466d8db73dd033af10b7995f1f8f91dc9a6601657be5aa12fd24f8f82cccb04e78dad4c4a1dc82e06ba6
7
- data.tar.gz: 380808d540765cb5dc19653a49577b0297e3c036ea02487059367152bc82ad8655523a9587f46d6a977cd98c6de87d49b91312da499b8934d22a85f628fcd5d0
6
+ metadata.gz: caa06fd4a0e6afded4227c7c159fa411137db1d2a2a08895688f0dd5a471411a987efb56187af62e3ab122f109cb23db31cf348cd9aa0c5434076b5d2506c53d
7
+ data.tar.gz: a3403fc15edd7e29205cf905d6d6d69f4fa47965df3d72a92ecad96fb98bfb50f39c06cf4894c6d38bb260b88658690ec928e41dca3a811d7891da389b5c2387
@@ -3,6 +3,7 @@ require 'meter/backends/udp'
3
3
  require 'meter/backends/statsd'
4
4
  require 'meter/backends/datadog'
5
5
  require 'meter/backends/json_log'
6
+ require 'meter/backends/logger'
6
7
  require 'meter/configure'
7
8
  require 'meter/mdc'
8
9
  require 'meter/metric/base'
@@ -5,7 +5,7 @@ module Meter
5
5
  class Datadog < ::Meter::Backends::Statsd
6
6
 
7
7
  def self.supported_metrics
8
- [:log, :counter, :gauge, :timing, :histogram]
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 = {log: 'c', counter: 'c', gauge: 'g', timing: 'ms', histogram: 'h'}
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 = "all" if 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
- meter_tags = {
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
- instrumented_layers = {
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.tags['user_agent_name'] = user_agent.browser
31
- Meter::MDC.tags['user_agent_platform'] = user_agent.platform
32
- Meter::MDC.tags['user_agent_bot'] = user_agent.bot?
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.tags['geoip_country'] = lookup.country_name if lookup.country_name
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
@@ -1,8 +1,8 @@
1
1
  module Meter
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
- MINOR = 2
5
- TINY = 3
4
+ MINOR = 3
5
+ TINY = 0
6
6
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
7
7
  end
8
8
  end
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.2.3
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: 2018-08-31 00:00:00.000000000 Z
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
- rubyforge_project:
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.