Class: GitLab::Exporter::Database::BloatProber
- Inherits:
-
Object
- Object
- GitLab::Exporter::Database::BloatProber
- Defined in:
- lib/gitlab_exporter/database/bloat.rb
Overview
Prober class to gather bloat metrics
Constant Summary collapse
- METRIC_KEYS =
%w(bloat_ratio bloat_size extra_size real_size).freeze
Instance Attribute Summary collapse
-
#bloat_types ⇒ Object
readonly
Returns the value of attribute bloat_types.
-
#collector ⇒ Object
readonly
Returns the value of attribute collector.
-
#metrics ⇒ Object
readonly
Returns the value of attribute metrics.
Instance Method Summary collapse
-
#initialize(opts, metrics: PrometheusMetrics.new, collector: BloatCollector.new(connection_string: opts[:connection_string])) ⇒ BloatProber
constructor
A new instance of BloatProber.
- #probe_db ⇒ Object
- #write_to(target) ⇒ Object
Constructor Details
#initialize(opts, metrics: PrometheusMetrics.new, collector: BloatCollector.new(connection_string: opts[:connection_string])) ⇒ BloatProber
Returns a new instance of BloatProber.
40 41 42 43 44 45 46 |
# File 'lib/gitlab_exporter/database/bloat.rb', line 40 def initialize(opts, metrics: PrometheusMetrics.new, collector: BloatCollector.new(connection_string: opts[:connection_string])) @metrics = metrics @collector = collector @bloat_types = opts[:bloat_types] || i(btree table) end |
Instance Attribute Details
#bloat_types ⇒ Object (readonly)
Returns the value of attribute bloat_types.
38 39 40 |
# File 'lib/gitlab_exporter/database/bloat.rb', line 38 def bloat_types @bloat_types end |
#collector ⇒ Object (readonly)
Returns the value of attribute collector.
38 39 40 |
# File 'lib/gitlab_exporter/database/bloat.rb', line 38 def collector @collector end |
#metrics ⇒ Object (readonly)
Returns the value of attribute metrics.
38 39 40 |
# File 'lib/gitlab_exporter/database/bloat.rb', line 38 def metrics @metrics end |
Instance Method Details
#probe_db ⇒ Object
48 49 50 51 52 |
# File 'lib/gitlab_exporter/database/bloat.rb', line 48 def probe_db bloat_types.each do |type| probe_for_type(type) end end |
#write_to(target) ⇒ Object
54 55 56 |
# File 'lib/gitlab_exporter/database/bloat.rb', line 54 def write_to(target) target.write(metrics.to_s) end |