Class: GraphQL::Tracing::InstrumentationTracing

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/tracing/instrumentation_tracing.rb

Instance Method Summary collapse

Constructor Details

#initialize(schema) ⇒ InstrumentationTracing

Returns a new instance of InstrumentationTracing.



4
5
6
# File 'lib/graphql/tracing/instrumentation_tracing.rb', line 4

def initialize(schema)
  @schema = schema
end

Instance Method Details

#trace(event, data) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/graphql/tracing/instrumentation_tracing.rb', line 8

def trace(event, data)
  instrumenters = nil
  query_instrumenters = nil
  case event
  when "execute_multiplex"
    instrumenters = @schema.instrumenters
    multiplex_instrumenters = instrumenters[:multiplex]
    query_instrumenters = instrumenters[:query]
    call_hooks(multiplex_instrumenters, data[:multiplex], :before_multiplex, :after_multiplex) {
      each_query_call_hooks(query_instrumenters, data[:multiplex].queries) {
        yield
      }
    }
  else
    yield
  end
end