Class: GitLab::Exporter::Database::RowCountProber
- Inherits:
-
Object
- Object
- GitLab::Exporter::Database::RowCountProber
- Defined in:
- lib/gitlab_exporter/database/row_count.rb
Overview
The prober which is called when gathering metrics
Instance Method Summary collapse
-
#initialize(metrics: PrometheusMetrics.new, **opts) ⇒ RowCountProber
constructor
A new instance of RowCountProber.
- #probe_db ⇒ Object
- #write_to(target) ⇒ Object
Constructor Details
#initialize(metrics: PrometheusMetrics.new, **opts) ⇒ RowCountProber
Returns a new instance of RowCountProber.
279 280 281 282 |
# File 'lib/gitlab_exporter/database/row_count.rb', line 279 def initialize(metrics: PrometheusMetrics.new, **opts) @metrics = metrics @collector = RowCountCollector.new(**opts) end |
Instance Method Details
#probe_db ⇒ Object
284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/gitlab_exporter/database/row_count.rb', line 284 def probe_db results = @collector.run results.each do |query_name, result| labels = { query_name: query_name.to_s } result.each do |row| @metrics.add("gitlab_database_rows", row[:count].to_f, **labels, **row[:labels]) end end self rescue PG::ConnectionBad self end |
#write_to(target) ⇒ Object
298 299 300 |
# File 'lib/gitlab_exporter/database/row_count.rb', line 298 def write_to(target) target.write(@metrics.to_s) end |