Skip to content

Commit

Permalink
Merge pull request #5846 from IntersectMBO/baldurb/rtview-opt
Browse files Browse the repository at this point in the history
Factoring out RTView
  • Loading branch information
mgmeier authored Jul 19, 2024
2 parents d0a88dc + 238d56a commit b161938
Show file tree
Hide file tree
Showing 57 changed files with 886 additions and 552 deletions.
11 changes: 11 additions & 0 deletions cardano-tracer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# ChangeLog

## 0.2.4 (July 12, 2024)

* Put RTView behind a feature flag that is disabled by default. To enable RTView,
use the cabal flag `-f +rtview`. No change to the service configuration.
* EKG monitoring moved from `threepenny-gui` to direct HTML rendering.
* Drop dependency on package `threepenny-gui` (unless RTView is enabled).
* Restructured modules `Cardano.Tracer.Handlers.RTView.Notifications.*`
to `Cardano.Tracer.Handlers.Notifications.*`.
* All modules related to notification, SSL, and others moved from the RTView
namespace.

## 0.2.3 (April 19, 2024)

* The field `rpMaxAgeHours` of `RotationParams` is changed to
Expand Down
6 changes: 6 additions & 0 deletions cardano-tracer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ For more details please [read the documentation](https://github.com/intersectmbo

## RTView

> Attention: RTView is hidden behind a build flag. Enable with this cabal flag: `-f +rtview`.
RTView is a real-time monitoring tool for Cardano nodes (RTView is an abbreviation for "Real Time View"), it is a part of `cardano-tracer` service. RTView provides an interactive web page where you can see different kinds of information about connected nodes (something like Grafana).

For more details please [read its documentation](https://github.com/intersectmbo/cardano-node/blob/master/cardano-tracer/docs/cardano-rtview.md).

RTView is not feature complete and is thus disabled by default. Being
an experimental/optional component of `cardano-tracer` we will still
guarantee it remains buildable and usable in its current state.

## Developers

Performance and Tracing team is responsible for this service. The primary developer is [Baldur Blöndal](https://github.com/Icelandjack).
Expand Down
26 changes: 16 additions & 10 deletions cardano-tracer/app/cardano-tracer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ import Paths_cardano_tracer (version)
main :: IO ()
main =
runCardanoTracer =<< customExecParser (prefs showHelpOnEmpty) tracerInfo
where
tracerInfo :: ParserInfo TracerParams
tracerInfo = info
(parseTracerParams <**> helper <**> versionOption)
(fullDesc <> header "cardano-tracer - the logging and monitoring service for Cardano nodes.")
versionOption = infoOption
(showVersion version)
(long "version" <>
short 'v' <>
help "Show version")

tracerInfo :: ParserInfo TracerParams
tracerInfo = info
(parseTracerParams <**> helper <**> versionOption)
#if RTVIEW
(fullDesc <> header "cardano-tracer/with RTView - the logging and monitoring service for Cardano nodes.")
#else
(fullDesc <> header "cardano-tracer/without RTView - the logging and monitoring service for Cardano nodes.")
#endif

versionOption :: Parser (a -> a)
versionOption = infoOption
(showVersion version)
(long "version" <>
short 'v' <>
help "Show version")
76 changes: 46 additions & 30 deletions cardano-tracer/bench/cardano-tracer-bench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ import Cardano.Logging hiding (LocalSocket)
import Cardano.Tracer.Configuration
import Cardano.Tracer.Environment
import Cardano.Tracer.Handlers.Logs.TraceObjects
#if RTVIEW
import Cardano.Tracer.Handlers.RTView.Run
import Cardano.Tracer.Handlers.RTView.State.Historical
#endif
import Cardano.Tracer.MetaTrace
import Cardano.Tracer.Types
import Cardano.Tracer.Utils

import Control.Concurrent.Extra (newLock)
#if RTVIEW
import Control.Concurrent.STM.TVar (newTVarIO)
#endif
import Control.DeepSeq
import qualified Data.List.NonEmpty as NE
import Data.Time.Clock (UTCTime, getCurrentTime)
Expand All @@ -36,64 +40,76 @@ main = do
connectedNodes <- initConnectedNodes
connectedNodesNames <- initConnectedNodesNames
acceptedMetrics <- initAcceptedMetrics
#if RTVIEW
savedTO <- initSavedTraceObjects

chainHistory <- initBlockchainHistory
resourcesHistory <- initResourcesHistory
txHistory <- initTransactionsHistory
#endif

protocolsBrake <- initProtocolsBrake
dpRequestors <- initDataPointRequestors

currentLogLock <- newLock
currentDPLock <- newLock
#if RTVIEW
eventsQueues <- initEventsQueues Nothing connectedNodesNames dpRequestors currentDPLock

rtViewPageOpened <- newTVarIO False
#endif

tracer <- mkTracerTracer $ SeverityF $ Just Warning

let tracerEnv :: TracerConfig -> HandleRegistry -> TracerEnv
tracerEnv config handleRegistry = TracerEnv
{ teConfig = config
, teConnectedNodes = connectedNodes
, teConnectedNodesNames = connectedNodesNames
, teAcceptedMetrics = acceptedMetrics
, teCurrentLogLock = currentLogLock
, teCurrentDPLock = currentDPLock
, teDPRequestors = dpRequestors
, teProtocolsBrake = protocolsBrake
, teTracer = tracer
, teReforwardTraceObjects = \_-> pure ()
, teRegistry = handleRegistry
, teStateDir = Nothing
}

tr <- mkTracerTracer $ SeverityF $ Just Warning

let te :: TracerConfig -> HandleRegistry -> TracerEnv
te c r =
TracerEnv
{ teConfig = c
, teConnectedNodes = connectedNodes
, teConnectedNodesNames = connectedNodesNames
, teAcceptedMetrics = acceptedMetrics
, teSavedTO = savedTO
, teBlockchainHistory = chainHistory
, teResourcesHistory = resourcesHistory
, teTxHistory = txHistory
, teCurrentLogLock = currentLogLock
, teCurrentDPLock = currentDPLock
, teEventsQueues = eventsQueues
, teDPRequestors = dpRequestors
, teProtocolsBrake = protocolsBrake
, teRTViewPageOpened = rtViewPageOpened
, teRTViewStateDir = Nothing
, teTracer = tr
, teReforwardTraceObjects = \_-> pure ()
, teRegistry = r
}
tracerEnvRTView :: TracerEnvRTView
tracerEnvRTView = TracerEnvRTView
#if RTVIEW
{ teSavedTO = savedTO
, teBlockchainHistory = chainHistory
, teResourcesHistory = resourcesHistory
, teTxHistory = txHistory
, teEventsQueues = eventsQueues
, teRTViewPageOpened = rtViewPageOpened
}
#endif

removePathForcibly root

let -- Handles cleanup between runs, closes handles before
myBench :: TracerConfig -> [TraceObject] -> Benchmarkable
myBench config traceObjects = let

action :: IO TracerEnv
action = te config <$> newRegistry
initialise :: IO TracerEnv
initialise =
tracerEnv config <$> newRegistry

cleanup :: TracerEnv -> IO ()
cleanup TracerEnv{teRegistry} = clearRegistry teRegistry
cleanup TracerEnv{teRegistry} =
clearRegistry teRegistry

benchmark :: TracerEnv -> IO ()
benchmark traceEnv = beforeProgramStops do
traceObjectsHandler traceEnv nId traceObjects
benchmark trEnv = do
beforeProgramStops do
traceObjectsHandler trEnv tracerEnvRTView nId traceObjects

in
perRunEnvWithCleanup @TracerEnv action cleanup benchmark
perRunEnvWithCleanup @TracerEnv initialise cleanup benchmark

now <- getCurrentTime

Expand Down
98 changes: 55 additions & 43 deletions cardano-tracer/cardano-tracer.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 3.0

name: cardano-tracer
version: 0.2.3
version: 0.2.4
synopsis: A service for logging and monitoring over Cardano nodes
description: A service for logging and monitoring over Cardano nodes.
category: Cardano,
Expand All @@ -16,6 +16,11 @@ build-type: Simple
extra-doc-files: README.md
CHANGELOG.md

flag rtview
Description: Enable RTView. False by default. Enable with `-f +rtview`.
Default: False
Manual: True

common project-config
default-language: Haskell2010
build-depends: base >= 4.14 && < 5
Expand All @@ -27,8 +32,12 @@ common project-config
, ImportQualifiedPost
, InstanceSigs
, ScopedTypeVariables
, StandaloneKindSignatures
, TypeApplications

if flag(rtview)
CPP-Options: -DRTVIEW=1

ghc-options: -Wall
-Wcompat
-Wincomplete-record-updates
Expand All @@ -42,46 +51,18 @@ common project-config
library
import: project-config

hs-source-dirs: src

exposed-modules: Cardano.Tracer.Acceptors.Client
Cardano.Tracer.Acceptors.Run
Cardano.Tracer.Acceptors.Server
Cardano.Tracer.Acceptors.Utils

Cardano.Tracer.Handlers.Logs.File
Cardano.Tracer.Handlers.Logs.Journal
Cardano.Tracer.Handlers.Logs.Rotator
Cardano.Tracer.Handlers.Logs.TraceObjects
Cardano.Tracer.Handlers.Logs.Utils

Cardano.Tracer.Handlers.Metrics.Monitoring
Cardano.Tracer.Handlers.Metrics.Prometheus
Cardano.Tracer.Handlers.Metrics.Servers
Cardano.Tracer.Handlers.Metrics.Utils

Cardano.Tracer.Handlers.ReForwarder

Cardano.Tracer.Handlers.RTView.Notifications.Check
Cardano.Tracer.Handlers.RTView.Notifications.Email
Cardano.Tracer.Handlers.RTView.Notifications.Send
Cardano.Tracer.Handlers.RTView.Notifications.Settings
Cardano.Tracer.Handlers.RTView.Notifications.Timer
Cardano.Tracer.Handlers.RTView.Notifications.Types
Cardano.Tracer.Handlers.RTView.Notifications.Utils

Cardano.Tracer.Handlers.RTView.Run
hs-source-dirs: src

Cardano.Tracer.Handlers.RTView.SSL.Certs
if flag(rtview)
exposed-modules: Cardano.Tracer.Handlers.RTView.Run
Cardano.Tracer.Handlers.RTView.Utils

Cardano.Tracer.Handlers.RTView.State.Displayed
Cardano.Tracer.Handlers.RTView.State.EraSettings
Cardano.Tracer.Handlers.RTView.State.Historical
Cardano.Tracer.Handlers.RTView.State.Last
Cardano.Tracer.Handlers.RTView.State.Peers
Cardano.Tracer.Handlers.RTView.State.TraceObjects

Cardano.Tracer.Handlers.RTView.System

Cardano.Tracer.Handlers.RTView.UI.CSS.Bulma
Cardano.Tracer.Handlers.RTView.UI.CSS.Own
Expand Down Expand Up @@ -119,9 +100,36 @@ library
Cardano.Tracer.Handlers.RTView.Update.Reload
Cardano.Tracer.Handlers.RTView.Update.Resources
Cardano.Tracer.Handlers.RTView.Update.Transactions
Cardano.Tracer.Handlers.RTView.Update.Utils

Cardano.Tracer.Handlers.RTView.Utils
exposed-modules: Cardano.Tracer.Acceptors.Client
Cardano.Tracer.Acceptors.Run
Cardano.Tracer.Acceptors.Server
Cardano.Tracer.Acceptors.Utils

Cardano.Tracer.Handlers.Logs.File
Cardano.Tracer.Handlers.Logs.Journal
Cardano.Tracer.Handlers.Logs.Rotator
Cardano.Tracer.Handlers.Logs.TraceObjects
Cardano.Tracer.Handlers.Logs.Utils

Cardano.Tracer.Handlers.Metrics.Monitoring
Cardano.Tracer.Handlers.Metrics.Prometheus
Cardano.Tracer.Handlers.Metrics.Servers
Cardano.Tracer.Handlers.Metrics.Utils

Cardano.Tracer.Handlers.Notifications.Check
Cardano.Tracer.Handlers.Notifications.Email
Cardano.Tracer.Handlers.Notifications.Send
Cardano.Tracer.Handlers.Notifications.Settings
Cardano.Tracer.Handlers.Notifications.Timer
Cardano.Tracer.Handlers.Notifications.Types
Cardano.Tracer.Handlers.Notifications.Utils

Cardano.Tracer.Handlers.ReForwarder
Cardano.Tracer.Handlers.SSL.Certs
Cardano.Tracer.Handlers.State.TraceObjects
Cardano.Tracer.Handlers.System
Cardano.Tracer.Handlers.Utils

Cardano.Tracer.CLI
Cardano.Tracer.Configuration
Expand All @@ -134,19 +142,23 @@ library
other-modules: Paths_cardano_tracer
autogen-modules: Paths_cardano_tracer

if flag(rtview)
build-depends:
cardano-git-rev ^>=0.2.2
, cassava
, threepenny-gui
, vector

build-depends: aeson
, async
, async-extras
, bimap
, blaze-html
, bytestring
, cardano-git-rev ^>=0.2.2
, cardano-node
, cassava
, cborg
, containers
, contra-tracer
, cryptonite
, directory
, ekg
, ekg-core
Expand All @@ -166,21 +178,20 @@ library
, stm
, string-qq
, text
, threepenny-gui
, time
, trace-dispatcher
, trace-forward
, trace-resources
, unordered-containers
, vector
, yaml

if os(linux)
build-depends: libsystemd-journal >= 1.4.4

if os(windows)
build-depends: Win32
build-depends: Win32
else
build-depends: unix
build-depends: unix

executable cardano-tracer
import: project-config
Expand Down Expand Up @@ -412,13 +423,14 @@ benchmark cardano-tracer-bench

main-is: cardano-tracer-bench.hs

if flag(rtview)
build-depends: stm
build-depends: cardano-tracer
, criterion
, directory
, deepseq
, extra
, filepath
, stm
, time
, trace-dispatcher

Expand Down
8 changes: 7 additions & 1 deletion cardano-tracer/docs/cardano-rtview.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Cardano RTView

RTView is a part of `cardano-tracer` [service](https://github.com/intersectmbo/cardano-node/blob/master/cardano-tracer/docs/cardano-tracer.md). It is a real-time monitoring tool for Cardano nodes (RTView is an abbreviation for "Real Time View"). It provides an interactive web page where you can see different kinds of information about connected nodes.
> Attention: RTView is hidden behind a build flag. Enable with this cabal flag: `-f +rtview`.
RTView is an optional part of `cardano-tracer` [service](https://github.com/intersectmbo/cardano-node/blob/master/cardano-tracer/docs/cardano-tracer.md). It is a real-time monitoring tool for Cardano nodes (RTView is an abbreviation for "Real Time View"). It provides an interactive web page where you can see different kinds of information about connected nodes.

RTView is not feature complete and is thus disabled by default. Being
an experimental/optional component of `cardano-tracer` we will still
guarantee it remains buildable and usable in its current state.

# Contents

Expand Down
Loading

0 comments on commit b161938

Please sign in to comment.