Module: GraphQL::Tracing::NewRelicTrace

Includes:
PlatformTrace
Defined in:
lib/graphql/tracing/new_relic_trace.rb

Instance Method Summary collapse

Methods included from PlatformTrace

#platform_authorized_lazy, #platform_execute_field_lazy, #platform_resolve_type_lazy

Instance Method Details

#execute_query(query:) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/graphql/tracing/new_relic_trace.rb', line 16

def execute_query(query:)
  set_this_txn_name =  query.context[:set_new_relic_transaction_name]
  if set_this_txn_name == true || (set_this_txn_name.nil? && @set_transaction_name)
    NewRelic::Agent.set_transaction_name(transaction_name(query))
  end
  NewRelic::Agent::MethodTracerHelpers.trace_execution_scoped("GraphQL/execute") do
    super
  end
end

#initialize(set_transaction_name: false, **_rest) ⇒ Object

Parameters:

  • set_transaction_name (Boolean) (defaults to: false)

    If true, the GraphQL operation name will be used as the transaction name. This is not advised if you run more than one query per HTTP request, for example, with graphql-client or multiplexing. It can also be specified per-query with context[:set_new_relic_transaction_name].



11
12
13
14
# File 'lib/graphql/tracing/new_relic_trace.rb', line 11

def initialize(set_transaction_name: false, **_rest)
  @set_transaction_name = set_transaction_name
  super
end

#platform_authorized(platform_key) ⇒ Object



50
51
52
53
54
# File 'lib/graphql/tracing/new_relic_trace.rb', line 50

def platform_authorized(platform_key)
  NewRelic::Agent::MethodTracerHelpers.trace_execution_scoped(platform_key) do
    yield
  end
end

#platform_authorized_key(type) ⇒ Object



66
67
68
# File 'lib/graphql/tracing/new_relic_trace.rb', line 66

def platform_authorized_key(type)
  "GraphQL/Authorize/#{type.graphql_name}"
end

#platform_execute_field(platform_key) ⇒ Object



44
45
46
47
48
# File 'lib/graphql/tracing/new_relic_trace.rb', line 44

def platform_execute_field(platform_key)
  NewRelic::Agent::MethodTracerHelpers.trace_execution_scoped(platform_key) do
    yield
  end
end

#platform_field_key(field) ⇒ Object



62
63
64
# File 'lib/graphql/tracing/new_relic_trace.rb', line 62

def platform_field_key(field)
  "GraphQL/#{field.owner.graphql_name}/#{field.graphql_name}"
end

#platform_resolve_type(platform_key) ⇒ Object



56
57
58
59
60
# File 'lib/graphql/tracing/new_relic_trace.rb', line 56

def platform_resolve_type(platform_key)
  NewRelic::Agent::MethodTracerHelpers.trace_execution_scoped(platform_key) do
    yield
  end
end

#platform_resolve_type_key(type) ⇒ Object



70
71
72
# File 'lib/graphql/tracing/new_relic_trace.rb', line 70

def platform_resolve_type_key(type)
  "GraphQL/ResolveType/#{type.graphql_name}"
end