meter 1.1.1 → 1.2.1

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: 2e4fe8867e08d07d0adb0e35f1a8cf041ada499a
4
- data.tar.gz: 66f19201e9223cb4cd574815a29121df3df34946
3
+ metadata.gz: 49b88e1042ae098d5a6f155f43a8b56cf07f3309
4
+ data.tar.gz: be9549ae95fe98d1a193bc20883e5a079c07d911
5
5
  SHA512:
6
- metadata.gz: 547b9c096006b355735b2d7d9ef6e3052c6f5321ecc4ac689689aa4edc6a0bd6159cb1852cb6b78cb1ceaf2dd66114b48221561712966e5abcd3bb9e782ebb4e
7
- data.tar.gz: e75bd06a2fed817a27b0059792da0daae404ba5424ce970b71d1583f68b553ebb528463eafbdc1da0fedafbacd72883e913be64355be2eaf30b43f351d48cea3
6
+ metadata.gz: 7a90c89c3f78075dc68e96f32a82b4c62d777ffb3297ef721f2e61f7ac614f1c9010472aca2a253a0d08fc10c57ef1705690db665c9d11b6c93a843e4bc19bca
7
+ data.tar.gz: dc334243bb9fa5d724730599ac9247f5851a111eadb6aec7b272477e21e57fc2a2023e5cd8cb6162395514ab8dad773bcd639658f0a4c2d5c598bf9eae8a4d10
@@ -5,7 +5,7 @@ module Meter
5
5
  class Datadog < ::Meter::Backends::Statsd
6
6
 
7
7
  def self.supported_metrics
8
- [:counter, :gauge, :timing, :histogram]
8
+ [:log, :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 = {counter: 'c', gauge: 'g', timing: 'ms', histogram: 'h'}
22
+ types = {log: 'c', counter: 'c', gauge: 'g', timing: 'ms', histogram: 'h'}
23
23
  types[metric.type]
24
24
  end
25
25
 
@@ -5,15 +5,19 @@ module Meter
5
5
  class JsonLog < ::Meter::Backends::Base
6
6
 
7
7
  def self.supported_metrics
8
- [:counter, :gauge, :timing, :histogram]
8
+ [:log]
9
9
  end
10
10
 
11
11
  def convert_to_backend_format(metric)
12
- {statname: metric.name, metric_type: metric.type, metric_value: metric.value}.merge(metric.data).merge(metric.tags)
12
+ {
13
+ statname: metric.name,
14
+ metric_type: metric.type,
15
+ metric_value: metric.value
16
+ }.merge(metric.data).merge(metric.tags)
13
17
  end
14
18
 
15
19
  def output_data(data)
16
- log_file.open('a') { |f| f.puts(JSON.dump data) }
20
+ log_file.open('a') { |f| f.puts(JSON.dump(data)) }
17
21
  end
18
22
 
19
23
  private
@@ -0,0 +1,17 @@
1
+ module Meter
2
+ module Metric
3
+ class Log < Meter::Metric::Base
4
+
5
+ def type
6
+ :log
7
+ end
8
+
9
+ private
10
+
11
+ def default_value
12
+ 1
13
+ end
14
+
15
+ end
16
+ end
17
+ end
data/lib/meter/version.rb CHANGED
@@ -1,9 +1,8 @@
1
1
  module Meter
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
- MINOR = 1
4
+ MINOR = 2
5
5
  TINY = 1
6
-
7
6
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
8
7
  end
9
8
  end
data/lib/meter.rb CHANGED
@@ -9,6 +9,7 @@ require 'meter/metric/base'
9
9
  require 'meter/metric/counter'
10
10
  require 'meter/metric/gauge'
11
11
  require 'meter/metric/histogram'
12
+ require 'meter/metric/log'
12
13
  require 'meter/metric/timing'
13
14
  require 'meter/rails/middleware'
14
15
  require "meter/rails/railtie" if defined?(Rails::Railtie)
@@ -22,11 +23,14 @@ module Meter
22
23
  rescue => exception
23
24
  ::Meter.config.logger.error exception.inspect
24
25
  end
25
- alias :track :increment
26
26
 
27
- def log(key, log_data = {})
28
- track key, data: log_data
27
+ def log(key, tags: {}, data: {})
28
+ metric = Metric::Log.new(name: key, value: 1, sample_rate: 1, tags: tags, data: data)
29
+ send_metric_to_backends(metric)
30
+ rescue => exception
31
+ ::Meter.config.logger.error exception.inspect
29
32
  end
33
+ alias :track :log
30
34
 
31
35
  def gauge(key, value, sample_rate: 1, tags: {}, data: {})
32
36
  metric = Metric::Gauge.new(name: key, value: value, sample_rate: sample_rate, tags: tags, data: data)
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.1.1
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - bukowskis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-15 00:00:00.000000000 Z
11
+ date: 2018-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: useragent
@@ -116,6 +116,7 @@ files:
116
116
  - lib/meter/metric/counter.rb
117
117
  - lib/meter/metric/gauge.rb
118
118
  - lib/meter/metric/histogram.rb
119
+ - lib/meter/metric/log.rb
119
120
  - lib/meter/metric/timing.rb
120
121
  - lib/meter/rails/controller_instrumentation.rb
121
122
  - lib/meter/rails/middleware.rb
@@ -143,9 +144,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
144
  version: '0'
144
145
  requirements: []
145
146
  rubyforge_project:
146
- rubygems_version: 2.2.2
147
+ rubygems_version: 2.5.1
147
148
  signing_key:
148
149
  specification_version: 4
149
150
  summary: A generic abstraction layer for fire and forgetting measurements via UDP.
150
151
  test_files: []
151
- has_rdoc: