{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Ouroboros.Network.Tracing.ConnectionManager () where
import Data.Aeson (ToJSON, Value (String), object, toJSON, (.=))
import Data.Aeson.Types (listValue)
import Data.Map.Strict qualified as Map
import Data.Set qualified as Set
import Data.Text (pack)
import Cardano.Logging
import Ouroboros.Network.ConnectionHandler (ConnectionHandlerTrace (..))
import Ouroboros.Network.ConnectionId (ConnectionId (..))
import Ouroboros.Network.ConnectionManager.ConnMap (ConnMap (..))
import Ouroboros.Network.ConnectionManager.Core as ConnectionManager
(Trace (..))
import Ouroboros.Network.ConnectionManager.Types
(ConnectionManagerCounters (..))
import Ouroboros.Network.ConnectionManager.Types qualified as ConnectionManager
import Ouroboros.Network.RethrowPolicy (ErrorCommand (..))
import Ouroboros.Network.OrphanInstances qualified ()
import Ouroboros.Network.Util (PrettyShow)
instance (Show addr, LogFormatting addr, ToJSON addr, LogFormatting handler, Show handler)
=> LogFormatting (ConnectionManager.Trace addr handler) where
forMachine :: DetailLevel -> Trace addr handler -> Object
forMachine DetailLevel
dtal (TrIncludeConnection Provenance
prov addr
peerAddr) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat ([Object] -> Object) -> [Object] -> Object
forall a b. (a -> b) -> a -> b
$ [Object] -> [Object]
forall a. [a] -> [a]
reverse
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"IncludeConnection"
, Key
"remoteAddress" Key -> Object -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= DetailLevel -> addr -> Object
forall a. LogFormatting a => DetailLevel -> a -> Object
forMachine DetailLevel
dtal addr
peerAddr
, Key
"provenance" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> (Provenance -> String) -> Provenance -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Provenance -> String
forall a. Show a => a -> String
show (Provenance -> Text) -> Provenance -> Text
forall a b. (a -> b) -> a -> b
$ Provenance
prov)
]
forMachine DetailLevel
dtal (TrInboundConnectionNotFound addr
peerAddr) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat ([Object] -> Object) -> [Object] -> Object
forall a b. (a -> b) -> a -> b
$ [Object] -> [Object]
forall a. [a] -> [a]
reverse
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"InboundConnectionNotFound"
, Key
"remoteAddress" Key -> Object -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= DetailLevel -> addr -> Object
forall a. LogFormatting a => DetailLevel -> a -> Object
forMachine DetailLevel
dtal addr
peerAddr
]
forMachine DetailLevel
_dtal (TrReleaseConnection Provenance
prov ConnectionId addr
connId) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat ([Object] -> Object) -> [Object] -> Object
forall a b. (a -> b) -> a -> b
$ [Object] -> [Object]
forall a. [a] -> [a]
reverse
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"UnregisterConnection"
, Key
"remoteAddress" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId addr
connId
, Key
"provenance" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> (Provenance -> String) -> Provenance -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Provenance -> String
forall a. Show a => a -> String
show (Provenance -> Text) -> Provenance -> Text
forall a b. (a -> b) -> a -> b
$ Provenance
prov)
]
forMachine DetailLevel
_dtal (TrConnect (Just addr
localAddress) addr
remoteAddress DiffusionMode
diffusionMode) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"Connect"
, Key
"connectionId" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId { addr
localAddress :: addr
localAddress :: addr
localAddress, addr
remoteAddress :: addr
remoteAddress :: addr
remoteAddress }
, Key
"diffusionMode" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= DiffusionMode -> Value
forall a. ToJSON a => a -> Value
toJSON DiffusionMode
diffusionMode
]
forMachine DetailLevel
dtal (TrConnect Maybe addr
Nothing addr
remoteAddress DiffusionMode
diffusionMode) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"Connect"
, Key
"remoteAddress" Key -> Object -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= DetailLevel -> addr -> Object
forall a. LogFormatting a => DetailLevel -> a -> Object
forMachine DetailLevel
dtal addr
remoteAddress
, Key
"diffusionMode" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= DiffusionMode -> Value
forall a. ToJSON a => a -> Value
toJSON DiffusionMode
diffusionMode
]
forMachine DetailLevel
_dtal (TrConnectError (Just addr
localAddress) addr
remoteAddress SomeException
err) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectError"
, Key
"connectionId" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId { addr
localAddress :: addr
localAddress :: addr
localAddress, addr
remoteAddress :: addr
remoteAddress :: addr
remoteAddress }
, Key
"reason" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text)
-> (SomeException -> String) -> SomeException -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SomeException -> String
forall a. Show a => a -> String
show (SomeException -> Text) -> SomeException -> Text
forall a b. (a -> b) -> a -> b
$ SomeException
err)
]
forMachine DetailLevel
dtal (TrConnectError Maybe addr
Nothing addr
remoteAddress SomeException
err) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectError"
, Key
"remoteAddress" Key -> Object -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= DetailLevel -> addr -> Object
forall a. LogFormatting a => DetailLevel -> a -> Object
forMachine DetailLevel
dtal addr
remoteAddress
, Key
"reason" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text)
-> (SomeException -> String) -> SomeException -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SomeException -> String
forall a. Show a => a -> String
show (SomeException -> Text) -> SomeException -> Text
forall a b. (a -> b) -> a -> b
$ SomeException
err)
]
forMachine DetailLevel
_dtal (TrTerminatingConnection Provenance
prov ConnectionId addr
connId) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"TerminatingConnection"
, Key
"provenance" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> (Provenance -> String) -> Provenance -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Provenance -> String
forall a. Show a => a -> String
show (Provenance -> Text) -> Provenance -> Text
forall a b. (a -> b) -> a -> b
$ Provenance
prov)
, Key
"connectionId" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId addr
connId
]
forMachine DetailLevel
dtal (TrTerminatedConnection Provenance
prov addr
remoteAddress) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"TerminatedConnection"
, Key
"provenance" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> (Provenance -> String) -> Provenance -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Provenance -> String
forall a. Show a => a -> String
show (Provenance -> Text) -> Provenance -> Text
forall a b. (a -> b) -> a -> b
$ Provenance
prov)
, Key
"remoteAddress" Key -> Object -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= DetailLevel -> addr -> Object
forall a. LogFormatting a => DetailLevel -> a -> Object
forMachine DetailLevel
dtal addr
remoteAddress
]
forMachine DetailLevel
dtal (TrConnectionHandler ConnectionId addr
connId handler
handler) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectionHandler"
, Key
"connectionId" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId addr
connId
, Key
"connectionHandler" Key -> Object -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= DetailLevel -> handler -> Object
forall a. LogFormatting a => DetailLevel -> a -> Object
forMachine DetailLevel
dtal handler
handler
]
forMachine DetailLevel
_dtal Trace addr handler
TrShutdown =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"Shutdown"
]
forMachine DetailLevel
dtal (TrConnectionExists Provenance
prov addr
remoteAddress AbstractState
inState) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectionExists"
, Key
"provenance" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> (Provenance -> String) -> Provenance -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Provenance -> String
forall a. Show a => a -> String
show (Provenance -> Text) -> Provenance -> Text
forall a b. (a -> b) -> a -> b
$ Provenance
prov)
, Key
"remoteAddress" Key -> Object -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= DetailLevel -> addr -> Object
forall a. LogFormatting a => DetailLevel -> a -> Object
forMachine DetailLevel
dtal addr
remoteAddress
, Key
"state" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= AbstractState -> Value
forall a. ToJSON a => a -> Value
toJSON AbstractState
inState
]
forMachine DetailLevel
_dtal (TrForbiddenConnection ConnectionId addr
connId) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ForbiddenConnection"
, Key
"connectionId" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId addr
connId
]
forMachine DetailLevel
_dtal (TrConnectionFailure ConnectionId addr
connId) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectionFailure"
, Key
"connectionId" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId addr
connId
]
forMachine DetailLevel
dtal (TrConnectionNotFound Provenance
prov addr
remoteAddress) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectionNotFound"
, Key
"remoteAddress" Key -> Object -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= DetailLevel -> addr -> Object
forall a. LogFormatting a => DetailLevel -> a -> Object
forMachine DetailLevel
dtal addr
remoteAddress
, Key
"provenance" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> (Provenance -> String) -> Provenance -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Provenance -> String
forall a. Show a => a -> String
show (Provenance -> Text) -> Provenance -> Text
forall a b. (a -> b) -> a -> b
$ Provenance
prov)
]
forMachine DetailLevel
dtal (TrForbiddenOperation addr
remoteAddress AbstractState
connState) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ForbiddenOperation"
, Key
"remoteAddress" Key -> Object -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= DetailLevel -> addr -> Object
forall a. LogFormatting a => DetailLevel -> a -> Object
forMachine DetailLevel
dtal addr
remoteAddress
, Key
"connectionState" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= AbstractState -> Value
forall a. ToJSON a => a -> Value
toJSON AbstractState
connState
]
forMachine DetailLevel
_dtal (TrPruneConnections Set (ConnectionId addr)
pruningSet Int
numberPruned Set (ConnectionId addr)
chosenPeers) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PruneConnections"
, Key
"prunedPeers" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Set (ConnectionId addr) -> Value
forall a. ToJSON a => a -> Value
toJSON Set (ConnectionId addr)
pruningSet
, Key
"numberPrunedPeers" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON Int
numberPruned
, Key
"choiceSet" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Set Value -> Value
forall a. ToJSON a => a -> Value
toJSON (ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON (ConnectionId addr -> Value)
-> Set (ConnectionId addr) -> Set Value
forall b a. Ord b => (a -> b) -> Set a -> Set b
`Set.map` Set (ConnectionId addr)
chosenPeers)
]
forMachine DetailLevel
_dtal (TrConnectionCleanup ConnectionId addr
connId) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectionCleanup"
, Key
"connectionId" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId addr
connId
]
forMachine DetailLevel
_dtal (TrConnectionTimeWait ConnectionId addr
connId) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectionTimeWait"
, Key
"connectionId" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId addr
connId
]
forMachine DetailLevel
_dtal (TrConnectionTimeWaitDone ConnectionId addr
connId) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectionTimeWaitDone"
, Key
"connectionId" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId addr
connId
]
forMachine DetailLevel
_dtal (TrConnectionManagerCounters ConnectionManagerCounters
cmCounters) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectionManagerCounters"
, Key
"state" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ConnectionManagerCounters -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionManagerCounters
cmCounters
]
forMachine DetailLevel
_dtal (TrState ConnMap addr AbstractState
cmState) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectionManagerState"
, Key
"state" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ((addr, Map (LocalAddr addr) AbstractState) -> Value)
-> [(addr, Map (LocalAddr addr) AbstractState)] -> Value
forall a. (a -> Value) -> [a] -> Value
listValue (\(addr
remoteAddr, Map (LocalAddr addr) AbstractState
inner) ->
[Pair] -> Value
object
[ Key
"connections" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=
((LocalAddr addr, AbstractState) -> Value)
-> [(LocalAddr addr, AbstractState)] -> Value
forall a. (a -> Value) -> [a] -> Value
listValue (\(LocalAddr addr
localAddr, AbstractState
connState) ->
[Pair] -> Value
object
[ Key
"localAddress" Key -> LocalAddr addr -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= LocalAddr addr
localAddr
, Key
"state" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= AbstractState -> Value
forall a. ToJSON a => a -> Value
toJSON AbstractState
connState
]
)
(Map (LocalAddr addr) AbstractState
-> [(LocalAddr addr, AbstractState)]
forall k a. Map k a -> [(k, a)]
Map.toList Map (LocalAddr addr) AbstractState
inner)
, Key
"remoteAddress" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= addr -> Value
forall a. ToJSON a => a -> Value
toJSON addr
remoteAddr
]
)
(Map addr (Map (LocalAddr addr) AbstractState)
-> [(addr, Map (LocalAddr addr) AbstractState)]
forall k a. Map k a -> [(k, a)]
Map.toList (ConnMap addr AbstractState
-> Map addr (Map (LocalAddr addr) AbstractState)
forall peerAddr a.
ConnMap peerAddr a -> Map peerAddr (Map (LocalAddr peerAddr) a)
getConnMap ConnMap addr AbstractState
cmState))
]
forMachine DetailLevel
_dtal (ConnectionManager.TrUnexpectedlyFalseAssertion AssertionLocation addr
info) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"UnexpectedlyFalseAssertion"
, Key
"info" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text)
-> (AssertionLocation addr -> String)
-> AssertionLocation addr
-> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AssertionLocation addr -> String
forall a. Show a => a -> String
show (AssertionLocation addr -> Text) -> AssertionLocation addr -> Text
forall a b. (a -> b) -> a -> b
$ AssertionLocation addr
info)
]
forHuman :: Trace addr handler -> Text
forHuman = String -> Text
pack (String -> Text)
-> (Trace addr handler -> String) -> Trace addr handler -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Trace addr handler -> String
forall a. Show a => a -> String
show
asMetrics :: Trace addr handler -> [Metric]
asMetrics (TrConnectionManagerCounters ConnectionManagerCounters {Int
fullDuplexConns :: Int
duplexConns :: Int
unidirectionalConns :: Int
inboundConns :: Int
outboundConns :: Int
terminatingConns :: Int
duplexConns :: ConnectionManagerCounters -> Int
fullDuplexConns :: ConnectionManagerCounters -> Int
inboundConns :: ConnectionManagerCounters -> Int
outboundConns :: ConnectionManagerCounters -> Int
terminatingConns :: ConnectionManagerCounters -> Int
unidirectionalConns :: ConnectionManagerCounters -> Int
..}) =
[ Text -> Integer -> Metric
IntM
Text
"connectionManager.fullDuplexConns"
(Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
fullDuplexConns)
, Text -> Integer -> Metric
IntM
Text
"connectionManager.duplexConns"
(Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
duplexConns)
, Text -> Integer -> Metric
IntM
Text
"connectionManager.unidirectionalConns"
(Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
unidirectionalConns)
, Text -> Integer -> Metric
IntM
Text
"connectionManager.inboundConns"
(Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
inboundConns)
, Text -> Integer -> Metric
IntM
Text
"connectionManager.outboundConns"
(Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
outboundConns)
]
asMetrics Trace addr handler
_ = []
instance (Show versionNumber, ToJSON versionNumber, ToJSON agreedOptions)
=> LogFormatting (ConnectionHandlerTrace versionNumber agreedOptions) where
forMachine :: DetailLevel
-> ConnectionHandlerTrace versionNumber agreedOptions -> Object
forMachine DetailLevel
_dtal (TrHandshakeSuccess versionNumber
versionNumber agreedOptions
agreedOptions) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"HandshakeSuccess"
, Key
"versionNumber" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= versionNumber -> Value
forall a. ToJSON a => a -> Value
toJSON versionNumber
versionNumber
, Key
"agreedOptions" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= agreedOptions -> Value
forall a. ToJSON a => a -> Value
toJSON agreedOptions
agreedOptions
]
forMachine DetailLevel
_dtal (TrHandshakeQuery Map versionNumber (Either Text agreedOptions)
vMap) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"HandshakeQuery"
, Key
"versions" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Value] -> Value
forall a. ToJSON a => a -> Value
toJSON ((\(versionNumber
k,Either Text agreedOptions
v) -> [Pair] -> Value
object [
Key
"versionNumber" Key -> versionNumber -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= versionNumber
k
, Key
"options" Key -> Either Text agreedOptions -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Either Text agreedOptions
v
]) ((versionNumber, Either Text agreedOptions) -> Value)
-> [(versionNumber, Either Text agreedOptions)] -> [Value]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map versionNumber (Either Text agreedOptions)
-> [(versionNumber, Either Text agreedOptions)]
forall k a. Map k a -> [(k, a)]
Map.toList Map versionNumber (Either Text agreedOptions)
vMap)
]
forMachine DetailLevel
_dtal (TrHandshakeClientError HandshakeException versionNumber
err) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"HandshakeClientError"
, Key
"reason" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= HandshakeException versionNumber -> Value
forall a. ToJSON a => a -> Value
toJSON HandshakeException versionNumber
err
]
forMachine DetailLevel
_dtal (TrHandshakeServerError HandshakeException versionNumber
err) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"HandshakeServerError"
, Key
"reason" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= HandshakeException versionNumber -> Value
forall a. ToJSON a => a -> Value
toJSON HandshakeException versionNumber
err
]
forMachine DetailLevel
_dtal (TrConnectionHandlerError ErrorContext
e SomeException
err ErrorCommand
cerr) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"Error"
, Key
"context" Key -> String -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ErrorContext -> String
forall a. Show a => a -> String
show ErrorContext
e
, Key
"reason" Key -> String -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= SomeException -> String
forall a. Show a => a -> String
show SomeException
err
, Key
"command" Key -> String -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ErrorCommand -> String
forall a. Show a => a -> String
show ErrorCommand
cerr
]
instance MetaTrace handler => MetaTrace (ConnectionManager.Trace addr handler) where
namespaceFor :: Trace addr handler -> Namespace (Trace addr handler)
namespaceFor TrIncludeConnection {} = [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"IncludeConnection"]
namespaceFor TrInboundConnectionNotFound {} = [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"InboundConnectionNotFound"]
namespaceFor TrReleaseConnection {} = [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"UnregisterConnection"]
namespaceFor TrConnect {} = [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"Connect"]
namespaceFor TrConnectError {} = [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"ConnectError"]
namespaceFor TrTerminatingConnection {} = [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"TerminatingConnection"]
namespaceFor TrTerminatedConnection {} = [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"TerminatedConnection"]
namespaceFor (TrConnectionHandler ConnectionId addr
_ handler
hdl) =
Text -> Namespace handler -> Namespace (Trace addr handler)
forall a b. Text -> Namespace a -> Namespace b
nsPrependInner Text
"ConnectionHandler" (handler -> Namespace handler
forall a. MetaTrace a => a -> Namespace a
namespaceFor handler
hdl)
namespaceFor TrShutdown {} = [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"Shutdown"]
namespaceFor TrConnectionExists {} = [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"ConnectionExists"]
namespaceFor TrForbiddenConnection {} = [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"ForbiddenConnection"]
namespaceFor TrConnectionFailure {} = [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"ConnectionFailure"]
namespaceFor TrConnectionNotFound {} = [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"ConnectionNotFound"]
namespaceFor TrForbiddenOperation {} = [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"ForbiddenOperation"]
namespaceFor TrPruneConnections {} = [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"PruneConnections"]
namespaceFor TrConnectionCleanup {} = [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"ConnectionCleanup"]
namespaceFor TrConnectionTimeWait {} = [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"ConnectionTimeWait"]
namespaceFor TrConnectionTimeWaitDone {} = [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"ConnectionTimeWaitDone"]
namespaceFor TrConnectionManagerCounters {} = [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"ConnectionManagerCounters"]
namespaceFor TrState {} = [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"State"]
namespaceFor ConnectionManager.TrUnexpectedlyFalseAssertion {} =
[Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"UnexpectedlyFalseAssertion"]
severityFor :: Namespace (Trace addr handler)
-> Maybe (Trace addr handler) -> Maybe SeverityS
severityFor (Namespace [Text]
_ [Text
"IncludeConnection"]) Maybe (Trace addr handler)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Debug
severityFor (Namespace [Text]
_ [Text
"UnregisterConnection"]) Maybe (Trace addr handler)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Debug
severityFor (Namespace [Text]
_ [Text
"Connect"]) Maybe (Trace addr handler)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Debug
severityFor (Namespace [Text]
_ [Text
"ConnectError"]) Maybe (Trace addr handler)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Info
severityFor (Namespace [Text]
_ [Text
"TerminatingConnection"]) Maybe (Trace addr handler)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Debug
severityFor (Namespace [Text]
_ [Text
"TerminatedConnection"]) Maybe (Trace addr handler)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Debug
severityFor (Namespace [Text]
out (Text
"ConnectionHandler" : [Text]
tl)) (Just (TrConnectionHandler ConnectionId addr
_ handler
hdl)) =
Namespace handler -> Maybe handler -> Maybe SeverityS
forall a. MetaTrace a => Namespace a -> Maybe a -> Maybe SeverityS
severityFor ([Text] -> [Text] -> Namespace handler
forall a. [Text] -> [Text] -> Namespace a
Namespace [Text]
out [Text]
tl) (handler -> Maybe handler
forall a. a -> Maybe a
Just handler
hdl)
severityFor (Namespace [Text]
_ (Text
"ConnectionHandler" : [Text]
_)) Maybe (Trace addr handler)
Nothing = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Info
severityFor (Namespace [Text]
_ [Text
"Shutdown"]) Maybe (Trace addr handler)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Info
severityFor (Namespace [Text]
_ [Text
"ConnectionExists"]) Maybe (Trace addr handler)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Info
severityFor (Namespace [Text]
_ [Text
"ForbiddenConnection"]) Maybe (Trace addr handler)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Info
severityFor (Namespace [Text]
_ [Text
"ConnectionFailure"]) Maybe (Trace addr handler)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Info
severityFor (Namespace [Text]
_ [Text
"ConnectionNotFound"]) Maybe (Trace addr handler)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Debug
severityFor (Namespace [Text]
_ [Text
"ForbiddenOperation"]) Maybe (Trace addr handler)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Info
severityFor (Namespace [Text]
_ [Text
"PruneConnections"]) Maybe (Trace addr handler)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Notice
severityFor (Namespace [Text]
_ [Text
"ConnectionCleanup"]) Maybe (Trace addr handler)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Debug
severityFor (Namespace [Text]
_ [Text
"ConnectionTimeWait"]) Maybe (Trace addr handler)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Debug
severityFor (Namespace [Text]
_ [Text
"ConnectionTimeWaitDone"]) Maybe (Trace addr handler)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Info
severityFor (Namespace [Text]
_ [Text
"ConnectionManagerCounters"]) Maybe (Trace addr handler)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Info
severityFor (Namespace [Text]
_ [Text
"State"]) Maybe (Trace addr handler)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Info
severityFor (Namespace [Text]
_ [Text
"UnexpectedlyFalseAssertion"]) Maybe (Trace addr handler)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Error
severityFor Namespace (Trace addr handler)
_ Maybe (Trace addr handler)
_ = Maybe SeverityS
forall a. Maybe a
Nothing
documentFor :: Namespace (Trace addr handler) -> Maybe Text
documentFor (Namespace [Text]
_ [Text
"IncludeConnection"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor (Namespace [Text]
_ [Text
"UnregisterConnection"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor (Namespace [Text]
_ [Text
"Connect"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor (Namespace [Text]
_ [Text
"ConnectError"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor (Namespace [Text]
_ [Text
"TerminatingConnection"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor (Namespace [Text]
_ [Text
"TerminatedConnection"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor (Namespace [Text]
out (Text
"ConnectionHandler" : [Text]
tl)) =
Namespace handler -> Maybe Text
forall a. MetaTrace a => Namespace a -> Maybe Text
documentFor ([Text] -> [Text] -> Namespace handler
forall a. [Text] -> [Text] -> Namespace a
Namespace [Text]
out [Text]
tl :: Namespace handler)
documentFor (Namespace [Text]
_ [Text
"Shutdown"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor (Namespace [Text]
_ [Text
"ConnectionExists"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor (Namespace [Text]
_ [Text
"ForbiddenConnection"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor (Namespace [Text]
_ [Text
"ConnectionFailure"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor (Namespace [Text]
_ [Text
"ConnectionNotFound"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor (Namespace [Text]
_ [Text
"ForbiddenOperation"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor (Namespace [Text]
_ [Text
"PruneConnections"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor (Namespace [Text]
_ [Text
"ConnectionCleanup"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor (Namespace [Text]
_ [Text
"ConnectionTimeWait"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor (Namespace [Text]
_ [Text
"ConnectionTimeWaitDone"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor (Namespace [Text]
_ [Text
"ConnectionManagerCounters"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor (Namespace [Text]
_ [Text
"State"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor (Namespace [Text]
_ [Text
"UnexpectedlyFalseAssertion"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor Namespace (Trace addr handler)
_ = Maybe Text
forall a. Maybe a
Nothing
metricsDocFor :: Namespace (Trace addr handler) -> [(Text, Text)]
metricsDocFor (Namespace [Text]
_ [Text
"ConnectionManagerCounters"]) =
[(Text
"connectionManager.fullDuplexConns",Text
"")
,(Text
"connectionManager.duplexConns",Text
"")
,(Text
"connectionManager.unidirectionalConns",Text
"")
,(Text
"connectionManager.inboundConns",Text
"")
,(Text
"connectionManager.outboundConns",Text
"")
,(Text
"connectionManager.prunableConns",Text
"")
]
metricsDocFor Namespace (Trace addr handler)
_ = []
allNamespaces :: [Namespace (Trace addr handler)]
allNamespaces = [
[Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"IncludeConnection"]
, [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"UnregisterConnection"]
, [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"Connect"]
, [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"ConnectError"]
, [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"TerminatingConnection"]
, [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"TerminatedConnection"]
, [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"Shutdown"]
, [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"ConnectionExists"]
, [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"ForbiddenConnection"]
, [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"ConnectionFailure"]
, [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"ConnectionNotFound"]
, [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"ForbiddenOperation"]
, [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"PruneConnections"]
, [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"ConnectionCleanup"]
, [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"ConnectionTimeWait"]
, [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"ConnectionTimeWaitDone"]
, [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"ConnectionManagerCounters"]
, [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"State"]
, [Text] -> [Text] -> Namespace (Trace addr handler)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"UnexpectedlyFalseAssertion"]]
[Namespace (Trace addr handler)]
-> [Namespace (Trace addr handler)]
-> [Namespace (Trace addr handler)]
forall a. [a] -> [a] -> [a]
++ (Namespace handler -> Namespace (Trace addr handler))
-> [Namespace handler] -> [Namespace (Trace addr handler)]
forall a b. (a -> b) -> [a] -> [b]
map (Text -> Namespace handler -> Namespace (Trace addr handler)
forall a b. Text -> Namespace a -> Namespace b
nsPrependInner Text
"ConnectionHandler")
([Namespace handler]
forall a. MetaTrace a => [Namespace a]
allNamespaces :: [Namespace handler])
instance MetaTrace (ConnectionHandlerTrace versionNumber agreedOptions) where
namespaceFor :: ConnectionHandlerTrace versionNumber agreedOptions
-> Namespace (ConnectionHandlerTrace versionNumber agreedOptions)
namespaceFor TrHandshakeSuccess {} = [Text]
-> [Text]
-> Namespace (ConnectionHandlerTrace versionNumber agreedOptions)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"HandshakeSuccess"]
namespaceFor TrHandshakeQuery {} = [Text]
-> [Text]
-> Namespace (ConnectionHandlerTrace versionNumber agreedOptions)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"HandshakeQuery"]
namespaceFor TrHandshakeClientError {} = [Text]
-> [Text]
-> Namespace (ConnectionHandlerTrace versionNumber agreedOptions)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"HandshakeClientError"]
namespaceFor TrHandshakeServerError {} = [Text]
-> [Text]
-> Namespace (ConnectionHandlerTrace versionNumber agreedOptions)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"HandshakeServerError"]
namespaceFor TrConnectionHandlerError {} = [Text]
-> [Text]
-> Namespace (ConnectionHandlerTrace versionNumber agreedOptions)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"Error"]
severityFor :: Namespace (ConnectionHandlerTrace versionNumber agreedOptions)
-> Maybe (ConnectionHandlerTrace versionNumber agreedOptions)
-> Maybe SeverityS
severityFor (Namespace [Text]
_ [Text
"HandshakeSuccess"]) Maybe (ConnectionHandlerTrace versionNumber agreedOptions)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Info
severityFor (Namespace [Text]
_ [Text
"HandshakeQuery"]) Maybe (ConnectionHandlerTrace versionNumber agreedOptions)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Info
severityFor (Namespace [Text]
_ [Text
"HandshakeClientError"]) Maybe (ConnectionHandlerTrace versionNumber agreedOptions)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Notice
severityFor (Namespace [Text]
_ [Text
"HandshakeServerError"]) Maybe (ConnectionHandlerTrace versionNumber agreedOptions)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Info
severityFor (Namespace [Text]
_ [Text
"Error"]) (Just (TrConnectionHandlerError ErrorContext
_ SomeException
_ ErrorCommand
ShutdownNode)) = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Critical
severityFor (Namespace [Text]
_ [Text
"Error"]) (Just (TrConnectionHandlerError ErrorContext
_ SomeException
_ ErrorCommand
ShutdownPeer)) = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Info
severityFor (Namespace [Text]
_ [Text
"Error"]) Maybe (ConnectionHandlerTrace versionNumber agreedOptions)
Nothing = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Info
severityFor Namespace (ConnectionHandlerTrace versionNumber agreedOptions)
_ Maybe (ConnectionHandlerTrace versionNumber agreedOptions)
_ = Maybe SeverityS
forall a. Maybe a
Nothing
documentFor :: Namespace (ConnectionHandlerTrace versionNumber agreedOptions)
-> Maybe Text
documentFor (Namespace [Text]
_ [Text
"HandshakeSuccess"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor (Namespace [Text]
_ [Text
"HandshakeQuery"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor (Namespace [Text]
_ [Text
"HandshakeClientError"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor (Namespace [Text]
_ [Text
"HandshakeServerError"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor (Namespace [Text]
_ [Text
"Error"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor Namespace (ConnectionHandlerTrace versionNumber agreedOptions)
_ = Maybe Text
forall a. Maybe a
Nothing
allNamespaces :: [Namespace (ConnectionHandlerTrace versionNumber agreedOptions)]
allNamespaces = [
[Text]
-> [Text]
-> Namespace (ConnectionHandlerTrace versionNumber agreedOptions)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"HandshakeSuccess"]
, [Text]
-> [Text]
-> Namespace (ConnectionHandlerTrace versionNumber agreedOptions)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"HandshakeQuery"]
, [Text]
-> [Text]
-> Namespace (ConnectionHandlerTrace versionNumber agreedOptions)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"HandshakeClientError"]
, [Text]
-> [Text]
-> Namespace (ConnectionHandlerTrace versionNumber agreedOptions)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"HandshakeServerError"]
, [Text]
-> [Text]
-> Namespace (ConnectionHandlerTrace versionNumber agreedOptions)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"Error"]
]
instance (PrettyShow peerAddr, ToJSON peerAddr)
=> LogFormatting (ConnectionManager.AbstractTransitionTrace peerAddr) where
forMachine :: DetailLevel -> AbstractTransitionTrace peerAddr -> Object
forMachine DetailLevel
_dtal (ConnectionManager.TransitionTrace peerAddr
peerAddr Transition' AbstractState
tr) =
[Object] -> Object
forall a. Monoid a => [a] -> a
mconcat ([Object] -> Object) -> [Object] -> Object
forall a b. (a -> b) -> a -> b
$ [Object] -> [Object]
forall a. [a] -> [a]
reverse
[ Key
"kind" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectionManagerTransition"
, Key
"address" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= peerAddr -> Value
forall a. ToJSON a => a -> Value
toJSON peerAddr
peerAddr
, Key
"from" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= AbstractState -> Value
forall a. ToJSON a => a -> Value
toJSON (Transition' AbstractState -> AbstractState
forall state. Transition' state -> state
ConnectionManager.fromState Transition' AbstractState
tr)
, Key
"to" Key -> Value -> Object
forall v. ToJSON v => Key -> v -> Object
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= AbstractState -> Value
forall a. ToJSON a => a -> Value
toJSON (Transition' AbstractState -> AbstractState
forall state. Transition' state -> state
ConnectionManager.toState Transition' AbstractState
tr)
]
forHuman :: AbstractTransitionTrace peerAddr -> Text
forHuman = String -> Text
pack (String -> Text)
-> (AbstractTransitionTrace peerAddr -> String)
-> AbstractTransitionTrace peerAddr
-> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbstractTransitionTrace peerAddr -> String
forall a. Show a => a -> String
show
asMetrics :: AbstractTransitionTrace peerAddr -> [Metric]
asMetrics AbstractTransitionTrace peerAddr
_ = []
instance MetaTrace (ConnectionManager.AbstractTransitionTrace peerAddr) where
namespaceFor :: AbstractTransitionTrace peerAddr
-> Namespace (AbstractTransitionTrace peerAddr)
namespaceFor ConnectionManager.TransitionTrace {} =
[Text] -> [Text] -> Namespace (AbstractTransitionTrace peerAddr)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"Transition"]
severityFor :: Namespace (AbstractTransitionTrace peerAddr)
-> Maybe (AbstractTransitionTrace peerAddr) -> Maybe SeverityS
severityFor (Namespace [Text]
_ [Text
"Transition"]) Maybe (AbstractTransitionTrace peerAddr)
_ = SeverityS -> Maybe SeverityS
forall a. a -> Maybe a
Just SeverityS
Debug
severityFor Namespace (AbstractTransitionTrace peerAddr)
_ Maybe (AbstractTransitionTrace peerAddr)
_ = Maybe SeverityS
forall a. Maybe a
Nothing
documentFor :: Namespace (AbstractTransitionTrace peerAddr) -> Maybe Text
documentFor (Namespace [Text]
_ [Text
"Transition"]) = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
""
documentFor Namespace (AbstractTransitionTrace peerAddr)
_ = Maybe Text
forall a. Maybe a
Nothing
allNamespaces :: [Namespace (AbstractTransitionTrace peerAddr)]
allNamespaces = [[Text] -> [Text] -> Namespace (AbstractTransitionTrace peerAddr)
forall a. [Text] -> [Text] -> Namespace a
Namespace [] [Text
"Transition"]]