Skip to content

Commit 86bc644

Browse files
committed
Skip tracing unless eventlog is enabled
This was done only for otTracedAction but not for otTracedHandler and otTracedProvider
1 parent 3a10119 commit 86bc644

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

Diff for: ghcide/src/Development/IDE/Core/Tracing.hs

+20-14
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ module Development.IDE.Core.Tracing
66
, startTelemetry
77
, measureMemory
88
, getInstrumentCached
9-
,otTracedProvider,otSetUri)
9+
, otTracedProvider
10+
, otSetUri
11+
, isTracingEnabled
12+
)
1013
where
1114

1215
import Control.Concurrent.Async (Async, async)
@@ -58,14 +61,15 @@ otTracedHandler
5861
-> (SpanInFlight -> m a)
5962
-> m a
6063
otTracedHandler requestType label act =
61-
let !name =
62-
if null label
63-
then requestType
64-
else requestType <> ":" <> show label
65-
-- Add an event so all requests can be quickly seen in the viewer without searching
66-
in do
67-
runInIO <- askRunInIO
68-
liftIO $ withSpan (fromString name) (\sp -> addEvent sp "" (fromString $ name <> " received") >> runInIO (act sp))
64+
| isTracingEnabled = do
65+
let !name =
66+
if null label
67+
then requestType
68+
else requestType <> ":" <> show label
69+
-- Add an event so all requests can be quickly seen in the viewer without searching
70+
runInIO <- askRunInIO
71+
liftIO $ withSpan (fromString name) (\sp -> addEvent sp "" (fromString $ name <> " received") >> runInIO (act sp))
72+
| otherwise = act
6973

7074
otSetUri :: SpanInFlight -> Uri -> IO ()
7175
otSetUri sp (Uri t) = setTag sp "uri" (encodeUtf8 t)
@@ -106,11 +110,13 @@ otTracedProvider :: MonadUnliftIO m => PluginId -> ByteString -> m a -> m a
106110
#else
107111
otTracedProvider :: MonadUnliftIO m => PluginId -> String -> m a -> m a
108112
#endif
109-
otTracedProvider (PluginId pluginName) provider act = do
110-
runInIO <- askRunInIO
111-
liftIO $ withSpan (provider <> " provider") $ \sp -> do
112-
setTag sp "plugin" (encodeUtf8 pluginName)
113-
runInIO act
113+
otTracedProvider (PluginId pluginName) provider act
114+
| isTracingEnabled = do
115+
runInIO <- askRunInIO
116+
liftIO $ withSpan (provider <> " provider") $ \sp -> do
117+
setTag sp "plugin" (encodeUtf8 pluginName)
118+
runInIO act
119+
| otherwise = act
114120

115121
startTelemetry :: Bool -> Logger -> Var Values -> IO ()
116122
startTelemetry allTheTime logger stateRef = do

0 commit comments

Comments
 (0)