Module: GraphQL::Metrics

Defined in:
lib/graphql/metrics.rb,
lib/graphql/metrics/tracer.rb,
lib/graphql/metrics/version.rb,
lib/graphql/metrics/analyzer.rb,
lib/graphql/metrics/instrumentation.rb

Defined Under Namespace

Classes: Analyzer, Instrumentation, TimedResult, Tracer

Constant Summary collapse

CONTEXT_NAMESPACE =

The context namespace for all values stored by this gem.

:graphql_metrics_analysis
SKIP_GRAPHQL_METRICS_ANALYSIS =

Skip metrics capture altogher, by setting ‘skip_graphql_metrics_analysis: true` in query context.

:skip_graphql_metrics_analysis
SKIP_FIELD_AND_ARGUMENT_METRICS =

Skips just field and argument logging, when query metrics logging is still desirable

:skip_field_and_argument_metrics
TIMINGS_CAPTURE_ENABLED =

Timings related constants.

:timings_capture_enabled
ANALYZER_INSTANCE_KEY =
:analyzer_instance
MULTIPLEX_START_TIME =

Context keys to store timings for query phases of execution, field resolver timings.

:multiplex_start_time
MULTIPLEX_START_TIME_MONOTONIC =
:multiplex_start_time_monotonic
QUERY_START_TIME =
:query_start_time
QUERY_START_TIME_MONOTONIC =
:query_start_time_monotonic
LEXING_START_TIME_OFFSET =
:lexing_start_time_offset
LEXING_DURATION =
:lexing_duration
PARSING_START_TIME_OFFSET =
:parsing_start_time_offset
PARSING_DURATION =
:parsing_duration
VALIDATION_START_TIME_OFFSET =
:validation_start_time_offset
VALIDATION_DURATION =
:validation_duration
ANALYSIS_START_TIME_OFFSET =
:analysis_start_time_offset
ANALYSIS_DURATION =
:analysis_duration
INLINE_FIELD_TIMINGS =
:inline_field_timings
LAZY_FIELD_TIMINGS =
:lazy_field_timings
VERSION =
"5.0.0"

Class Method Summary collapse

Class Method Details

.current_timeObject



45
46
47
# File 'lib/graphql/metrics.rb', line 45

def self.current_time
  Process.clock_gettime(Process::CLOCK_REALTIME)
end

.current_time_monotonicObject



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

def self.current_time_monotonic
  Process.clock_gettime(Process::CLOCK_MONOTONIC)
end

.time(*args) ⇒ Object



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

def self.time(*args)
  TimedResult.new(*args) { yield }
end

.timings_capture_enabled?(context) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
43
# File 'lib/graphql/metrics.rb', line 40

def self.timings_capture_enabled?(context)
  return false unless context
  !!context.namespace(CONTEXT_NAMESPACE)[TIMINGS_CAPTURE_ENABLED]
end