Class: Skylight::Core::Probes::GraphQL::Probe Private

Inherits:
Object
  • Object
show all
Defined in:
lib/skylight/core/probes/graphql.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#installObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/skylight/core/probes/graphql.rb', line 8

def install
  ::GraphQL::Schema.instance_eval do
    class << self
      alias_method :multiplex_without_sk, :multiplex # rubocop:disable Style/Alias
    end

    # Schema#execute also delegates to multiplex, so this is the only method
    # we need to override.
    def multiplex(*args, **kwargs)
      sk_add_tracer
      multiplex_without_sk(*args, **kwargs)
    end

    def sk_add_tracer
      Skylight::Core::Config::MUTEX.synchronize do
        graphql_tracer = ::GraphQL::Tracing::ActiveSupportNotificationsTracing
        unless tracers.include?(graphql_tracer)
          $stdout.puts "[SKYLIGHT::CORE] Adding tracer 'GraphQL::Tracing::ActiveSupportNotificationsTracing' to schema" # rubocop:disable Metrics/LineLength
          tracer(graphql_tracer)
        end

        class << self
          # Remove the probe and reset multiplex/execute to original version
          # after the tracer has been added
          alias_method :multiplex, :multiplex_without_sk # rubocop:disable Style/Alias
        end
      end
    end
  end
end