{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-unrecognised-pragmas #-}

module Simplex.Messaging.Server.Prometheus
  ( ServerMetrics (..),
    RealTimeMetrics (..),
    RTSubscriberMetrics (..),
    rtsOptionsEnv,
    prometheusMetrics,
  ) where

import Data.Int (Int64)
import qualified Data.IntMap.Strict as IM
import Data.List (mapAccumL)
import Data.Text (Text)
import qualified Data.Text as T
import Data.Time.Clock (UTCTime (..), diffUTCTime)
import Data.Time.Clock.System (systemEpochDay)
import Data.Time.Format.ISO8601 (iso8601Show)
import Network.Socket (ServiceName)
import Simplex.Messaging.Server.MsgStore.Types (LoadedQueueCounts (..))
import Simplex.Messaging.Server.QueueStore.Types (EntityCounts (..))
import Simplex.Messaging.Server.Stats
import Simplex.Messaging.Transport (simplexMQVersion)
import Simplex.Messaging.Transport.Server (SocketStats (..))
import Simplex.Messaging.Util (tshow)

data ServerMetrics = ServerMetrics
  { ServerMetrics -> ServerStatsData
statsData :: ServerStatsData,
    ServerMetrics -> PeriodStatCounts
activeQueueCounts :: PeriodStatCounts,
    ServerMetrics -> PeriodStatCounts
activeNtfCounts :: PeriodStatCounts,
    ServerMetrics -> EntityCounts
entityCounts :: EntityCounts,
    ServerMetrics -> Text
rtsOptions :: Text
  }

rtsOptionsEnv :: Text
rtsOptionsEnv :: Text
rtsOptionsEnv = Text
"SMP_RTS_OPTIONS"

data RealTimeMetrics = RealTimeMetrics
  { RealTimeMetrics -> [(ServiceName, SocketStats)]
socketStats :: [(ServiceName, SocketStats)],
    RealTimeMetrics -> Int
threadsCount :: Int,
    RealTimeMetrics -> Int
clientsCount :: Int,
    RealTimeMetrics -> RTSubscriberMetrics
deliveredSubs :: RTSubscriberMetrics,
    RealTimeMetrics -> TimeBuckets
deliveredTimes :: TimeBuckets,
    RealTimeMetrics -> RTSubscriberMetrics
smpSubs :: RTSubscriberMetrics,
    RealTimeMetrics -> RTSubscriberMetrics
ntfSubs :: RTSubscriberMetrics,
    RealTimeMetrics -> LoadedQueueCounts
loadedCounts :: LoadedQueueCounts
  }

data RTSubscriberMetrics = RTSubscriberMetrics
  { RTSubscriberMetrics -> Int
subsCount :: Int,
    RTSubscriberMetrics -> Int
subClientsCount :: Int,
    RTSubscriberMetrics -> Int
subServicesCount :: Int
  }

{-# FOURMOLU_DISABLE\n#-}
prometheusMetrics :: ServerMetrics -> RealTimeMetrics -> UTCTime -> Text
prometheusMetrics :: ServerMetrics -> RealTimeMetrics -> UTCTime -> Text
prometheusMetrics ServerMetrics
sm RealTimeMetrics
rtm UTCTime
ts =
  Text
time Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
queues Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
subscriptions Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
messages Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
ntfMessages Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
ntfs Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
relays Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
services Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
info
  where
    ServerMetrics {ServerStatsData
statsData :: ServerMetrics -> ServerStatsData
statsData :: ServerStatsData
statsData, activeQueueCounts :: ServerMetrics -> PeriodStatCounts
activeQueueCounts = PeriodStatCounts
ps, activeNtfCounts :: ServerMetrics -> PeriodStatCounts
activeNtfCounts = PeriodStatCounts
psNtf, EntityCounts
entityCounts :: ServerMetrics -> EntityCounts
entityCounts :: EntityCounts
entityCounts, Text
rtsOptions :: ServerMetrics -> Text
rtsOptions :: Text
rtsOptions} = ServerMetrics
sm
    RealTimeMetrics
      { [(ServiceName, SocketStats)]
socketStats :: RealTimeMetrics -> [(ServiceName, SocketStats)]
socketStats :: [(ServiceName, SocketStats)]
socketStats,
        Int
threadsCount :: RealTimeMetrics -> Int
threadsCount :: Int
threadsCount,
        Int
clientsCount :: RealTimeMetrics -> Int
clientsCount :: Int
clientsCount,
        RTSubscriberMetrics
deliveredSubs :: RealTimeMetrics -> RTSubscriberMetrics
deliveredSubs :: RTSubscriberMetrics
deliveredSubs,
        TimeBuckets
deliveredTimes :: RealTimeMetrics -> TimeBuckets
deliveredTimes :: TimeBuckets
deliveredTimes,
        RTSubscriberMetrics
smpSubs :: RealTimeMetrics -> RTSubscriberMetrics
smpSubs :: RTSubscriberMetrics
smpSubs,
        RTSubscriberMetrics
ntfSubs :: RealTimeMetrics -> RTSubscriberMetrics
ntfSubs :: RTSubscriberMetrics
ntfSubs,
        LoadedQueueCounts
loadedCounts :: RealTimeMetrics -> LoadedQueueCounts
loadedCounts :: LoadedQueueCounts
loadedCounts
      } = RealTimeMetrics
rtm
    ServerStatsData
      { UTCTime
_fromTime :: UTCTime
_fromTime :: ServerStatsData -> UTCTime
_fromTime,
        Int
_qCreated :: Int
_qCreated :: ServerStatsData -> Int
_qCreated,
        Int
_qSecured :: Int
_qSecured :: ServerStatsData -> Int
_qSecured,
        Int
_qDeletedAll :: Int
_qDeletedAll :: ServerStatsData -> Int
_qDeletedAll,
        Int
_qDeletedAllB :: Int
_qDeletedAllB :: ServerStatsData -> Int
_qDeletedAllB,
        Int
_qDeletedNew :: Int
_qDeletedNew :: ServerStatsData -> Int
_qDeletedNew,
        Int
_qDeletedSecured :: Int
_qDeletedSecured :: ServerStatsData -> Int
_qDeletedSecured,
        Int
_qBlocked :: Int
_qBlocked :: ServerStatsData -> Int
_qBlocked,
        Int
_qSub :: Int
_qSub :: ServerStatsData -> Int
_qSub,
        Int
_qSubAllB :: Int
_qSubAllB :: ServerStatsData -> Int
_qSubAllB,
        Int
_qSubAuth :: Int
_qSubAuth :: ServerStatsData -> Int
_qSubAuth,
        Int
_qSubDuplicate :: Int
_qSubDuplicate :: ServerStatsData -> Int
_qSubDuplicate,
        Int
_qSubProhibited :: Int
_qSubProhibited :: ServerStatsData -> Int
_qSubProhibited,
        Int
_qSubEnd :: Int
_qSubEnd :: ServerStatsData -> Int
_qSubEnd,
        Int
_qSubEndB :: Int
_qSubEndB :: ServerStatsData -> Int
_qSubEndB,
        Int
_ntfCreated :: Int
_ntfCreated :: ServerStatsData -> Int
_ntfCreated,
        Int
_ntfNewCreated :: Int
_ntfNewCreated :: ServerStatsData -> Int
_ntfNewCreated,
        Int
_ntfDeleted :: Int
_ntfDeleted :: ServerStatsData -> Int
_ntfDeleted,
        Int
_ntfDeletedB :: Int
_ntfDeletedB :: ServerStatsData -> Int
_ntfDeletedB,
        Int
_ntfSub :: Int
_ntfSub :: ServerStatsData -> Int
_ntfSub,
        Int
_ntfSubB :: Int
_ntfSubB :: ServerStatsData -> Int
_ntfSubB,
        Int
_ntfSubAuth :: Int
_ntfSubAuth :: ServerStatsData -> Int
_ntfSubAuth,
        Int
_ntfSubDuplicate :: Int
_ntfSubDuplicate :: ServerStatsData -> Int
_ntfSubDuplicate,
        Int
_msgSent :: Int
_msgSent :: ServerStatsData -> Int
_msgSent,
        Int
_msgSentAuth :: Int
_msgSentAuth :: ServerStatsData -> Int
_msgSentAuth,
        Int
_msgSentQuota :: Int
_msgSentQuota :: ServerStatsData -> Int
_msgSentQuota,
        Int
_msgSentLarge :: Int
_msgSentLarge :: ServerStatsData -> Int
_msgSentLarge,
        Int
_msgSentBlock :: Int
_msgSentBlock :: ServerStatsData -> Int
_msgSentBlock,
        Int
_msgRecv :: Int
_msgRecv :: ServerStatsData -> Int
_msgRecv,
        TimeBuckets
_msgRecvAckTimes :: TimeBuckets
_msgRecvAckTimes :: ServerStatsData -> TimeBuckets
_msgRecvAckTimes,
        Int
_msgRecvGet :: Int
_msgRecvGet :: ServerStatsData -> Int
_msgRecvGet,
        Int
_msgGet :: Int
_msgGet :: ServerStatsData -> Int
_msgGet,
        Int
_msgGetNoMsg :: Int
_msgGetNoMsg :: ServerStatsData -> Int
_msgGetNoMsg,
        Int
_msgGetAuth :: Int
_msgGetAuth :: ServerStatsData -> Int
_msgGetAuth,
        Int
_msgGetDuplicate :: Int
_msgGetDuplicate :: ServerStatsData -> Int
_msgGetDuplicate,
        Int
_msgGetProhibited :: Int
_msgGetProhibited :: ServerStatsData -> Int
_msgGetProhibited,
        Int
_msgExpired :: Int
_msgExpired :: ServerStatsData -> Int
_msgExpired,
        Int
_msgSentNtf :: Int
_msgSentNtf :: ServerStatsData -> Int
_msgSentNtf,
        Int
_msgRecvNtf :: Int
_msgRecvNtf :: ServerStatsData -> Int
_msgRecvNtf,
        Int
_msgNtfs :: Int
_msgNtfs :: ServerStatsData -> Int
_msgNtfs,
        Int
_msgNtfsB :: Int
_msgNtfsB :: ServerStatsData -> Int
_msgNtfsB,
        Int
_msgNtfNoSub :: Int
_msgNtfNoSub :: ServerStatsData -> Int
_msgNtfNoSub,
        Int
_msgNtfLost :: Int
_msgNtfLost :: ServerStatsData -> Int
_msgNtfLost,
        Int
_msgNtfExpired :: Int
_msgNtfExpired :: ServerStatsData -> Int
_msgNtfExpired,
        ProxyStatsData
_pRelays :: ProxyStatsData
_pRelays :: ServerStatsData -> ProxyStatsData
_pRelays,
        ProxyStatsData
_pRelaysOwn :: ProxyStatsData
_pRelaysOwn :: ServerStatsData -> ProxyStatsData
_pRelaysOwn,
        ProxyStatsData
_pMsgFwds :: ProxyStatsData
_pMsgFwds :: ServerStatsData -> ProxyStatsData
_pMsgFwds,
        ProxyStatsData
_pMsgFwdsOwn :: ProxyStatsData
_pMsgFwdsOwn :: ServerStatsData -> ProxyStatsData
_pMsgFwdsOwn,
        Int
_pMsgFwdsRecv :: Int
_pMsgFwdsRecv :: ServerStatsData -> Int
_pMsgFwdsRecv,
        ServiceStatsData
_rcvServices :: ServiceStatsData
_rcvServices :: ServerStatsData -> ServiceStatsData
_rcvServices,
        ServiceStatsData
_ntfServices :: ServiceStatsData
_ntfServices :: ServerStatsData -> ServiceStatsData
_ntfServices,
        Int
_qCount :: Int
_qCount :: ServerStatsData -> Int
_qCount,
        Int
_msgCount :: Int
_msgCount :: ServerStatsData -> Int
_msgCount,
        Int
_ntfCount :: Int
_ntfCount :: ServerStatsData -> Int
_ntfCount
      } = ServerStatsData
statsData
    time :: Text
time =
      Text
"# Recorded at: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> ServiceName -> Text
T.pack (UTCTime -> ServiceName
forall t. ISO8601 t => t -> ServiceName
iso8601Show UTCTime
ts) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n\
      \# Stats from: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> ServiceName -> Text
T.pack (UTCTime -> ServiceName
forall t. ISO8601 t => t -> ServiceName
iso8601Show UTCTime
_fromTime) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n\
      \\n"
    queues :: Text
queues =
      Text
"# Queues\n\
      \# ------\n\
      \\n\
      \# HELP simplex_smp_queues_created Created queues\n\
      \# TYPE simplex_smp_queues_created counter\n\
      \simplex_smp_queues_created " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_qCreated Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# qCreated\n\
      \\n\
      \# HELP simplex_smp_queues_secured Secured queues\n\
      \# TYPE simplex_smp_queues_secured counter\n\
      \simplex_smp_queues_secured " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_qSecured Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# qSecured\n\
      \\n\
      \# HELP simplex_smp_queues_deleted Deleted queues\n\
      \# TYPE simplex_smp_queues_deleted counter\n\
      \simplex_smp_queues_deleted{type=\"all\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_qDeletedAll Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# qDeleted\n\
      \simplex_smp_queues_deleted{type=\"new\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_qDeletedNew Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# qDeletedNew\n\
      \simplex_smp_queues_deleted{type=\"secured\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_qDeletedSecured Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# qDeletedSecured\n\
      \\n\
      \# HELP simplex_smp_queues_blocked Deleted queues\n\
      \# TYPE simplex_smp_queues_blocked counter\n\
      \simplex_smp_queues_blocked " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_qBlocked Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# qBlocked\n\
      \\n\
      \# HELP simplex_smp_queues_deleted_batch Batched requests to delete queues\n\
      \# TYPE simplex_smp_queues_deleted_batch counter\n\
      \simplex_smp_queues_deleted_batch " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_qDeletedAllB Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# qDeletedAllB\n\
      \\n\
      \# HELP simplex_smp_queues_total1 Total number of stored queues (first type of count).\n\
      \# TYPE simplex_smp_queues_total1 gauge\n\
      \simplex_smp_queues_total1 " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_qCount Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# qCount\n\
      \\n\
      \# HELP simplex_smp_queues_total2 Total number of stored queues (second type of count).\n\
      \# TYPE simplex_smp_queues_total2 gauge\n\
      \simplex_smp_queues_total2 " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (EntityCounts -> Int
queueCount EntityCounts
entityCounts) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# qCount2\n\
      \\n\
      \# HELP simplex_smp_queues_daily Daily active queues.\n\
      \# TYPE simplex_smp_queues_daily gauge\n\
      \simplex_smp_queues_daily " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text -> Text
mstr (PeriodStatCounts -> Text
dayCount PeriodStatCounts
ps) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# dayMsgQueues\n\
      \\n\
      \# HELP simplex_smp_queues_weekly Weekly active queues.\n\
      \# TYPE simplex_smp_queues_weekly gauge\n\
      \simplex_smp_queues_weekly " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text -> Text
mstr (PeriodStatCounts -> Text
weekCount PeriodStatCounts
ps) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# weekMsgQueues\n\
      \\n\
      \# HELP simplex_smp_queues_monthly Monthly active queues.\n\
      \# TYPE simplex_smp_queues_monthly gauge\n\
      \simplex_smp_queues_monthly " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text -> Text
mstr (PeriodStatCounts -> Text
monthCount PeriodStatCounts
ps) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# monthMsgQueues\n\
      \\n\
      \# HELP simplex_smp_queues_notify_daily Daily active queues with notifications.\n\
      \# TYPE simplex_smp_queues_notify_daily gauge\n\
      \simplex_smp_queues_notify_daily " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text -> Text
mstr (PeriodStatCounts -> Text
dayCount PeriodStatCounts
psNtf) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# dayCountNtf\n\
      \\n\
      \# HELP simplex_smp_queues_notify_weekly Weekly active queues with notifications.\n\
      \# TYPE simplex_smp_queues_notify_weekly gauge\n\
      \simplex_smp_queues_notify_weekly " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text -> Text
mstr (PeriodStatCounts -> Text
weekCount PeriodStatCounts
psNtf) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# weekCountNtf\n\
      \\n\
      \# HELP simplex_smp_queues_notify_monthly Monthly active queues with notifications.\n\
      \# TYPE simplex_smp_queues_notify_monthly gauge\n\
      \simplex_smp_queues_notify_monthly " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text -> Text
mstr (PeriodStatCounts -> Text
monthCount PeriodStatCounts
psNtf) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# monthCountNtf\n\
      \\n"
    subscriptions :: Text
subscriptions =
      Text
"# Subscriptions\n\
      \# -------------\n\
      \\n\
      \# HELP simplex_smp_subscribtion_successes Successful subscriptions.\n\
      \# TYPE simplex_smp_subscribtion_successes counter\n\
      \simplex_smp_subscribtion_successes " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_qSub Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# qSub\n\
      \\n\
      \# HELP simplex_smp_subscribtion_successes_batch Batched successful subscriptions.\n\
      \# TYPE simplex_smp_subscribtion_successes_batch counter\n\
      \simplex_smp_subscribtion_successes_batch " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_qSubAllB Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# qSubAllB\n\
      \\n\
      \# HELP simplex_smp_subscribtion_end Ended subscriptions.\n\
      \# TYPE simplex_smp_subscribtion_end counter\n\
      \simplex_smp_subscribtion_end " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_qSubEnd Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# qSubEnd\n\
      \\n\
      \# HELP simplex_smp_subscribtion_end_batch Batched ended subscriptions.\n\
      \# TYPE simplex_smp_subscribtion_end_batch counter\n\
      \simplex_smp_subscribtion_end_batch " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_qSubEndB Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# qSubEndB\n\
      \\n\
      \# HELP simplex_smp_subscribtion_errors Subscription errors.\n\
      \# TYPE simplex_smp_subscribtion_errors counter\n\
      \simplex_smp_subscribtion_errors{type=\"auth\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_qSubAuth Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# qSubAuth\n\
      \simplex_smp_subscribtion_errors{type=\"duplicate\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_qSubDuplicate Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# qSubDuplicate\n\
      \simplex_smp_subscribtion_errors{type=\"prohibited\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_qSubProhibited Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# qSubProhibited\n\
      \\n"
    messages :: Text
messages =
      Text
"# Messages\n\
      \# --------\n\
      \\n\
      \# HELP simplex_smp_messages_sent Sent messages.\n\
      \# TYPE simplex_smp_messages_sent counter\n\
      \simplex_smp_messages_sent " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_msgSent Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# msgSent\n\
      \\n\
      \# HELP simplex_smp_messages_sent_errors Total number of messages errors by type.\n\
      \# TYPE simplex_smp_messages_sent_errors counter\n\
      \simplex_smp_messages_sent_errors{type=\"auth\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_msgSentAuth Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# msgSentAuth\n\
      \simplex_smp_messages_sent_errors{type=\"quota\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_msgSentQuota Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# msgSentQuota\n\
      \simplex_smp_messages_sent_errors{type=\"large\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_msgSentLarge Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# msgSentLarge\n\
      \simplex_smp_messages_sent_errors{type=\"block\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_msgSentBlock Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# msgSentBlock\n\
      \\n\
      \# HELP simplex_smp_messages_received Received messages.\n\
      \# TYPE simplex_smp_messages_received counter\n\
      \simplex_smp_messages_received " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_msgRecv Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# msgRecv\n\
      \\n\
      \# HELP simplex_smp_messages_expired Expired messages.\n\
      \# TYPE simplex_smp_messages_expired counter\n\
      \simplex_smp_messages_expired " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_msgExpired Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# msgExpired\n\
      \\n\
      \# HELP simplex_smp_messages_total Total number of messages stored.\n\
      \# TYPE simplex_smp_messages_total gauge\n\
      \simplex_smp_messages_total " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_msgCount Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# msgCount\n\
      \\n"
    ntfMessages :: Text
ntfMessages =
      Text
"# Notification messages (client)\n\
      \# ------------------------------\n\
      \\n\
      \# HELP simplex_smp_messages_notify_sent Sent messages with notification flag (cleint).\n\
      \# TYPE simplex_smp_messages_notify_sent counter\n\
      \simplex_smp_messages_notify_sent " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_msgSentNtf Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# msgSentNtf\n\
      \\n\
      \# HELP simplex_smp_messages_notify_received Received messages with notification flag (client).\n\
      \# TYPE simplex_smp_messages_notify_received counter\n\
      \simplex_smp_messages_notify_received " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_msgRecvNtf Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# msgRecvNtf\n\
      \\n\
      \# HELP simplex_smp_messages_notify_get_sent Requests to get messages with notification flag (client).\n\
      \# TYPE simplex_smp_messages_notify_get_sent counter\n\
      \simplex_smp_messages_notify_get_sent " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_msgGet Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# msgGet\n\
      \\n\
      \# HELP simplex_smp_messages_notify_get_received Succesfully received get requests messages with notification flag (client).\n\
      \# TYPE simplex_smp_messages_notify_get_received counter\n\
      \simplex_smp_messages_notify_get_received " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_msgRecvGet Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# msgRecvGet\n\
      \\n\
      \# HELP simplex_smp_messages_notify_get_errors Error events with messages with notification flag (client). \n\
      \# TYPE simplex_smp_messages_notify_get_errors counter\n\
      \simplex_smp_messages_notify_get_errors{type=\"nomsg\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_msgGetNoMsg Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# msgGetNoMsg\n\
      \simplex_smp_messages_notify_get_errors{type=\"auth\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_msgGetAuth Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# msgGetAuth\n\
      \simplex_smp_messages_notify_get_errors{type=\"duplicate\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_msgGetDuplicate Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# msgGetDuplicate\n\
      \simplex_smp_messages_notify_get_errors{type=\"prohibited\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_msgGetProhibited Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# msgGetProhibited\n\
      \\n\
      \# HELP simplex_smp_queues_notify_created Created queue notification credentials.\n\
      \# TYPE simplex_smp_queues_notify_created counter\n\
      \simplex_smp_queues_notify_created " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_ntfCreated Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# ntfCreated\n\
      \\n\
      \# HELP simplex_smp_queues_notify_new_created Created new queues with notification credentials.\n\
      \# TYPE simplex_smp_queues_notify_new_created counter\n\
      \simplex_smp_queues_notify_new_created " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_ntfNewCreated Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# ntfNewCreated\n\
      \\n\
      \# HELP simplex_smp_queues_notify_deleted Deleted queue notification credentials.\n\
      \# TYPE simplex_smp_queues_notify_deleted counter\n\
      \simplex_smp_queues_notify_deleted " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_ntfDeleted Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# ntfDeleted\n\
      \\n\
      \# HELP simplex_smp_queues_notify_deleted_batch Deleted batched queue notification credentials.\n\
      \# TYPE simplex_smp_queues_notify_deleted_batch counter\n\
      \simplex_smp_queues_notify_deleted_batch " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_ntfDeletedB Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# ntfDeletedB\n\
      \\n\
      \# HELP simplex_smp_queues_notify_total1 Total number of stored queues with notification flag (first type of count).\n\
      \# TYPE simplex_smp_queues_notify_total1 gauge\n\
      \simplex_smp_queues_notify_total1 " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_ntfCount Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# ntfCount1\n\
      \\n\
      \# HELP simplex_smp_queues_notify_total2 Total number of stored queues with notification flag (second type of count).\n\
      \# TYPE simplex_smp_queues_notify_total2 gauge\n\
      \simplex_smp_queues_notify_total2 " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (EntityCounts -> Int
notifierCount EntityCounts
entityCounts) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# ntfCount2\n\
      \\n"
    ntfs :: Text
ntfs =
      Text
"# Notifications (server)\n\
      \# ----------------------\n\
      \\n\
      \# HELP simplex_smp_messages_ntf_successes Successful events with notification messages (to ntf server). \n\
      \# TYPE simplex_smp_messages_ntf_successes counter\n\
      \simplex_smp_messages_ntf_successes " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_msgNtfs Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# msgNtfs\n\
      \\n\
      \# HELP simplex_smp_messages_ntf_successes_batch Successful batched events with notification messages (to ntf server). \n\
      \# TYPE simplex_smp_messages_ntf_successes_batch counter\n\
      \simplex_smp_messages_ntf_successes_batch " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_msgNtfsB Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# msgNtfsB\n\
      \\n\
      \# HELP simplex_smp_messages_ntf_errors Error events with notification messages (to ntf server). \n\
      \# TYPE simplex_smp_messages_ntf_errors counter\n\
      \simplex_smp_messages_ntf_errors{type=\"nosub\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_msgNtfNoSub Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# msgNtfNoSub\n\
      \simplex_smp_messages_ntf_errors{type=\"lost\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_msgNtfLost Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# msgNtfLost\n\
      \simplex_smp_messages_ntf_errors{type=\"expired\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_msgNtfExpired Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# msgNtfExpired\n\
      \\n\
      \# HELP simplex_smp_subscription_ntf_requests Subscription requests with notification flag (from ntf server). \n\
      \# TYPE simplex_smp_subscription_ntf_requests counter\n\
      \simplex_smp_subscription_ntf_requests " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_ntfSub Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# ntfSub\n\
      \\n\
      \# HELP simplex_smp_subscription_ntf_requests_batch Batched subscription requests with notification flag (from ntf server). \n\
      \# TYPE simplex_smp_subscription_ntf_requests_batch counter\n\
      \simplex_smp_subscription_ntf_requests_batch " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_ntfSubB Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# ntfSubB\n\
      \\n\
      \# HELP simplex_smp_subscribtion_ntf_errors Subscription errors with notification flag (from ntf server). \n\
      \# TYPE simplex_smp_subscribtion_ntf_errors counter\n\
      \simplex_smp_subscribtion_ntf_errors{type=\"auth\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_ntfSubAuth Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# ntfSubAuth\n\
      \simplex_smp_subscribtion_ntf_errors{type=\"duplicate\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_ntfSubDuplicate Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# ntfSubDuplicate\n\
      \\n"
    relays :: Text
relays =
      Text
"# Relays\n\
      \# ------\n\
      \\n\
      \# HELP simplex_smp_relay_sessions_requests Session requests through relay.\n\
      \# TYPE simplex_smp_relay_sessions_requests counter\n\
      \simplex_smp_relay_sessions_requests{source=\"all\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ProxyStatsData -> Int
_pRequests ProxyStatsData
_pRelays) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# pRelays_pRequests\n\
      \simplex_smp_relay_sessions_requests{source=\"own\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ProxyStatsData -> Int
_pRequests ProxyStatsData
_pRelaysOwn) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# pRelaysOwn_pRequests\n\
      \\n\
      \# HELP simplex_smp_relay_sessions_successes Successful session events through relay.\n\
      \# TYPE simplex_smp_relay_sessions_successes counter\n\
      \simplex_smp_relay_sessions_successes{source=\"all\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ProxyStatsData -> Int
_pSuccesses ProxyStatsData
_pRelays) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# pRelays_pSuccesses\n\
      \simplex_smp_relay_sessions_successes{source=\"own\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ProxyStatsData -> Int
_pSuccesses ProxyStatsData
_pRelaysOwn) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# pRelaysOwn_pSuccesses\n\
      \\n\
      \# HELP simplex_smp_relay_sessions_errors Error session events through relay.\n\
      \# TYPE simplex_smp_relay_sessions_errors counter\n\
      \simplex_smp_relay_sessions_errors{source=\"all\",type=\"connect\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ProxyStatsData -> Int
_pErrorsConnect ProxyStatsData
_pRelays) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# pRelays_pErrorsConnect\n\
      \simplex_smp_relay_sessions_errors{source=\"all\",type=\"compat\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ProxyStatsData -> Int
_pErrorsCompat ProxyStatsData
_pRelays) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# pRelays_pErrorsCompat\n\
      \simplex_smp_relay_sessions_errors{source=\"all\",type=\"other\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ProxyStatsData -> Int
_pErrorsOther ProxyStatsData
_pRelays) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# pRelays_pErrorsOther\n\
      \simplex_smp_relay_sessions_errors{source=\"own\",type=\"connect\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ProxyStatsData -> Int
_pErrorsConnect ProxyStatsData
_pRelaysOwn) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# pRelaysOwn_pErrorsConnect\n\
      \simplex_smp_relay_sessions_errors{source=\"own\",type=\"compat\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ProxyStatsData -> Int
_pErrorsCompat ProxyStatsData
_pRelaysOwn) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# pRelaysOwn_pErrorsCompat\n\
      \simplex_smp_relay_sessions_errors{source=\"own\",type=\"other\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ProxyStatsData -> Int
_pErrorsOther ProxyStatsData
_pRelaysOwn) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# pRelaysOwn_pErrorsOther\n\
      \\n\
      \# HELP simplex_smp_relay_messages_requests Message requests sent through relay.\n\
      \# TYPE simplex_smp_relay_messages_requests counter\n\
      \simplex_smp_relay_messages_requests{source=\"all\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ProxyStatsData -> Int
_pRequests ProxyStatsData
_pMsgFwds) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# pMsgFwds_pRequests\n\
      \simplex_smp_relay_messages_requests{source=\"own\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ProxyStatsData -> Int
_pRequests ProxyStatsData
_pMsgFwdsOwn) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# pMsgFwdsOwn_pRequests\n\
      \\n\
      \# HELP simplex_smp_relay_messages_successes Successful messages sent through relay.\n\
      \# TYPE simplex_smp_relay_messages_successes counter\n\
      \simplex_smp_relay_messages_successes{source=\"all\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ProxyStatsData -> Int
_pSuccesses ProxyStatsData
_pMsgFwds) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# pMsgFwds_pSuccesses\n\
      \simplex_smp_relay_messages_successes{source=\"own\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ProxyStatsData -> Int
_pSuccesses ProxyStatsData
_pMsgFwdsOwn) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# pMsgFwdsOwn_pSuccesses\n\
      \\n\
      \# HELP simplex_smp_relay_messages_errors Error events with messages sent through relay.\n\
      \# TYPE simplex_smp_relay_messages_errors counter\n\
      \simplex_smp_relay_messages_errors{source=\"all\",type=\"connect\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ProxyStatsData -> Int
_pErrorsConnect ProxyStatsData
_pMsgFwds) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# pMsgFwds_pErrorsConnect\n\
      \simplex_smp_relay_messages_errors{source=\"all\",type=\"compat\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ProxyStatsData -> Int
_pErrorsCompat ProxyStatsData
_pMsgFwds) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# pMsgFwds_pErrorsCompat\n\
      \simplex_smp_relay_messages_errors{source=\"all\",type=\"other\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ProxyStatsData -> Int
_pErrorsOther ProxyStatsData
_pMsgFwds) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# pMsgFwds_pErrorsOther\n\
      \simplex_smp_relay_messages_errors{source=\"own\",type=\"connect\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ProxyStatsData -> Int
_pErrorsConnect ProxyStatsData
_pMsgFwdsOwn) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# pMsgFwdsOwn_pErrorsConnect\n\
      \simplex_smp_relay_messages_errors{source=\"own\",type=\"compat\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ProxyStatsData -> Int
_pErrorsCompat ProxyStatsData
_pMsgFwdsOwn) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# pMsgFwdsOwn_pErrorsCompat\n\
      \simplex_smp_relay_messages_errors{source=\"own\",type=\"other\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ProxyStatsData -> Int
_pErrorsOther ProxyStatsData
_pMsgFwdsOwn) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# pMsgFwdsOwn_pErrorsOther\n\
      \\n\
      \# HELP simplex_smp_relay_messages_received Relay messages statistics.\n\
      \# TYPE simplex_smp_relay_messages_received counter\n\
      \simplex_smp_relay_messages_received " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
