Module: GraphQL::Tracing::NotificationsTrace
  
  
  
Overview
  
    This implementation forwards events to a notification handler
(i.e. ActiveSupport::Notifications or Dry::Monitor::Notifications) with a graphql suffix.
   
 
Defined Under Namespace
  
    
  
    
      Classes: ActiveSupportNotificationsAdapter, Adapter, DryMonitorAdapter
    
  
  
    
      Constant Summary
      collapse
    
    
      
        - CURRENT_EV_KEY =
          
        
 
        :__notifications_graphql_trace_event
 
      
        - PREVIOUS_EV_KEY =
          
        
 
        :__notifications_graphql_trace_previous_event
 
      
    
  
  
    
      Instance Method Summary
      collapse
    
    
      
        - 
  
    
      #begin_analyze_multiplex(multiplex, analyzers)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #begin_authorized(type, object, context)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #begin_dataloader_source(source)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #begin_execute_field(field, object, arguments, query)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #begin_resolve_type(type, object, context)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #dataloader_fiber_resume(source)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #dataloader_fiber_yield(source)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #end_analyze_multiplex(_multiplex, _analyzers)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #end_authorized(type, object, context, result)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #end_dataloader_source(source)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #end_execute_field(_field, _object, _arguments, _query, _result)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #end_resolve_type(type, object, context, resolved_type)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #execute_multiplex(**payload)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #initialize(engine:, **rest)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #lex(**payload)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #parse(**payload)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
        - 
  
    
      #validate(**payload)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
  
 
      
    
  
  
    Instance Method Details
    
      
  
  
    #begin_analyze_multiplex(multiplex, analyzers)  ⇒ Object 
  
  
  
  
    
      
107
108
109
110 
     | 
    
      # File 'lib/graphql/tracing/notifications_trace.rb', line 107
def begin_analyze_multiplex(multiplex, analyzers)
  begin_notifications_event("analyze.graphql", {multiplex: multiplex, analyzers: analyzers})
  super
end
     | 
  
 
    
      
  
  
    #begin_authorized(type, object, context)  ⇒ Object 
  
  
  
  
    
      
146
147
148
149 
     | 
    
      # File 'lib/graphql/tracing/notifications_trace.rb', line 146
def begin_authorized(type, object, context)
  begin_notifications_event("authorized.graphql", {type: type, object: object, context: context})
  super
end
     | 
  
 
    
      
  
  
    #begin_dataloader_source(source)  ⇒ Object 
  
  
  
  
    
      
166
167
168
169 
     | 
    
      # File 'lib/graphql/tracing/notifications_trace.rb', line 166
def begin_dataloader_source(source)
  begin_notifications_event("dataloader_source.graphql", { source: source })
  super
end
     | 
  
 
    
      
  
  
    #begin_execute_field(field, object, arguments, query)  ⇒ Object 
  
  
  
  
    
      
123
124
125
126 
     | 
    
      # File 'lib/graphql/tracing/notifications_trace.rb', line 123
def begin_execute_field(field, object, arguments, query)
  begin_notifications_event("execute_field.graphql", {field: field, object: object, arguments: arguments, query: query})
  super
end
     | 
  
 
    
      
  
  
    #begin_resolve_type(type, object, context)  ⇒ Object 
  
  
  
  
    
      
156
157
158
159 
     | 
    
      # File 'lib/graphql/tracing/notifications_trace.rb', line 156
def begin_resolve_type(type, object, context)
  begin_notifications_event("resolve_type.graphql", {type: type, object: object, context: context})
  super
end
     | 
  
 
    
      
  
  
    #dataloader_fiber_resume(source)  ⇒ Object 
  
  
  
  
    
      
138
139
140
141
142
143
144 
     | 
    
      # File 'lib/graphql/tracing/notifications_trace.rb', line 138
def dataloader_fiber_resume(source)
  prev_ev = Fiber[PREVIOUS_EV_KEY]
  if prev_ev
    begin_notifications_event(prev_ev.name, prev_ev.payload)
  end
  super
