summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorMike Greiling <mike@pixelcog.com>2019-04-06 02:02:44 +0000
committerMike Greiling <mike@pixelcog.com>2019-04-06 02:02:44 +0000
commit3198867fe3d6257aff61d6a4c0e3768f35bcc6b5 (patch)
treecd984b8bb900a6b3e37c8f6106101ba8617bf524 /app/controllers
parent8e33e7cf474b61bbc684d993d86cb5aa775a01d0 (diff)
parentb77fe7db3e885edca14c862f362e2bbd43f0e498 (diff)
downloadgitlab-ce-3198867fe3d6257aff61d6a4c0e3768f35bcc6b5.tar.gz
Merge branch 'knative-prometheus' into 'master'
Add Knative metrics to Prometheus See merge request gitlab-org/gitlab-ce!24663
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/projects/serverless/functions_controller.rb23
1 files changed, 17 insertions, 6 deletions
diff --git a/app/controllers/projects/serverless/functions_controller.rb b/app/controllers/projects/serverless/functions_controller.rb
index 39eca10134f..8c3d141c888 100644
--- a/app/controllers/projects/serverless/functions_controller.rb
+++ b/app/controllers/projects/serverless/functions_controller.rb
@@ -7,19 +7,14 @@ module Projects
before_action :authorize_read_cluster!
- INDEX_PRIMING_INTERVAL = 15_000
- INDEX_POLLING_INTERVAL = 60_000
-
def index
respond_to do |format|
format.json do
functions = finder.execute
if functions.any?
- Gitlab::PollingInterval.set_header(response, interval: INDEX_POLLING_INTERVAL)
render json: serialize_function(functions)
else
- Gitlab::PollingInterval.set_header(response, interval: INDEX_PRIMING_INTERVAL)
head :no_content
end
end
@@ -33,6 +28,8 @@ module Projects
def show
@service = serialize_function(finder.service(params[:environment_id], params[:id]))
+ @prometheus = finder.has_prometheus?(params[:environment_id])
+
return not_found if @service.nil?
respond_to do |format|
@@ -44,10 +41,24 @@ module Projects
end
end
+ def metrics
+ respond_to do |format|
+ format.json do
+ metrics = finder.invocation_metrics(params[:environment_id], params[:id])
+
+ if metrics.nil?
+ head :no_content
+ else
+ render json: metrics
+ end
+ end
+ end
+ end
+
private
def finder
- Projects::Serverless::FunctionsFinder.new(project.clusters)
+ Projects::Serverless::FunctionsFinder.new(project)
end
def serialize_function(function)