Class: GitLab::Exporter::GitProber
- Inherits:
-
Object
- Object
- GitLab::Exporter::GitProber
- Defined in:
- lib/gitlab_exporter/git.rb
Overview
Handles creating a Git object, probing for both pull and push, and finally writing to metrics
Optionally takes a metrics object which by default is a PrometheusMetrics, useful to change the metrics writer to something else.
Instance Method Summary collapse
-
#initialize(source:, metrics: PrometheusMetrics.new, labels: {}, **opts) ⇒ GitProber
constructor
rubocop:disable Lint/UnusedMethodArgument.
- #probe_pull ⇒ Object
- #probe_push ⇒ Object
- #write_to(target) ⇒ Object
Constructor Details
#initialize(source:, metrics: PrometheusMetrics.new, labels: {}, **opts) ⇒ GitProber
rubocop:disable Lint/UnusedMethodArgument
67 68 69 70 71 |
# File 'lib/gitlab_exporter/git.rb', line 67 def initialize(source:, metrics: PrometheusMetrics.new, labels: {}, **opts) # rubocop:disable Lint/UnusedMethodArgument @metrics = metrics @labels = labels @git = Git.new(source) end |
Instance Method Details
#probe_pull ⇒ Object
73 74 75 76 |
# File 'lib/gitlab_exporter/git.rb', line 73 def probe_pull @metrics.add "git_pull_time_milliseconds", (@git.pull.time * 1000).to_i, **@labels self end |
#probe_push ⇒ Object
78 79 80 81 |
# File 'lib/gitlab_exporter/git.rb', line 78 def probe_push @metrics.add "git_push_time_milliseconds", (@git.push.time * 1000).to_i, **@labels self end |
#write_to(target) ⇒ Object
83 84 85 |
# File 'lib/gitlab_exporter/git.rb', line 83 def write_to(target) target.write(@metrics.to_s) end |