summaryrefslogtreecommitdiff
path: root/metrics_server/metrics_server.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-12-20 15:12:25 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-12-20 15:12:25 +0000
commit068b3a417794ab8506b2e149301b3a60c01df078 (patch)
tree26ce51b45ae535a6fc47fb04cad8da42ec408a2f /metrics_server/metrics_server.rb
parent62c78157be8fe8888787162293f13945a5fa5d3e (diff)
downloadgitlab-ce-068b3a417794ab8506b2e149301b3a60c01df078.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'metrics_server/metrics_server.rb')
-rw-r--r--metrics_server/metrics_server.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/metrics_server/metrics_server.rb b/metrics_server/metrics_server.rb
index 56fc20dcc9d..33b31326d2a 100644
--- a/metrics_server/metrics_server.rb
+++ b/metrics_server/metrics_server.rb
@@ -40,14 +40,20 @@ class MetricsServer # rubocop:disable Gitlab/NamespacedClass
def start
::Prometheus::Client.configure do |config|
config.multiprocess_files_dir = @metrics_dir
+ config.pid_provider = proc { "#{@target}_exporter" }
end
FileUtils.mkdir_p(@metrics_dir, mode: 0700)
::Prometheus::CleanupMultiprocDirService.new.execute if @wipe_metrics_dir
- settings = Settings.new(Settings.monitoring[name])
+ # We need to `warmup: true` since otherwise the sampler and exporter threads enter
+ # a race where not all Prometheus db files will be visible to the exporter, resulting
+ # in missing metrics.
+ # Warming up ensures that these files exist prior to the exporter starting up.
+ Gitlab::Metrics::Samplers::RubySampler.initialize_instance(warmup: true).start
exporter_class = "Gitlab::Metrics::Exporter::#{@target.camelize}Exporter".constantize
+ settings = Settings.new(Settings.monitoring[name])
server = exporter_class.instance(settings, synchronous: true)
server.start