mettric 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mettric/client.rb +12 -1
- data/lib/mettric/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a14cc6806c5c54cfd62ada74fd3bf38325393318
|
4
|
+
data.tar.gz: eafe9169e9c89e39f5ca0fa16f98361d0a320a0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f61ebb4d42c205458746c5be9e6e6bfd9f31ec86ddba3b8b7c4359915985451d24c592d0cb661798f40e8c391d443d4ce7bb28c1b75382f30ec3537eb569d34d
|
7
|
+
data.tar.gz: 31e9e31719392d09a31e805b3cdfa8e5aeda920987e70e106adf467526db0d78be1443bb5ab3ae715cbed972699849647b4be7d4ba3d0991f52a42ba40dec893
|
data/lib/mettric/client.rb
CHANGED
@@ -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
|
data/lib/mettric/version.rb
CHANGED