Class: Gitlab::Graphql::Tracers::ApplicationContextTracer

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/graphql/tracers/application_context_tracer.rb

Overview

This graphql-ruby tracer sets up ‘ApplicationContext` for certain operations.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.use(schema) ⇒ Object



8
9
10
# File 'lib/gitlab/graphql/tracers/application_context_tracer.rb', line 8

def self.use(schema)
  schema.tracer(self.new)
end

Instance Method Details

#trace(key, data) ⇒ Object

See docs on expected interface for trace graphql-ruby.org/api-doc/1.12.17/GraphQL/Tracing



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/gitlab/graphql/tracers/application_context_tracer.rb', line 14

def trace(key, data)
  case key
  when "execute_query"
    operation = known_operation(data)

    ::Gitlab::ApplicationContext.with_context(caller_id: operation.to_caller_id) do
      yield
    end
  else
    yield
  end
end