_pMsgFwdsRecv Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# pMsgFwdsRecv\n\
      \\n"
    services :: Text
services =
      Text
"# Services\n\
      \# --------\n\
      \# HELP simplex_smp_rcv_services_count The count of receiving services.\n\
      \# TYPE simplex_smp_rcv_services_count gauge\n\
      \simplex_smp_rcv_services_count " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (EntityCounts -> Int
rcvServiceCount EntityCounts
entityCounts) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# rcvServiceCount\n\
      \\n\
      \# HELP simplex_smp_rcv_services_queues_count The count of queues associated with receiving services.\n\
      \# TYPE simplex_smp_rcv_services_queues_count gauge\n\
      \simplex_smp_rcv_services_queues_count " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (EntityCounts -> Int
rcvServiceQueuesCount EntityCounts
entityCounts) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# rcv.rcvServiceQueuesCount\n\
      \\n\
      \# HELP simplex_smp_ntf_services_count The count of notification services.\n\
      \# TYPE simplex_smp_ntf_services_count gauge\n\
      \simplex_smp_ntf_services_count " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (EntityCounts -> Int
ntfServiceCount EntityCounts
entityCounts) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# ntfServiceCount\n\
      \\n\
      \# HELP simplex_smp_ntf_services_queues_count The count of queues associated with notification services.\n\
      \# TYPE simplex_smp_ntf_services_queues_count gauge\n\
      \simplex_smp_ntf_services_queues_count " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (EntityCounts -> Int
