Class: Statsby::Context
- Inherits:
-
Object
- Object
- Statsby::Context
- Defined in:
- lib/statsby/context.rb
Overview
This is meant to be used as a thin layer over a client or another context as a way to organize tags.
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
- #counter(metric_name, value, local_tags = {}) ⇒ Object
- #format_message(metric_name, value, type, message_tags = {}) ⇒ Object
- #format_tags(message_tags = {}) ⇒ Object
- #gauge(metric_name, value, local_tags = {}) ⇒ Object
-
#initialize(client, tags = {}) ⇒ Context
constructor
A new instance of Context.
- #set(metric_name, value, local_tags = {}) ⇒ Object
- #subcontext(tags = {}) ⇒ Object
- #timing(metric_name, value, local_tags = {}) ⇒ Object
Constructor Details
#initialize(client, tags = {}) ⇒ Context
Returns a new instance of Context.
10 11 12 13 |
# File 'lib/statsby/context.rb', line 10 def initialize(client, = {}) self.client = client self. = Statsby::TagSet.from_hash() end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
8 9 10 |
# File 'lib/statsby/context.rb', line 8 def client @client end |
#tags ⇒ Object
Returns the value of attribute tags.
8 9 10 |
# File 'lib/statsby/context.rb', line 8 def end |
Instance Method Details
#counter(metric_name, value, local_tags = {}) ⇒ Object
15 16 17 18 |
# File 'lib/statsby/context.rb', line 15 def counter(metric_name, value, = {}) = .merge() client.counter(metric_name, value, ) end |
#format_message(metric_name, value, type, message_tags = {}) ⇒ Object
39 40 41 42 |
# File 'lib/statsby/context.rb', line 39 def (metric_name, value, type, = {}) = .merge() client.(metric_name, value, type, ) end |
#format_tags(message_tags = {}) ⇒ Object
35 36 37 |
# File 'lib/statsby/context.rb', line 35 def ( = {}) client.(.merge()) end |
#gauge(metric_name, value, local_tags = {}) ⇒ Object
20 21 22 23 |
# File 'lib/statsby/context.rb', line 20 def gauge(metric_name, value, = {}) = .merge() client.gauge(metric_name, value, ) end |
#set(metric_name, value, local_tags = {}) ⇒ Object
30 31 32 33 |
# File 'lib/statsby/context.rb', line 30 def set(metric_name, value, = {}) = .merge() client.set(metric_name, value, ) end |
#subcontext(tags = {}) ⇒ Object
44 45 46 |
# File 'lib/statsby/context.rb', line 44 def subcontext( = {}) Statsby::Context.new(self, ) end |
#timing(metric_name, value, local_tags = {}) ⇒ Object
25 26 27 28 |
# File 'lib/statsby/context.rb', line 25 def timing(metric_name, value, = {}) = .merge() client.timing(metric_name, value, ) end |