Module: GraphQL::Metrics::Trace

Defined in:
lib/graphql/metrics/trace.rb

Instance Method Summary collapse

Instance Method Details

#analyze_query(query:) ⇒ Object



37
38
39
40
# File 'lib/graphql/metrics/trace.rb', line 37

def analyze_query(query:)
  return super if @skip_tracing
  capture_analysis_time(query.context) { super }
end

#execute_field(field:, query:, ast_node:, arguments:, object:) ⇒ Object



47
48
49
50
51
# File 'lib/graphql/metrics/trace.rb', line 47

def execute_field(field:, query:, ast_node:, arguments:, object:)
  return super if @skip_tracing || query.context[SKIP_FIELD_AND_ARGUMENT_METRICS]
  return super unless capture_field_timings?(query.context)
  trace_field(GraphQL::Metrics::INLINE_FIELD_TIMINGS, query) { super }
end

#execute_field_lazy(field:, query:, ast_node:, arguments:, object:) ⇒ Object



53
54
55
56
57
# File 'lib/graphql/metrics/trace.rb', line 53

def execute_field_lazy(field:, query:, ast_node:, arguments:, object:)
  return super if @skip_tracing || query.context[SKIP_FIELD_AND_ARGUMENT_METRICS]
  return super unless capture_field_timings?(query.context)
  trace_field(GraphQL::Metrics::LAZY_FIELD_TIMINGS, query) { super }
end

#execute_query(query:) ⇒ Object



42
43
44
45
# File 'lib/graphql/metrics/trace.rb', line 42

def execute_query(query:)
  return super if @skip_tracing
  capture_query_start_time(query.context) { super }
end

#initialize(**_rest) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/graphql/metrics/trace.rb', line 6

def initialize(**_rest)
  super

  query_or_multiplex = @query || @multiplex
  @skip_tracing = query_or_multiplex.context&.fetch(SKIP_GRAPHQL_METRICS_ANALYSIS, false) if query_or_multiplex
  @parsing_duration = 0.0
  @lexing_duration = 0.0
end

#lex(query_string:) ⇒ Object

may not trigger if the query is passed in pre-parsed



21
22
23
24
# File 'lib/graphql/metrics/trace.rb', line 21

def lex(query_string:)
  return super if @skip_tracing
  capture_lexing_time { super }
end

#parse(query_string:) ⇒ Object

may not trigger if the query is passed in pre-parsed



27
28
29
30
# File 'lib/graphql/metrics/trace.rb', line 27

def parse(query_string:)
  return super if @skip_tracing
  capture_parsing_time { super }
end

#validate(query:, validate:) ⇒ Object



32
33
34
35
# File 'lib/graphql/metrics/trace.rb', line 32

def validate(query:, validate:)
  return super if @skip_tracing
  capture_validation_time(query.context) { super }
end