@@ -6,6 +6,7 @@ defmodule Absinthe.Subscription.Local do
66 require Logger
77
88 alias Absinthe.Pipeline.BatchResolver
9+ alias Absinthe . { Phase , Pipeline }
910
1011 # This module handles running and broadcasting documents that are local to this
1112 # node.
@@ -23,19 +24,37 @@ defmodule Absinthe.Subscription.Local do
2324 def publish_mutation ( pubsub , mutation_result , subscribed_fields ) do
2425 docs_and_topics =
2526 for { field , key_strategy } <- subscribed_fields ,
26- { topic , doc } <- get_docs ( pubsub , field , mutation_result , key_strategy ) do
27+ { topic , doc } <- get_docs_with_telemetry ( pubsub , field , mutation_result , key_strategy ) do
2728 { topic , key_strategy , doc }
2829 end
2930
3031 run_docset_fn =
3132 if function_exported? ( pubsub , :run_docset , 3 ) , do: & pubsub . run_docset / 3 , else: & run_docset / 3
3233
33- run_docset_fn . ( pubsub , docs_and_topics , mutation_result )
34+ :telemetry . span (
35+ [ :absinthe , :subscription , :local , :run_docset ] ,
36+ % {
37+ run_docset_fn: run_docset_fn ,
38+ mutation_result: mutation_result ,
39+ docs_and_topics: docs_and_topics
40+ } ,
41+ fn ->
42+ { run_docset_fn . ( pubsub , docs_and_topics , mutation_result ) , % { } }
43+ end
44+ )
3445
3546 :ok
3647 end
3748
38- alias Absinthe . { Phase , Pipeline }
49+ defp get_docs_with_telemetry ( pubsub , field , mutation_result , key_strategy ) do
50+ :telemetry . span (
51+ [ :absinthe , :subscription , :local , :get_docs ] ,
52+ % { pubsub: pubsub , field: field , mutation_result: mutation_result , key_strategy: key_strategy } ,
53+ fn ->
54+ { get_docs ( pubsub , field , mutation_result , key_strategy ) , % { } }
55+ end
56+ )
57+ end
3958
4059 defp run_docset ( pubsub , docs_and_topics , mutation_result ) do
4160 for { topic , key_strategy , doc } <- docs_and_topics do
0 commit comments