summaryrefslogtreecommitdiff
path: root/lib/gitlab/metrics/exporter/sidekiq_exporter.rb
blob: 4d38d9e67bfc0780361c4bb00583ac6d5a52ffea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# frozen_string_literal: true

module Gitlab
  module Metrics
    module Exporter
      class SidekiqExporter < BaseExporter
        def settings
          Settings.monitoring.sidekiq_exporter
        end

        def log_filename
          if settings['log_enabled']
            File.join(Rails.root, 'log', 'sidekiq_exporter.log')
          else
            File::NULL
          end
        end

        private

        # Sidekiq Exporter does not work properly in sidekiq-cluster
        # mode. It tries to start the service on the same port for
        # each of the cluster workers, this results in failure
        # due to duplicate binding.
        #
        # For now we ignore this error, as metrics are still "kind of"
        # valid as they are rendered from shared directory.
        #
        # Issue: https://gitlab.com/gitlab-org/gitlab/issues/5714
        def start_working
          super
        rescue Errno::EADDRINUSE => e
          Sidekiq.logger.error(
            class: self.class.to_s,
            message: 'Cannot start sidekiq_exporter',
            'exception.message' => e.message
          )

          false
        end
      end
    end
  end
end