File tree Expand file tree Collapse file tree 5 files changed +34
-7
lines changed
src/Database/LSMTree/Internal Expand file tree Collapse file tree 5 files changed +34
-7
lines changed Original file line number Diff line number Diff line change @@ -211,13 +211,21 @@ mkTableConfigOverride GlobalOpts{diskCachePolicy} RunOpts {pipelined} =
211211mkTracer :: GlobalOpts -> Tracer IO LSM. LSMTreeTrace
212212mkTracer gopts
213213 | trace gopts =
214+ #if MIN_VERSION_contra_tracer(0,2,0)
214215 -- Don't trace update/lookup messages, because they are too noisy
215216 squelchUnless
216217 (\ case
217218 LSM. TraceTable _ LSM. TraceUpdates {} -> False
218219 LSM. TraceTable _ LSM. TraceLookups {} -> False
219220 _ -> True )
220221 (show `contramap` stdoutTracer)
222+ #else
223+ Tracer $
224+ \ case
225+ LSM. TraceTable _ LSM. TraceUpdates {} -> pure ()
226+ LSM. TraceTable _ LSM. TraceLookups {} -> pure ()
227+ e -> traceWith (show `contramap` stdoutTracer) e
228+ #endif
221229 | otherwise = nullTracer
222230
223231-------------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -613,7 +613,7 @@ library
613613 , bytestring ^>= 0.11.4.0 || ^>= 0.12.1.0
614614 , cborg ^>= 0.2.10.0
615615 , containers ^>= 0.6 || ^>= 0.7
616- , contra-tracer ^>= 0.2
616+ , contra-tracer ^>= 0.1 || ^ >= 0. 2
617617 , crc32c ^>= 0.2.1
618618 , deepseq ^>= 1.4 || ^>= 1.5
619619 , filepath
Original file line number Diff line number Diff line change @@ -202,12 +202,17 @@ data TableTrace =
202202 | TraceSupplyUnionCredits UnionCredits
203203 deriving stock Show
204204
205+ #if MIN_VERSION_contra_tracer(0,2,0)
205206contramapTraceMerge :: Monad m => Tracer m TableTrace -> Tracer m (AtLevel MergeTrace )
206207#ifdef DEBUG_TRACES
207208contramapTraceMerge t = TraceMerge `contramap` t
208209#else
209210contramapTraceMerge t = traceMaybe (const Nothing ) t
210211#endif
212+ #else
213+ contramapTraceMerge :: Applicative m => Tracer m TableTrace -> Tracer m (AtLevel MergeTrace )
214+ contramapTraceMerge _t = nullTracer
215+ #endif
211216
212217data CursorTrace =
213218 TraceCreateCursor TableId
Original file line number Diff line number Diff line change 1+ {-# LANGUAGE CPP #-}
2+
13module Test.ScheduledMerges (tests ) where
24
35import Control.Exception
46import Control.Monad (replicateM_ , when )
57import Control.Monad.ST
68import Control.Tracer (Tracer (Tracer ))
9+ #if MIN_VERSION_contra_tracer(0,2,0)
710import qualified Control.Tracer as Tracer
11+ #endif
812import Data.Foldable (find , traverse_ )
913import Data.Maybe (fromJust )
1014import Data.STRef
@@ -526,7 +530,11 @@ genShrinkTrace !n x
526530runWithTracer :: (Tracer (ST RealWorld ) Event -> IO a ) -> IO a
527531runWithTracer action = do
528532 events <- stToIO $ newSTRef []
529- let tracer = Tracer $ Tracer. emit $ \ e -> modifySTRef events (e : )
533+ let tracer = Tracer $
534+ #if MIN_VERSION_contra_tracer(0,2,0)
535+ Tracer. emit $
536+ #endif
537+ \ e -> modifySTRef events (e : )
530538 action tracer `catch` \ e -> do
531539 if isDiscard e -- don't intercept these
532540 then throwIO e
Original file line number Diff line number Diff line change 1+ {-# LANGUAGE CPP #-}
12{-# LANGUAGE LambdaCase #-}
23{-# LANGUAGE OverloadedStrings #-}
34{-# LANGUAGE RecordWildCards #-}
@@ -134,11 +135,16 @@ prop_openSession_restoreSession =
134135-- | A tracer that records session open, session new, and session restore
135136-- messages in a mutable variable.
136137mkSessionOpenModeTracer :: IORef [String ] -> Tracer IO LSMTreeTrace
137- mkSessionOpenModeTracer var = Tracer $ emit $ \ case
138- TraceOpenSession {} -> modifyIORef var (" Open" : )
139- TraceNewSession {} -> modifyIORef var (" New" : )
140- TraceRestoreSession {} -> modifyIORef var (" Restore" : )
141- _ -> pure ()
138+ mkSessionOpenModeTracer var =
139+ Tracer $
140+ #if MIN_VERSION_contra_tracer(0,2,0)
141+ emit $
142+ #endif
143+ \ case
144+ TraceOpenSession {} -> modifyIORef var (" Open" : )
145+ TraceNewSession {} -> modifyIORef var (" New" : )
146+ TraceRestoreSession {} -> modifyIORef var (" Restore" : )
147+ _ -> pure ()
142148
143149{- ------------------------------------------------------------------------------
144150 Session: happy path
You can’t perform that action at this time.
0 commit comments