Skip to content

Trace log events and fix ghcide logger #2277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 16, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
trace build reason
  • Loading branch information
pepeiborra committed Oct 16, 2021
commit a76f8acd7a05cca61d366aac599aaab1791febd7
9 changes: 6 additions & 3 deletions ghcide/src/Development/IDE/Core/Shake.hs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ import Data.HashSet (HashSet)
import qualified Data.HashSet as HSet
import Data.IORef.Extra (atomicModifyIORef'_,
atomicModifyIORef_)
import Data.String (fromString)
import Data.Text (pack)
import qualified Development.IDE.Types.Exports as ExportsMap
import HieDb.Types
Expand Down Expand Up @@ -546,7 +547,7 @@ shakeOpen lspEnv defaultConfig logger debouncer
-- | Must be called in the 'Initialized' handler and only once
shakeSessionInit :: IdeState -> IO ()
shakeSessionInit IdeState{..} = do
initSession <- newSession shakeExtras shakeDb []
initSession <- newSession shakeExtras shakeDb [] "shakeSessionInit"
putMVar shakeSession initSession

shakeShut :: IdeState -> IO ()
Expand Down Expand Up @@ -606,7 +607,7 @@ shakeRestart IdeState{..} reason acts =
-- between spawning the new thread and updating shakeSession.
-- See https://github.com/haskell/ghcide/issues/79
(\() -> do
(,()) <$> newSession shakeExtras shakeDb acts)
(,()) <$> newSession shakeExtras shakeDb acts reason)

notifyTestingLogMessage :: ShakeExtras -> T.Text -> IO ()
notifyTestingLogMessage extras msg = do
Expand Down Expand Up @@ -643,8 +644,9 @@ newSession
:: ShakeExtras
-> ShakeDatabase
-> [DelayedActionInternal]
-> String
-> IO ShakeSession
newSession extras@ShakeExtras{..} shakeDb acts = do
newSession extras@ShakeExtras{..} shakeDb acts reason = do
IdeOptions{optRunSubset} <- getIdeOptionsIO extras
reenqueued <- atomically $ peekInProgress actionQueue
allPendingKeys <-
Expand Down Expand Up @@ -673,6 +675,7 @@ newSession extras@ShakeExtras{..} shakeDb acts = do
-- The inferred type signature doesn't work in ghc >= 9.0.1
workRun :: (forall b. IO b -> IO b) -> IO (IO ())
workRun restore = withSpan "Shake session" $ \otSpan -> do
setTag otSpan "_reason" (fromString reason)
whenJust allPendingKeys $ \kk -> setTag otSpan "keys" (BS8.pack $ unlines $ map show $ toList kk)
let keysActs = pumpActionThread otSpan : map (run otSpan) (reenqueued ++ acts)
res <- try @SomeException $
Expand Down