Class: Gitlab::Graphql::QueryAnalyzers::LoggerAnalyzer
- Inherits:
-
Object
- Object
- Gitlab::Graphql::QueryAnalyzers::LoggerAnalyzer
- Defined in:
- lib/gitlab/graphql/query_analyzers/logger_analyzer.rb
Constant Summary collapse
- COMPLEXITY_ANALYZER =
GraphQL::Analysis::QueryComplexity.new { |query, complexity_value| complexity_value }
- DEPTH_ANALYZER =
GraphQL::Analysis::QueryDepth.new { |query, depth_value| depth_value }
- FIELD_USAGE_ANALYZER =
GraphQL::Analysis::FieldUsage.new { |query, used_fields, used_deprecated_fields| [used_fields, used_deprecated_fields] }
- ALL_ANALYZERS =
[COMPLEXITY_ANALYZER, DEPTH_ANALYZER, FIELD_USAGE_ANALYZER].freeze
Instance Method Summary collapse
Instance Method Details
#call(memo) ⇒ Object
19 20 21 |
# File 'lib/gitlab/graphql/query_analyzers/logger_analyzer.rb', line 19 def call(memo, *) memo end |
#final_value(memo) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/gitlab/graphql/query_analyzers/logger_analyzer.rb', line 23 def final_value(memo) return if memo.nil? query = memo[:query] complexity, depth, field_usages = GraphQL::Analysis.analyze_query(query, ALL_ANALYZERS) memo[:depth] = depth memo[:complexity] = complexity # This duration is not the execution time of the # query but the execution time of the analyzer. memo[:duration_s] = duration(memo[:time_started]) memo[:used_fields] = field_usages.first memo[:used_deprecated_fields] = field_usages.second push_to_request_store(memo) # This gl_analysis is included in the tracer log query.context[:gl_analysis] = memo.except!(:time_started, :query) rescue StandardError => e Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e) end |
#initial_value(query) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/gitlab/graphql/query_analyzers/logger_analyzer.rb', line 12 def initial_value(query) { time_started: Gitlab::Metrics::System.monotonic_time, query: query } end |