diff options
author | syasonik <syasonik@gitlab.com> | 2019-03-15 19:20:59 +0800 |
---|---|---|
committer | syasonik <syasonik@gitlab.com> | 2019-04-03 17:21:56 +0800 |
commit | ab1e1b55a84ffc6b09233a6831be9bdc77c05115 (patch) | |
tree | dd59f2fd052b1112429580855536faa59855972a /app/models | |
parent | 478077747da82a3dfaafbebc1797b26b965b030f (diff) | |
download | gitlab-ce-ab1e1b55a84ffc6b09233a6831be9bdc77c05115.tar.gz |
Specify time window for additional metrics apisupport-time-windows-api
Adds support for start and end parameters in the #additional_metrics
endpoint of the EnvironmentsController. start and end are meant to be
unix timestamps, per the Prometheus API (as the consumer of this
endpoint will eventually be transitioned to a prometheus endpoint).
This functionality is behind the :metrics_time_window feature flag
for development.
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/concerns/prometheus_adapter.rb | 2 | ||||
-rw-r--r-- | app/models/environment.rb | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/app/models/concerns/prometheus_adapter.rb b/app/models/concerns/prometheus_adapter.rb index a29e80fe0c1..decbbbd87f2 100644 --- a/app/models/concerns/prometheus_adapter.rb +++ b/app/models/concerns/prometheus_adapter.rb @@ -51,7 +51,7 @@ module PrometheusAdapter end def build_query_args(*args) - args.map(&:id) + args.map { |arg| arg.respond_to?(:id) ? arg.id : arg } end end end diff --git a/app/models/environment.rb b/app/models/environment.rb index 25373c7a1f7..fa29a83e517 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -170,8 +170,10 @@ class Environment < ApplicationRecord prometheus_adapter.query(:environment, self) if has_metrics? end - def additional_metrics - prometheus_adapter.query(:additional_metrics_environment, self) if has_metrics? + def additional_metrics(*args) + return unless has_metrics? + + prometheus_adapter.query(:additional_metrics_environment, self, *args.map(&:to_f)) end # rubocop: disable CodeReuse/ServiceClass |