diff --git a/ghcide/src/Development/IDE/Core/Shake.hs b/ghcide/src/Development/IDE/Core/Shake.hs index f4b702b794..499d8b043c 100644 --- a/ghcide/src/Development/IDE/Core/Shake.hs +++ b/ghcide/src/Development/IDE/Core/Shake.hs @@ -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 () @@ -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 diff --git a/ghcide/src/Development/IDE/Core/Tracing.hs b/ghcide/src/Development/IDE/Core/Tracing.hs index db0acc27b5..1c773587bc 100644 --- a/ghcide/src/Development/IDE/Core/Tracing.hs +++ b/ghcide/src/Development/IDE/Core/Tracing.hs @@ -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, @@ -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