Class: Gitlab::Prometheus::Queries::AdditionalMetricsEnvironmentQuery

Inherits:
BaseQuery
  • Object
show all
Includes:
QueryAdditionalMetrics
Defined in:
lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb

Instance Attribute Summary

Attributes inherited from BaseQuery

#client

Instance Method Summary collapse

Methods included from QueryAdditionalMetrics

#query_metrics

Methods inherited from BaseQuery

#initialize, #raw_cpu_usage_query, #raw_memory_usage_query, transform_reactive_result

Constructor Details

This class inherits a constructor from Gitlab::Prometheus::Queries::BaseQuery

Instance Method Details

#query(environment_id, timeframe_start = 8.hours.ago, timeframe_end = Time.now) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord


10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb', line 10

def query(environment_id, timeframe_start = 8.hours.ago, timeframe_end = Time.now)
  ::Environment.find_by(id: environment_id).try do |environment|
    query_metrics(
      environment.project,
      environment,
      common_query_context(
        environment,
        timeframe_start: timeframe_start.to_f,
        timeframe_end: timeframe_end.to_f
      )
    )
  end
end