class GraphQL::Tracing::MonitorTrace::Monitor
Public Class Methods
# File lib/graphql/tracing/monitor_trace.rb, line 12 def initialize(trace:, set_transaction_name:, **_rest) @trace = trace @set_transaction_name = set_transaction_name @platform_field_key_cache = Hash.new { |h, k| h[k] = platform_field_key(k) }.compare_by_identity @platform_authorized_key_cache = Hash.new { |h, k| h[k] = platform_authorized_key(k) }.compare_by_identity @platform_resolve_type_key_cache = Hash.new { |h, k| h[k] = platform_resolve_type_key(k) }.compare_by_identity @platform_source_class_key_cache = Hash.new { |h, source_cls| h[source_cls] = platform_source_class_key(source_cls) }.compare_by_identity end
Public Instance Methods
# File lib/graphql/tracing/monitor_trace.rb, line 45 def fallback_transaction_name(context) context[:tracing_fallback_transaction_name] end
# File lib/graphql/tracing/monitor_trace.rb, line 21 def instrument(keyword, object, &block) raise "Implement #{self.class}#instrument to measure the block" end
Source
# File lib/graphql/tracing/monitor_trace.rb, line 49 def name_for(keyword, object) case keyword when :execute_field @platform_field_key_cache[object] when :authorized @platform_authorized_key_cache[object] when :resolve_type @platform_resolve_type_key_cache[object] when :dataloader_source @platform_source_class_key_cache[object.class] when :parse then self.class.const_get(:PARSE_NAME) when :lex then self.class.const_get(:LEX_NAME) when :execute then self.class.const_get(:EXECUTE_NAME) when :analyze then self.class.const_get(:ANALYZE_NAME) when :validate then self.class.const_get(:VALIDATE_NAME) else raise "No name for #{keyword.inspect}" end end
# File lib/graphql/tracing/monitor_trace.rb, line 25 def start_event(keyword, object) ev = self.class.const_get(:Event).new(self, keyword, object) ev.start ev end
Source
# File lib/graphql/tracing/monitor_trace.rb, line 33 def transaction_name(query) selected_op = query.selected_operation txn_name = if selected_op op_type = selected_op.operation_type op_name = selected_op.name || fallback_transaction_name(query.context) || "anonymous" "#{op_type}.#{op_name}" else "query.anonymous" end "GraphQL/#{txn_name}" end
Get the transaction name based on the operation type and name if possible, or fall back to a user provided one. Useful for anonymous queries.