Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcharlieablett <cablett@gitlab.com>2019-05-24 00:29:19 +0300
committercharlieablett <cablett@gitlab.com>2019-05-30 09:27:42 +0300
commit5f0c230a18b677bd4ec6a4a54085775b0c69a498 (patch)
tree6dcd917429f27497669406429ee8192507fcb39b /lib/gitlab/graphql
parentd0e32c2cd33476c5ee7f835d14b97068adeb805d (diff)
Move complexity/depth to `final_value`
Tidy tests according to reviewer comments. Move complexity and depth calls from `initial_value` to `final_value` Log variables as json
Diffstat (limited to 'lib/gitlab/graphql')
-rw-r--r--lib/gitlab/graphql/query_analyzers/logger_analyzer.rb20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/gitlab/graphql/query_analyzers/logger_analyzer.rb b/lib/gitlab/graphql/query_analyzers/logger_analyzer.rb
index 1e49c894ecb..8119d232124 100644
--- a/lib/gitlab/graphql/query_analyzers/logger_analyzer.rb
+++ b/lib/gitlab/graphql/query_analyzers/logger_analyzer.rb
@@ -9,14 +9,11 @@ module Gitlab
end
def initial_value(query)
- analyzers = [complexity_analyzer, depth_analyzer]
- complexity, depth = GraphQL::Analysis.analyze_query(query, analyzers)
{
time_started: Gitlab::Metrics::System.monotonic_time,
query_string: query.query_string,
+ query: query,
variables: process_variables(query.provided_variables),
- complexity: complexity,
- depth: depth,
duration: nil
}
end
@@ -26,16 +23,21 @@ module Gitlab
end
def final_value(memo)
- memo[:duration] = "#{duration(memo[:time_started]).round(1)}ms"
- GraphqlLogger.info(memo.except!(:time_started))
- memo
+ analyzers = [complexity_analyzer, depth_analyzer]
+ complexity, depth = GraphQL::Analysis.analyze_query(memo[:query], analyzers)
+
+ memo[:depth] = depth
+ memo[:complexity] = complexity
+ memo[:duration] = duration(memo[:time_started]).round(1)
+
+ GraphqlLogger.info(memo.except!(:time_started, :query))
end
private
def process_variables(variables)
- if variables.respond_to?(:to_unsafe_h)
- variables.to_unsafe_h
+ if variables.respond_to?(:to_json)
+ variables.to_json
else
variables
end