Class: GitLab::Exporter::Database::TuplesProber
- Inherits:
-
Object
- Object
- GitLab::Exporter::Database::TuplesProber
- Defined in:
- lib/gitlab_exporter/database/tuple_stats.rb
Overview
Probes the DB specified by opts for tuple stats, then converts them to metrics
Instance Method Summary collapse
-
#initialize(metrics: PrometheusMetrics.new, **opts) ⇒ TuplesProber
constructor
A new instance of TuplesProber.
- #probe_db ⇒ Object
- #write_to(target) ⇒ Object
Constructor Details
#initialize(metrics: PrometheusMetrics.new, **opts) ⇒ TuplesProber
Returns a new instance of TuplesProber.
28 29 30 31 |
# File 'lib/gitlab_exporter/database/tuple_stats.rb', line 28 def initialize(metrics: PrometheusMetrics.new, **opts) @metrics = metrics @collector = TupleStatsCollector.new(**opts) end |
Instance Method Details
#probe_db ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/gitlab_exporter/database/tuple_stats.rb', line 33 def probe_db result = @collector.run result.each do |table_name, tuple_stats| tuple_stats.each do |column_name, value| next if value.is_a?(Numeric) @metrics.add("gitlab_database_stat_table_#{column_name}", value.to_f, table_name: table_name) end end self rescue PG::ConnectionBad self end |
#write_to(target) ⇒ Object
51 52 53 |
# File 'lib/gitlab_exporter/database/tuple_stats.rb', line 51 def write_to(target) target.write(@metrics.to_s) end |