diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-08 12:07:53 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-08 12:07:53 +0300 |
commit | a821bd6ad17e304ca93838a411410a44ee9cff9f (patch) | |
tree | 5444ab20a2f8b22db736a93c5c376928dde8e450 /lib/gitlab/prometheus | |
parent | f6e985dba4d0f5b1ede95e9174d30dd6a8bedf0d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/prometheus')
-rw-r--r-- | lib/gitlab/prometheus/adapter.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/gitlab/prometheus/adapter.rb b/lib/gitlab/prometheus/adapter.rb new file mode 100644 index 00000000000..ed10ef2917f --- /dev/null +++ b/lib/gitlab/prometheus/adapter.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module Gitlab + module Prometheus + class Adapter + attr_reader :project, :cluster + + def initialize(project, cluster) + @project = project + @cluster = cluster + end + + def prometheus_adapter + @prometheus_adapter ||= if service_prometheus_adapter.can_query? + service_prometheus_adapter + else + cluster_prometheus_adapter + end + end + + def cluster_prometheus_adapter + application = cluster&.application_prometheus + + application if application&.available? + end + + private + + def service_prometheus_adapter + project.find_or_initialize_service('prometheus') + end + end + end +end |