{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}

{-# OPTIONS_GHC -Wno-orphans  #-}

module Cardano.Node.Tracing.Tracers.P2P
  (
    namesForLocalRootPeers
  , severityLocalRootPeers
  , docLocalRootPeers

  , namesForPublicRootPeers
  , severityPublicRootPeers
  , docPublicRootPeers

  , namesForPeerSelection
  , severityPeerSelection
  , docPeerSelection

  , namesForDebugPeerSelection
  , severityDebugPeerSelection
  , docDebugPeerSelection

  , namesForPeerSelectionCounters
  , severityPeerSelectionCounters
  , docPeerSelectionCounters

  , namesForPeerSelectionActions
  , severityPeerSelectionActions
  , docPeerSelectionActions

  , namesForConnectionManager
  , severityConnectionManager
  , docConnectionManager

  , namesForConnectionManagerTransition
  , severityConnectionManagerTransition
  , docConnectionManagerTransition

  , namesForServer
  , severityServer
  , docServer

  , namesForInboundGovernor
  , severityInboundGovernor
  , docInboundGovernorLocal
  , docInboundGovernorRemote

  , namesForInboundGovernorTransition
  , severityInboundGovernorTransition
  , docInboundGovernorTransition

  ) where

import           Cardano.Logging
import           Cardano.Prelude hiding (group, show)
import           Data.Aeson (ToJSON, ToJSONKey, Value (..), object, toJSON, toJSONList, (.=))
import           Data.Aeson.Types (listValue)
import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
import           Data.Text (pack)
import           Network.Socket (SockAddr (..))
import           Prelude (id, show)

import           Cardano.Node.Configuration.TopologyP2P ()
import           Cardano.Tracing.OrphanInstances.Network ()

import           Cardano.Node.Tracing.Tracers.NodeToNode ()
import           Cardano.Node.Tracing.Tracers.NonP2P ()

import           Ouroboros.Network.ConnectionHandler (ConnectionHandlerTrace (..))
import           Ouroboros.Network.ConnectionId (ConnectionId (..))
import           Ouroboros.Network.ConnectionManager.Types (ConnectionManagerCounters (..),
                   ConnectionManagerTrace (..))
import qualified Ouroboros.Network.ConnectionManager.Types as ConnectionManager
import           Ouroboros.Network.InboundGovernor (InboundGovernorTrace (..))
import qualified Ouroboros.Network.InboundGovernor as InboundGovernor
import           Ouroboros.Network.InboundGovernor.State (InboundGovernorCounters (..))
import qualified Ouroboros.Network.PeerSelection.EstablishedPeers as EstablishedPeers
import           Ouroboros.Network.PeerSelection.Governor (DebugPeerSelection (..),
                   PeerSelectionCounters (..), PeerSelectionState (..), PeerSelectionTargets (..),
                   TracePeerSelection (..))
import qualified Ouroboros.Network.PeerSelection.KnownPeers as KnownPeers
import           Ouroboros.Network.PeerSelection.PeerStateActions (PeerSelectionActionsTrace (..))
import           Ouroboros.Network.PeerSelection.RelayAccessPoint (RelayAccessPoint)
import           Ouroboros.Network.PeerSelection.RootPeersDNS (TraceLocalRootPeers (..),
                   TracePublicRootPeers (..))
import           Ouroboros.Network.PeerSelection.Types ()
import           Ouroboros.Network.RethrowPolicy (ErrorCommand (..))
import           Ouroboros.Network.Server2 (ServerTrace (..))
import           Ouroboros.Network.Snocket (LocalAddress (..))

--------------------------------------------------------------------------------
-- LocalRootPeers Tracer
--------------------------------------------------------------------------------

namesForLocalRootPeers :: TraceLocalRootPeers ntnAddr resolverError -> [Text]
namesForLocalRootPeers :: TraceLocalRootPeers ntnAddr resolverError -> [Text]
namesForLocalRootPeers TraceLocalRootDomains {} = [Text
"LocalRootDomains"]
namesForLocalRootPeers TraceLocalRootWaiting {} = [Text
"LocalRootWaiting"]
namesForLocalRootPeers TraceLocalRootResult {}  = [Text
"LocalRootResult"]
namesForLocalRootPeers TraceLocalRootGroups {}  = [Text
"LocalRootGroups"]
namesForLocalRootPeers TraceLocalRootFailure {} = [Text
"LocalRootFailure"]
namesForLocalRootPeers TraceLocalRootError {}   = [Text
"LocalRootError"]

severityLocalRootPeers :: TraceLocalRootPeers ntnAddr resolverError -> SeverityS
severityLocalRootPeers :: TraceLocalRootPeers ntnAddr resolverError -> SeverityS
severityLocalRootPeers TraceLocalRootPeers ntnAddr resolverError
_ = SeverityS
Info

instance (ToJSONKey ntnAddr, ToJSONKey RelayAccessPoint, Show ntnAddr, Show exception) =>
    LogFormatting (TraceLocalRootPeers ntnAddr exception) where
  forMachine :: DetailLevel -> TraceLocalRootPeers ntnAddr exception -> Object
forMachine DetailLevel
_dtal (TraceLocalRootDomains [(Int, Map RelayAccessPoint PeerAdvertise)]
groups) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"LocalRootDomains"
             , Key
"localRootDomains" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [(Int, Map RelayAccessPoint PeerAdvertise)] -> Value
forall a. ToJSON a => a -> Value
toJSON [(Int, Map RelayAccessPoint PeerAdvertise)]
groups
             ]
  forMachine DetailLevel
_dtal (TraceLocalRootWaiting DomainAccessPoint
d DiffTime
dt) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"LocalRootWaiting"
             , Key
"domainAddress" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DomainAccessPoint -> Value
forall a. ToJSON a => a -> Value
toJSON DomainAccessPoint
d
             , Key
"diffTime" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DiffTime -> String
forall a. Show a => a -> String
show DiffTime
dt
             ]
  forMachine DetailLevel
_dtal (TraceLocalRootResult DomainAccessPoint
d [(IP, TTL)]
res) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"LocalRootResult"
             , Key
"domainAddress" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DomainAccessPoint -> Value
forall a. ToJSON a => a -> Value
toJSON DomainAccessPoint
d
             , Key
"result" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [(IP, TTL)] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList [(IP, TTL)]
res
             ]
  forMachine DetailLevel
_dtal (TraceLocalRootGroups Seq (Int, Map ntnAddr PeerAdvertise)
groups) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"LocalRootGroups"
             , Key
"localRootGroups" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Seq (Int, Map ntnAddr PeerAdvertise) -> Value
forall a. ToJSON a => a -> Value
toJSON Seq (Int, Map ntnAddr PeerAdvertise)
groups
             ]
  forMachine DetailLevel
_dtal (TraceLocalRootFailure DomainAccessPoint
d DNSorIOError exception
exception) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"LocalRootFailure"
             , Key
"domainAddress" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DomainAccessPoint -> Value
forall a. ToJSON a => a -> Value
toJSON DomainAccessPoint
d
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DNSorIOError exception -> String
forall a. Show a => a -> String
show DNSorIOError exception
exception
             ]
  forMachine DetailLevel
_dtal (TraceLocalRootError DomainAccessPoint
d SomeException
exception) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"LocalRootError"
             , Key
"domainAddress" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DomainAccessPoint -> Value
forall a. ToJSON a => a -> Value
toJSON DomainAccessPoint
d
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SomeException -> String
forall a. Show a => a -> String
show SomeException
exception
             ]
  forHuman :: TraceLocalRootPeers ntnAddr exception -> Text
forHuman = String -> Text
pack (String -> Text)
-> (TraceLocalRootPeers ntnAddr exception -> String)
-> TraceLocalRootPeers ntnAddr exception
-> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TraceLocalRootPeers ntnAddr exception -> String
forall a. Show a => a -> String
show

docLocalRootPeers :: Documented (TraceLocalRootPeers ntnAddr resolverError)
docLocalRootPeers :: Documented (TraceLocalRootPeers ntnAddr resolverError)
docLocalRootPeers =  [Text]
-> Documented (TraceLocalRootPeers Any Any)
-> Documented (TraceLocalRootPeers ntnAddr resolverError)
forall a b. [Text] -> Documented a -> Documented b
addDocumentedNamespace  [] Documented (TraceLocalRootPeers Any Any)
forall ntnAddr resolverError.
Documented (TraceLocalRootPeers ntnAddr resolverError)
docLocalRootPeers'

docLocalRootPeers' :: Documented (TraceLocalRootPeers ntnAddr resolverError)
docLocalRootPeers' :: Documented (TraceLocalRootPeers ntnAddr resolverError)
docLocalRootPeers' = [DocMsg (TraceLocalRootPeers ntnAddr resolverError)]
-> Documented (TraceLocalRootPeers ntnAddr resolverError)
forall a. [DocMsg a] -> Documented a
Documented [
    [Text]
-> [(Text, Text)]
-> Text
-> DocMsg (TraceLocalRootPeers ntnAddr resolverError)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"LocalRootDomains"]
      []
      Text
""
  , [Text]
-> [(Text, Text)]
-> Text
-> DocMsg (TraceLocalRootPeers ntnAddr resolverError)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"LocalRootWaiting"]
      []
      Text
""
  , [Text]
-> [(Text, Text)]
-> Text
-> DocMsg (TraceLocalRootPeers ntnAddr resolverError)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"LocalRootResult"]
      []
      Text
""
  , [Text]
-> [(Text, Text)]
-> Text
-> DocMsg (TraceLocalRootPeers ntnAddr resolverError)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"LocalRootGroups"]
      []
      Text
""
  , [Text]
-> [(Text, Text)]
-> Text
-> DocMsg (TraceLocalRootPeers ntnAddr resolverError)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"LocalRootFailure"]
      []
      Text
""
  , [Text]
-> [(Text, Text)]
-> Text
-> DocMsg (TraceLocalRootPeers ntnAddr resolverError)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"LocalRootError"]
      []
      Text
""
  ]

--------------------------------------------------------------------------------
-- PublicRootPeers Tracer
--------------------------------------------------------------------------------

namesForPublicRootPeers :: TracePublicRootPeers -> [Text]
namesForPublicRootPeers :: TracePublicRootPeers -> [Text]
namesForPublicRootPeers TracePublicRootRelayAccessPoint {} = [Text
"PublicRootRelayAccessPoint"]
namesForPublicRootPeers TracePublicRootDomains {} = [Text
"PublicRootDomains"]
namesForPublicRootPeers TracePublicRootResult {}  = [Text
"PublicRootResult"]
namesForPublicRootPeers TracePublicRootFailure {}  = [Text
"PublicRootFailure"]

severityPublicRootPeers :: TracePublicRootPeers -> SeverityS
severityPublicRootPeers :: TracePublicRootPeers -> SeverityS
severityPublicRootPeers TracePublicRootPeers
_ = SeverityS
Info

instance LogFormatting TracePublicRootPeers where
  forMachine :: DetailLevel -> TracePublicRootPeers -> Object
forMachine DetailLevel
_dtal (TracePublicRootRelayAccessPoint [RelayAccessPoint]
relays) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PublicRootRelayAddresses"
             , Key
