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

Inherits:
Object
  • Object
show all
Defined in:
lib/skylight/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.



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/skylight/probes/graphql.rb', line 110

def install
  new_tracing = false
  begin
    require "graphql/tracing/active_support_notifications_trace"
    new_tracing = true
  rescue LoadError # rubocop:disable Lint/SuppressedException
  end

  if new_tracing
    # GraphQL >= 2.0.18
    ::GraphQL::Schema.include(InstrumentationV2)
  else
    tracing_klass_name = "::GraphQL::Tracing::ActiveSupportNotificationsTracing"
    klasses_to_probe = %w[::GraphQL::Execution::Multiplex ::GraphQL::Query]

    return unless ([tracing_klass_name] + klasses_to_probe).all?(&method(:safe_constantize))

    klasses_to_probe.each { |klass_name| safe_constantize(klass_name).prepend(Instrumentation) }
  end
end

#safe_constantize(klass_name) ⇒ Object

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.



131
132
133
# File 'lib/skylight/probes/graphql.rb', line 131

def safe_constantize(klass_name)
  ActiveSupport::Inflector.safe_constantize(klass_name)
end