Skip to content

Commit 271977b

Browse files
committed
Fixes
1 parent 0b9d9c0 commit 271977b

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

cardano-node/src/Cardano/Node/Tracing/Tracers/LedgerMetrics.hs

+6-11
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ import qualified Ouroboros.Network.AnchoredFragment as AF
2929

3030
import Control.Concurrent (threadDelay)
3131
import Control.Concurrent.Async (async)
32-
import Control.Concurrent.STM.TVar (readTVar, registerDelay)
3332
import Control.Monad.Class.MonadAsync (link)
34-
import Control.Monad.STM (STM, atomically, check, retry)
33+
import Control.Monad.STM (atomically, retry)
3534
import "contra-tracer" Control.Tracer (Tracer, traceWith)
3635
import Data.Aeson (Value (Number, String), toJSON, (.=))
3736
import Data.Text as Text
38-
import GHC.Conc (unsafeIOToSTM)
37+
import GHC.Conc (labelThread, myThreadId, unsafeIOToSTM)
3938

4039
startLedgerMetricsTracer
4140
:: forall blk
@@ -53,7 +52,9 @@ startLedgerMetricsTracer tr everyNThSlot nodeKernelData = do
5352
link as
5453
where
5554
ledgerMetricsThread :: IO ()
56-
ledgerMetricsThread = go 1 SNothing
55+
ledgerMetricsThread = do
56+
myThreadId >>= flip labelThread "Peer Tracer"
57+
go 1 SNothing
5758
where
5859
go :: Int -> StrictMaybe SlotNo -> IO ()
5960
go !i !prevSlot = do
@@ -74,16 +75,10 @@ startLedgerMetricsTracer tr everyNThSlot nodeKernelData = do
7475
case mSlot of
7576
CurrentSlot s' | SJust s' /= prev -> return s'
7677
_ -> do
77-
delaySTM $ 5 * 1000 -- 5 milliseconds
78+
unsafeIOToSTM ( threadDelay $ 1 * 1000)
7879
retry
7980
) nodeKernelData
8081

81-
-- STM action that completes after a given delay (in microseconds)
82-
delaySTM :: Int -> STM ()
83-
delaySTM micros = do
84-
tvar <- unsafeIOToSTM (registerDelay micros) -- gives you a TVar Bool
85-
readTVar tvar >>= check
86-
8782
data LedgerMetrics =
8883
LedgerMetrics {
8984
tsSlotNo :: SlotNo

0 commit comments

Comments
 (0)