ntfServiceQueuesCount EntityCounts
entityCounts) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# ntfServiceQueuesCount\n\
      \\n"
        Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> ServiceStatsData -> Text -> Text -> Text
showServices ServiceStatsData
_rcvServices Text
"rcv" Text
"receiving"
        Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> ServiceStatsData -> Text -> Text -> Text
showServices ServiceStatsData
_ntfServices Text
"ntf" Text
"notification"
    showServices :: ServiceStatsData -> Text -> Text -> Text
showServices ServiceStatsData
ss Text
pfx Text
name =
      Text
"# HELP simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_assoc_new New queue associations with " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
name Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" services.\n\
      \# TYPE simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_assoc_new counter\n\
      \simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_assoc_new " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ServiceStatsData -> Int
_srvAssocNew ServiceStatsData
ss) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
".srvAssocNew\n\
      \\n\
      \# HELP simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_assoc_duplicate Duplicate queue associations with " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
name Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" services.\n\
      \# TYPE simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_assoc_duplicate counter\n\
      \simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_assoc_duplicate " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ServiceStatsData -> Int
_srvAssocDuplicate ServiceStatsData
ss) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
".srvAssocDuplicate\n\
      \\n\
      \# HELP simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_assoc_updated Updated queue associations with " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
name Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" services.\n\
      \# TYPE simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_assoc_updated counter\n\
      \simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_assoc_updated " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ServiceStatsData -> Int
