mettric 0.1.3 → 0.1.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: e7965486fe39533c7ae113b0a6614ff619deec5c
4
- data.tar.gz: 3088bd7cadff0c2f30da5daeaa8b6220ca5d7925
3
+ metadata.gz: a14cc6806c5c54cfd62ada74fd3bf38325393318
4
+ data.tar.gz: eafe9169e9c89e39f5ca0fa16f98361d0a320a0b
5
5
  SHA512:
6
- metadata.gz: 516155e541c687ed76d4d28fd0465919a9fc0968a23e0f31c58bf0a9b7486028acac21e1d7ec077f25dd8f5eaf20dcee24ff283f5dd240309f918c5ec0ae59c1
7
- data.tar.gz: f1f88f700f4dfc9bd3b6211511939e3bab2c829761616b67ed5a1b9607e24bddba2758d10eff65d4a5e7e95e58660524e378adcfef6d29b040e44b37ec9bb3ca
6
+ metadata.gz: f61ebb4d42c205458746c5be9e6e6bfd9f31ec86ddba3b8b7c4359915985451d24c592d0cb661798f40e8c391d443d4ce7bb28c1b75382f30ec3537eb569d34d
7
+ data.tar.gz: 31e9e31719392d09a31e805b3cdfa8e5aeda920987e70e106adf467526db0d78be1443bb5ab3ae715cbed972699849647b4be7d4ba3d0991f52a42ba40dec893
@@ -4,7 +4,7 @@ require 'active_support/core_ext/object/blank'
4
4
  require 'riemann/client'
5
5
 
6
6
  class Mettric::Client
7
- attr_reader :app, :host
7
+ attr_reader :app, :host, :env
8
8
 
9
9
  def initialize(config = ::Mettric.config)
10
10
  @config = config || {}
@@ -16,6 +16,7 @@ class Mettric::Client
16
16
 
17
17
  self.app = (@config[:app] || rails_app_name).to_s.underscore
18
18
  self.host = (@config[:reporting_host] || host_name).to_s.underscore
19
+ self.env = (@config[:env] || rails_env).to_s.underscore
19
20
 
20
21
 
21
22
  if block_given?
@@ -37,6 +38,10 @@ class Mettric::Client
37
38
  @host = host_name
38
39
  end
39
40
 
41
+ def env=(env)
42
+ @env = env
43
+ end
44
+
40
45
  def <<(payload)
41
46
  @riemann.tcp << standardize_payload(payload)
42
47
  rescue => e
@@ -62,6 +67,7 @@ class Mettric::Client
62
67
  raise Mettric::MissingService, out if out[:service].blank?
63
68
  out[:tags] ||= []
64
69
  out[:tags] << 'mettric'
70
+ out[:tags] << env if env.present?
65
71
  out[:host] = host
66
72
  out[:service] = "#{app}.#{out[:service]}"
67
73
  out
@@ -72,6 +78,11 @@ class Mettric::Client
72
78
  Rails.application.class.parent.to_s.underscore
73
79
  end
74
80
 
81
+ def rails_env
82
+ return unless Kernel.const_defined?(:Rails)
83
+ Rails.env
84
+ end
85
+
75
86
  def host_name
76
87
  (ENV['METTRIC_REPORTING_HOST'] || `hostname`).to_s.chomp.underscore
77
88
  end
@@ -1,3 +1,3 @@
1
1
  class Mettric
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mettric
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jannis Hermanns