Skip to content

Commit b161938

Browse files
authored
Merge pull request #5846 from IntersectMBO/baldurb/rtview-opt
Factoring out RTView
2 parents d0a88dc + 238d56a commit b161938

57 files changed

Lines changed: 886 additions & 552 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cardano-tracer/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# ChangeLog
22

3+
## 0.2.4 (July 12, 2024)
4+
5+
* Put RTView behind a feature flag that is disabled by default. To enable RTView,
6+
use the cabal flag `-f +rtview`. No change to the service configuration.
7+
* EKG monitoring moved from `threepenny-gui` to direct HTML rendering.
8+
* Drop dependency on package `threepenny-gui` (unless RTView is enabled).
9+
* Restructured modules `Cardano.Tracer.Handlers.RTView.Notifications.*`
10+
to `Cardano.Tracer.Handlers.Notifications.*`.
11+
* All modules related to notification, SSL, and others moved from the RTView
12+
namespace.
13+
314
## 0.2.3 (April 19, 2024)
415

516
* The field `rpMaxAgeHours` of `RotationParams` is changed to

cardano-tracer/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@ For more details please [read the documentation](https://github.com/intersectmbo
66

77
## RTView
88

9+
> Attention: RTView is hidden behind a build flag. Enable with this cabal flag: `-f +rtview`.
10+
911
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).
1012

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

15+
RTView is not feature complete and is thus disabled by default. Being
16+
an experimental/optional component of `cardano-tracer` we will still
17+
guarantee it remains buildable and usable in its current state.
18+
1319
## Developers
1420

