@@ -155,21 +155,6 @@ import qualified Focus
155
155
import GHC.Fingerprint
156
156
import Language.LSP.Types.Capabilities
157
157
import OpenTelemetry.Eventlog
158
-
159
- import Control.Exception.Extra hiding (bracket_ )
160
- import Data.Aeson (toJSON )
161
- import qualified Data.ByteString.Char8 as BS8
162
- import Data.Coerce (coerce )
163
- import Data.Default
164
- import Data.Foldable (for_ , toList )
165
- import Data.HashSet (HashSet )
166
- import qualified Data.HashSet as HSet
167
- import Data.IORef.Extra (atomicModifyIORef'_ ,
168
- atomicModifyIORef_ )
169
- import Data.String (fromString )
170
- import Data.Text (pack )
171
- import Debug.Trace.Flags (userTracingEnabled )
172
- import qualified Development.IDE.Types.Exports as ExportsMap
173
158
import HieDb.Types
174
159
import Ide.Plugin.Config
175
160
import qualified Ide.PluginUtils as HLS
@@ -178,10 +163,8 @@ import Language.LSP.Diagnostics
178
163
import qualified Language.LSP.Server as LSP
179
164
import Language.LSP.Types
180
165
import qualified Language.LSP.Types as LSP
181
- import Language.LSP.Types.Capabilities
182
166
import Language.LSP.VFS
183
167
import qualified "list-t" ListT
184
- import OpenTelemetry.Eventlog
185
168
import qualified StmContainers.Map as STM
186
169
import System.FilePath hiding (makeRelative )
187
170
import System.IO.Unsafe (unsafePerformIO )
@@ -641,10 +624,10 @@ shakeOpen recorder lspEnv defaultConfig logger debouncer
641
624
642
625
checkParents <- optCheckParents
643
626
for_ metrics $ \ store -> do
644
- let readValuesCounter = fromIntegral . countRelevantKeys checkParents . HMap. keys <$> readVar (state shakeExtras)
645
- readDirtyKeys = fromIntegral . countRelevantKeys checkParents . HSet. toList <$> readIORef (dirtyKeys shakeExtras)
627
+ let readValuesCounter = fromIntegral . countRelevantKeys checkParents <$> getStateKeys shakeExtras
628
+ readDirtyKeys = fromIntegral . countRelevantKeys checkParents . HSet. toList <$> readTVarIO (dirtyKeys shakeExtras)
646
629
readIndexPending = fromIntegral . HMap. size <$> readTVarIO (indexPending $ hiedbWriter shakeExtras)
647
- readExportsMap = fromIntegral . HMap. size . getExportsMap <$> readVar (exportsMap shakeExtras)
630
+ readExportsMap = fromIntegral . HMap. size . getExportsMap <$> readTVarIO (exportsMap shakeExtras)
648
631
readDatabaseCount = fromIntegral . countRelevantKeys checkParents . map fst <$> shakeGetDatabaseKeys shakeDb
649
632
readDatabaseStep = fromIntegral <$> shakeGetBuildStep shakeDb
650
633
@@ -666,7 +649,7 @@ startTelemetry db extras@ShakeExtras{..}
666
649
IdeOptions {optCheckParents} <- getIdeOptionsIO extras
667
650
checkParents <- optCheckParents
668
651
regularly 1 $ do
669
- observe countKeys . countRelevantKeys checkParents . map fst =<< (atomically . ListT. toList . STM. listT) state
652
+ observe countKeys . countRelevantKeys checkParents =<< getStateKeys extras
670
653
readTVarIO dirtyKeys >>= observe countDirty . countRelevantKeys checkParents . HSet. toList
671
654
shakeGetBuildStep db >>= observe countBuilds
672
655
@@ -675,6 +658,8 @@ startTelemetry db extras@ShakeExtras{..}
675
658
regularly :: Seconds -> IO () -> IO (Async () )
676
659
regularly delay act = async $ forever (act >> sleep delay)
677
660
661
+ getStateKeys :: ShakeExtras -> IO [Key ]
662
+ getStateKeys = (fmap . fmap ) fst . atomically . ListT. toList . STM. listT . state
678
663
679
664
-- | Must be called in the 'Initialized' handler and only once
680
665
shakeSessionInit :: Recorder (WithPriority Log ) -> IdeState -> IO ()
0 commit comments