"relayAddresses" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [RelayAccessPoint] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList [RelayAccessPoint]
relays
             ]
  forMachine DetailLevel
_dtal (TracePublicRootDomains [DomainAccessPoint]
domains) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PublicRootDomains"
             , Key
"domainAddresses" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [DomainAccessPoint] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList [DomainAccessPoint]
domains
             ]
  forMachine DetailLevel
_dtal (TracePublicRootResult Domain
b [(IP, TTL)]
res) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PublicRootResult"
             , Key
"domain" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Domain -> String
forall a. Show a => a -> String
show Domain
b
             , Key
"result" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [(IP, TTL)] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList [(IP, TTL)]
res
             ]
  forMachine DetailLevel
_dtal (TracePublicRootFailure Domain
b DNSError
d) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PublicRootFailure"
             , Key
"domain" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Domain -> String
forall a. Show a => a -> String
show Domain
b
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DNSError -> String
forall a. Show a => a -> String
show DNSError
d
             ]
  forHuman :: TracePublicRootPeers -> Text
forHuman = String -> Text
pack (String -> Text)
-> (TracePublicRootPeers -> String) -> TracePublicRootPeers -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TracePublicRootPeers -> String
forall a. Show a => a -> String
show

docPublicRootPeers :: Documented TracePublicRootPeers
docPublicRootPeers :: Documented TracePublicRootPeers
docPublicRootPeers =  [Text]
-> Documented TracePublicRootPeers
-> Documented TracePublicRootPeers
forall a b. [Text] -> Documented a -> Documented b
addDocumentedNamespace  [Text
"PublicRootPeers"] Documented TracePublicRootPeers
docPublicRootPeers'

docPublicRootPeers' :: Documented TracePublicRootPeers
docPublicRootPeers' :: Documented TracePublicRootPeers
docPublicRootPeers' = [DocMsg TracePublicRootPeers] -> Documented TracePublicRootPeers
forall a. [DocMsg a] -> Documented a
Documented [
    [Text] -> [(Text, Text)] -> Text -> DocMsg TracePublicRootPeers
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"PublicRootRelayAccessPoint"]
      []
      Text
""
  , [Text] -> [(Text, Text)] -> Text -> DocMsg TracePublicRootPeers
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"PublicRootDomains"]
      []
      Text
""
  , [Text] -> [(Text, Text)] -> Text -> DocMsg TracePublicRootPeers
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"PublicRootResult"]
      []
      Text
""
  , [Text] -> [(Text, Text)] -> Text -> DocMsg TracePublicRootPeers
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"PublicRootFailure"]
      []
      Text
""
  ]

--------------------------------------------------------------------------------
-- PeerSelection Tracer
--------------------------------------------------------------------------------

namesForPeerSelection :: TracePeerSelection peeraddr -> [Text]
namesForPeerSelection :: TracePeerSelection peeraddr -> [Text]
namesForPeerSelection TraceLocalRootPeersChanged {} = [Text
"LocalRootPeersChanged"]
namesForPeerSelection TraceTargetsChanged {}        = [Text
"TargetsChanged"]
namesForPeerSelection TracePublicRootsRequest {}    = [Text
"PublicRootsRequest"]
namesForPeerSelection TracePublicRootsResults {}    = [Text
"PublicRootsResults"]
namesForPeerSelection TracePublicRootsFailure {}    = [Text
"PublicRootsFailure"]
namesForPeerSelection TraceGossipRequests {}        = [Text
"GossipRequests"]
namesForPeerSelection TraceGossipResults {}         = [Text
"GossipResults"]
namesForPeerSelection TraceForgetColdPeers {}       = [Text
"ForgetColdPeers"]
namesForPeerSelection TracePromoteColdPeers {}      = [Text
"PromoteColdPeers"]
namesForPeerSelection TracePromoteColdLocalPeers {} = [Text
"PromoteColdLocalPeers"]
namesForPeerSelection TracePromoteColdFailed {}     = [Text
"PromoteColdFailed"]
namesForPeerSelection TracePromoteColdDone {}       = [Text
"PromoteColdDone"]
namesForPeerSelection TracePromoteWarmPeers {}      = [Text
"PromoteWarmPeers"]
namesForPeerSelection TracePromoteWarmLocalPeers {} = [Text
"PromoteWarmLocalPeers"]
namesForPeerSelection TracePromoteWarmFailed {}     = [Text
"PromoteWarmFailed"]
namesForPeerSelection TracePromoteWarmDone {}       = [Text
"PromoteWarmDone"]
namesForPeerSelection TracePromoteWarmAborted {}    = [Text
"PromoteWarmAborted"]
namesForPeerSelection TraceDemoteWarmPeers {}       = [Text
"DemoteWarmPeers"]
namesForPeerSelection TraceDemoteWarmFailed {}      = [Text
"DemoteWarmFailed"]
namesForPeerSelection TraceDemoteWarmDone {}        = [Text
"DemoteWarmDone"]
namesForPeerSelection TraceDemoteHotPeers {}        = [Text
"DemoteHotPeers"]
namesForPeerSelection TraceDemoteLocalHotPeers {}   = [Text
"DemoteLocalHotPeers"]
namesForPeerSelection TraceDemoteHotFailed {}       = [Text
"DemoteHotFailed"]
namesForPeerSelection TraceDemoteHotDone {}         = [Text
"DemoteHotDone"]
namesForPeerSelection TraceDemoteAsynchronous {}    = [Text
"DemoteAsynchronous"]
namesForPeerSelection TraceGovernorWakeup {}        = [Text
"GovernorWakeup"]
namesForPeerSelection TraceChurnWait {}             = [Text
"ChurnWait"]
namesForPeerSelection TraceChurnMode {}             = [Text
"ChurnMode"]


severityPeerSelection :: TracePeerSelection peeraddr -> SeverityS
severityPeerSelection :: TracePeerSelection peeraddr -> SeverityS
severityPeerSelection TraceLocalRootPeersChanged {} = SeverityS
Notice
severityPeerSelection TraceTargetsChanged        {} = SeverityS
Notice
severityPeerSelection TracePublicRootsRequest    {} = SeverityS
Info
severityPeerSelection TracePublicRootsResults    {} = SeverityS
Info
severityPeerSelection TracePublicRootsFailure    {} = SeverityS
Error
severityPeerSelection TraceGossipRequests        {} = SeverityS
Debug
severityPeerSelection TraceGossipResults         {} = SeverityS
Debug
severityPeerSelection TraceForgetColdPeers       {} = SeverityS
Info
severityPeerSelection TracePromoteColdPeers      {} = SeverityS
Info
severityPeerSelection TracePromoteColdLocalPeers {} = SeverityS
Info
severityPeerSelection TracePromoteColdFailed     {} = SeverityS
Info
severityPeerSelection TracePromoteColdDone       {} = SeverityS
Info
severityPeerSelection TracePromoteWarmPeers      {} = SeverityS
Info
severityPeerSelection TracePromoteWarmLocalPeers {} = SeverityS
Info
severityPeerSelection TracePromoteWarmFailed     {} = SeverityS
Info
severityPeerSelection TracePromoteWarmDone       {} = SeverityS
Info
severityPeerSelection TracePromoteWarmAborted    {} = SeverityS
Info
severityPeerSelection TraceDemoteWarmPeers       {} = SeverityS
Info
severityPeerSelection TraceDemoteWarmFailed      {} = SeverityS
Info
severityPeerSelection TraceDemoteWarmDone        {} = SeverityS
Info
severityPeerSelection TraceDemoteHotPeers        {} = SeverityS
Info
severityPeerSelection TraceDemoteLocalHotPeers   {} = SeverityS
Info
severityPeerSelection TraceDemoteHotFailed       {} = SeverityS
Info
severityPeerSelection TraceDemoteHotDone         {} = SeverityS
Info
severityPeerSelection TraceDemoteAsynchronous    {} = SeverityS
Info
severityPeerSelection TraceGovernorWakeup        {} = SeverityS
Info
severityPeerSelection TraceChurnWait             {} = SeverityS
Info
severityPeerSelection TraceChurnMode             {} = SeverityS
Info

instance LogFormatting (TracePeerSelection SockAddr) where
  forMachine :: DetailLevel -> TracePeerSelection SockAddr -> Object
forMachine DetailLevel
_dtal (TraceLocalRootPeersChanged LocalRootPeers SockAddr
lrp LocalRootPeers SockAddr
lrp') =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"LocalRootPeersChanged"
             , Key
"previous" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= LocalRootPeers SockAddr -> Value
forall a. ToJSON a => a -> Value
toJSON LocalRootPeers SockAddr
lrp
             , Key
"current" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= LocalRootPeers SockAddr -> Value
forall a. ToJSON a => a -> Value
toJSON LocalRootPeers SockAddr
lrp'
             ]
  forMachine DetailLevel
_dtal (TraceTargetsChanged PeerSelectionTargets
pst PeerSelectionTargets
pst') =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"TargetsChanged"
             , Key
"previous" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PeerSelectionTargets -> Value
forall a. ToJSON a => a -> Value
toJSON PeerSelectionTargets
pst
             , Key
"current" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PeerSelectionTargets -> Value
forall a. ToJSON a => a -> Value
toJSON PeerSelectionTargets
pst'
             ]
  forMachine DetailLevel
_dtal (TracePublicRootsRequest Int
tRootPeers Int
nRootPeers) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PublicRootsRequest"
             , Key
"targetNumberOfRootPeers" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tRootPeers
             , Key
"numberOfRootPeers" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
nRootPeers
             ]
  forMachine DetailLevel
_dtal (TracePublicRootsResults Set SockAddr
res Int
group DiffTime
dt) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PublicRootsResults"
             , Key
"result" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [SockAddr] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList (Set SockAddr -> [SockAddr]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set SockAddr
res)
             , Key
"group" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
group
             , Key
"diffTime" Key -> DiffTime -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DiffTime
dt
             ]
  forMachine DetailLevel
_dtal (TracePublicRootsFailure SomeException
err Int
group DiffTime
dt) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PublicRootsFailure"
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SomeException -> String
forall a. Show a => a -> String
show SomeException
err
             , Key
"group" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
group
             , Key
"diffTime" Key -> DiffTime -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DiffTime
dt
             ]
  forMachine DetailLevel
_dtal (TraceGossipRequests Int
targetKnown Int
actualKnown Set SockAddr
aps Set SockAddr
sps) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"GossipRequests"
             , Key
"targetKnown" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
targetKnown
             , Key
"actualKnown" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
actualKnown
             , Key
"availablePeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [SockAddr] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList (Set SockAddr -> [SockAddr]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set SockAddr
aps)
             , Key
"selectedPeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [SockAddr] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList (Set SockAddr -> [SockAddr]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set SockAddr
sps)
             ]
  forMachine DetailLevel
_dtal (TraceGossipResults [(SockAddr, Either SomeException [SockAddr])]
res) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"GossipResults"
             , Key
