Class: Gitlab::Metrics::Exporter::BaseExporter

Inherits:
Daemon
  • Object
show all
Defined in:
lib/gitlab/metrics/exporter/base_exporter.rb

Direct Known Subclasses

SidekiqExporter, WebExporter

Instance Attribute Summary collapse

Attributes inherited from Daemon

#thread

Instance Method Summary collapse

Methods inherited from Daemon

initialize_instance, instance, #start, #stop, #thread?, #thread_name

Constructor Details

#initialize(settings, log_enabled:, log_file:, gc_requests: false, **options) ⇒ BaseExporter

Returns a new instance of BaseExporter.

Parameters:

  • settings (Hash)

    SettingsLogic hash containing the `*_exporter` config

  • log_enabled (Boolean)

    whether to log HTTP requests

  • log_file (String)

    path to where the server log should be located

  • gc_requests (Boolean) (defaults to: false)

    whether to run a major GC after each scraper request


16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gitlab/metrics/exporter/base_exporter.rb', line 16

def initialize(settings, log_enabled:, log_file:, gc_requests: false, **options)
  super(**options)

  @settings = settings
  @gc_requests = gc_requests

  # log_enabled does not exist for all exporters
  log_sink = log_enabled ? File.join(Rails.root, 'log', log_file) : File::NULL
  @logger = WEBrick::Log.new(log_sink)
  @logger.time_format = "[%Y-%m-%dT%H:%M:%S.%L%z]"
end

Instance Attribute Details

#serverObject (readonly)

Returns the value of attribute server.


10
11
12
# File 'lib/gitlab/metrics/exporter/base_exporter.rb', line 10

def server
  @server
end

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)

28
29
30
# File 'lib/gitlab/metrics/exporter/base_exporter.rb', line 28

def enabled?
  settings.enabled
end