_srvAssocUpdated ServiceStatsData
ss) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
".srvAssocUpdated\n\
      \\n\
      \# HELP simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_assoc_removed Removed queue associations with " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
name Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" services.\n\
      \# TYPE simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_assoc_removed counter\n\
      \simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_assoc_removed " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ServiceStatsData -> Int
_srvAssocRemoved ServiceStatsData
ss) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
".srvAssocRemoved\n\
      \\n\
      \# HELP simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_sub_count Service subscriptions by " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
name Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" services.\n\
      \# TYPE simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_sub_count counter\n\
      \simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_sub_count " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ServiceStatsData -> Int
_srvSubCount ServiceStatsData
ss) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
".srvSubCount\n\
      \\n\
      \# HELP simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_sub_duplicate Duplicate service subscriptions by " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
name Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" services.\n\
      \# TYPE simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_sub_duplicate counter\n\
      \simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_sub_duplicate " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ServiceStatsData -> Int
_srvSubDuplicate ServiceStatsData
ss) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
".srvSubDuplicate\n\
      \\n\
      \# HELP simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_sub_queues Queues subscribed by " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
name Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" services.\n\
      \# TYPE simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_sub_queues gauge\n\
      \simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_sub_queues " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ServiceStatsData -> Int