"result" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [(SockAddr, Either String [SockAddr])] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList (((SockAddr, Either SomeException [SockAddr])
 -> (SockAddr, Either String [SockAddr]))
-> [(SockAddr, Either SomeException [SockAddr])]
-> [(SockAddr, Either String [SockAddr])]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
map ( (SomeException -> String)
-> ([SockAddr] -> [SockAddr])
-> Either SomeException [SockAddr]
-> Either String [SockAddr]
forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap SomeException -> String
forall a. Show a => a -> String
show [SockAddr] -> [SockAddr]
forall a. a -> a
id (Either SomeException [SockAddr] -> Either String [SockAddr])
-> (SockAddr, Either SomeException [SockAddr])
-> (SockAddr, Either String [SockAddr])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ) [(SockAddr, Either SomeException [SockAddr])]
res)
             ]
  forMachine DetailLevel
_dtal (TraceForgetColdPeers Int
targetKnown Int
actualKnown Set SockAddr
sp) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ForgeColdPeers"
             , Key
"targetKnown" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
targetKnown
             , Key
"actualKnown" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
actualKnown
             , Key
"selectedPeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [SockAddr] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList (Set SockAddr -> [SockAddr]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set SockAddr
sp)
             ]
  forMachine DetailLevel
_dtal (TracePromoteColdPeers Int
targetKnown Int
actualKnown Set SockAddr
sp) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PromoteColdPeers"
             , Key
"targetEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
targetKnown
             , Key
"actualEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
actualKnown
             , Key
"selectedPeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [SockAddr] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList (Set SockAddr -> [SockAddr]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set SockAddr
sp)
             ]
  forMachine DetailLevel
_dtal (TracePromoteColdLocalPeers Int
tLocalEst Int
aLocalEst Set SockAddr
sp) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PromoteColdLocalPeers"
             , Key
"targetLocalEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tLocalEst
             , Key
"actualLocalEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aLocalEst
             , Key
"selectedPeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [SockAddr] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList (Set SockAddr -> [SockAddr]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set SockAddr
sp)
             ]
  forMachine DetailLevel
_dtal (TracePromoteColdFailed Int
tEst Int
aEst SockAddr
p DiffTime
d SomeException
err) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PromoteColdFailed"
             , Key
"targetEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tEst
             , Key
"actualEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aEst
             , Key
"peer" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SockAddr -> Value
forall a. ToJSON a => a -> Value
toJSON SockAddr
p
             , Key
"delay" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DiffTime -> Value
forall a. ToJSON a => a -> Value
toJSON DiffTime
d
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SomeException -> String
forall a. Show a => a -> String
show SomeException
err
             ]
  forMachine DetailLevel
_dtal (TracePromoteColdDone Int
tEst Int
aEst SockAddr
p) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PromoteColdDone"
             , Key
"targetEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tEst
             , Key
"actualEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aEst
             , Key
"peer" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SockAddr -> Value
forall a. ToJSON a => a -> Value
toJSON SockAddr
p
             ]
  forMachine DetailLevel
_dtal (TracePromoteWarmPeers Int
tActive Int
aActive Set SockAddr
sp) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PromoteWarmPeers"
             , Key
"targetActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tActive
             , Key
"actualActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aActive
             , Key
"selectedPeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [SockAddr] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList (Set SockAddr -> [SockAddr]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set SockAddr
sp)
             ]
  forMachine DetailLevel
_dtal (TracePromoteWarmLocalPeers [(Int, Int)]
taa Set SockAddr
sp) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PromoteWarmLocalPeers"
             , Key
"targetActualActive" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [(Int, Int)] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList [(Int, Int)]
taa
             , Key
"selectedPeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [SockAddr] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList (Set SockAddr -> [SockAddr]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set SockAddr
sp)
             ]
  forMachine DetailLevel
_dtal (TracePromoteWarmFailed Int
tActive Int
aActive SockAddr
p SomeException
err) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PromoteWarmFailed"
             , Key
"targetActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tActive
             , Key
"actualActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aActive
             , Key
"peer" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SockAddr -> Value
forall a. ToJSON a => a -> Value
toJSON SockAddr
p
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SomeException -> String
forall a. Show a => a -> String
show SomeException
err
             ]
  forMachine DetailLevel
_dtal (TracePromoteWarmDone Int
tActive Int
aActive SockAddr
p) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PromoteWarmDone"
             , Key
"targetActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tActive
             , Key
"actualActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aActive
             , Key
"peer" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SockAddr -> Value
forall a. ToJSON a => a -> Value
toJSON SockAddr
p
             ]
  forMachine DetailLevel
_dtal (TracePromoteWarmAborted Int
tActive Int
aActive SockAddr
p) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PromoteWarmAborted"
             , Key
"targetActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tActive
             , Key
"actualActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aActive
             , Key
"peer" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SockAddr -> Value
forall a. ToJSON a => a -> Value
toJSON SockAddr
p
             ]
  forMachine DetailLevel
_dtal (TraceDemoteWarmPeers Int
tEst Int
aEst Set SockAddr
sp) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DemoteWarmPeers"
             , Key
"targetEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tEst
             , Key
"actualEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aEst
             , Key
"selectedPeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [SockAddr] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList (Set SockAddr -> [SockAddr]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set SockAddr
sp)
             ]
  forMachine DetailLevel
_dtal (TraceDemoteWarmFailed Int
tEst Int
aEst SockAddr
p SomeException
err) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DemoteWarmFailed"
             , Key
"targetEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tEst
             , Key
"actualEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aEst
             , Key
"peer" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SockAddr -> Value
forall a. ToJSON a => a -> Value
toJSON SockAddr
p
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SomeException -> String
forall a. Show a => a -> String
show SomeException
err
             ]
  forMachine DetailLevel
_dtal (TraceDemoteWarmDone Int
tEst Int
aEst SockAddr
p) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DemoteWarmDone"
             , Key
"targetEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tEst
             , Key
"actualEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aEst
             , Key
"peer" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SockAddr -> Value
forall a. ToJSON a => a -> Value
toJSON SockAddr
p
             ]
  forMachine DetailLevel
_dtal (TraceDemoteHotPeers Int
tActive Int
aActive Set SockAddr
sp) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DemoteHotPeers"
             , Key
"targetActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tActive
             , Key
"actualActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aActive
             , Key
"selectedPeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [SockAddr] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList (Set SockAddr -> [SockAddr]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set SockAddr
sp)
             ]
  forMachine DetailLevel
_dtal (TraceDemoteLocalHotPeers [(Int, Int)]
taa Set SockAddr
sp) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DemoteLocalHotPeers"
             , Key
"targetActualActive" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [(Int, Int)] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList [(Int, Int)]
taa
             , Key
"selectedPeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [SockAddr] -> Value
forall a. ToJSON a => [a] -> Value
toJSONList (Set SockAddr -> [SockAddr]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set SockAddr
sp)
             ]
  forMachine DetailLevel
_dtal (TraceDemoteHotFailed Int
tActive Int
aActive SockAddr
p SomeException
err) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DemoteHotFailed"
             , Key
"targetActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tActive
             , Key
"actualActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aActive
             , Key
"peer" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SockAddr -> Value
forall a. ToJSON a => a -> Value
toJSON SockAddr
p
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SomeException -> String
forall a. Show a => a -> String
show SomeException
err
             ]
  forMachine DetailLevel
_dtal (TraceDemoteHotDone Int
tActive Int
aActive SockAddr
p) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DemoteHotDone"
             , Key
"targetActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tActive
             , Key
"actualActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aActive
             , Key
"peer" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SockAddr -> Value
forall a. ToJSON a => a -> Value
toJSON SockAddr
p
             ]
  forMachine DetailLevel
_dtal (TraceDemoteAsynchronous Map SockAddr PeerStatus
msp) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DemoteAsynchronous"
             , Key
"state" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Map SockAddr PeerStatus -> Value
forall a. ToJSON a => a -> Value
toJSON Map SockAddr PeerStatus
msp
             ]
  forMachine DetailLevel
_dtal TracePeerSelection SockAddr
TraceGovernorWakeup =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"GovernorWakeup"
             ]
  forMachine DetailLevel
_dtal (TraceChurnWait DiffTime
dt) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ChurnWait"
             , Key
"diffTime" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DiffTime -> Value
forall a. ToJSON a => a -> Value
toJSON DiffTime
dt
             ]
  forMachine DetailLevel
_dtal (TraceChurnMode ChurnMode
c) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ChurnMode"
             , Key
"event" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ChurnMode -> String
forall a. Show a => a -> String
show ChurnMode
c ]
  forHuman :: TracePeerSelection SockAddr -> Text
forHuman = String -> Text
pack (String -> Text)
-> (TracePeerSelection SockAddr -> String)
-> TracePeerSelection SockAddr
-> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TracePeerSelection SockAddr -> String
forall a. Show a => a -> String
show

docPeerSelection ::  Documented (TracePeerSelection SockAddr)
docPeerSelection :: Documented (TracePeerSelection SockAddr)
docPeerSelection =  [Text]
-> Documented (TracePeerSelection SockAddr)
-> Documented (TracePeerSelection SockAddr)
forall a b. [Text] -> Documented a -> Documented b
addDocumentedNamespace  [] Documented (TracePeerSelection SockAddr)
docPeerSelection'

docPeerSelection' :: Documented (TracePeerSelection SockAddr)
docPeerSelection' :: Documented (TracePeerSelection SockAddr)
docPeerSelection' = [DocMsg (TracePeerSelection SockAddr)]
-> Documented (TracePeerSelection SockAddr)
forall a. [DocMsg a] -> Documented a
Documented [
    [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"LocalRootPeersChanged"]
      []
      Text
""
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"TargetsChanged"]
      []
      Text
""
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"PublicRootsRequest"]
      []
      Text
""
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"PublicRootsResults"]
      []
      Text
""
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"PublicRootsFailure"]
      []
      Text
""
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"GossipRequests"]
      []
      Text
"target known peers, actual known peers, peers available for gossip,\
      \ peers selected for gossip"
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"GossipResults"]
      []
      Text
""
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"ForgetColdPeers"]
      []
      Text
"target known peers, actual known peers, selected peers"
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"PromoteColdPeers"]
      []
      Text
"target established, actual established, selected peers"
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"PromoteColdLocalPeers"]
      []
      Text
"target local established, actual local established, selected peers"
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"PromoteColdFailed"]
      []
      Text
"target established, actual established, peer, delay until next\
      \ promotion, reason"
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"PromoteColdDone"]
      []
      Text
"target active, actual active, selected peers"
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"PromoteWarmPeers"]
      []
      Text
"target active, actual active, selected peers"
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"PromoteWarmLocalPeers"]
      []
      Text
"local per-group (target active, actual active), selected peers"
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"PromoteWarmFailed"]
      []
      Text
"target active, actual active, peer, reason"
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"PromoteWarmDone"]
      []
      Text
"target active, actual active, peer"
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"PromoteWarmAborted"]
      []
      Text
""
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"DemoteWarmPeers"]
      []
      Text
"target established, actual established, selected peers"
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"DemoteWarmFailed"]
      []
      Text
"target established, actual established, peer, reason"
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"DemoteWarmDone"]
      []
      Text
"target established, actual established, peer"
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"DemoteHotPeers"]
      []
      Text
"target active, actual active, selected peers"
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"DemoteLocalHotPeers"]
      []
      Text
"local per-group (target active, actual active), selected peers"
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"DemoteHotFailed"]
      []
      Text
