Class: Mettric::Client
- Inherits:
-
Object
- Object
- Mettric::Client
- Defined in:
- lib/mettric/client.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#env ⇒ Object
Returns the value of attribute env.
-
#host ⇒ Object
Returns the value of attribute host.
Instance Method Summary collapse
- #<<(payload) ⇒ Object
- #[](*args) ⇒ Object
- #close ⇒ Object
- #connected? ⇒ Boolean
-
#initialize(config = ::Mettric.config) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(config = ::Mettric.config) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mettric/client.rb', line 9 def initialize(config = ::Mettric.config) @config = config || {} @riemann = Riemann::Client.new( host: @config[:host] || 'localhost', port: @config[:port] || 5555, timeout: @config[:timeout] || 5 ) self.app = (@config[:app] || rails_app_name).to_s.underscore self.host = (@config[:reporting_host] || host_name).to_s.underscore self.env = (@config[:env] || rails_env).to_s.underscore if block_given? begin yield self ensure close end end end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
7 8 9 |
# File 'lib/mettric/client.rb', line 7 def app @app end |
#env ⇒ Object
Returns the value of attribute env.
7 8 9 |
# File 'lib/mettric/client.rb', line 7 def env @env end |
#host ⇒ Object
Returns the value of attribute host.
7 8 9 |
# File 'lib/mettric/client.rb', line 7 def host @host end |
Instance Method Details
#<<(payload) ⇒ Object
45 46 47 48 49 |
# File 'lib/mettric/client.rb', line 45 def <<(payload) @riemann.tcp << standardize_payload(payload) rescue => e track_exception(e, payload) end |
#[](*args) ⇒ Object
51 52 53 |
# File 'lib/mettric/client.rb', line 51 def [](*args) @riemann[*args] end |
#close ⇒ Object
55 56 57 |
# File 'lib/mettric/client.rb', line 55 def close @riemann.close end |
#connected? ⇒ Boolean
59 60 61 |
# File 'lib/mettric/client.rb', line 59 def connected? @riemann.connected? end |