diff options
author | Stan Hu <stanhu@gmail.com> | 2018-04-02 07:06:56 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-04-02 18:58:17 +0300 |
commit | 05e1cbc4cae3032eca371e09f35a451628a4e9c6 (patch) | |
tree | abe96ae2be630685eaca7ace2e17c97c396cdee2 /lib/gitlab | |
parent | 6b89ab116110f177ecb809adf429fe05f76e97f5 (diff) |
Move Sidekiq exporter logs to log/sidekiq_exporter.log
The Sidekiq exporter logs were mixing with the normal Sidekiq logs. In order
to support structured logging in Sidekiq, we either need to split this data
out or convert the exporter to produce structured logs. Since Sidekiq job
processing is fundamentally different information from Web server traffic,
it seems cleaner to move the metrics traffic into a separate file, where they
can be parsed by a different filter if needed.
Relates to #20060
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/metrics/sidekiq_metrics_exporter.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/gitlab/metrics/sidekiq_metrics_exporter.rb b/lib/gitlab/metrics/sidekiq_metrics_exporter.rb index db8bdde74b2..47b4af5d649 100644 --- a/lib/gitlab/metrics/sidekiq_metrics_exporter.rb +++ b/lib/gitlab/metrics/sidekiq_metrics_exporter.rb @@ -4,6 +4,8 @@ require 'prometheus/client/rack/exporter' module Gitlab module Metrics class SidekiqMetricsExporter < Daemon + LOG_FILENAME = File.join(Rails.root, 'log', 'sidekiq_exporter.log') + def enabled? Gitlab::Metrics.metrics_folder_present? && settings.enabled end @@ -17,7 +19,13 @@ module Gitlab attr_reader :server def start_working - @server = ::WEBrick::HTTPServer.new(Port: settings.port, BindAddress: settings.address) + logger = WEBrick::Log.new(LOG_FILENAME) + access_log = [ + [logger, WEBrick::AccessLog::COMBINED_LOG_FORMAT] + ] + + @server = ::WEBrick::HTTPServer.new(Port: settings.port, BindAddress: settings.address, + Logger: logger, AccessLog: access_log) server.mount "/", Rack::Handler::WEBrick, rack_app server.start end |