"target active, actual active, peer, reason"
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"DemoteHotDone"]
      []
      Text
"target active, actual active, peer"
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"DemoteAsynchronous"]
      []
      Text
""
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"GovernorWakeup"]
      []
      Text
""
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"ChurnWait"]
      []
      Text
""
  , [Text]
-> [(Text, Text)] -> Text -> DocMsg (TracePeerSelection SockAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"ChurnMode"]
      []
      Text
""
  ]

peerSelectionTargetsToObject :: PeerSelectionTargets -> Value
peerSelectionTargetsToObject :: PeerSelectionTargets -> Value
peerSelectionTargetsToObject
  PeerSelectionTargets { Int
targetNumberOfRootPeers :: PeerSelectionTargets -> Int
targetNumberOfRootPeers :: Int
targetNumberOfRootPeers,
                         Int
targetNumberOfKnownPeers :: PeerSelectionTargets -> Int
targetNumberOfKnownPeers :: Int
targetNumberOfKnownPeers,
                         Int
targetNumberOfEstablishedPeers :: PeerSelectionTargets -> Int
targetNumberOfEstablishedPeers :: Int
targetNumberOfEstablishedPeers,
                         Int
targetNumberOfActivePeers :: PeerSelectionTargets -> Int
targetNumberOfActivePeers :: Int
targetNumberOfActivePeers } =
    Object -> Value
Object (Object -> Value) -> Object -> Value
forall a b. (a -> b) -> a -> b
$
      [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"roots" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
targetNumberOfRootPeers
               , Key
"knownPeers" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
targetNumberOfKnownPeers
               , Key
"established" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
targetNumberOfEstablishedPeers
               , Key
"active" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
targetNumberOfActivePeers
               ]

--------------------------------------------------------------------------------
-- DebugPeerSelection Tracer
--------------------------------------------------------------------------------

namesForDebugPeerSelection :: DebugPeerSelection SockAddr peerConn -> [Text]
namesForDebugPeerSelection :: DebugPeerSelection SockAddr peerConn -> [Text]
namesForDebugPeerSelection DebugPeerSelection SockAddr peerConn
_ = [Text
"GovernorState"]

severityDebugPeerSelection :: DebugPeerSelection SockAddr peerConn -> SeverityS
severityDebugPeerSelection :: DebugPeerSelection SockAddr peerConn -> SeverityS
severityDebugPeerSelection DebugPeerSelection SockAddr peerConn
_ = SeverityS
Debug

instance Show peerConn => LogFormatting (DebugPeerSelection SockAddr peerConn) where
  forMachine :: DetailLevel -> DebugPeerSelection SockAddr peerConn -> Object
forMachine DetailLevel
DNormal (TraceGovernorState Time
blockedAt Maybe DiffTime
wakeupAfter
                   PeerSelectionState { PeerSelectionTargets
targets :: forall peeraddr peerconn.
PeerSelectionState peeraddr peerconn -> PeerSelectionTargets
targets :: PeerSelectionTargets
targets, KnownPeers SockAddr
knownPeers :: forall peeraddr peerconn.
PeerSelectionState peeraddr peerconn -> KnownPeers peeraddr
knownPeers :: KnownPeers SockAddr
knownPeers, EstablishedPeers SockAddr peerConn
establishedPeers :: forall peeraddr peerconn.
PeerSelectionState peeraddr peerconn
-> EstablishedPeers peeraddr peerconn
establishedPeers :: EstablishedPeers SockAddr peerConn
establishedPeers, Set SockAddr
activePeers :: forall peeraddr peerconn.
PeerSelectionState peeraddr peerconn -> Set peeraddr
activePeers :: Set SockAddr
activePeers }) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DebugPeerSelection"
             , Key
"blockedAt" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ Time -> String
forall a. Show a => a -> String
show Time
blockedAt)
             , Key
"wakeupAfter" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ Maybe DiffTime -> String
forall a. Show a => a -> String
show Maybe DiffTime
wakeupAfter)
             , Key
"targets" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PeerSelectionTargets -> Value
peerSelectionTargetsToObject PeerSelectionTargets
targets
             , Key
"numberOfPeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.=
                 Object -> Value
Object ([Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"known" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= KnownPeers SockAddr -> Int
forall peeraddr. KnownPeers peeraddr -> Int
KnownPeers.size KnownPeers SockAddr
knownPeers
                                  , Key
"established" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= EstablishedPeers SockAddr peerConn -> Int
forall peeraddr peerconn. EstablishedPeers peeraddr peerconn -> Int
EstablishedPeers.size EstablishedPeers SockAddr peerConn
establishedPeers
                                  , Key
"active" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set SockAddr -> Int
forall a. Set a -> Int
Set.size Set SockAddr
activePeers
                                  ])
             ]
  forMachine DetailLevel
_ (TraceGovernorState Time
blockedAt Maybe DiffTime
wakeupAfter PeerSelectionState SockAddr peerConn
ev) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DebugPeerSelection"
             , Key
"blockedAt" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ Time -> String
forall a. Show a => a -> String
show Time
blockedAt)
             , Key
"wakeupAfter" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ Maybe DiffTime -> String
forall a. Show a => a -> String
show Maybe DiffTime
wakeupAfter)
             , Key
"peerSelectionState" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerSelectionState SockAddr peerConn -> String
forall a. Show a => a -> String
show PeerSelectionState SockAddr peerConn
ev)
             ]
  forHuman :: DebugPeerSelection SockAddr peerConn -> Text
forHuman = String -> Text
pack (String -> Text)
-> (DebugPeerSelection SockAddr peerConn -> String)
-> DebugPeerSelection SockAddr peerConn
-> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. DebugPeerSelection SockAddr peerConn -> String
forall a. Show a => a -> String
show

docDebugPeerSelection :: Documented (DebugPeerSelection SockAddr peerConn)
docDebugPeerSelection :: Documented (DebugPeerSelection SockAddr peerConn)
docDebugPeerSelection = [DocMsg (DebugPeerSelection SockAddr peerConn)]
-> Documented (DebugPeerSelection SockAddr peerConn)
forall a. [DocMsg a] -> Documented a
Documented
  [  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg (DebugPeerSelection SockAddr peerConn)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"DebugPeerSelection", Text
"GovernorState"]
      []
      Text
""
  ]

namesForPeerSelectionCounters :: PeerSelectionCounters -> [Text]
namesForPeerSelectionCounters :: PeerSelectionCounters -> [Text]
namesForPeerSelectionCounters PeerSelectionCounters
_ = []

severityPeerSelectionCounters :: PeerSelectionCounters -> SeverityS
severityPeerSelectionCounters :: PeerSelectionCounters -> SeverityS
severityPeerSelectionCounters PeerSelectionCounters
_ = SeverityS
Info

instance LogFormatting PeerSelectionCounters where
  forMachine :: DetailLevel -> PeerSelectionCounters -> Object
forMachine DetailLevel
_dtal PeerSelectionCounters
ev =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PeerSelectionCounters"
             , Key
"coldPeers" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PeerSelectionCounters -> Int
coldPeers PeerSelectionCounters
ev
             , Key
"warmPeers" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PeerSelectionCounters -> Int
warmPeers PeerSelectionCounters
ev
             , Key
"hotPeers" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PeerSelectionCounters -> Int
hotPeers PeerSelectionCounters
ev
             ]
  forHuman :: PeerSelectionCounters -> Text
forHuman = String -> Text
pack (String -> Text)
-> (PeerSelectionCounters -> String)
-> PeerSelectionCounters
-> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. PeerSelectionCounters -> String
forall a. Show a => a -> String
show
  asMetrics :: PeerSelectionCounters -> [Metric]
asMetrics PeerSelectionCounters {Int
hotPeers :: Int
warmPeers :: Int
coldPeers :: Int
hotPeers :: PeerSelectionCounters -> Int
warmPeers :: PeerSelectionCounters -> Int
coldPeers :: PeerSelectionCounters -> Int
..} =
    [ Text -> Integer -> Metric
IntM
        Text
"cardano.node.peerSelection.cold"
        (Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
coldPeers)
    , Text -> Integer -> Metric
IntM
        Text
"cardano.node.peerSelection.warm"
        (Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
warmPeers)
    , Text -> Integer -> Metric
IntM
        Text
"cardano.node.peerSelection.hot"
        (Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
hotPeers)
      ]

docPeerSelectionCounters :: Documented PeerSelectionCounters
docPeerSelectionCounters :: Documented PeerSelectionCounters
docPeerSelectionCounters = [DocMsg PeerSelectionCounters] -> Documented PeerSelectionCounters
forall a. [DocMsg a] -> Documented a
Documented
  [  [Text] -> [(Text, Text)] -> Text -> DocMsg PeerSelectionCounters
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"PeerSelectionCounters"]
      [ (Text
"cardano.node.peerSelection.cold", Text
"Number of cold peers")
      , (Text
"cardano.node.peerSelection.warm", Text
"Number of warm peers")
      , (Text
"cardano.node.peerSelection.hot", Text
"Number of hot peers") ]
      Text
"Counters for cold, warm and hot peers"
  ]

--------------------------------------------------------------------------------
-- PeerSelectionActions Tracer
--------------------------------------------------------------------------------

namesForPeerSelectionActions :: PeerSelectionActionsTrace ntnAddr -> [Text]
namesForPeerSelectionActions :: PeerSelectionActionsTrace ntnAddr -> [Text]
namesForPeerSelectionActions PeerStatusChanged   {}     = [Text
"StatusChanged"]
namesForPeerSelectionActions PeerStatusChangeFailure {} = [Text
"StatusChangeFailure"]
namesForPeerSelectionActions PeerMonitoringError {}     = [Text
"MonitoringError"]
namesForPeerSelectionActions PeerMonitoringResult {}    = [Text
"MonitoringResult"]

severityPeerSelectionActions :: PeerSelectionActionsTrace ntnAddr -> SeverityS
severityPeerSelectionActions :: PeerSelectionActionsTrace ntnAddr -> SeverityS
severityPeerSelectionActions PeerStatusChanged {}       = SeverityS
Info
severityPeerSelectionActions PeerStatusChangeFailure {} = SeverityS
Error
severityPeerSelectionActions PeerMonitoringError {}     = SeverityS
Error
severityPeerSelectionActions PeerMonitoringResult {}    = SeverityS
Debug

-- TODO: Write PeerStatusChangeType ToJSON at ouroboros-network
-- For that an export is needed at ouroboros-network
instance LogFormatting (PeerSelectionActionsTrace SockAddr) where
  forMachine :: DetailLevel -> PeerSelectionActionsTrace SockAddr -> Object
forMachine DetailLevel
_dtal (PeerStatusChanged PeerStatusChangeType SockAddr
ps) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PeerStatusChanged"
             , Key
"peerStatusChangeType" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PeerStatusChangeType SockAddr -> String
forall a. Show a => a -> String
show PeerStatusChangeType SockAddr
ps
             ]
  forMachine DetailLevel
_dtal (PeerStatusChangeFailure PeerStatusChangeType SockAddr
ps FailureType
f) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PeerStatusChangeFailure"
             , Key
