Class: GitLab::Exporter::WebExporter
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- GitLab::Exporter::WebExporter
show all
- Defined in:
- lib/gitlab_exporter/web_exporter.rb
Overview
Defined Under Namespace
Classes: MemoryKillerMiddleware, RunGC
Constant Summary
collapse
- DEFAULT_WEB_SERVER =
"webrick".freeze
Class Method Summary
collapse
Class Method Details
.logger ⇒ Object
69
70
71
|
# File 'lib/gitlab_exporter/web_exporter.rb', line 69
def logger
request.logger
end
|
.setup(config) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/gitlab_exporter/web_exporter.rb', line 56
def setup(config)
setup_server(config[:server])
setup_probes(config[:probes])
memory_threshold = (config[:server] && config[:server][:memory_threshold]) || 1024
use MemoryKillerMiddleware, memory_threshold
use Rack::Logger
use RunGC
GC.compact
end
|
.setup_probes(config) ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/gitlab_exporter/web_exporter.rb', line 81
def setup_probes(config)
(config || {}).each do |probe_name, params|
opts =
if params.delete(:multiple)
params
else
{ probe_name => params }
end
get "/#{probe_name}" do
content_type "text/plain; version=0.0.4"
prober = Prober.new(metrics: PrometheusMetrics.new(include_timestamp: false), logger: logger, **opts)
prober.probe_all
prober.write_to(response)
response
end
end
end
|
.setup_server(config) ⇒ Object
73
74
75
76
77
78
79
|
# File 'lib/gitlab_exporter/web_exporter.rb', line 73
def setup_server(config)
config ||= {}
set(:server, config.fetch(:name, DEFAULT_WEB_SERVER))
set(:bind, config.fetch(:listen_address, "0.0.0.0"))
set(:port, config.fetch(:listen_port, 9168))
end
|