Sha256: 028fc4bc74853689b03043ea7e5ee3fa434acde286a898cbb990a49f981d0e84

Contents?: true

Size: 1.05 KB

Versions: 13

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require "active_support/inflector"

module Skylight
  module Probes
    module GraphQL
      module Instrumentation
        def initialize(*, **)
          super

          return unless defined?(@tracers)

          unless @tracers.include?(::GraphQL::Tracing::ActiveSupportNotificationsTracing)
            @tracers << ::GraphQL::Tracing::ActiveSupportNotificationsTracing
          end
        end
      end

      class Probe
        def install
          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

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

    register(:graphql, "GraphQL", "graphql", GraphQL::Probe.new)
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
skylight-5.3.5 lib/skylight/probes/graphql.rb
skylight-6.0.0.beta lib/skylight/probes/graphql.rb
skylight-5.3.4 lib/skylight/probes/graphql.rb
skylight-5.3.3 lib/skylight/probes/graphql.rb
skylight-5.3.2 lib/skylight/probes/graphql.rb
skylight-5.3.1 lib/skylight/probes/graphql.rb
skylight-5.3.0 lib/skylight/probes/graphql.rb
skylight-5.2.0 lib/skylight/probes/graphql.rb
skylight-5.2.0.beta2 lib/skylight/probes/graphql.rb
skylight-5.2.0.beta lib/skylight/probes/graphql.rb
skylight-5.1.1 lib/skylight/probes/graphql.rb
skylight-5.1.0.beta3 lib/skylight/probes/graphql.rb
skylight-5.1.0.beta2 lib/skylight/probes/graphql.rb