Commit bc523a5f authored by Ahmad Sherif's avatar Ahmad Sherif
Browse files

Add better handling for namespaced prober classes

parent 382c7682
probes:
dead_tuples_count:
class_name: DatabaseDeadTuplesProber
class_name: Database::DeadTuplesProber
methods:
- probe_db
opts:
......
......@@ -8,7 +8,7 @@ module GitLab
def setup(config) # rubocop:disable Metrics/AbcSize
config[:probes].each do |probe_name, params|
prober_class_name = params.delete(:class_name) || Utils.camel_case_string("#{probe_name}_prober")
prober_class = GitLab::Monitor.const_get(prober_class_name)
prober_class = resolve_prober_class(prober_class_name)
get "/#{probe_name}" do
Utils.wrap_in_array(params[:opts]).each do |opts|
......@@ -23,6 +23,12 @@ module GitLab
end
end
end
def resolve_prober_class(prober_class_name)
prober_class_name.split("::").reduce(GitLab::Monitor) do |ancestor, const_name|
ancestor.const_get(const_name)
end
end
end
end
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment