Class: LogStash::Instrument::MetricType::Counter
- Inherits:
-
Base
- Object
- Base
- LogStash::Instrument::MetricType::Counter
show all
- Defined in:
- lib/logstash/instrument/metric_type/counter.rb
Instance Attribute Summary
Attributes inherited from Base
#key, #namespaces
Instance Method Summary
collapse
Methods inherited from Base
#inspect, #to_hash, #to_json_data, #type
Constructor Details
#initialize(namespaces, key, value = 0) ⇒ Counter
Returns a new instance of Counter.
7
8
9
10
11
|
# File 'lib/logstash/instrument/metric_type/counter.rb', line 7
def initialize(namespaces, key, value = 0)
super(namespaces, key)
@counter = Concurrent::AtomicFixnum.new(value)
end
|
Instance Method Details
#decrement(value = 1) ⇒ Object
17
18
19
|
# File 'lib/logstash/instrument/metric_type/counter.rb', line 17
def decrement(value = 1)
@counter.decrement(value)
end
|
#execute(action, value = 1) ⇒ Object
21
22
23
|
# File 'lib/logstash/instrument/metric_type/counter.rb', line 21
def execute(action, value = 1)
@counter.send(action, value)
end
|
#increment(value = 1) ⇒ Object
13
14
15
|
# File 'lib/logstash/instrument/metric_type/counter.rb', line 13
def increment(value = 1)
@counter.increment(value)
end
|
#value ⇒ Object
25
26
27
|
# File 'lib/logstash/instrument/metric_type/counter.rb', line 25
def value
@counter.value
end
|