@@ -35,6 +35,48 @@ def execute_multiplex(**metadata, &blk)
3535 end
3636 end
3737
38+ # GraphQL versions >= 2.5 are missing this notification
39+ module ExecuteQueryNotification
40+ def execute_query ( **metadata , &blk )
41+ if @notifications_engine
42+ @notifications_engine . instrument ( "execute_query.graphql" , metadata , &blk )
43+ elsif @notifications
44+ @notifications . instrument ( "execute_query.graphql" , metadata , &blk )
45+ else
46+ # safety fallback in case graphql's authors unexpectedly rename @notifications_engine or @notifications
47+ super
48+ end
49+ end
50+ end
51+
52+ # GraphQL versions >= 2.5 are missing this notification
53+ module ExecuteQueryLazyNotification
54+ def execute_query_lazy ( **metadata , &blk )
55+ if @notifications_engine
56+ @notifications_engine . instrument ( "execute_query_lazy.graphql" , metadata , &blk )
57+ elsif @notifications
58+ @notifications . instrument ( "execute_query_lazy.graphql" , metadata , &blk )
59+ else
60+ # safety fallback in case graphql's authors unexpectedly rename @notifications_engine or @notifications
61+ super
62+ end
63+ end
64+ end
65+
66+ # GraphQL versions >= 2.5 are missing this notification
67+ module AnalyzeQueryNotification
68+ def analyze_query ( **metadata , &blk )
69+ if @notifications_engine
70+ @notifications_engine . instrument ( "analyze_query.graphql" , metadata , &blk )
71+ elsif @notifications
72+ @notifications . instrument ( "analyze_query.graphql" , metadata , &blk )
73+ else
74+ # safety fallback in case graphql's authors unexpectedly rename @notifications_engine or @notifications
75+ super
76+ end
77+ end
78+ end
79+
3880 module ClassMethods
3981 def new_trace ( *, **)
4082 unless @__sk_instrumentation_installed
@@ -44,6 +86,18 @@ def new_trace(*, **)
4486 trace_with ( ExecuteMultiplexNotification )
4587 end
4688
89+ unless ::GraphQL ::Tracing ::ActiveSupportNotificationsTrace . instance_methods . include? ( :execute_query )
90+ trace_with ( ExecuteQueryNotification )
91+ end
92+
93+ unless ::GraphQL ::Tracing ::ActiveSupportNotificationsTrace . instance_methods . include? ( :execute_query_lazy )
94+ trace_with ( ExecuteQueryLazyNotification )
95+ end
96+
97+ unless ::GraphQL ::Tracing ::ActiveSupportNotificationsTrace . instance_methods . include? ( :analyze_query )
98+ trace_with ( AnalyzeQueryNotification )
99+ end
100+
47101 @__sk_instrumentation_installed = true
48102 end
49103
0 commit comments