Skip to content

Commit

Permalink
Merge #757
Browse files Browse the repository at this point in the history
757: CAD-790: Tracers for node version. r=CodiePP a=denisshevchenko

Issue
-----------

- New tracers for node's release, version and commit. Currently, I'm creating the new service for a real-time view of metrics from the node. Since my service is a separate process, it receives these metrics via socket, using `TraceForwarder`/`TraceAcceptor` mechanism. So I need new tracers that will send `LogObject`s with node's release (for example, "Shelley"), version (for example, "1.8.0") and Git commit. It will allow me to show this information in my service.

- Please not that currently it doesn't work: I don't see version info in the log!

- This PR **does not result** in breaking changes to upstream dependencies.

Checklist
---------
- [ ] This PR contains all the work required to resolve the linked issue.

- [ ] The work contained has sufficient documentation to describe what it does and how to do it.

- [ ] The work has sufficient tests and/or testing.

- [x] I have committed clear and descriptive commits. Be considerate as somebody else will have to read these.

- [x] I have added the appropriate labels to this PR.


Co-authored-by: Denis Shevchenko <[email protected]>
  • Loading branch information
iohk-bors[bot] and Denis Shevchenko authored Apr 3, 2020
2 parents 9405d84 + cf6bce4 commit d309267
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions cardano-node/src/Cardano/Node/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,31 @@ import qualified Data.List as List
import Data.Proxy (Proxy (..))
import Data.Semigroup ((<>))
import Data.Text (Text, breakOn, pack, take)
import Data.Version (showVersion)
import Network.HostName (getHostName)
import Network.Socket (AddrInfo)
import System.Directory (canonicalizePath, makeAbsolute)

import Control.Monad.Class.MonadSTM

import Paths_cardano_node (version)
#ifdef UNIX
import qualified Cardano.BM.Configuration.Model as CM
import Cardano.BM.Data.Backend
import Cardano.BM.Data.BackendKind (BackendKind (..))
#endif
import Cardano.BM.Data.LogItem (LOContent (..),
PrivacyAnnotation (..), mkLOMeta)
import Cardano.BM.Data.Tracer (ToLogObject (..),
TracingVerbosity (..))
import Cardano.BM.Data.Transformers (setHostname)
import Cardano.BM.Trace
import Cardano.Config.Logging (LoggingLayer (..))

import Cardano.Config.GitRev (gitRev)
import Cardano.Config.Logging (LoggingLayer (..), Severity (..))
import Cardano.Config.Types (MiscellaneousFilepaths(..),
NodeConfiguration (..), ViewMode (..))


import Ouroboros.Network.Block
import Ouroboros.Network.NodeToClient (LocalConnectionId)
import Ouroboros.Network.NodeToNode (AcceptedConnectionsLimit (..))
Expand Down Expand Up @@ -176,7 +181,7 @@ handleSimpleNode p trace nodeTracers npm onKernel = do
-- Node configuration
nc <- parseNodeConfiguration npm

createTracers npm tracer cfg
createTracers npm trace tracer cfg

addrs <- nodeAddressInfo npm

Expand Down Expand Up @@ -262,10 +267,11 @@ handleSimpleNode p trace nodeTracers npm onKernel = do

createTracers
:: NodeProtocolMode
-> Trace IO Text
-> Tracer IO GHC.Base.String
-> Consensus.TopLevelConfig blk
-> IO ()
createTracers npm' tracer cfg = do
createTracers npm' tr tracer cfg = do
case npm' of
RealProtocolMode (NodeCLI _ rNodeAddr _ runDBValidation) -> do
eitherTopology <- readTopologyFile npm
Expand All @@ -288,6 +294,14 @@ handleSimpleNode p trace nodeTracers npm onKernel = do
, "**************************************"
]

meta <- mkLOMeta Notice Public
let rTr = appendName "release" tr
vTr = appendName "version" tr
cTr = appendName "commit" tr
traceNamedObject rTr (meta, LogMessage "Byron")
traceNamedObject vTr (meta, LogMessage . pack . showVersion $ version)
traceNamedObject cTr (meta, LogMessage gitRev)

when runDBValidation $ traceWith tracer "Performing DB validation"

MockProtocolMode (NodeMockCLI _ mockNodeAddress _ runDBValidation) -> do
Expand Down

0 comments on commit d309267

Please sign in to comment.