_srvSubQueues ServiceStatsData
ss) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
".srvSubQueues\n\
      \\n\
      \# HELP simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_sub_end Ended subscriptions with " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
name Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" services.\n\
      \# TYPE simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_sub_end gauge\n\
      \simplex_smp_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_services_sub_end " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (ServiceStatsData -> Int
_srvSubEnd ServiceStatsData
ss) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
pfx Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
".srvSubEnd\n\
      \\n"
    info :: Text
info =
      Text
"# Info\n\
      \# ----\n\
      \\n\
      \# HELP simplex_smp_info Server information. RTS options have to be passed via " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
rtsOptionsEnv Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" env var\n\
      \# TYPE simplex_smp_info gauge\n\
      \simplex_smp_info{version=\"" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> ServiceName -> Text
T.pack ServiceName
simplexMQVersion Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\",rts_options=\"" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
rtsOptions Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\"} 1\n\
      \\n"
      Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> (SocketStats -> Int) -> Text -> Text -> Text
socketsMetric SocketStats -> Int
socketsAccepted Text
"simplex_smp_sockets_accepted" Text
"Accepted sockets"
      Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> (SocketStats -> Int) -> Text -> Text -> Text
socketsMetric SocketStats -> Int
socketsClosed Text
"simplex_smp_sockets_closed" Text
"Closed sockets"
      Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> (SocketStats -> Int) -> Text -> Text -> Text
