Skip to content

Commit

Permalink
test app: same as before, but working
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmeier authored and Icelandjack committed Sep 21, 2024
1 parent c8ef498 commit 7fc0f9a
Show file tree
Hide file tree
Showing 14 changed files with 295 additions and 657 deletions.
5 changes: 0 additions & 5 deletions bench/ekg-restart-test/CHANGELOG.md

This file was deleted.

121 changes: 0 additions & 121 deletions bench/ekg-restart-test/app/Main.hs

This file was deleted.

54 changes: 0 additions & 54 deletions bench/ekg-restart-test/ekg-restart-test.cabal

This file was deleted.

9 changes: 3 additions & 6 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ packages:
trace-resources
trace-forward

-- ||| TMP PACKAGE, DON'T MAKE PR
bench/ekg-restart-test
-- ||| TMP PACKAGE, DON'T MAKE PR

extra-packages: Cabal

program-options
Expand All @@ -52,7 +48,7 @@ package cryptonite
flags: -support_rdrand

package snap-server
flags: +openssl
flags: -openssl

package bitvec
flags: -simd
Expand All @@ -66,8 +62,9 @@ constraints:

allow-newer:
, katip:Win32
, ekg-wai:time
-- , ekg-wai:Win32-network

-- IMPORTANT
-- Do NOT add more source-repository-package stanzas here unless they are strictly
-- temporary! Please read the section in CONTRIBUTING about updating dependencies.

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.3 (September 20, 2024)

* Abondon `snap` webserver in favour of `wai`/`warp` for Prometheus and EKG Monitoring.
* Add dynamic routing to EKG stores of all connected nodes.
* Derive URL compliant routes from connected node names (instead of plain node names).
* Remove the requirement of two distinct ports for the EKG backend (changing `hasEKG` config type).
* For optional RTView component only: Disable SSL/https connections. Force `snap-server`
dependency to build with `-flag -openssl`.
* Add JSON responses when listing connected nodes for both Prometheus and EKG Monitoring.
* Add consistency check for redundant port values in the config.

## 0.2.4 (August 13, 2024)

* `systemd` is enabled by default. To disable it use the cabal
Expand Down
7 changes: 2 additions & 5 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.4
version: 0.3
synopsis: A service for logging and monitoring over Cardano nodes
description: A service for logging and monitoring over Cardano nodes.
category: Cardano,
Expand Down Expand Up @@ -160,6 +160,7 @@ library
build-depends: aeson
, async
, async-extras
, auto-update
, bimap
, blaze-html
, bytestring
Expand All @@ -182,9 +183,6 @@ library
, signal
, slugify
, smtp-mail == 0.3.0.0
, snap-blaze
, snap-core
, snap-server
, stm
, string-qq
, text
Expand All @@ -194,7 +192,6 @@ library
, trace-resources
, unordered-containers
, wai
, wai-extra
, warp
, yaml

Expand Down
24 changes: 9 additions & 15 deletions cardano-tracer/docs/cardano-tracer.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ The fields `rpMaxAgeMinutes`, `rpMaxAgeHours` specify the lifetime of the log fi

## Prometheus

At top-level route `/` Promtheus gives a list of connected nodes.

The optional field `hasPrometheus` specifies the host and port of the web page with metrics. For example:

```
Expand Down Expand Up @@ -374,24 +376,16 @@ rts_gc_cumulative_bytes_used 184824

## EKG Monitoring

The optional field `hasEKG` specifies the hosts and ports of two web pages:

1. the list of identifiers of connected nodes,
2. EKG monitoring page.
At top-level route `/` EKG gives a list of connected nodes.

For example, if you use JSON configuration file:
The optional field `hasPrometheus` specifies the host and port of the
web page with metrics. For example:

```
"hasEKG": [
{
"epHost": "127.0.0.1",
"epPort": 3100
},
{
"epHost": "127.0.0.1",
"epPort": 3101
}
]
"hasEKG": {
"epHost": "127.0.0.1",
"epPort": 3100
}
```

The page with the list of identifiers of connected nodes will be available at `http://127.0.0.1:3100`, for example:
Expand Down
26 changes: 20 additions & 6 deletions cardano-tracer/src/Cardano/Tracer/Acceptors/Utils.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{-# LANGUAGE NamedFieldPuns #-}
#if RTVIEW
{-# LANGUAGE OverloadedStrings #-}
#endif
{-# LANGUAGE TupleSections #-}

module Cardano.Tracer.Acceptors.Utils
( prepareDataPointRequestor
Expand All @@ -26,6 +25,7 @@ import Control.Concurrent.STM.TVar (TVar, modifyTVar', newTVarIO)
import qualified Data.Bimap as BM
import qualified Data.Map.Strict as M
import qualified Data.Set as S
import Data.Time.Clock.POSIX (getPOSIXTime)
#if RTVIEW
import Data.Time.Clock.System (getSystemTime, systemToUTCTime)
#endif
Expand All @@ -51,12 +51,26 @@ prepareMetricsStores
-> IO (EKG.Store, TVar MetricsLocalStore)
prepareMetricsStores TracerEnv{teConnectedNodes, teAcceptedMetrics} connId = do
addConnectedNode teConnectedNodes connId
storesForNewNode <- (,) <$> EKG.newStore
<*> newTVarIO emptyMetricsLocalStore
atomically $
modifyTVar' teAcceptedMetrics $ M.insert (connIdToNodeId connId) storesForNewNode
store <- EKG.newStore

EKG.registerCounter "ekg.server_timestamp_ms" getTimeMs store
storesForNewNode <- (store ,) <$> newTVarIO emptyMetricsLocalStore

atomically do
modifyTVar' teAcceptedMetrics do
M.insert (connIdToNodeId connId) storesForNewNode

return storesForNewNode

where
-- forkServer definition of `getTimeMs'. The ekg frontend relies
-- on the "ekg.server_timestamp_ms" metric being in every
-- store. While forkServer adds that that automatically we must
-- manually add it.
-- url
-- + https://github.com/tvh/ekg-wai/blob/master/System/Remote/Monitoring/Wai.hs#L237-L238
getTimeMs = (round . (* 1000)) `fmap` getPOSIXTime

addConnectedNode
:: ConnectedNodes
-> ConnectionId LocalAddress
Expand Down
Loading

0 comments on commit 7fc0f9a

Please sign in to comment.