From a62a65b869946db25e94ac6d250883cfe2d8758c Mon Sep 17 00:00:00 2001 From: Andrew Newdigate Date: Tue, 4 Sep 2018 17:14:22 +0000 Subject: [PATCH] Add gitaly_calls to API structured logs --- changelogs/unreleased/an-ap_log_gitaly_calls.yml | 5 +++++ lib/api/api.rb | 3 ++- lib/gitlab/grape_logging/loggers/perf_logger.rb | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/an-ap_log_gitaly_calls.yml create mode 100644 lib/gitlab/grape_logging/loggers/perf_logger.rb diff --git a/changelogs/unreleased/an-ap_log_gitaly_calls.yml b/changelogs/unreleased/an-ap_log_gitaly_calls.yml new file mode 100644 index 00000000000..65bac55a73e --- /dev/null +++ b/changelogs/unreleased/an-ap_log_gitaly_calls.yml @@ -0,0 +1,5 @@ +--- +title: Add gitaly_calls attribute to API logs +merge_request: 21496 +author: +type: other diff --git a/lib/api/api.rb b/lib/api/api.rb index c000666d992..850cef26449 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -16,7 +16,8 @@ module API GrapeLogging::Loggers::FilterParameters.new, GrapeLogging::Loggers::ClientEnv.new, Gitlab::GrapeLogging::Loggers::UserLogger.new, - Gitlab::GrapeLogging::Loggers::QueueDurationLogger.new + Gitlab::GrapeLogging::Loggers::QueueDurationLogger.new, + Gitlab::GrapeLogging::Loggers::PerfLogger.new ] allow_access_with_scope :api diff --git a/lib/gitlab/grape_logging/loggers/perf_logger.rb b/lib/gitlab/grape_logging/loggers/perf_logger.rb new file mode 100644 index 00000000000..e3b9c59bd6e --- /dev/null +++ b/lib/gitlab/grape_logging/loggers/perf_logger.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +# This module adds additional performance metrics to the grape logger +module Gitlab + module GrapeLogging + module Loggers + class PerfLogger < ::GrapeLogging::Loggers::Base + def parameters(_, _) + { gitaly_calls: Gitlab::GitalyClient.get_request_count } + end + end + end + end +end