socketsMetric SocketStats -> Int
socketsActive Text
"simplex_smp_sockets_active" Text
"Active sockets"
      Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> (SocketStats -> Int) -> Text -> Text -> Text
socketsMetric SocketStats -> Int
socketsLeaked Text
"simplex_smp_sockets_leaked" Text
"Leaked sockets"
      Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"# HELP simplex_smp_threads_total Threads\n\
      \# TYPE simplex_smp_threads_total gauge\n\
      \simplex_smp_threads_total " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
threadsCount Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n\
      \\n\
      \# HELP simplex_smp_clients_total Clients\n\
      \# TYPE simplex_smp_clients_total gauge\n\
      \simplex_smp_clients_total " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
clientsCount Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n\
      \\n\
      \# HELP simplex_smp_delivered_total Total SMP subscriptions with delivered messages\n\
      \# TYPE simplex_smp_delivered_total gauge\n\
      \simplex_smp_delivered_total " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (RTSubscriberMetrics -> Int
subsCount RTSubscriberMetrics
deliveredSubs) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# delivered.subsCount\n\
      \\n\
      \# HELP simplex_smp_delivered_clients_total Subscribed clients\n\
      \# TYPE simplex_smp_delivered_clients_total gauge\n\
      \simplex_smp_delivered_clients_total " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (RTSubscriberMetrics -> Int