"peerStatusChangeType" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PeerStatusChangeType SockAddr -> String
forall a. Show a => a -> String
show PeerStatusChangeType SockAddr
ps
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= FailureType -> String
forall a. Show a => a -> String
show FailureType
f
             ]
  forMachine DetailLevel
_dtal (PeerMonitoringError ConnectionId SockAddr
connId SomeException
s) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PeerMonitoridngError"
             , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ConnectionId SockAddr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId SockAddr
connId
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SomeException -> String
forall a. Show a => a -> String
show SomeException
s
             ]
  forMachine DetailLevel
_dtal (PeerMonitoringResult ConnectionId SockAddr
connId WithSomeProtocolTemperature FirstToFinishResult
wf) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PeerMonitoringResult"
             , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ConnectionId SockAddr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId SockAddr
connId
             , Key
"withProtocolTemp" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= WithSomeProtocolTemperature FirstToFinishResult -> String
forall a. Show a => a -> String
show WithSomeProtocolTemperature FirstToFinishResult
wf
             ]
  forHuman :: PeerSelectionActionsTrace SockAddr -> Text
forHuman = String -> Text
pack (String -> Text)
-> (PeerSelectionActionsTrace SockAddr -> String)
-> PeerSelectionActionsTrace SockAddr
-> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. PeerSelectionActionsTrace SockAddr -> String
forall a. Show a => a -> String
show

docPeerSelectionActions :: Documented (PeerSelectionActionsTrace ntnAddr)
docPeerSelectionActions :: Documented (PeerSelectionActionsTrace ntnAddr)
docPeerSelectionActions =
    [Text]
-> Documented (PeerSelectionActionsTrace Any)
-> Documented (PeerSelectionActionsTrace ntnAddr)
forall a b. [Text] -> Documented a -> Documented b
addDocumentedNamespace  []  Documented (PeerSelectionActionsTrace Any)
forall ntnAddr. Documented (PeerSelectionActionsTrace ntnAddr)
docPeerSelectionActions'

