Method: Atatus::GraphQL.trace

Defined in:
lib/atatus/graphql.rb

.trace(key, data) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

rubocop:disable Style/ExplicitBlockArgument



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/atatus/graphql.rb', line 52

def self.trace(key, data)
  return yield unless KEYS_TO_NAME.key?(key)
  return yield unless (transaction = Atatus.current_transaction)

  if key == 'execute_query'
    transaction.name =
      "#{PREFIX}#{query_name(data[:query])}"
  end

  results =
    Atatus.with_span(
      KEYS_TO_NAME.fetch(key, key),
      TYPE, subtype: SUBTYPE, action: key
    ) { yield }

  if key == 'execute_multiplex'
    transaction.name = "#{PREFIX}#{concat_names(results)}"
  end

  results
end