subClientsCount RTSubscriberMetrics
deliveredSubs) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# delivered.subClientsCount\n\
      \\n\
      \# HELP simplex_smp_delivery_ack_confirmed_time Times to confirm message delivery, only confirmed deliveries\n\
      \# TYPE simplex_smp_delivery_ack_confirmed_time histogram\n\
      \simplex_smp_delivery_ack_confirmed_time_sum " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int64 -> Text
forall a. Show a => a -> Text
mshow (TimeBuckets -> Int64
sumTime TimeBuckets
_msgRecvAckTimes) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n\
      \simplex_smp_delivery_ack_confirmed_time_count " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (Int
_msgRecv Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
_msgRecvGet) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n"
      Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text -> IntMap Int -> Text
showTimeBuckets Text
"simplex_smp_delivery_ack_confirmed_time" (TimeBuckets -> IntMap Int
timeBuckets TimeBuckets
_msgRecvAckTimes)
      Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text -> Text -> Int -> Text
showTimeBucket Text
"simplex_smp_delivery_ack_confirmed_time" Text
"+Inf" (Int
_msgRecv Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
_msgRecvGet)
      Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n\
      \# HELP simplex_smp_delivery_ack_confirmed_count Counts for confirmed deliveries\n\
      \# TYPE simplex_smp_delivery_ack_confirmed_count counter\n"
      Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text -> IntMap Int -> Text
showBucketSums Text
"simplex_smp_delivery_ack_confirmed_count" (TimeBuckets -> IntMap Int
timeBuckets TimeBuckets
_msgRecvAckTimes)
      Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n\
      \# HELP simplex_smp_delivery_ack_pending_count Counts for pending delivery\n\
      \# TYPE simplex_smp_delivery_ack_pending_count gauge\n"
      Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text -> IntMap Int -> Text
showBucketSums Text
"simplex_smp_delivery_ack_pending_count" (TimeBuckets -> IntMap Int
timeBuckets TimeBuckets
deliveredTimes)
      Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n\
      \# HELP simplex_smp_delivery_ack_time_max Max time to confirm message delivery\n\
      \# TYPE simplex_smp_delivery_ack_time_max gauge\n\
      \simplex_smp_delivery_ack_time_max " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int64 -> Text
forall a. Show a => a -> Text
mshow (TimeBuckets -> Int64
maxTime TimeBuckets
deliveredTimes) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# delivered.maxTime\n\
      \\n\
      \# HELP simplex_smp_subscribtion_total Total SMP subscriptions\n\
      \# TYPE simplex_smp_subscribtion_total gauge\n\
      \simplex_smp_subscribtion_total " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (RTSubscriberMetrics -> Int
subsCount RTSubscriberMetrics
smpSubs) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# smp.subsCount\n\
      \\n\
      \# HELP simplex_smp_subscribtion_clients_total Subscribed clients\n\
      \# TYPE simplex_smp_subscribtion_clients_total gauge\n\
      \simplex_smp_subscribtion_clients_total " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (RTSubscriberMetrics -> Int
subClientsCount RTSubscriberMetrics
smpSubs) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# smp.subClientsCount\n\
      \\n\
      \# HELP simplex_smp_subscribtion_services_total Subscribed services, first counting method\n\
      \# TYPE simplex_smp_subscribtion_services_total gauge\n\
      \simplex_smp_subscribtion_services_total " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (RTSubscriberMetrics -> Int
subServicesCount RTSubscriberMetrics
smpSubs) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# smp.subServicesCount\n\
      \\n\
      \# HELP simplex_smp_subscription_ntf_total Total notification subscripbtions (from ntf server)\n\
      \# TYPE simplex_smp_subscription_ntf_total gauge\n\
      \simplex_smp_subscription_ntf_total " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (RTSubscriberMetrics -> Int
subsCount RTSubscriberMetrics
ntfSubs) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# ntf.subsCount\n\
      \\n\
      \# HELP simplex_smp_subscription_ntf_clients_total Total subscribed NTF servers\n\
      \# TYPE simplex_smp_subscription_ntf_clients_total gauge\n\
      \simplex_smp_subscription_ntf_clients_total " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (RTSubscriberMetrics -> Int
subClientsCount RTSubscriberMetrics
ntfSubs) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# ntf.subClientsCount\n\
      \\n\
      \# HELP simplex_smp_subscribtion_nts_services_total Subscribed NTF services, first counting method\n\
      \# TYPE simplex_smp_subscribtion_nts_services_total gauge\n\
      \simplex_smp_subscribtion_nts_services_total " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (RTSubscriberMetrics -> Int
subServicesCount RTSubscriberMetrics
ntfSubs) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# ntf.subServicesCount\n\
      \\n\
      \# HELP simplex_smp_loaded_queues_queue_count Total loaded queues count (all queues for memory/journal storage)\n\
      \# TYPE simplex_smp_loaded_queues_queue_count gauge\n\
      \simplex_smp_loaded_queues_queue_count " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (LoadedQueueCounts -> Int
loadedQueueCount LoadedQueueCounts
loadedCounts) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# loadedCounts.loadedQueueCount\n\
      \\n\
      \# HELP simplex_smp_loaded_queues_ntf_count Total loaded ntf credential references (all ntf credentials for memory/journal storage)\n\
      \# TYPE simplex_smp_loaded_queues_ntf_count gauge\n\
      \simplex_smp_loaded_queues_ntf_count " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (LoadedQueueCounts -> Int
loadedNotifierCount LoadedQueueCounts
loadedCounts) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# loadedCounts.loadedNotifierCount\n\
      \\n\
      \# HELP simplex_smp_loaded_queues_open_journal_count Total opened queue journals (0 for memory storage)\n\
      \# TYPE simplex_smp_loaded_queues_open_journal_count gauge\n\
      \simplex_smp_loaded_queues_open_journal_count " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (LoadedQueueCounts -> Int
openJournalCount LoadedQueueCounts
loadedCounts) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# loadedCounts.openJournalCount\n\
      \\n\
      \# HELP simplex_smp_loaded_queues_queue_lock_count Total queue locks (0 for memory storage)\n\
      \# TYPE simplex_smp_loaded_queues_queue_lock_count gauge\n\
      \simplex_smp_loaded_queues_queue_lock_count " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (LoadedQueueCounts -> Int
queueLockCount LoadedQueueCounts
loadedCounts) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# loadedCounts.queueLockCount\n\
      \\n\
      \# HELP simplex_smp_loaded_queues_ntf_lock_count Total notifier locks (0 for memory/journal storage)\n\
      \# TYPE simplex_smp_loaded_queues_ntf_lock_count gauge\n\
      \simplex_smp_loaded_queues_ntf_lock_count " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (LoadedQueueCounts -> Int
