Class: Fluent::Plugin::LocalMetrics
Constant Summary
Constants inherited
from Metrics
Metrics::DEFAULT_TYPE
Configurable::CONFIG_TYPE_REGISTRY
Instance Attribute Summary
Attributes inherited from Metrics
#has_methods_for_counter, #has_methods_for_gauge, #use_gauge_metric
#log
Attributes inherited from Base
#under_plugin_development
Instance Method Summary
collapse
Methods inherited from Metrics
#create, #dec, #set, #sub
#dump_unique_id_hex, #generate_unique_id
included, #terminate
#plugin_id, #plugin_id_configured?, #plugin_id_for_test?, #plugin_root_dir, #stop
Methods inherited from Base
#acquire_worker_lock, #after_shutdown, #after_shutdown?, #after_start, #after_started?, #before_shutdown, #before_shutdown?, #called_in_test?, #close, #closed?, #configured?, #context_router, #context_router=, #fluentd_worker_id, #get_lock_path, #has_router?, #inspect, #plugin_root_dir, #reloadable_plugin?, #shutdown, #shutdown?, #start, #started?, #stop, #stopped?, #string_safe_encoding, #terminate, #terminated?
#system_config, #system_config_override
#config, #configure_proxy_generate, #configured_section_create, included, lookup_type, register_type
Constructor Details
Returns a new instance of LocalMetrics.
25
26
27
28
29
|
# File 'lib/fluent/plugin/metrics_local.rb', line 25
def initialize
super
@store = 0
@monitor = Monitor.new
end
|
Instance Method Details
#add(value) ⇒ Object
69
70
71
72
73
|
# File 'lib/fluent/plugin/metrics_local.rb', line 69
def add(value)
@monitor.synchronize do
@store += value
end
end
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/fluent/plugin/metrics_local.rb', line 31
def configure(conf)
super
if use_gauge_metric
class << self
alias_method :dec, :dec_gauge
alias_method :set, :set_gauge
alias_method :sub, :sub_gauge
end
else
class << self
alias_method :set, :set_counter
end
end
end
|
#dec_gauge ⇒ Object
63
64
65
66
67
|
# File 'lib/fluent/plugin/metrics_local.rb', line 63
def dec_gauge
@monitor.synchronize do
@store -= 1
end
end
|
#get ⇒ Object
51
52
53
54
55
|
# File 'lib/fluent/plugin/metrics_local.rb', line 51
def get
@monitor.synchronize do
@store
end
end
|
#inc ⇒ Object
57
58
59
60
61
|
# File 'lib/fluent/plugin/metrics_local.rb', line 57
def inc
@monitor.synchronize do
@store += 1
end
end
|
#multi_workers_ready? ⇒ Boolean
47
48
49
|
# File 'lib/fluent/plugin/metrics_local.rb', line 47
def multi_workers_ready?
true
end
|
#set_counter(value) ⇒ Object
81
82
83
84
85
86
87
|
# File 'lib/fluent/plugin/metrics_local.rb', line 81
def set_counter(value)
return if @store > value
@monitor.synchronize do
@store = value
end
end
|
#set_gauge(value) ⇒ Object
89
90
91
92
93
|
# File 'lib/fluent/plugin/metrics_local.rb', line 89
def set_gauge(value)
@monitor.synchronize do
@store = value
end
end
|
#sub_gauge(value) ⇒ Object
75
76
77
78
79
|
# File 'lib/fluent/plugin/metrics_local.rb', line 75
def sub_gauge(value)
@monitor.synchronize do
@store -= value
end
end
|