Sha256: e9a78d902e72fc1d3962218f8878d6baa3d6de06f5d0a57dc749f4b1d7f53d0e

Contents?: true

Size: 1.2 KB

Versions: 24

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module GraphQL
  module Tracing
    # This implementation forwards events to ActiveSupport::Notifications
    # with a `graphql` suffix.
    #
    # @see KEYS for event names
    module ActiveSupportNotificationsTracing
      # A cache of frequently-used keys to avoid needless string allocations
      KEYS = {
        "lex" => "lex.graphql",
        "parse" => "parse.graphql",
        "validate" => "validate.graphql",
        "analyze_multiplex" => "analyze_multiplex.graphql",
        "analyze_query" => "analyze_query.graphql",
        "execute_query" => "execute_query.graphql",
        "execute_query_lazy" => "execute_query_lazy.graphql",
        "execute_field" => "execute_field.graphql",
        "execute_field_lazy" => "execute_field_lazy.graphql",
        "authorized" => "authorized.graphql",
        "authorized_lazy" => "authorized_lazy.graphql",
        "resolve_type" => "resolve_type.graphql",
        "resolve_type_lazy" => "resolve_type.graphql",
      }

      def self.trace(key, metadata)
        prefixed_key = KEYS[key] || "#{key}.graphql"
        ActiveSupport::Notifications.instrument(prefixed_key, metadata) do
          yield
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
graphql-1.12.9 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.12.8 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.12.7 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.12.6 lib/graphql/tracing/active_support_notifications_tracing.rb