ouroboros-network
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Network.PeerSelection.PeerMetric

Synopsis

Peer metrics

data PeerMetrics (m :: Type -> Type) p Source #

Mutable peer metrics state accessible via STM.

newtype PeerMetricsConfiguration Source #

Constructors

PeerMetricsConfiguration 

Fields

  • maxEntriesToTrack :: Int

    The maximum numbers of slots we will store data for. On some chains sometimes this corresponds to 1h worth of metrics *sighs*.

    this number MUST correspond to number of headers / blocks which are produced in one hour.

Instances

Instances details
NFData PeerMetricsConfiguration Source # 
Instance details

Defined in Ouroboros.Network.PeerSelection.PeerMetric

Generic PeerMetricsConfiguration Source # 
Instance details

Defined in Ouroboros.Network.PeerSelection.PeerMetric

Associated Types

type Rep PeerMetricsConfiguration 
Instance details

Defined in Ouroboros.Network.PeerSelection.PeerMetric

type Rep PeerMetricsConfiguration = D1 ('MetaData "PeerMetricsConfiguration" "Ouroboros.Network.PeerSelection.PeerMetric" "ouroboros-network-0.17.1.1-inplace" 'True) (C1 ('MetaCons "PeerMetricsConfiguration" 'PrefixI 'True) (S1 ('MetaSel ('Just "maxEntriesToTrack") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))
Show PeerMetricsConfiguration Source # 
Instance details

Defined in Ouroboros.Network.PeerSelection.PeerMetric

NoThunks PeerMetricsConfiguration Source # 
Instance details

Defined in Ouroboros.Network.PeerSelection.PeerMetric

type Rep PeerMetricsConfiguration Source # 
Instance details

Defined in Ouroboros.Network.PeerSelection.PeerMetric

type Rep PeerMetricsConfiguration = D1 ('MetaData "PeerMetricsConfiguration" "Ouroboros.Network.PeerSelection.PeerMetric" "ouroboros-network-0.17.1.1-inplace" 'True) (C1 ('MetaCons "PeerMetricsConfiguration" 'PrefixI 'True) (S1 ('MetaSel ('Just "maxEntriesToTrack") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

Metric calculations

joinedPeerMetricAt :: forall p (m :: Type -> Type). (MonadSTM m, Ord p) => PeerMetrics m p -> STM m (Map p SlotNo) Source #

upstreamyness :: forall p (m :: Type -> Type). (MonadSTM m, Ord p) => PeerMetrics m p -> STM m (Map p Int) Source #

Returns a Map which counts the number of times a given peer was the first to present us with a block/header.

fetchynessBytes :: forall p (m :: Type -> Type). (MonadSTM m, Ord p) => PeerMetrics m p -> STM m (Map p Int) Source #

Returns a Map which counts the number of bytes downloaded for a given peer.

fetchynessBlocks :: forall p (m :: Type -> Type). (MonadSTM m, Ord p) => PeerMetrics m p -> STM m (Map p Int) Source #

Returns a Map which counts the number of times a given peer was the first we downloaded a block from.

Tracers

headerMetricTracer :: forall (m :: Type -> Type) p. (MonadSTM m, Ord p) => PeerMetricsConfiguration -> PeerMetrics m p -> Tracer (STM m) (TraceLabelPeer (ConnectionId p) (SlotNo, Time)) Source #

Tracer which updates header metrics (upstreameness) and inserts new peers into peerRegistry.

fetchedMetricTracer :: forall (m :: Type -> Type) p. (MonadSTM m, Ord p) => PeerMetricsConfiguration -> PeerMetrics m p -> Tracer (STM m) (TraceLabelPeer (ConnectionId p) (SizeInBytes, SlotNo, Time)) Source #

Tracer which updates fetched metrics (fetchyness) and inserts new peers into peerRegistry.

Metrics reporters

data ReportPeerMetrics (m :: Type -> Type) peerAddr #

Constructors

ReportPeerMetrics 

nullMetric :: forall (m :: Type -> Type) p. MonadSTM m => ReportPeerMetrics m p Source #

Internals

type SlotMetric p = IntPSQ SlotNo (p, Time) Source #

Integer based metric ordered by SlotNo which holds the peer and time.

The p parameter is truly polymorphic. For upstreamyness and we use peer address, and for fetchyness it is a pair of peer id and bytes downloaded.