docPeerSelectionActions' :: Documented (PeerSelectionActionsTrace ntnAddr)
docPeerSelectionActions' :: Documented (PeerSelectionActionsTrace ntnAddr)
docPeerSelectionActions' = [DocMsg (PeerSelectionActionsTrace ntnAddr)]
-> Documented (PeerSelectionActionsTrace ntnAddr)
forall a. [DocMsg a] -> Documented a
Documented
  [  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg (PeerSelectionActionsTrace ntnAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"StatusChanged"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg (PeerSelectionActionsTrace ntnAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"StatusChangeFailure"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg (PeerSelectionActionsTrace ntnAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"MonitoringError"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg (PeerSelectionActionsTrace ntnAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"MonitoringResult"]
      []
      Text
""
  ]

--------------------------------------------------------------------------------
-- Connection Manager Tracer
--------------------------------------------------------------------------------

namesForConnectionManager :: ConnectionManagerTrace ntnAddr cht -> [Text]
namesForConnectionManager :: ConnectionManagerTrace ntnAddr cht -> [Text]
namesForConnectionManager TrIncludeConnection {}  = [Text
"IncludeConnection"]
namesForConnectionManager TrUnregisterConnection {} = [Text
"UnregisterConnection"]
namesForConnectionManager TrConnect {}  = [Text
"Connect"]
namesForConnectionManager TrConnectError {} = [Text
"ConnectError"]
namesForConnectionManager TrTerminatingConnection {} = [Text
"TerminatingConnection"]
namesForConnectionManager TrTerminatedConnection {} = [Text
"TerminatedConnection"]
namesForConnectionManager TrConnectionHandler {} = [Text
"ConnectionHandler"]
namesForConnectionManager TrShutdown {} = [Text
"Shutdown"]
namesForConnectionManager TrConnectionExists {} = [Text
"ConnectionExists"]
namesForConnectionManager TrForbiddenConnection {} = [Text
"ForbiddenConnection"]
namesForConnectionManager TrImpossibleConnection {} = [Text
"ImpossibleConnection"]
namesForConnectionManager TrConnectionFailure {} = [Text
"ConnectionFailure"]
namesForConnectionManager TrConnectionNotFound {} = [Text
"ConnectionNotFound"]
namesForConnectionManager TrForbiddenOperation {} = [Text
"ForbiddenOperation"]
namesForConnectionManager TrPruneConnections {}  = [Text
"PruneConnections"]
namesForConnectionManager TrConnectionCleanup {} = [Text
"ConnectionCleanup"]
namesForConnectionManager TrConnectionTimeWait {} = [Text
"ConnectionTimeWait"]
namesForConnectionManager TrConnectionTimeWaitDone {} = [Text
"ConnectionTimeWaitDone"]
namesForConnectionManager TrConnectionManagerCounters {} = [Text
"ConnectionManagerCounters"]
namesForConnectionManager TrState {} = [Text
"State"]
namesForConnectionManager ConnectionManager.TrUnexpectedlyFalseAssertion {} =
                            [Text
"UnexpectedlyFalseAssertion"]
namesForConnectionManager TrUnknownConnection {} = [Text
"UnknownConnection"]

severityConnectionManager ::
  ConnectionManagerTrace addr
    (ConnectionHandlerTrace versionNumber agreedOptions) -> SeverityS
severityConnectionManager :: ConnectionManagerTrace
  addr (ConnectionHandlerTrace versionNumber agreedOptions)
-> SeverityS
severityConnectionManager TrIncludeConnection {}                  = SeverityS
Debug
severityConnectionManager TrUnregisterConnection {}               = SeverityS
Debug
severityConnectionManager TrConnect {}                            = SeverityS
Debug
severityConnectionManager TrConnectError {}                       = SeverityS
Info
severityConnectionManager TrTerminatingConnection {}              = SeverityS
Debug
severityConnectionManager TrTerminatedConnection {}               = SeverityS
Debug
severityConnectionManager (TrConnectionHandler ConnectionId addr
_ ConnectionHandlerTrace versionNumber agreedOptions
ev')             =
        case ConnectionHandlerTrace versionNumber agreedOptions
ev' of
          TrHandshakeSuccess {}     -> SeverityS
Info
          TrHandshakeClientError {} -> SeverityS
Notice
          TrHandshakeServerError {} -> SeverityS
Info
          TrError ErrorContext
_ SomeException
_ ErrorCommand
ShutdownNode  -> SeverityS
Critical
          TrError ErrorContext
_ SomeException
_ ErrorCommand
ShutdownPeer  -> SeverityS
Info

severityConnectionManager ConnectionManagerTrace
  addr (ConnectionHandlerTrace versionNumber agreedOptions)
TrShutdown                              = SeverityS
Info
severityConnectionManager TrConnectionExists {}                   = SeverityS
Info
severityConnectionManager TrForbiddenConnection {}                = SeverityS
Info
severityConnectionManager TrImpossibleConnection {}               = SeverityS
Info
severityConnectionManager TrConnectionFailure {}                  = SeverityS
Info
severityConnectionManager TrConnectionNotFound {}                 = SeverityS
Debug
severityConnectionManager TrForbiddenOperation {}                 = SeverityS
Info

severityConnectionManager TrPruneConnections {}                   = SeverityS
Notice
severityConnectionManager TrConnectionCleanup {}                  = SeverityS
Debug
severityConnectionManager TrConnectionTimeWait {}                 = SeverityS
Debug
severityConnectionManager TrConnectionTimeWaitDone {}             = SeverityS
Debug
severityConnectionManager TrConnectionManagerCounters {}          = SeverityS
Info
severityConnectionManager TrState {}                              = SeverityS
Info
severityConnectionManager ConnectionManager.TrUnexpectedlyFalseAssertion {} =
                            SeverityS
Error
severityConnectionManager TrUnknownConnection {}                  = SeverityS
Debug

instance (Show addr, Show versionNumber, Show agreedOptions, LogFormatting addr,
          ToJSON addr, ToJSON versionNumber, ToJSON agreedOptions)
      => LogFormatting (ConnectionManagerTrace addr (ConnectionHandlerTrace versionNumber agreedOptions)) where
    forMachine :: DetailLevel
-> ConnectionManagerTrace
     addr (ConnectionHandlerTrace versionNumber agreedOptions)
-> 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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"IncludeConnection"
          , Key
"remoteAddress" Key -> Object -> Object
forall kv v. (KeyValue 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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> (Provenance -> String) -> Provenance -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat 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 (TrUnregisterConnection 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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"UnregisterConnection"
          , Key
"remoteAddress" Key -> Object -> Object
forall kv v. (KeyValue 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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> (Provenance -> String) -> Provenance -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat 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) =
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
          [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectTo"
          , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId :: forall addr. addr -> addr -> ConnectionId addr
ConnectionId { addr
localAddress :: addr
localAddress :: addr
localAddress, addr
remoteAddress :: addr
remoteAddress :: addr
remoteAddress }
          ]
    forMachine DetailLevel
dtal (TrConnect Maybe addr
Nothing addr
remoteAddress) =
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
          [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectTo"
          , Key
"remoteAddress" Key -> Object -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DetailLevel -> addr -> Object
forall a. LogFormatting a => DetailLevel -> a -> Object
forMachine DetailLevel
dtal addr
remoteAddress
          ]
    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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectError"
          , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId :: forall addr. addr -> addr -> ConnectionId addr
ConnectionId { addr
localAddress :: addr
localAddress :: addr
localAddress, addr
remoteAddress :: addr
remoteAddress :: addr
remoteAddress }
          , Key
"reason" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text)
-> (SomeException -> String) -> SomeException -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat 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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectError"
          , Key
"remoteAddress" Key -> Object -> Object
forall kv v. (KeyValue 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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text)
-> (SomeException -> String) -> SomeException -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat 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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"TerminatingConnection"
          , Key
"provenance" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> (Provenance -> String) -> Provenance -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat 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 kv v. (KeyValue 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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"TerminatedConnection"
          , Key
"provenance" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> (Provenance -> String) -> Provenance -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat 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 kv v. (KeyValue 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 ConnectionHandlerTrace versionNumber agreedOptions
a) =
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
          [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectionHandler"
          , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue 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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DetailLevel
-> ConnectionHandlerTrace versionNumber agreedOptions -> Object
forall a. LogFormatting a => DetailLevel -> a -> Object
forMachine DetailLevel
dtal ConnectionHandlerTrace versionNumber agreedOptions
a
          ]
    forMachine DetailLevel
_dtal ConnectionManagerTrace
  addr (ConnectionHandlerTrace versionNumber agreedOptions)
TrShutdown =
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
          [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue 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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectionExists"
          , Key
"provenance" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> (Provenance -> String) -> Provenance -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat 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 kv v. (KeyValue 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 kv v. (KeyValue 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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ForbiddenConnection"
          , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId addr
connId
          ]
    forMachine DetailLevel
_dtal (TrImpossibleConnection ConnectionId addr
connId) =
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
          [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ImpossibleConnection"
          , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue 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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectionFailure"
          , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue 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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectionNotFound"
          , Key
"remoteAddress" Key -> Object -> Object
forall kv v. (KeyValue 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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> (Provenance -> String) -> Provenance -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat 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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ForbiddenOperation"
          , Key
"remoteAddress" Key -> Object -> Object
forall kv v. (KeyValue 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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= AbstractState -> Value
forall a. ToJSON a => a -> Value
toJSON AbstractState
connState
          ]
    forMachine DetailLevel
dtal (TrPruneConnections Set addr
pruningSet Int
numberPruned Set addr
chosenPeers) =
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
          [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PruneConnections"
          , Key
"prunedPeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set addr -> Value
forall a. ToJSON a => a -> Value
toJSON Set addr
pruningSet
          , Key
"numberPrunedPeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON Int
numberPruned
          , Key
"choiceSet" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Set Object -> Value
forall a. ToJSON a => a -> Value
toJSON (DetailLevel -> addr -> Object
forall a. LogFormatting a => DetailLevel -> a -> Object
forMachine DetailLevel
dtal (addr -> Object) -> Set addr -> Set Object
forall b a. Ord b => (a -> b) -> Set a -> Set b
`Set.map` Set addr
chosenPeers)
          ]
    forMachine DetailLevel
_dtal (TrConnectionCleanup ConnectionId addr
connId) =
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
          [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectionCleanup"
          , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue 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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectionTimeWait"
          , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue 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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectionTimeWaitDone"
          , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue 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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectionManagerCounters"
          , Key
"state" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ConnectionManagerCounters -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionManagerCounters
cmCounters
          ]
    forMachine DetailLevel
_dtal (TrState Map addr AbstractState
cmState) =
        [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
          [ Key
"kind"  Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectionManagerState"
          , Key
"state" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ((addr, AbstractState) -> Value)
-> [(addr, AbstractState)] -> Value
forall a. (a -> Value) -> [a] -> Value
listValue (\(addr
addr, AbstractState
connState) ->
                                         [Pair] -> Value
object
                                           [ Key
"remoteAddress"   Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= addr -> Value
forall a. ToJSON a => a -> Value
toJSON addr
addr
                                           , Key
"connectionState" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= AbstractState -> Value
forall a. ToJSON a => a -> Value
toJSON AbstractState
connState
                                           ])
                                       (Map addr AbstractState -> [(addr, AbstractState)]
forall k a. Map k a -> [(k, a)]
Map.toList Map 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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"UnexpectedlyFalseAssertion"
          , Key
"info" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text)
-> (AssertionLocation addr -> String)
-> AssertionLocation addr
-> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat 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)
          ]
    forMachine DetailLevel
_dtal (TrUnknownConnection ConnectionId addr
info) =
      [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
        [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"UnknownConnection"
        , Key
"info" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text)
-> (ConnectionId addr -> String) -> ConnectionId addr -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. ConnectionId addr -> String
forall a. Show a => a -> String
show (ConnectionId addr -> Text) -> ConnectionId addr -> Text
forall a b. (a -> b) -> a -> b
$ ConnectionId addr
info)
        ]
    forHuman :: ConnectionManagerTrace
  addr (ConnectionHandlerTrace versionNumber agreedOptions)
-> Text
forHuman = String -> Text
pack (String -> Text)
-> (ConnectionManagerTrace
      addr (ConnectionHandlerTrace versionNumber agreedOptions)
    -> String)
-> ConnectionManagerTrace
     addr (ConnectionHandlerTrace versionNumber agreedOptions)
-> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. ConnectionManagerTrace
  addr (ConnectionHandlerTrace versionNumber agreedOptions)
-> String
forall a. Show a => a -> String
show
    asMetrics :: ConnectionManagerTrace
  addr (ConnectionHandlerTrace versionNumber agreedOptions)
-> [Metric]
asMetrics (TrConnectionManagerCounters ConnectionManagerCounters {Int
unidirectionalConns :: ConnectionManagerCounters -> Int
outboundConns :: ConnectionManagerCounters -> Int
inboundConns :: ConnectionManagerCounters -> Int
fullDuplexConns :: ConnectionManagerCounters -> Int
duplexConns :: ConnectionManagerCounters -> Int
outboundConns :: Int
inboundConns :: Int
unidirectionalConns :: Int
duplexConns :: Int
fullDuplexConns :: Int
..}) =
          [ Text -> Integer -> Metric
IntM
              Text
"cardano.node.connectionManager.fullDuplexConns"
              (Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
fullDuplexConns)
          , Text -> Integer -> Metric
IntM
              Text
"cardano.node.connectionManager.duplexConns"
              (Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
duplexConns)
          , Text -> Integer -> Metric
IntM
              Text
"cardano.node.connectionManager.unidirectionalConns"
              (Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
unidirectionalConns)
          , Text -> Integer -> Metric
IntM
              Text
"cardano.node.connectionManager.inboundConns"
              (Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
inboundConns)
          , Text -> Integer -> Metric
IntM
              Text
"cardano.node.connectionManager.outboundConns"
              (Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
outboundConns)
            ]
    asMetrics ConnectionManagerTrace
  addr (ConnectionHandlerTrace versionNumber agreedOptions)
_ = []

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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"HandshakeSuccess"
      , Key
"versionNumber" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= versionNumber -> Value
forall a. ToJSON a => a -> Value
toJSON versionNumber
versionNumber
      , Key
"agreedOptions" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= agreedOptions -> Value
forall a. ToJSON a => a -> Value
toJSON agreedOptions
agreedOptions
      ]
  forMachine DetailLevel
_dtal (TrHandshakeClientError HandshakeException versionNumber
err) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"HandshakeClientError"
      , Key
"reason" Key -> Value -> Object
forall kv v. (KeyValue 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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"HandshakeServerError"
      , Key
"reason" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= HandshakeException versionNumber -> Value
forall a. ToJSON a => a -> Value
toJSON HandshakeException versionNumber
err
      ]
  forMachine DetailLevel
_dtal (TrError ErrorContext
e SomeException
err ErrorCommand
cerr) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"Error"
      , Key
"context" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ErrorContext -> String
forall a. Show a => a -> String
show ErrorContext
e
      , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SomeException -> String
forall a. Show a => a -> String
show SomeException
err
      , Key
"command" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ErrorCommand -> String
forall a. Show a => a -> String
show ErrorCommand
cerr
      ]

docConnectionManager :: Documented
  (ConnectionManagerTrace
    ntnAddr
    (ConnectionHandlerTrace
      ntnVersion
      ntnVersionData))
docConnectionManager :: Documented
  (ConnectionManagerTrace
     ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
docConnectionManager = [Text]
-> Documented
     (ConnectionManagerTrace Any (ConnectionHandlerTrace Any Any))
-> Documented
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a b. [Text] -> Documented a -> Documented b
addDocumentedNamespace  [] Documented
  (ConnectionManagerTrace Any (ConnectionHandlerTrace Any Any))
forall ntnAddr ntnVersion ntnVersionData.
Documented
  (ConnectionManagerTrace
     ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
docConnectionManager'

docConnectionManager' :: Documented
  (ConnectionManagerTrace
    ntnAddr
    (ConnectionHandlerTrace
      ntnVersion
      ntnVersionData))
docConnectionManager' :: Documented
  (ConnectionManagerTrace
     ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
docConnectionManager' = [DocMsg
   (ConnectionManagerTrace
      ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))]
-> Documented
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [DocMsg a] -> Documented a
Documented
  [  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"IncludeConnection"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"UnregisterConnection"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"Connect"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"ConnectError"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"TerminatingConnection"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"TerminatedConnection"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"ConnectionHandler"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"Shutdown"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
     [Text
"ConnectionExists"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"ForbiddenConnection"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"ImpossibleConnection"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"ConnectionFailure"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"ConnectionNotFound"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"ForbiddenOperation"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"PruneConnections"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"ConnectionCleanup"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"ConnectionTimeWait"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"ConnectionTimeWaitDone"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"ConnectionManagerCounters"]
      [(Text
"cardano.node.connectionManager.fullDuplexConns",Text
"")
      ,(Text
"cardano.node.connectionManager.duplexConns",Text
"")
      ,(Text
"cardano.node.connectionManager.unidirectionalConns",Text
"")
      ,(Text
"cardano.node.connectionManager.inboundConns",Text
"")
      ,(Text
"cardano.node.connectionManager.outboundConns",Text
"")
      ]
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"State"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"UnexpectedlyFalseAssertion"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)]
-> Text
-> DocMsg
     (ConnectionManagerTrace
        ntnAddr (ConnectionHandlerTrace ntnVersion ntnVersionData))
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"UnknownConnection"]
      []
      Text
""
  ]

--------------------------------------------------------------------------------
-- Connection Manager Transition Tracer
--------------------------------------------------------------------------------

namesForConnectionManagerTransition
    :: ConnectionManager.AbstractTransitionTrace peerAddr -> [Text]
namesForConnectionManagerTransition :: AbstractTransitionTrace peerAddr -> [Text]
namesForConnectionManagerTransition ConnectionManager.TransitionTrace {} =
    []

severityConnectionManagerTransition
  :: ConnectionManager.AbstractTransitionTrace peerAddr -> SeverityS
severityConnectionManagerTransition :: AbstractTransitionTrace peerAddr -> SeverityS
severityConnectionManagerTransition AbstractTransitionTrace peerAddr
_ = SeverityS
Debug

instance (Show 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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectionManagerTransition"
        , Key
"address" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= peerAddr -> Value
forall a. ToJSON a => a -> Value
toJSON peerAddr
peerAddr
        , Key
"from"    Key -> Value -> Object
forall kv v. (KeyValue 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 kv v. (KeyValue 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 k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. AbstractTransitionTrace peerAddr -> String
forall a. Show a => a -> String
show
    asMetrics :: AbstractTransitionTrace peerAddr -> [Metric]
asMetrics AbstractTransitionTrace peerAddr
_ = []

docConnectionManagerTransition
    :: Documented (ConnectionManager.AbstractTransitionTrace peerAddr)
docConnectionManagerTransition :: Documented (AbstractTransitionTrace peerAddr)
docConnectionManagerTransition = [DocMsg (AbstractTransitionTrace peerAddr)]
-> Documented (AbstractTransitionTrace peerAddr)
forall a. [DocMsg a] -> Documented a
Documented
  [ [Text]
-> [(Text, Text)]
-> Text
-> DocMsg (AbstractTransitionTrace peerAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"ConnectionManagerTransition"]
      []
      Text
""
  ]

--------------------------------------------------------------------------------
-- Server Tracer
--------------------------------------------------------------------------------

namesForServer :: ServerTrace ntnAddr -> [Text]
namesForServer :: ServerTrace ntnAddr -> [Text]
namesForServer TrAcceptConnection {}  = [Text
"AcceptConnection"]
namesForServer TrAcceptError {}       = [Text
"AcceptError"]
namesForServer TrAcceptPolicyTrace {} = [Text
"AcceptPolicy"]
namesForServer TrServerStarted {}     = [Text
"Started"]
namesForServer TrServerStopped {}     = [Text
"Stopped"]
namesForServer TrServerError {}       = [Text
"Error"]

severityServer ::  ServerTrace ntnAddr -> SeverityS
severityServer :: ServerTrace ntnAddr -> SeverityS
severityServer TrAcceptConnection {}  = SeverityS
Debug
severityServer TrAcceptError {}       = SeverityS
Error
severityServer TrAcceptPolicyTrace {} = SeverityS
Notice
severityServer TrServerStarted {}     = SeverityS
Notice
severityServer TrServerStopped {}     = SeverityS
Notice
severityServer TrServerError {}       = SeverityS
Critical

instance (Show addr, LogFormatting addr, ToJSON addr)
      => LogFormatting (ServerTrace addr) where
  forMachine :: DetailLevel -> ServerTrace addr -> Object
forMachine DetailLevel
dtal (TrAcceptConnection addr
peerAddr)     =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"AcceptConnection"
             , Key
"address" Key -> Object -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DetailLevel -> addr -> Object
forall a. LogFormatting a => DetailLevel -> a -> Object
forMachine DetailLevel
dtal addr
peerAddr
             ]
  forMachine DetailLevel
_dtal (TrAcceptError SomeException
exception)         =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"AcceptErroor"
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SomeException -> String
forall a. Show a => a -> String
show SomeException
exception
             ]
  forMachine DetailLevel
dtal (TrAcceptPolicyTrace AcceptConnectionsPolicyTrace
policyTrace) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"AcceptPolicyTrace"
             , Key
"policy" Key -> Object -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DetailLevel -> AcceptConnectionsPolicyTrace -> Object
forall a. LogFormatting a => DetailLevel -> a -> Object
forMachine DetailLevel
dtal AcceptConnectionsPolicyTrace
policyTrace
             ]
  forMachine DetailLevel
dtal (TrServerStarted [addr]
peerAddrs)       =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"AcceptPolicyTrace"
             , Key
"addresses" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Object] -> Value
forall a. ToJSON a => a -> Value
toJSON (DetailLevel -> addr -> Object
forall a. LogFormatting a => DetailLevel -> a -> Object
forMachine DetailLevel
dtal (addr -> Object) -> [addr] -> [Object]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`map` [addr]
peerAddrs)
             ]
  forMachine DetailLevel
_dtal ServerTrace addr
TrServerStopped                   =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ServerStopped"
             ]
  forMachine DetailLevel
_dtal (TrServerError SomeException
exception)         =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ServerError"
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SomeException -> String
forall a. Show a => a -> String
show SomeException
exception
             ]
  forHuman :: ServerTrace addr -> Text
forHuman = String -> Text
pack (String -> Text)
-> (ServerTrace addr -> String) -> ServerTrace addr -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. ServerTrace addr -> String
forall a. Show a => a -> String
show


docServer :: Documented (ServerTrace ntnAddr)
docServer :: Documented (ServerTrace ntnAddr)
docServer = [Text]
-> Documented (ServerTrace Any) -> Documented (ServerTrace ntnAddr)
forall a b. [Text] -> Documented a -> Documented b
addDocumentedNamespace  [] Documented (ServerTrace Any)
forall ntnAddr. Documented (ServerTrace ntnAddr)
docServer'

docServer' :: Documented (ServerTrace ntnAddr)
docServer' :: Documented (ServerTrace ntnAddr)
docServer' = [DocMsg (ServerTrace ntnAddr)] -> Documented (ServerTrace ntnAddr)
forall a. [DocMsg a] -> Documented a
Documented
  [  [Text] -> [(Text, Text)] -> Text -> DocMsg (ServerTrace ntnAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"AcceptConnection"]
      []
      Text
""
  ,  [Text] -> [(Text, Text)] -> Text -> DocMsg (ServerTrace ntnAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"AcceptError"]
      []
      Text
""
  ,  [Text] -> [(Text, Text)] -> Text -> DocMsg (ServerTrace ntnAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"AcceptPolicy"]
      []
      Text
""
  ,  [Text] -> [(Text, Text)] -> Text -> DocMsg (ServerTrace ntnAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"Started"]
      []
      Text
""
  ,  [Text] -> [(Text, Text)] -> Text -> DocMsg (ServerTrace ntnAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"Stopped"]
      []
      Text
""
  ,  [Text] -> [(Text, Text)] -> Text -> DocMsg (ServerTrace ntnAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"Error"]
      []
      Text
""
  ]

--------------------------------------------------------------------------------
-- InboundGovernor Tracer
--------------------------------------------------------------------------------

namesForInboundGovernor :: InboundGovernorTrace peerAddr -> [Text]
namesForInboundGovernor :: InboundGovernorTrace peerAddr -> [Text]
namesForInboundGovernor TrNewConnection {}         = [Text
"NewConnection"]
namesForInboundGovernor TrResponderRestarted {}    = [Text
"ResponderRestarted"]
namesForInboundGovernor TrResponderStartFailure {} = [Text
"ResponderStartFailure"]
namesForInboundGovernor TrResponderErrored {}      = [Text
"ResponderErrored"]
namesForInboundGovernor TrResponderStarted {}      = [Text
"ResponderStarted"]
namesForInboundGovernor TrResponderTerminated {}   = [Text
"ResponderTerminated"]
namesForInboundGovernor TrPromotedToWarmRemote {}  = [Text
"PromotedToWarmRemote"]
namesForInboundGovernor TrPromotedToHotRemote {}   = [Text
"PromotedToHotRemote"]
namesForInboundGovernor TrDemotedToColdRemote {}   = [Text
"DemotedToColdRemote"]
namesForInboundGovernor TrDemotedToWarmRemote {}   = [Text
"DemotedToWarmRemote"]
namesForInboundGovernor TrWaitIdleRemote {}        = [Text
"WaitIdleRemote"]
namesForInboundGovernor TrMuxCleanExit {}          = [Text
"MuxCleanExit"]
namesForInboundGovernor TrMuxErrored {}            = [Text
"MuxErrored"]
namesForInboundGovernor TrInboundGovernorCounters {} = [Text
"InboundGovernorCounters"]
namesForInboundGovernor TrRemoteState {}           = [Text
"RemoteState"]
namesForInboundGovernor InboundGovernor.TrUnexpectedlyFalseAssertion {} =
                            [Text
"UnexpectedlyFalseAssertion"]
namesForInboundGovernor InboundGovernor.TrInboundGovernorError {} =
                            [Text
"InboundGovernorError"]

severityInboundGovernor :: InboundGovernorTrace peerAddr -> SeverityS
severityInboundGovernor :: InboundGovernorTrace peerAddr -> SeverityS
severityInboundGovernor TrNewConnection {}                              = SeverityS
Debug
severityInboundGovernor TrResponderRestarted {}                         = SeverityS
Debug
severityInboundGovernor TrResponderStartFailure {}                      = SeverityS
Error
severityInboundGovernor TrResponderErrored {}                           = SeverityS
Info
severityInboundGovernor TrResponderStarted {}                           = SeverityS
Debug
severityInboundGovernor TrResponderTerminated {}                        = SeverityS
Debug
severityInboundGovernor TrPromotedToWarmRemote {}                       = SeverityS
Info
severityInboundGovernor TrPromotedToHotRemote {}                        = SeverityS
Info
severityInboundGovernor TrDemotedToColdRemote {}                        = SeverityS
Info
severityInboundGovernor TrDemotedToWarmRemote {}                        = SeverityS
Info
severityInboundGovernor TrWaitIdleRemote {}                             = SeverityS
Debug
severityInboundGovernor TrMuxCleanExit {}                               = SeverityS
Debug
severityInboundGovernor TrMuxErrored {}                                 = SeverityS
Info
severityInboundGovernor TrInboundGovernorCounters {}                    = SeverityS
Info
severityInboundGovernor TrRemoteState {}                                = SeverityS
Debug
severityInboundGovernor InboundGovernor.TrUnexpectedlyFalseAssertion {} = SeverityS
Error
severityInboundGovernor InboundGovernor.TrInboundGovernorError {}       = SeverityS
Error

instance (ToJSON addr, Show addr)
      => LogFormatting (InboundGovernorTrace addr) where
  forMachine :: DetailLevel -> InboundGovernorTrace addr -> Object
forMachine DetailLevel
_dtal (TrNewConnection Provenance
p ConnectionId addr
connId)            =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"NewConnection"
             , Key
"provenance" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Provenance -> String
forall a. Show a => a -> String
show Provenance
p
             , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId addr
connId
             ]
  forMachine DetailLevel
