Class: Gitlab::Prometheus::Adapter

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/prometheus/adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, cluster) ⇒ Adapter

Returns a new instance of Adapter.



8
9
10
11
# File 'lib/gitlab/prometheus/adapter.rb', line 8

def initialize(project, cluster)
  @project = project
  @cluster = cluster
end

Instance Attribute Details

#clusterObject (readonly)

Returns the value of attribute cluster.



6
7
8
# File 'lib/gitlab/prometheus/adapter.rb', line 6

def cluster
  @cluster
end

#projectObject (readonly)

Returns the value of attribute project.



6
7
8
# File 'lib/gitlab/prometheus/adapter.rb', line 6

def project
  @project
end

Instance Method Details

#cluster_prometheus_adapterObject



21
22
23
24
# File 'lib/gitlab/prometheus/adapter.rb', line 21

def cluster_prometheus_adapter
  integration = cluster&.integration_prometheus
  integration if integration&.available?
end

#prometheus_adapterObject



13
14
15
16
17
18
19
# File 'lib/gitlab/prometheus/adapter.rb', line 13

def prometheus_adapter
  @prometheus_adapter ||= if service_prometheus_adapter.can_query?
                            service_prometheus_adapter
                          else
                            cluster_prometheus_adapter
                          end
end