Sha256: e9093789b573964cc8d02762dbddfb90cbde4dedd45bab25ae8cbf612de9f8f1

Contents?: true

Size: 1.05 KB

Versions: 37

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module GraphQL
  module Tracing
    # This implementation forwards events to ActiveSupport::Notifications
    # with a `graphql.` prefix.
    #
    # Installed automatically when `ActiveSupport::Notifications` is discovered.
    module ActiveSupportNotificationsTracing
      # A cache of frequently-used keys to avoid needless string allocations
      KEYS = {
        "lex" => "graphql.lex",
        "parse" => "graphql.parse",
        "validate" => "graphql.validate",
        "analyze_multiplex" => "graphql.analyze_multiplex",
        "analyze_query" => "graphql.analyze_query",
        "execute_query" => "graphql.execute_query",
        "execute_query_lazy" => "graphql.execute_query_lazy",
        "execute_field" => "graphql.execute_field",
        "execute_field_lazy" => "graphql.execute_field_lazy",
      }

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

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
graphql-1.8.10 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.8.9 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.8.8 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.8.7 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.8.6 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.8.5 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.8.4 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.8.3 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.8.2 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.8.1 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.8.0 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.8.0.pre11 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.8.0.pre10 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.7.14 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.8.0.pre9 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.8.0.pre8 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.7.13 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.8.0.pre7 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.7.12 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.7.11 lib/graphql/tracing/active_support_notifications_tracing.rb