_dtal (TrResponderRestarted ConnectionId addr
connId MiniProtocolNum
m)       =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ResponderStarted"
             , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId addr
connId
             , Key
"miniProtocolNum" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= MiniProtocolNum -> Value
forall a. ToJSON a => a -> Value
toJSON MiniProtocolNum
m
             ]
  forMachine DetailLevel
_dtal (TrResponderStartFailure ConnectionId addr
connId MiniProtocolNum
m SomeException
s)  =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ResponderStartFailure"
             , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId addr
connId
             , Key
"miniProtocolNum" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= MiniProtocolNum -> Value
forall a. ToJSON a => a -> Value
toJSON MiniProtocolNum
m
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SomeException -> String
forall a. Show a => a -> String
show SomeException
s
             ]
  forMachine DetailLevel
_dtal (TrResponderErrored ConnectionId addr
connId MiniProtocolNum
m SomeException
s)       =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ResponderErrored"
             , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId addr
connId
             , Key
"miniProtocolNum" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= MiniProtocolNum -> Value
forall a. ToJSON a => a -> Value
toJSON MiniProtocolNum
m
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SomeException -> String
forall a. Show a => a -> String
show SomeException
s
             ]
  forMachine DetailLevel
_dtal (TrResponderStarted ConnectionId addr
connId MiniProtocolNum
m)         =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ResponderStarted"
             , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId addr
connId
             , Key
"miniProtocolNum" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= MiniProtocolNum -> Value
forall a. ToJSON a => a -> Value
toJSON MiniProtocolNum
m
             ]
  forMachine DetailLevel
_dtal (TrResponderTerminated ConnectionId addr
connId MiniProtocolNum
m)      =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ResponderTerminated"
             , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId addr
connId
             , Key
"miniProtocolNum" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= MiniProtocolNum -> Value
forall a. ToJSON a => a -> Value
toJSON MiniProtocolNum
m
             ]
  forMachine DetailLevel
_dtal (TrPromotedToWarmRemote ConnectionId addr
connId OperationResult AbstractState
opRes) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PromotedToWarmRemote"
             , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId addr
connId
             , Key
"result" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= OperationResult AbstractState -> Value
forall a. ToJSON a => a -> Value
toJSON OperationResult AbstractState
opRes
             ]
  forMachine DetailLevel
_dtal (TrPromotedToHotRemote ConnectionId addr
connId)        =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PromotedToHotRemote"
             , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId addr
connId
             ]
  forMachine DetailLevel
_dtal (TrDemotedToColdRemote ConnectionId addr
connId OperationResult DemotedToColdRemoteTr
od)     =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DemotedToColdRemote"
             , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId addr
connId
             , Key
"result" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= OperationResult DemotedToColdRemoteTr -> String
forall a. Show a => a -> String
show OperationResult DemotedToColdRemoteTr
od
             ]
  forMachine DetailLevel
_dtal (TrDemotedToWarmRemote ConnectionId addr
connId)     =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DemotedToWarmRemote"
             , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId addr
connId
             ]
  forMachine DetailLevel
_dtal (TrWaitIdleRemote ConnectionId addr
connId OperationResult AbstractState
opRes) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WaitIdleRemote"
             , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId addr
