@@ -19,71 +19,75 @@ import qualified Ouroboros.Network.Protocol.LocalStateQuery.Type as LSQ
1919import qualified Ouroboros.Network.Protocol.LocalTxMonitor.Type as LTM
2020import qualified Ouroboros.Network.Protocol.LocalTxSubmission.Type as LTS
2121
22- import Data.Aeson (Value (String ), (.=) )
22+ import Control.Monad.Class.MonadTime.SI (Time (.. ))
23+ import Data.Aeson (Value (String ), (.=) , (.?=) )
2324import Data.Text (Text , pack )
2425import qualified Network.TypedProtocol.Codec as Simple
2526import qualified Network.TypedProtocol.Stateful.Codec as Stateful
2627
2728{-# ANN module ("HLint: ignore Redundant bracket" :: Text) #-}
2829
30+ jsonTime :: Time -> Double
31+ jsonTime (Time x) = realToFrac x
32+
2933instance LogFormatting (Simple. AnyMessage ps )
3034 => LogFormatting (Simple. TraceSendRecv ps ) where
31- forMachine dtal (Simple. TraceSendMsg m) = mconcat
32- [ " kind" .= String " Send" , " msg" .= forMachine dtal m ]
33- forMachine dtal (Simple. TraceRecvMsg m) = mconcat
34- [ " kind" .= String " Recv" , " msg" .= forMachine dtal m ]
35+ forMachine dtal (Simple. TraceSendMsg tm m) = mconcat
36+ [ " kind" .= String " Send" , " msg" .= forMachine dtal m, " mux_at " .= jsonTime tm ]
37+ forMachine dtal (Simple. TraceRecvMsg mbTm m) = mconcat
38+ [ " kind" .= String " Recv" , " msg" .= forMachine dtal m, " mux_at " .?= fmap jsonTime mbTm ]
3539
36- forHuman (Simple. TraceSendMsg m) = " Send: " <> forHumanOrMachine m
37- forHuman (Simple. TraceRecvMsg m) = " Receive: " <> forHumanOrMachine m
40+ forHuman (Simple. TraceSendMsg _tm m) = " Send: " <> forHumanOrMachine m
41+ forHuman (Simple. TraceRecvMsg _mbTm m) = " Receive: " <> forHumanOrMachine m
3842
39- asMetrics (Simple. TraceSendMsg m) = asMetrics m
40- asMetrics (Simple. TraceRecvMsg m) = asMetrics m
43+ asMetrics (Simple. TraceSendMsg _tm m) = asMetrics m
44+ asMetrics (Simple. TraceRecvMsg _mbTm m) = asMetrics m
4145
4246instance LogFormatting (Stateful. AnyMessage ps f )
4347 => LogFormatting (Stateful. TraceSendRecv ps f ) where
44- forMachine dtal (Stateful. TraceSendMsg m) = mconcat
45- [ " kind" .= String " Send" , " msg" .= forMachine dtal m ]
46- forMachine dtal (Stateful. TraceRecvMsg m) = mconcat
47- [ " kind" .= String " Recv" , " msg" .= forMachine dtal m ]
48+ forMachine dtal (Stateful. TraceSendMsg tm m) = mconcat
49+ [ " kind" .= String " Send" , " msg" .= forMachine dtal m, " mux_at " .= jsonTime tm ]
50+ forMachine dtal (Stateful. TraceRecvMsg mbTm m) = mconcat
51+ [ " kind" .= String " Recv" , " msg" .= forMachine dtal m, " mux_at " .?= fmap jsonTime mbTm ]
4852
49- forHuman (Stateful. TraceSendMsg m) = " Send: " <> forHumanOrMachine m
50- forHuman (Stateful. TraceRecvMsg m) = " Receive: " <> forHumanOrMachine m
53+ forHuman (Stateful. TraceSendMsg _tm m) = " Send: " <> forHumanOrMachine m
54+ forHuman (Stateful. TraceRecvMsg _mbTm m) = " Receive: " <> forHumanOrMachine m
5155
52- asMetrics (Stateful. TraceSendMsg m) = asMetrics m
53- asMetrics (Stateful. TraceRecvMsg m) = asMetrics m
56+ asMetrics (Stateful. TraceSendMsg _tm m) = asMetrics m
57+ asMetrics (Stateful. TraceRecvMsg _mbTm m) = asMetrics m
5458
5559instance MetaTrace (Simple. AnyMessage ps ) =>
5660 MetaTrace (Simple. TraceSendRecv ps ) where
57- namespaceFor (Simple. TraceSendMsg msg) =
61+ namespaceFor (Simple. TraceSendMsg _tm msg) =
5862 nsPrependInner " Send" (namespaceFor msg)
59- namespaceFor (Simple. TraceRecvMsg msg) =
63+ namespaceFor (Simple. TraceRecvMsg _mbTm msg) =
6064 nsPrependInner " Receive" (namespaceFor msg)
6165
62- severityFor (Namespace out (" Send" : tl)) (Just (Simple. TraceSendMsg msg)) =
66+ severityFor (Namespace out (" Send" : tl)) (Just (Simple. TraceSendMsg _tm msg)) =
6367 severityFor (Namespace out tl) (Just msg)
6468 severityFor (Namespace out (" Send" : tl)) Nothing =
6569 severityFor (Namespace out tl :: Namespace (Simple. AnyMessage ps )) Nothing
66- severityFor (Namespace out (" Receive" : tl)) (Just (Simple. TraceSendMsg msg)) =
70+ severityFor (Namespace out (" Receive" : tl)) (Just (Simple. TraceSendMsg _tm msg)) =
6771 severityFor (Namespace out tl) (Just msg)
6872 severityFor (Namespace out (" Receive" : tl)) Nothing =
6973 severityFor (Namespace out tl :: Namespace (Simple. AnyMessage ps )) Nothing
7074 severityFor _ _ = Nothing
7175
72- privacyFor (Namespace out (" Send" : tl)) (Just (Simple. TraceSendMsg msg)) =
76+ privacyFor (Namespace out (" Send" : tl)) (Just (Simple. TraceSendMsg _tm msg)) =
7377 privacyFor (Namespace out tl) (Just msg)
7478 privacyFor (Namespace out (" Send" : tl)) Nothing =
7579 privacyFor (Namespace out tl :: Namespace (Simple. AnyMessage ps )) Nothing
76- privacyFor (Namespace out (" Receive" : tl)) (Just (Simple. TraceSendMsg msg)) =
80+ privacyFor (Namespace out (" Receive" : tl)) (Just (Simple. TraceSendMsg _tm msg)) =
7781 privacyFor (Namespace out tl) (Just msg)
7882 privacyFor (Namespace out (" Receive" : tl)) Nothing =
7983 privacyFor (Namespace out tl :: Namespace (Simple. AnyMessage ps )) Nothing
8084 privacyFor _ _ = Nothing
8185
82- detailsFor (Namespace out (" Send" : tl)) (Just (Simple. TraceSendMsg msg)) =
86+ detailsFor (Namespace out (" Send" : tl)) (Just (Simple. TraceSendMsg _tm msg)) =
8387 detailsFor (Namespace out tl) (Just msg)
8488 detailsFor (Namespace out (" Send" : tl)) Nothing =
8589 detailsFor (Namespace out tl :: Namespace (Simple. AnyMessage ps )) Nothing
86- detailsFor (Namespace out (" Receive" : tl)) (Just (Simple. TraceSendMsg msg)) =
90+ detailsFor (Namespace out (" Receive" : tl)) (Just (Simple. TraceSendMsg _tm msg)) =
8791 detailsFor (Namespace out tl) (Just msg)
8892 detailsFor (Namespace out (" Receive" : tl)) Nothing =
8993 detailsFor (Namespace out tl :: Namespace (Simple. AnyMessage ps )) Nothing
@@ -107,36 +111,36 @@ instance MetaTrace (Simple.AnyMessage ps) =>
107111
108112instance MetaTrace (Stateful. AnyMessage ps f ) =>
109113 MetaTrace (Stateful. TraceSendRecv ps f ) where
110- namespaceFor (Stateful. TraceSendMsg msg) =
114+ namespaceFor (Stateful. TraceSendMsg _tm msg) =
111115 nsPrependInner " Send" (namespaceFor msg)
112- namespaceFor (Stateful. TraceRecvMsg msg) =
116+ namespaceFor (Stateful. TraceRecvMsg _mbTm msg) =
113117 nsPrependInner " Receive" (namespaceFor msg)
114118
115- severityFor (Namespace out (" Send" : tl)) (Just (Stateful. TraceSendMsg msg)) =
119+ severityFor (Namespace out (" Send" : tl)) (Just (Stateful. TraceSendMsg _tm msg)) =
116120 severityFor (Namespace out tl) (Just msg)
117121 severityFor (Namespace out (" Send" : tl)) Nothing =
118122 severityFor (Namespace out tl :: Namespace (Stateful. AnyMessage ps f )) Nothing
119- severityFor (Namespace out (" Receive" : tl)) (Just (Stateful. TraceSendMsg msg)) =
123+ severityFor (Namespace out (" Receive" : tl)) (Just (Stateful. TraceSendMsg _tm msg)) =
120124 severityFor (Namespace out tl) (Just msg)
121125 severityFor (Namespace out (" Receive" : tl)) Nothing =
122126 severityFor (Namespace out tl :: Namespace (Stateful. AnyMessage ps f )) Nothing
123127 severityFor _ _ = Nothing
124128
125- privacyFor (Namespace out (" Send" : tl)) (Just (Stateful. TraceSendMsg msg)) =
129+ privacyFor (Namespace out (" Send" : tl)) (Just (Stateful. TraceSendMsg _tm msg)) =
126130 privacyFor (Namespace out tl) (Just msg)
127131 privacyFor (Namespace out (" Send" : tl)) Nothing =
128132 privacyFor (Namespace out tl :: Namespace (Stateful. AnyMessage ps f )) Nothing
129- privacyFor (Namespace out (" Receive" : tl)) (Just (Stateful. TraceSendMsg msg)) =
133+ privacyFor (Namespace out (" Receive" : tl)) (Just (Stateful. TraceSendMsg _tm msg)) =
130134 privacyFor (Namespace out tl) (Just msg)
131135 privacyFor (Namespace out (" Receive" : tl)) Nothing =
132136 privacyFor (Namespace out tl :: Namespace (Stateful. AnyMessage ps f )) Nothing
133137 privacyFor _ _ = Nothing
134138
135- detailsFor (Namespace out (" Send" : tl)) (Just (Stateful. TraceSendMsg msg)) =
139+ detailsFor (Namespace out (" Send" : tl)) (Just (Stateful. TraceSendMsg _tm msg)) =
136140 detailsFor (Namespace out tl) (Just msg)
137141 detailsFor (Namespace out (" Send" : tl)) Nothing =
138142 detailsFor (Namespace out tl :: Namespace (Stateful. AnyMessage ps f )) Nothing
139- detailsFor (Namespace out (" Receive" : tl)) (Just (Stateful. TraceSendMsg msg)) =
143+ detailsFor (Namespace out (" Receive" : tl)) (Just (Stateful. TraceSendMsg _tm msg)) =
140144 detailsFor (Namespace out tl) (Just msg)
141145 detailsFor (Namespace out (" Receive" : tl)) Nothing =
142146 detailsFor (Namespace out tl :: Namespace (Stateful. AnyMessage ps f )) Nothing
0 commit comments