@@ -8,7 +8,6 @@ module Development.IDE.Core.Tracing
88 , getInstrumentCached
99 , otTracedProvider
1010 , otSetUri
11- , isTracingEnabled
1211 )
1312where
1413
@@ -29,6 +28,7 @@ import Data.IORef (modifyIORef', newIORef,
2928 readIORef , writeIORef )
3029import Data.String (IsString (fromString ))
3130import Data.Text.Encoding (encodeUtf8 )
31+ import Debug.Trace.Flags (userTracingEnabled )
3232import Development.IDE.Core.RuleTypes (GhcSession (GhcSession ),
3333 GhcSessionDeps (GhcSessionDeps ),
3434 GhcSessionIO (GhcSessionIO ))
@@ -39,7 +39,6 @@ import Development.IDE.Types.Shake (Key (..), Value,
3939 Values )
4040import Development.Shake (Action , actionBracket )
4141import Foreign.Storable (Storable (sizeOf ))
42- import GHC.RTS.Flags
4342import HeapSize (recursiveSize , runHeapsize )
4443import Ide.PluginUtils (installSigUsr1Handler )
4544import Ide.Types (PluginId (.. ))
@@ -51,7 +50,6 @@ import OpenTelemetry.Eventlog (Instrument, SpanInFlight (..),
5150 addEvent , beginSpan , endSpan ,
5251 mkValueObserver , observe ,
5352 setTag , withSpan , withSpan_ )
54- import System.IO.Unsafe (unsafePerformIO )
5553
5654-- | Trace a handler using OpenTelemetry. Adds various useful info into tags in the OpenTelemetry span.
5755otTracedHandler
@@ -61,7 +59,7 @@ otTracedHandler
6159 -> (SpanInFlight -> m a )
6260 -> m a
6361otTracedHandler requestType label act
64- | isTracingEnabled = do
62+ | userTracingEnabled = do
6563 let ! name =
6664 if null label
6765 then requestType
@@ -74,14 +72,6 @@ otTracedHandler requestType label act
7472otSetUri :: SpanInFlight -> Uri -> IO ()
7573otSetUri sp (Uri t) = setTag sp " uri" (encodeUtf8 t)
7674
77- {-# NOINLINE isTracingEnabled #-}
78- isTracingEnabled :: Bool
79- isTracingEnabled = unsafePerformIO $ do
80- flags <- getTraceFlags
81- case tracing flags of
82- TraceNone -> return False
83- _ -> return True
84-
8575-- | Trace a Shake action using opentelemetry.
8676otTracedAction
8777 :: Show k
@@ -91,7 +81,7 @@ otTracedAction
9181 -> Action a -- ^ The action
9282 -> Action a
9383otTracedAction key file success act
94- | isTracingEnabled =
84+ | userTracingEnabled =
9585 actionBracket
9686 (do
9787 sp <- beginSpan (fromString (show key))
@@ -111,7 +101,7 @@ otTracedProvider :: MonadUnliftIO m => PluginId -> ByteString -> m a -> m a
111101otTracedProvider :: MonadUnliftIO m => PluginId -> String -> m a -> m a
112102#endif
113103otTracedProvider (PluginId pluginName) provider act
114- | isTracingEnabled = do
104+ | userTracingEnabled = do
115105 runInIO <- askRunInIO
116106 liftIO $ withSpan (provider <> " provider" ) $ \ sp -> do
117107 setTag sp " plugin" (encodeUtf8 pluginName)
0 commit comments