@@ -8,7 +8,6 @@ module Development.IDE.Core.Tracing
8
8
, getInstrumentCached
9
9
, otTracedProvider
10
10
, otSetUri
11
- , isTracingEnabled
12
11
)
13
12
where
14
13
@@ -29,6 +28,7 @@ import Data.IORef (modifyIORef', newIORef,
29
28
readIORef , writeIORef )
30
29
import Data.String (IsString (fromString ))
31
30
import Data.Text.Encoding (encodeUtf8 )
31
+ import Debug.Trace.Flags (userTracingEnabled )
32
32
import Development.IDE.Core.RuleTypes (GhcSession (GhcSession ),
33
33
GhcSessionDeps (GhcSessionDeps ),
34
34
GhcSessionIO (GhcSessionIO ))
@@ -39,7 +39,6 @@ import Development.IDE.Types.Shake (Key (..), Value,
39
39
Values )
40
40
import Development.Shake (Action , actionBracket )
41
41
import Foreign.Storable (Storable (sizeOf ))
42
- import GHC.RTS.Flags
43
42
import HeapSize (recursiveSize , runHeapsize )
44
43
import Ide.PluginUtils (installSigUsr1Handler )
45
44
import Ide.Types (PluginId (.. ))
@@ -51,7 +50,6 @@ import OpenTelemetry.Eventlog (Instrument, SpanInFlight (..),
51
50
addEvent , beginSpan , endSpan ,
52
51
mkValueObserver , observe ,
53
52
setTag , withSpan , withSpan_ )
54
- import System.IO.Unsafe (unsafePerformIO )
55
53
56
54
-- | Trace a handler using OpenTelemetry. Adds various useful info into tags in the OpenTelemetry span.
57
55
otTracedHandler
@@ -61,7 +59,7 @@ otTracedHandler
61
59
-> (SpanInFlight -> m a )
62
60
-> m a
63
61
otTracedHandler requestType label act
64
- | isTracingEnabled = do
62
+ | userTracingEnabled = do
65
63
let ! name =
66
64
if null label
67
65
then requestType
@@ -74,14 +72,6 @@ otTracedHandler requestType label act
74
72
otSetUri :: SpanInFlight -> Uri -> IO ()
75
73
otSetUri sp (Uri t) = setTag sp " uri" (encodeUtf8 t)
76
74
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
-
85
75
-- | Trace a Shake action using opentelemetry.
86
76
otTracedAction
87
77
:: Show k
@@ -91,7 +81,7 @@ otTracedAction
91
81
-> Action a -- ^ The action
92
82
-> Action a
93
83
otTracedAction key file success act
94
- | isTracingEnabled =
84
+ | userTracingEnabled =
95
85
actionBracket
96
86
(do
97
87
sp <- beginSpan (fromString (show key))
@@ -111,7 +101,7 @@ otTracedProvider :: MonadUnliftIO m => PluginId -> ByteString -> m a -> m a
111
101
otTracedProvider :: MonadUnliftIO m => PluginId -> String -> m a -> m a
112
102
#endif
113
103
otTracedProvider (PluginId pluginName) provider act
114
- | isTracingEnabled = do
104
+ | userTracingEnabled = do
115
105
runInIO <- askRunInIO
116
106
liftIO $ withSpan (provider <> " provider" ) $ \ sp -> do
117
107
setTag sp " plugin" (encodeUtf8 pluginName)
0 commit comments