Class: Gitlab::Graphql::QueryAnalyzers::AST::LoggerAnalyzer
- Inherits:
-
GraphQL::Analysis::AST::Analyzer
- Object
- GraphQL::Analysis::AST::Analyzer
- Gitlab::Graphql::QueryAnalyzers::AST::LoggerAnalyzer
- Defined in:
- lib/gitlab/graphql/query_analyzers/ast/logger_analyzer.rb
Constant Summary collapse
- COMPLEXITY_ANALYZER =
GraphQL::Analysis::AST::QueryComplexity
- DEPTH_ANALYZER =
GraphQL::Analysis::AST::QueryDepth
- FIELD_USAGE_ANALYZER =
GraphQL::Analysis::AST::FieldUsage
- ALL_ANALYZERS =
[COMPLEXITY_ANALYZER, DEPTH_ANALYZER, FIELD_USAGE_ANALYZER].freeze
Instance Method Summary collapse
-
#initialize(query) ⇒ LoggerAnalyzer
constructor
A new instance of LoggerAnalyzer.
- #result ⇒ Object
Constructor Details
#initialize(query) ⇒ LoggerAnalyzer
Returns a new instance of LoggerAnalyzer.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/gitlab/graphql/query_analyzers/ast/logger_analyzer.rb', line 13 def initialize(query) super @results = default_initial_values(query).merge({ time_started: Gitlab::Metrics::System.monotonic_time }) rescue StandardError => e Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e) @results = default_initial_values(query_or_multiplex) end |
Instance Method Details
#result ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/gitlab/graphql/query_analyzers/ast/logger_analyzer.rb', line 24 def result complexity, depth, field_usages = GraphQL::Analysis::AST.analyze_query(@subject, ALL_ANALYZERS, multiplex_analyzers: []) results[:depth] = depth results[:complexity] = complexity # This duration is not the execution time of the # query but the execution time of the analyzer. results[:duration_s] = duration(results[:time_started]) results[:used_fields] = field_usages[:used_fields] results[:used_deprecated_fields] = field_usages[:used_deprecated_fields] push_to_request_store(results) # This gl_analysis is included in the tracer log query.context[:gl_analysis] = results.except!(:time_started, :query) rescue StandardError => e Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e) end |