Sha256: e9a78d902e72fc1d3962218f8878d6baa3d6de06f5d0a57dc749f4b1d7f53d0e

Contents?: true

Size: 1.2 KB

Versions: 23

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

23 entries across 23 versions & 2 rubygems

Version Path
graphql_cody-1.13.0 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.12.24 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.12.23 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.13.2 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.13.1 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.12.22 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.13.0 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.12.21 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.12.20 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.12.19 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.12.18 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.12.17 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.12.16 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.12.15 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.12.14 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.12.13 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.12.12 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.12.11 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.12.10 lib/graphql/tracing/active_support_notifications_tracing.rb
graphql-1.12.9 lib/graphql/tracing/active_support_notifications_tracing.rb