end
     | 
  
 
    
      
  
  
    #dataloader_fiber_yield(source)  ⇒ Object 
  
  
  
  
    
      
133
134
135
136 
     | 
    
      # File 'lib/graphql/tracing/notifications_trace.rb', line 133
def dataloader_fiber_yield(source)
  Fiber[PREVIOUS_EV_KEY] = finish_notifications_event
  super
end 
     | 
  
 
    
      
  
  
    #end_analyze_multiplex(_multiplex, _analyzers)  ⇒ Object 
  
  
  
  
    
      
112
113
114
115 
     | 
    
      # File 'lib/graphql/tracing/notifications_trace.rb', line 112
def end_analyze_multiplex(_multiplex, _analyzers)
  finish_notifications_event
  super
end 
     | 
  
 
    
      
  
  
    #end_authorized(type, object, context, result)  ⇒ Object 
  
  
  
  
    
      
151
152
153
154 
     | 
    
      # File 'lib/graphql/tracing/notifications_trace.rb', line 151
def end_authorized(type, object, context, result)
  finish_notifications_event
  super
end 
     | 
  
 
    
      
  
  
    #end_dataloader_source(source)  ⇒ Object 
  
  
  
  
    
      
171
172
173
174 
     | 
    
      # File 'lib/graphql/tracing/notifications_trace.rb', line 171
def end_dataloader_source(source)
  finish_notifications_event
  super
end 
     | 
  
 
    
      
  
  
    #end_execute_field(_field, _object, _arguments, _query, _result)  ⇒ Object 
  
  
  
  
    
      
128
129
130
131 
     | 
    
      # File 'lib/graphql/tracing/notifications_trace.rb', line 128
def end_execute_field(_field, _object, _arguments, _query, _result)
  finish_notifications_event
  super
end 
     | 
  
 
    
      
  
  
    #end_resolve_type(type, object, context, resolved_type)  ⇒ Object 
  
  
  
  
    
      
161
162
163
164 
     | 
    
      # File 'lib/graphql/tracing/notifications_trace.rb', line 161
def end_resolve_type(type, object, context, resolved_type)
  finish_notifications_event
  super
end 
     | 
  
 
    
      
  
  
    #execute_multiplex(**payload)  ⇒ Object 
  
  
  
  
    
      
117
118
119
120
121 
     | 
    
      # File 'lib/graphql/tracing/notifications_trace.rb', line 117
def execute_multiplex(**payload)
  @notifications.instrument("execute.graphql", payload) do
    super
  end
end
     | 
  
 
    
      
  
  
    #initialize(engine:, **rest)  ⇒ Object 
  
  
  
  
    
      
77
78
79
80
81
82
83
84
85
86
87 
     | 
    
      # File 'lib/graphql/tracing/notifications_trace.rb', line 77
def initialize(engine:, **rest)
  adapter = if defined?(Dry::Monitor) && engine == Dry::Monitor
    DryMonitoringAdapter
  elsif defined?(ActiveSupport::Notifications) && engine == ActiveSupport::Notifications
    ActiveSupportNotificationsAdapter
  else
    engine
  end
  @notifications = adapter.new
  super
end
     | 
  
 
    
      
  
  
    #lex(**payload)  ⇒ Object 
  
  
  
  
    
      
95
96
97
98
99 
     | 
    
      # File 'lib/graphql/tracing/notifications_trace.rb', line 95
def lex(**payload)
  @notifications.instrument("lex.graphql", payload) do
    super
  end
end
     | 
  
 
    
      
  
  
    #parse(**payload)  ⇒ Object 
  
  
  
  
    
      
89
90
91
92
93 
     | 
    
      # File 'lib/graphql/tracing/notifications_trace.rb', line 89
def parse(**payload)
  @notifications.instrument("parse.graphql", payload) do
    super
  end
end
     | 
  
 
    
      
  
  
    #validate(**payload)  ⇒ Object 
  
  
  
  
    
      
101
102
103
104
105 
     | 
    
      # File 'lib/graphql/tracing/notifications_trace.rb', line 101
def validate(**payload)
  @notifications.instrument("validate.graphql", payload) do
    super
  end
end
     |