Skip to content

Trace more Shake evaluation details #1861

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 3 commits into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 5 additions & 5 deletions ghcide/src/Development/IDE/Core/Shake.hs
Original file line number Diff line number Diff line change
Expand Up @@ -829,9 +829,9 @@ defineEarlyCutoff
:: IdeRule k v
=> RuleBody k v
-> Rules ()
defineEarlyCutoff (Rule op) = addRule $ \(Q (key, file)) (old :: Maybe BS.ByteString) mode -> otTracedAction key file isSuccess $ do
defineEarlyCutoff (Rule op) = addRule $ \(Q (key, file)) (old :: Maybe BS.ByteString) mode -> otTracedAction key file mode isSuccess $ do
defineEarlyCutoff' True key file old mode $ op key file
defineEarlyCutoff (RuleNoDiagnostics op) = addRule $ \(Q (key, file)) (old :: Maybe BS.ByteString) mode -> otTracedAction key file isSuccess $ do
defineEarlyCutoff (RuleNoDiagnostics op) = addRule $ \(Q (key, file)) (old :: Maybe BS.ByteString) mode -> otTracedAction key file mode isSuccess $ do
defineEarlyCutoff' False key file old mode $ second (mempty,) <$> op key file

defineNoFile :: IdeRule k v => (k -> Action v) -> Rules ()
Expand Down Expand Up @@ -904,9 +904,9 @@ defineEarlyCutoff' doDiagnostics key file old mode action = do
(encodeShakeValue bs) $
A res

isSuccess :: RunResult (A v) -> Bool
isSuccess (RunResult _ _ (A Failed{})) = False
isSuccess _ = True
isSuccess :: A v -> Bool
isSuccess (A Failed{}) = False
isSuccess _ = True

-- | Rule type, input file
data QDisk k = QDisk k NormalizedFilePath
Expand Down
15 changes: 10 additions & 5 deletions ghcide/src/Development/IDE/Core/Tracing.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import Development.IDE.Core.RuleTypes (GhcSession (GhcSession),
GhcSessionDeps (GhcSessionDeps),
GhcSessionIO (GhcSessionIO))
import Development.IDE.Graph (Action, actionBracket)
import Development.IDE.Graph.Rule
import Development.IDE.Types.Location (Uri (..))
import Development.IDE.Types.Logger (Logger, logDebug, logInfo)
import Development.IDE.Types.Shake (Key (..), Value,
Expand Down Expand Up @@ -77,21 +78,25 @@ otTracedAction
:: Show k
=> k -- ^ The Action's Key
-> NormalizedFilePath -- ^ Path to the file the action was run for
-> (a -> Bool) -- ^ Did this action succeed?
-> Action a -- ^ The action
-> Action a
otTracedAction key file success act
-> RunMode
-> (a -> Bool)
-> Action (RunResult a) -- ^ The action
-> Action (RunResult a)
otTracedAction key file mode success act
| userTracingEnabled =
actionBracket
(do
sp <- beginSpan (fromString (show key))
setTag sp "File" (fromString $ fromNormalizedFilePath file)
setTag sp "Mode" (fromString $ show mode)
return sp
)
endSpan
(\sp -> do
res <- act
unless (success res) $ setTag sp "error" "1"
unless (success $ runValue res) $ setTag sp "error" "1"
setTag sp "changed" $ case res of
RunResult x _ _ -> fromString $ show x
return res)
| otherwise = act

Expand Down