1521
Performance and Tracing team is responsible for this service. The primary developer is [Baldur Blöndal](https://github.com/Icelandjack).

cardano-tracer/app/cardano-tracer.hs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ import Paths_cardano_tracer (version)
99
main :: IO ()
1010
main =
1111
runCardanoTracer =<< customExecParser (prefs showHelpOnEmpty) tracerInfo
12-
where
13-
tracerInfo :: ParserInfo TracerParams
14-
tracerInfo = info
15-
(parseTracerParams <**> helper <**> versionOption)
16-
(fullDesc <> header "cardano-tracer - the logging and monitoring service for Cardano nodes.")
17-
versionOption = infoOption
18-
(showVersion version)
19-
(long "version" <>
20-
short 'v' <>
21-
help "Show version")
12+
13+
tracerInfo :: ParserInfo TracerParams
14+
tracerInfo = info
15+
(parseTracerParams <**> helper <**> versionOption)
16+
#if RTVIEW
17+
(fullDesc <> header "cardano-tracer/with RTView - the logging and monitoring service for Cardano nodes.")
18+
#else
19+
(fullDesc <> header "cardano-tracer/without RTView - the logging and monitoring service for Cardano nodes.")
20+
#endif
21+
22+
versionOption :: Parser (a -> a)
23+
versionOption = infoOption
24+
(showVersion version)
25+
(long "version" <>
26+
short 'v' <>
27+
help "Show version")

cardano-tracer/bench/cardano-tracer-bench.hs

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@ import Cardano.Logging hiding (LocalSocket)
55
import Cardano.Tracer.Configuration
66
import Cardano.Tracer.Environment
77
import Cardano.Tracer.Handlers.Logs.TraceObjects
8+
#if RTVIEW
89
import Cardano.Tracer.Handlers.RTView.Run
910
import Cardano.Tracer.Handlers.RTView.State.Historical
11+
#endif
1012
import Cardano.Tracer.MetaTrace
1113
import Cardano.Tracer.Types
1214
import Cardano.Tracer.Utils
1315

1416
import Control.Concurrent.Extra (newLock)
17+
#if RTVIEW
1518
import Control.Concurrent.STM.TVar (newTVarIO)
19+
#endif
1620
import Control.DeepSeq
1721
import qualified Data.List.NonEmpty as NE
1822
import Data.Time.Clock (UTCTime, getCurrentTime)
@@ -36,64 +40,76 @@ main = do
3640
connectedNodes <- initConnectedNodes
3741
connectedNodesNames <- initConnectedNodesNames
3842
acceptedMetrics <- initAcceptedMetrics
43+
#if RTVIEW
3944
savedTO <- initSavedTraceObjects
4045

4146
chainHistory <- initBlockchainHistory
4247
resourcesHistory <- initResourcesHistory
4348
txHistory <- initTransactionsHistory
49+
#endif
4450

4551
protocolsBrake <- initProtocolsBrake
4652
dpRequestors <- initDataPointRequestors
4753

4854
currentLogLock <- newLock
4955
currentDPLock <- newLock
56+
#if RTVIEW
5057
eventsQueues <- initEventsQueues Nothing connectedNodesNames dpRequestors currentDPLock
5158

5259
rtViewPageOpened <- newTVarIO False
60+
#endif
61+
62+
tracer <- mkTracerTracer $ SeverityF $ Just Warning
63+
64+
let tracerEnv :: TracerConfig -> HandleRegistry -> TracerEnv
65+
tracerEnv config handleRegistry = TracerEnv
66+
{ teConfig = config
67+
, teConnectedNodes = connectedNodes
68+
, teConnectedNodesNames = connectedNodesNames
69+
, teAcceptedMetrics = acceptedMetrics
70+
, teCurrentLogLock = currentLogLock
71+
, teCurrentDPLock = currentDPLock
72+
, teDPRequestors = dpRequestors
73+
, teProtocolsBrake = protocolsBrake
74+
, teTracer = tracer
75+
, teReforwardTraceObjects = \_-> pure ()
76+
, teRegistry = handleRegistry
77+
, teStateDir = Nothing
78+
}
5379

54-
tr <- mkTracerTracer $ SeverityF $ Just Warning
55-
56-
let te :: TracerConfig -> HandleRegistry -> TracerEnv
57-
te c r =
58-
TracerEnv
59-
{ teConfig = c
60-
, teConnectedNodes = connectedNodes
61-
, teConnectedNodesNames = connectedNodesNames
62-
, teAcceptedMetrics = acceptedMetrics
63-
, teSavedTO = savedTO
64-
, teBlockchainHistory = chainHistory
65-
, teResourcesHistory = resourcesHistory
66-
, teTxHistory = txHistory
67-
, teCurrentLogLock = currentLogLock
68-
, teCurrentDPLock = currentDPLock
69-
, teEventsQueues = eventsQueues
70-
, teDPRequestors = dpRequestors
71-
, teProtocolsBrake = protocolsBrake
72-
, teRTViewPageOpened = rtViewPageOpened
73-
, teRTViewStateDir = Nothing
74-
, teTracer = tr
75-
, teReforwardTraceObjects = \_-> pure ()
76-
, teRegistry = r
77-
}
80+
tracerEnvRTView :: TracerEnvRTView
81+
tracerEnvRTView = TracerEnvRTView
82+
#if RTVIEW
83+
{ teSavedTO = savedTO
84+
, teBlockchainHistory = chainHistory
85+
, teResourcesHistory = resourcesHistory
86+
, teTxHistory = txHistory
87+
, teEventsQueues = eventsQueues
88+
, teRTViewPageOpened = rtViewPageOpened
89+
}
90+
#endif
7891

7992
removePathForcibly root
8093

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

85-
action :: IO TracerEnv
86-
action = te config <$> newRegistry
98+
initialise :: IO TracerEnv
99+
initialise =
100+
tracerEnv config <$> newRegistry
87101

88102
cleanup :: TracerEnv -> IO ()
89-
cleanup TracerEnv{teRegistry} = clearRegistry teRegistry
103+
cleanup TracerEnv{teRegistry} =
104+
clearRegistry teRegistry
90105

91106
benchmark :: TracerEnv -> IO ()
92-
benchmark traceEnv = beforeProgramStops do
93-
traceObjectsHandler traceEnv nId traceObjects
107+
benchmark trEnv = do
108+
beforeProgramStops do
109+
traceObjectsHandler trEnv tracerEnvRTView nId traceObjects
94110

95111
in
96-
perRunEnvWithCleanup @TracerEnv action cleanup benchmark
112+
perRunEnvWithCleanup @TracerEnv initialise cleanup benchmark
97113

98114
now <- getCurrentTime
99115

cardano-tracer/cardano-tracer.cabal

Lines changed: 55 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cabal-version: 3.0
22

33
name: cardano-tracer
4-
version: 0.2.3
4+
version: 0.2.4
55
synopsis: A service for logging and monitoring over Cardano nodes
66
description: A service for logging and monitoring over Cardano nodes.
77
category: Cardano,
@@ -16,6 +16,11 @@ build-type: Simple
1616
extra-doc-files: README.md
1717
CHANGELOG.md
1818

19+
flag rtview
20+
Description: Enable RTView. False by default. Enable with `-f +rtview`.
21+
Default: False
22+
Manual: True
23+
1924
common project-config
2025
default-language: Haskell2010
2126
build-depends: base >= 4.14 && < 5
@@ -27,8 +32,12 @@ common project-config
2732
, ImportQualifiedPost
2833
, InstanceSigs
2934
, ScopedTypeVariables
35+
, StandaloneKindSignatures
3036
, TypeApplications
3137

38+
if flag(rtview)
39+
CPP-Options: -DRTVIEW=1
40+
3241
ghc-options: -Wall
3342
-Wcompat
3443
-Wincomplete-record-updates
@@ -42,46 +51,18 @@ common project-config
4251
library
4352
import: project-config
4453

45-
hs-source-dirs: src
46-
47-
exposed-modules: Cardano.Tracer.Acceptors.Client
48-
Cardano.Tracer.Acceptors.Run
49-
Cardano.Tracer.Acceptors.Server
50-
Cardano.Tracer.Acceptors.Utils
51-
52-
Cardano.Tracer.Handlers.Logs.File
53-
Cardano.Tracer.Handlers.Logs.Journal
54-
Cardano.Tracer.Handlers.Logs.Rotator
55-
Cardano.Tracer.Handlers.Logs.TraceObjects
56-
Cardano.Tracer.Handlers.Logs.Utils
5754

58-
Cardano.Tracer.Handlers.Metrics.Monitoring
59-
Cardano.Tracer.Handlers.Metrics.Prometheus
60-
Cardano.Tracer.Handlers.Metrics.Servers
61-
Cardano.Tracer.Handlers.Metrics.Utils
62-
63-
Cardano.Tracer.Handlers.ReForwarder
64-
65-
Cardano.Tracer.Handlers.RTView.Notifications.Check
66-
Cardano.Tracer.Handlers.RTView.Notifications.Email
67-
Cardano.Tracer.Handlers.RTView.Notifications.Send
68-
Cardano.Tracer.Handlers.RTView.Notifications.Settings
69-
Cardano.Tracer.Handlers.RTView.Notifications.Timer
70-
Cardano.Tracer.Handlers.RTView.Notifications.Types
71-
Cardano.Tracer.Handlers.RTView.Notifications.Utils
72-
73-
Cardano.Tracer.Handlers.RTView.Run
55+
hs-source-dirs: src
7456

75-
Cardano.Tracer.Handlers.RTView.SSL.Certs
57+
if flag(rtview)
58+
exposed-modules: Cardano.Tracer.Handlers.RTView.Run
59+
Cardano.Tracer.Handlers.RTView.Utils
7660

7761
Cardano.Tracer.Handlers.RTView.State.Displayed
7862
Cardano.Tracer.Handlers.RTView.State.EraSettings
7963
Cardano.Tracer.Handlers.RTView.State.Historical
8064
Cardano.Tracer.Handlers.RTView.State.Last
8165
Cardano.Tracer.Handlers.RTView.State.Peers
82-
Cardano.Tracer.Handlers.RTView.State.TraceObjects
83-
84-
Cardano.Tracer.Handlers.RTView.System
8566

8667
Cardano.Tracer.Handlers.RTView.UI.CSS.Bulma
8768
Cardano.Tracer.Handlers.RTView.UI.CSS.Own
@@ -119,9 +100,36 @@ library
119100
Cardano.Tracer.Handlers.RTView.Update.Reload
120101
Cardano.Tracer.Handlers.RTView.Update.Resources
121102
Cardano.Tracer.Handlers.RTView.Update.Transactions
122-
Cardano.Tracer.Handlers.RTView.Update.Utils
123103

124-
Cardano.Tracer.Handlers.RTView.Utils
104+
exposed-modules: Cardano.Tracer.Acceptors.Client
105+
Cardano.Tracer.Acceptors.Run
106+
Cardano.Tracer.Acceptors.Server
107+
Cardano.Tracer.Acceptors.Utils
108+
109+
Cardano.Tracer.Handlers.Logs.File
110+
Cardano.Tracer.Handlers.Logs.Journal
111+
Cardano.Tracer.Handlers.Logs.Rotator
112+
Cardano.Tracer.Handlers.Logs.TraceObjects
113+
Cardano.Tracer.Handlers.Logs.Utils
114+
115+
Cardano.Tracer.Handlers.Metrics.Monitoring
116+
Cardano.Tracer.Handlers.Metrics.Prometheus
117+
Cardano.Tracer.Handlers.Metrics.Servers
118+
Cardano.Tracer.Handlers.Metrics.Utils
119+
120+
Cardano.Tracer.Handlers.Notifications.Check
121+
Cardano.Tracer.Handlers.Notifications.Email
122+
Cardano.Tracer.Handlers.Notifications.Send
123+
Cardano.Tracer.Handlers.Notifications.Settings
124+
Cardano.Tracer.Handlers.Notifications.Timer
125+
Cardano.Tracer.Handlers.Notifications.Types
126+
Cardano.Tracer.Handlers.Notifications.Utils
127+
128+
Cardano.Tracer.Handlers.ReForwarder
129+
Cardano.Tracer.Handlers.SSL.Certs
130+
Cardano.Tracer.Handlers.State.TraceObjects
131+
Cardano.Tracer.Handlers.System
132+
Cardano.Tracer.Handlers.Utils
125133

126134
Cardano.Tracer.CLI
127135
Cardano.Tracer.Configuration
@@ -134,19 +142,23 @@ library
134142
other-modules: Paths_cardano_tracer
135143
autogen-modules: Paths_cardano_tracer
136144

145+
if flag(rtview)
146+
build-depends:
147+
cardano-git-rev ^>=0.2.2
148+
, cassava
149+
, threepenny-gui
150+
, vector
151+
137152
build-depends: aeson
138153
, async
139154
, async-extras
140155
, bimap
141156
, blaze-html
142157
, bytestring
143-
, cardano-git-rev ^>=0.2.2
144158
, cardano-node
145-
, cassava
146159
, cborg
147160
, containers
148161
, contra-tracer
149-
, cryptonite
150162
, directory
151163
, ekg
152164
, ekg-core
@@ -166,21 +178,20 @@ library
166178
, stm
167179
, string-qq
168180
, text
169-
, threepenny-gui
170181
, time
171182
, trace-dispatcher
172183
, trace-forward
173184
, trace-resources
174185
, unordered-containers
175-
, vector
176186
, yaml
177187

178188
if os(linux)
179189
build-depends: libsystemd-journal >= 1.4.4
190+
180191
if os(windows)
181-
build-depends: Win32
192+
build-depends: Win32
182193
else
183-
build-depends: unix
194+
build-depends: unix
184195

185196
executable cardano-tracer
186197
import: project-config
@@ -412,13 +423,14 @@ benchmark cardano-tracer-bench
412423

413424
main-is: cardano-tracer-bench.hs
414425

426+
if flag(rtview)
427+
build-depends: stm
415428
build-depends: cardano-tracer
416429
, criterion
417430
, directory
418431
, deepseq
419432
, extra
420433
, filepath
421-
, stm
422434
, time
423435
, trace-dispatcher
424436

cardano-tracer/docs/cardano-rtview.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Cardano RTView
22

3-
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.
3+
> Attention: RTView is hidden behind a build flag. Enable with this cabal flag: `-f +rtview`.
4+
5+
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.
6+
7+
RTView is not feature complete and is thus disabled by default. Being
8+
an experimental/optional component of `cardano-tracer` we will still
9+
guarantee it remains buildable and usable in its current state.
410

511
# Contents
612

0 commit comments

Comments
 (0)