Class: Cube::Client
- Inherits:
-
Object
- Object
- Cube::Client
- Defined in:
- lib/cube.rb
Constant Summary collapse
- RESERVED_CHARS_REGEX =
We’ll use this to eliminate any unwanted/disallowed characters from our event type later on.
/[^\w\d]/
Class Attribute Summary collapse
-
.logger ⇒ Object
Set to any logger instance that responds to #debug and #error (like the Rails or stdlib logger) to enable metric logging.
Instance Attribute Summary collapse
-
#namespace ⇒ Object
A namespace to prepend to all Cube calls.
Instance Method Summary collapse
-
#initialize(host = "localhost", port = 1180) ⇒ Client
constructor
Set ‘er up with a host and port, defaults to `localhost:1180`.
-
#send(type, *args) ⇒ Object
The primary endpoint for sending metrics to Cube.
Constructor Details
#initialize(host = "localhost", port = 1180) ⇒ Client
Set ‘er up with a host and port, defaults to `localhost:1180`.
28 29 30 |
# File 'lib/cube.rb', line 28 def initialize(host="localhost", port=1180) @host, @port = host, port end |
Class Attribute Details
.logger ⇒ Object
Set to any logger instance that responds to #debug and #error (like the Rails or stdlib logger) to enable metric logging.
21 22 23 |
# File 'lib/cube.rb', line 21 def logger @logger end |
Instance Attribute Details
#namespace ⇒ Object
A namespace to prepend to all Cube calls.
12 13 14 |
# File 'lib/cube.rb', line 12 def namespace @namespace end |
Instance Method Details
#send(type, *args) ⇒ Object
The primary endpoint for sending metrics to Cube.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/cube.rb', line 37 def send(type, *args) time = nil id = nil data = nil until args.empty? arg = args.shift case arg when DateTime, Time time ||= arg when Hash data ||= arg else id ||= arg end end # Send off our parsed arguments to be further massaged and socketized. actual_send type, time, id, data end |