Class: Gremlin::Instruments::Counter
- Inherits:
-
Base
- Object
- Base
- Gremlin::Instruments::Counter
show all
- Defined in:
- lib/gremlin/instruments/counter.rb
Instance Attribute Summary
Attributes inherited from Base
#base_labels, #docstring, #name
Instance Method Summary
collapse
Methods inherited from Base
#get, #help, #help_string, #initialize, #node, #repr, #type_string, #values
Instance Method Details
#default ⇒ Object
15
16
17
|
# File 'lib/gremlin/instruments/counter.rb', line 15
def default
0
end
|
#increment(labels = {}, by = 1) ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'lib/gremlin/instruments/counter.rb', line 6
def increment(labels={}, by=1)
@mutex.synchronize do
prev_val = get(labels.to_json) || default
@values[labels.to_json] = prev_val + by
@values.save
@values[labels.to_json]
end
end
|
#retention_key ⇒ Object
23
24
25
|
# File 'lib/gremlin/instruments/counter.rb', line 23
def retention_key
"gremlin_prometheus_#{node}_metrics_counter_#{name}"
end
|
#type ⇒ Object
19
20
21
|
# File 'lib/gremlin/instruments/counter.rb', line 19
def type
:counter
end
|