notifierLockCount LoadedQueueCounts
loadedCounts) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n# loadedCounts.notifierLockCount\n"

    showTimeBuckets :: Text -> IM.IntMap Int -> Text
    showTimeBuckets :: Text -> IntMap Int -> Text
showTimeBuckets Text
metric = [Text] -> Text
T.concat ([Text] -> Text) -> (IntMap Int -> [Text]) -> IntMap Int -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Int, Int), [Text]) -> [Text]
forall a b. (a, b) -> b
snd (((Int, Int), [Text]) -> [Text])
-> (IntMap Int -> ((Int, Int), [Text])) -> IntMap Int -> [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Int, Int) -> (Int, Int) -> ((Int, Int), Text))
-> (Int, Int) -> [(Int, Int)] -> ((Int, Int), [Text])
forall (t :: * -> *) s a b.
Traversable t =>
(s -> a -> (s, b)) -> s -> t a -> (s, t b)
mapAccumL (Int, Int) -> (Int, Int) -> ((Int, Int), Text)
forall {a}.
(Ord a, Num a, Show a) =>
(a, Int) -> (a, Int) -> ((a, Int), Text)
accumBucket (Int
0, Int
0) ([(Int, Int)] -> ((Int, Int), [Text]))
-> (IntMap Int -> [(Int, Int)])
-> IntMap Int
-> ((Int, Int), [Text])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IntMap Int -> [(Int, Int)]
forall a. IntMap a -> [(Int, a)]
IM.assocs
      where
        accumBucket :: (a, Int) -> (a, Int) -> ((a, Int), Text)
accumBucket (a
prevSec, Int
total) (a
sec, Int
cnt) =
          let t :: Text
t
                | a
sec a -> a -> a
forall a. Num a => a -> a -> a
- a
60 a -> a -> Bool
forall a. Ord a => a -> a -> Bool
> a
prevSec = Text -> Text -> Int -> Text
showTimeBucket Text
metric (a -> Text
forall a. Show a => a -> Text
tshow (a
sec a -> a -> a
forall a. Num a => a -> a -> a
- a
60)) Int
total
                | Bool
otherwise = Text
""
           in ((a
sec, Int
total Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
cnt), Text
t Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text -> Text -> Int -> Text
showTimeBucket Text
metric (a -> Text
forall a. Show a => a -> Text
tshow a
sec) (Int
total Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
cnt))
    showTimeBucket :: Text -> Text -> Int -> Text
    showTimeBucket :: Text -> Text -> Int -> Text
showTimeBucket Text
metric Text
sec Int
count = Text
metric Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"_bucket{le=\"" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
sec Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
count Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n"
    showBucketSums :: Text -> IM.IntMap Int -> Text
    showBucketSums :: Text -> IntMap Int -> Text
showBucketSums Text
metric IntMap Int
buckets = [Text] -> Text
T.concat ([Text] -> Text) -> [Text] -> Text
forall a b. (a -> b) -> a -> b
$ ((Int, Int) -> Text) -> [(Int, Int)] -> [Text]
forall a b. (a -> b) -> [a] -> [b]
map (Int, Int) -> Text
showBucketSum [(Int
0, Int
60), (Int
60, Int
300), (Int
300, Int
1200), (Int
1200, Int
3600), (Int
3600, Int
forall a. Bounded a => a
maxBound)]
      where
        showBucketSum :: (Int, Int) -> Text
showBucketSum (Int
minTime, Int
maxTime) =
          Text
metric Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"{period=\"" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
tshow Int
minTime Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> (if Int
maxTime Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
3600 then Text
"-" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
tshow Int
maxTime else Text
"+") Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow Int
bucketsSum Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n"
          where
            bucketsSum :: Int
bucketsSum = (Int -> Int -> Int) -> Int -> IntMap Int -> Int
forall a b. (a -> b -> a) -> a -> IntMap b -> a
IM.foldl' Int -> Int -> Int
forall a. Num a => a -> a -> a
(+) Int
0 (IntMap Int -> Int) -> IntMap Int -> Int
forall a b. (a -> b) -> a -> b
$ (Int -> Bool) -> IntMap Int -> IntMap Int
forall a. (a -> Bool) -> IntMap a -> IntMap a
IM.filter (\Int
sec -> Int
minTime Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
sec Bool -> Bool -> Bool
&& Int
sec Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
maxTime) IntMap Int
buckets
    socketsMetric :: (SocketStats -> Int) -> Text -> Text -> Text
    socketsMetric :: (SocketStats -> Int) -> Text -> Text -> Text
socketsMetric SocketStats -> Int
sel Text
metric Text
descr =
      Text
"# HELP " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
metric Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
descr Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n"
        Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"# TYPE " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
metric Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" gauge\n"
        Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> [Text] -> Text
T.concat (((ServiceName, SocketStats) -> Text)
-> [(ServiceName, SocketStats)] -> [Text]
forall a b. (a -> b) -> [a] -> [b]
map (\(ServiceName
port, SocketStats
ss) -> Text
metric Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"{port=\"" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> ServiceName -> Text
T.pack ServiceName
port Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\"} " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text
forall a. Show a => a -> Text
mshow (SocketStats -> Int
sel SocketStats
ss) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n") [(ServiceName, SocketStats)]
socketStats)
        Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n"
    mstr :: Text -> Text
mstr Text
a = Text
a Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> UTCTime -> Text
tsEpoch UTCTime
ts
    mshow :: Show a => a -> Text
    mshow :: forall a. Show a => a -> Text
mshow = Text -> Text
mstr (Text -> Text) -> (a -> Text) -> a -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Text
forall a. Show a => a -> Text
tshow
    tsEpoch :: UTCTime -> Text
tsEpoch UTCTime
t = forall a. Show a => a -> Text
tshow @Int64 (Int64 -> Text) -> Int64 -> Text
forall a b. (a -> b) -> a -> b
$ forall a b. (RealFrac a, Integral b) => a -> b
floor @Double (Double -> Int64) -> Double -> Int64
forall a b. (a -> b) -> a -> b
$ NominalDiffTime -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac (UTCTime
t UTCTime -> UTCTime -> NominalDiffTime
`diffUTCTime` UTCTime
epoch) Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
1000
    epoch :: UTCTime
epoch = Day -> DiffTime -> UTCTime
UTCTime Day
systemEpochDay DiffTime
0
{-# FOURMOLU_ENABLE\n#-}