connId
             , Key
"result" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= OperationResult AbstractState -> Value
forall a. ToJSON a => a -> Value
toJSON OperationResult AbstractState
opRes
             ]
  forMachine DetailLevel
_dtal (TrMuxCleanExit ConnectionId addr
connId)               =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MuxCleanExit"
             , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId addr
connId
             ]
  forMachine DetailLevel
_dtal (TrMuxErrored ConnectionId addr
connId SomeException
s)               =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MuxErrored"
             , Key
"connectionId" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ConnectionId addr -> Value
forall a. ToJSON a => a -> Value
toJSON ConnectionId addr
connId
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SomeException -> String
forall a. Show a => a -> String
show SomeException
s
             ]
  forMachine DetailLevel
_dtal (TrInboundGovernorCounters InboundGovernorCounters
counters) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"InboundGovernorCounters"
             , Key
"idlePeers" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= InboundGovernorCounters -> Int
idlePeersRemote InboundGovernorCounters
counters
             , Key
"coldPeers" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= InboundGovernorCounters -> Int
coldPeersRemote InboundGovernorCounters
counters
             , Key
"warmPeers" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= InboundGovernorCounters -> Int
warmPeersRemote InboundGovernorCounters
counters
             , Key
"hotPeers" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= InboundGovernorCounters -> Int
hotPeersRemote InboundGovernorCounters
counters
             ]
  forMachine DetailLevel
_dtal (TrRemoteState Map (ConnectionId addr) RemoteSt
st) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"RemoteState"
             , Key
"remoteSt" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Map (ConnectionId addr) RemoteSt -> Value
forall a. ToJSON a => a -> Value
toJSON Map (ConnectionId addr) RemoteSt
st
             ]
  forMachine DetailLevel
_dtal (InboundGovernor.TrUnexpectedlyFalseAssertion IGAssertionLocation addr
info) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"UnexpectedlyFalseAssertion"
             , Key
"remoteSt" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text)
-> (IGAssertionLocation addr -> String)
-> IGAssertionLocation addr
-> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. IGAssertionLocation addr -> String
forall a. Show a => a -> String
show (IGAssertionLocation addr -> Text)
-> IGAssertionLocation addr -> Text
forall a b. (a -> b) -> a -> b
$ IGAssertionLocation addr
info)
             ]
  forMachine DetailLevel
_dtal (InboundGovernor.TrInboundGovernorError SomeException
err) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"InboundGovernorError"
             , Key
"remoteSt" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text)
-> (SomeException -> String) -> SomeException -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. SomeException -> String
forall a. Show a => a -> String
show (SomeException -> Text) -> SomeException -> Text
forall a b. (a -> b) -> a -> b
$ SomeException
err)
             ]
  forHuman :: InboundGovernorTrace addr -> Text
forHuman = String -> Text
pack (String -> Text)
-> (InboundGovernorTrace addr -> String)
-> InboundGovernorTrace addr
-> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. InboundGovernorTrace addr -> String
forall a. Show a => a -> String
show
  asMetrics :: InboundGovernorTrace addr -> [Metric]
asMetrics (TrInboundGovernorCounters InboundGovernorCounters {Int
hotPeersRemote :: Int
warmPeersRemote :: Int
idlePeersRemote :: Int
coldPeersRemote :: Int
hotPeersRemote :: InboundGovernorCounters -> Int
warmPeersRemote :: InboundGovernorCounters -> Int
coldPeersRemote :: InboundGovernorCounters -> Int
idlePeersRemote :: InboundGovernorCounters -> Int
..}) =
            [ Text -> Integer -> Metric
IntM
                Text
"cardano.node.inbound-governor.idle"
                (Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
idlePeersRemote)
            , Text -> Integer -> Metric
IntM
                Text
"cardano.node.inbound-governor.cold"
                (Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
coldPeersRemote)
            , Text -> Integer -> Metric
IntM
                Text
"cardano.node.inbound-governor.warm"
                (Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
warmPeersRemote)
            , Text -> Integer -> Metric
IntM
                Text
"cardano.node.inbound-governor.hot"
                (Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
hotPeersRemote)
              ]
  asMetrics InboundGovernorTrace addr
_ = []


docInboundGovernorLocal ::
   Documented (InboundGovernorTrace LocalAddress)
docInboundGovernorLocal :: Documented (InboundGovernorTrace LocalAddress)
docInboundGovernorLocal =
    [Text]
-> Documented (InboundGovernorTrace Any)
-> Documented (InboundGovernorTrace LocalAddress)
forall a b. [Text] -> Documented a -> Documented b
addDocumentedNamespace  [] Documented (InboundGovernorTrace Any)
forall peerAddr. Documented (InboundGovernorTrace peerAddr)
docInboundGovernor

docInboundGovernorRemote ::
   Documented (InboundGovernorTrace SockAddr)
docInboundGovernorRemote :: Documented (InboundGovernorTrace SockAddr)
docInboundGovernorRemote =
    [Text]
-> Documented (InboundGovernorTrace Any)
-> Documented (InboundGovernorTrace SockAddr)
forall a b. [Text] -> Documented a -> Documented b
addDocumentedNamespace  [] Documented (InboundGovernorTrace Any)
forall peerAddr. Documented (InboundGovernorTrace peerAddr)
docInboundGovernor

docInboundGovernor :: Documented (InboundGovernorTrace peerAddr)
docInboundGovernor :: Documented (InboundGovernorTrace peerAddr)
docInboundGovernor = [DocMsg (InboundGovernorTrace peerAddr)]
-> Documented (InboundGovernorTrace peerAddr)
forall a. [DocMsg a] -> Documented a
Documented
  [  [Text]
-> [(Text, Text)] -> Text -> DocMsg (InboundGovernorTrace peerAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"NewConnection"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)] -> Text -> DocMsg (InboundGovernorTrace peerAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"ResponderRestarted"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)] -> Text -> DocMsg (InboundGovernorTrace peerAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"ResponderStartFailure"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)] -> Text -> DocMsg (InboundGovernorTrace peerAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"ResponderErrored"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)] -> Text -> DocMsg (InboundGovernorTrace peerAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"ResponderStarted"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)] -> Text -> DocMsg (InboundGovernorTrace peerAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"ResponderTerminated"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)] -> Text -> DocMsg (InboundGovernorTrace peerAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"PromotedToWarmRemote"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)] -> Text -> DocMsg (InboundGovernorTrace peerAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"PromotedToHotRemote"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)] -> Text -> DocMsg (InboundGovernorTrace peerAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"DemotedToColdRemote"]
      []
      Text
"All mini-protocols terminated.  The boolean is true if this connection\
      \ was not used by p2p-governor, and thus the connection will be terminated."
  ,  [Text]
-> [(Text, Text)] -> Text -> DocMsg (InboundGovernorTrace peerAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"DemotedToWarmRemote"]
      []
      Text
"All mini-protocols terminated.  The boolean is true if this connection\
      \ was not used by p2p-governor, and thus the connection will be terminated."
  ,  [Text]
-> [(Text, Text)] -> Text -> DocMsg (InboundGovernorTrace peerAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"WaitIdleRemote"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)] -> Text -> DocMsg (InboundGovernorTrace peerAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"MuxCleanExit"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)] -> Text -> DocMsg (InboundGovernorTrace peerAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"MuxErrored"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)] -> Text -> DocMsg (InboundGovernorTrace peerAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"InboundGovernorCounters"]
      [(Text
"cardano.node.inbound-governor.idle",Text
"")
      ,(Text
"cardano.node.inbound-governor.cold",Text
"")
      ,(Text
"cardano.node.inbound-governor.warm",Text
"")
      ,(Text
"cardano.node.inbound-governor.hot",Text
"")
      ]
      Text
""
  ,  [Text]
-> [(Text, Text)] -> Text -> DocMsg (InboundGovernorTrace peerAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"RemoteState"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)] -> Text -> DocMsg (InboundGovernorTrace peerAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"UnexpectedlyFalseAssertion"]
      []
      Text
""
  ,  [Text]
-> [(Text, Text)] -> Text -> DocMsg (InboundGovernorTrace peerAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"InboundGovernorError"]
      []
      Text
""
  ]

--------------------------------------------------------------------------------
-- InboundGovernor Transition Tracer
--------------------------------------------------------------------------------

namesForInboundGovernorTransition
  :: InboundGovernor.RemoteTransitionTrace peerAddr -> [Text]
namesForInboundGovernorTransition :: RemoteTransitionTrace peerAddr -> [Text]
namesForInboundGovernorTransition RemoteTransitionTrace peerAddr
_ = []

severityInboundGovernorTransition
  :: InboundGovernor.RemoteTransitionTrace peerAddr -> SeverityS
severityInboundGovernorTransition :: RemoteTransitionTrace peerAddr -> SeverityS
severityInboundGovernorTransition RemoteTransitionTrace peerAddr
_ = SeverityS
Debug

instance (Show peerAddr, ToJSON peerAddr)
      => LogFormatting (InboundGovernor.RemoteTransitionTrace peerAddr) where
    forMachine :: DetailLevel -> RemoteTransitionTrace peerAddr -> Object
forMachine DetailLevel
_dtal (InboundGovernor.TransitionTrace peerAddr
peerAddr Transition' (Maybe RemoteSt)
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 kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConnectionManagerTransition"
        , Key
"address" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= peerAddr -> Value
forall a. ToJSON a => a -> Value
toJSON peerAddr
peerAddr
        , Key
"from"    Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe RemoteSt -> Value
forall a. ToJSON a => a -> Value
toJSON (Transition' (Maybe RemoteSt) -> Maybe RemoteSt
forall state. Transition' state -> state
ConnectionManager.fromState Transition' (Maybe RemoteSt)
tr)
        , Key
"to"      Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe RemoteSt -> Value
forall a. ToJSON a => a -> Value
toJSON (Transition' (Maybe RemoteSt) -> Maybe RemoteSt
forall state. Transition' state -> state
ConnectionManager.toState   Transition' (Maybe RemoteSt)
tr)
        ]
    forHuman :: RemoteTransitionTrace peerAddr -> Text
forHuman = String -> Text
pack (String -> Text)
-> (RemoteTransitionTrace peerAddr -> String)
-> RemoteTransitionTrace peerAddr
-> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. RemoteTransitionTrace peerAddr -> String
forall a. Show a => a -> String
show
    asMetrics :: RemoteTransitionTrace peerAddr -> [Metric]
asMetrics RemoteTransitionTrace peerAddr
_ = []

docInboundGovernorTransition
  :: Documented (InboundGovernor.RemoteTransitionTrace peerAddr)
docInboundGovernorTransition :: Documented (RemoteTransitionTrace peerAddr)
docInboundGovernorTransition = [DocMsg (RemoteTransitionTrace peerAddr)]
-> Documented (RemoteTransitionTrace peerAddr)
forall a. [DocMsg a] -> Documented a
Documented
  [ [Text]
-> [(Text, Text)]
-> Text
-> DocMsg (RemoteTransitionTrace peerAddr)
forall a. [Text] -> [(Text, Text)] -> Text -> DocMsg a
DocMsg
      [Text
"InboundGovernorTransition"]
      []
      Text
""
  ]