Method: GraphQL::Tracing::NotificationsTracing#trace

Defined in:
lib/graphql/tracing/notifications_tracing.rb

#trace(key, metadata) { ... } ⇒ Object

Sends a GraphQL tracing event to the notification handler

. notifications_engine = Dry::Monitor::Notifications.new(:graphql) . tracer = GraphQL::Tracing::NotificationsTracing.new(notifications_engine) . tracer.trace("lex") { ... }

Parameters:

  • key (string)

    The key for the event

  • metadata (Hash)

    The metadata for the event

Yields:

  • The block to execute for the event

[View source] [View on GitHub]

49
50
51
52
53
54
55
56
57
58
# File 'lib/graphql/tracing/notifications_tracing.rb', line 49

def trace(key, , &blk)
  prefixed_key = KEYS[key] || "#{key}.graphql"

  # Cache the new keys while making sure not to induce a memory leak
  if KEYS.size < MAX_KEYS_SIZE
    KEYS[key] ||= prefixed_key
  end

  @notifications_engine.instrument(prefixed_key, , &blk)
end