Sha256: 0eb47857c82791c6466446553f12f8fd2971e6507fca5420042526d1c11ac7cf

Contents?: true

Size: 1.17 KB

Versions: 33

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

module GraphQL
  module Tracing
    # This implementation forwards events to ActiveSupport::Notifications
    # with a `graphql.` prefix.
    #
    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

33 entries across 33 versions & 1 rubygems

Version Path
graphql-1.10.11 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.10.10 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.10.9 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.10.8 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.10.7 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.10.6 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.10.5 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.10.4 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.10.3 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.10.2 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.10.1 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.10.0 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.10.0.pre4 lib/graphql/tracing/active_support_notifications_tracing.rb