-
Notifications
You must be signed in to change notification settings - Fork 724
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cardano-node: initial NodeVersionTracer
- Loading branch information
Showing
4 changed files
with
113 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
cardano-node/src/Cardano/Node/Tracing/Tracers/NodeVersion.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
module Cardano.Node.Tracing.Tracers.NodeVersion | ||
( | ||
NodeVersion (..) | ||
) | ||
where | ||
|
||
import Cardano.Git.Rev (gitRev) | ||
import Data.Version | ||
import Paths_cardano_node (version) | ||
import System.Info (arch, compilerName, compilerVersion, os) | ||
|
||
data NodeVersionTrace = NodeVersionTrace | ||
{ applicationName :: Text | ||
, applicationVersion :: Version | ||
, osName :: Text | ||
, architecture :: Text | ||
, compilerName :: Text | ||
, compilerVersion :: Version | ||
, gitRevision :: Text | ||
} deriving (Eq, Show) | ||
|
||
getNodeVersion :: NodeVersionTrace | ||
getNodeVersion = | ||
let applicationName = "cardano-node" | ||
applicationVersion = version | ||
osName = pack os | ||
architecture = pack arch | ||
compilerName = pack compilerName | ||
compilerVersion = compilerVersion | ||
gitRevision = gitRev | ||
in NodeVersion {..} | ||
|
||
instance MetaTrace NodeVersionTrace where | ||
namespaceFor NodeVersion {} = | ||
Namespace [] ["NodeVersion"] | ||
severityFor (Namespace _ ["NodeVersion"]) _ = Just Info | ||
severityFor _ _ = Nothing | ||
documentFor NodeVersion {} = Just "Node version information" | ||
documentFor _ = Nothing | ||
metricsDocFor NodeVersion {} = | ||
[("Cardano.Version.Major", "Cardano node version information") | ||
,("Cardano.Version.Minor", "Cardano node version information") | ||
,("Cardano.Version.Patch", "Cardano node version information") | ||
,("Cardano.Version.VersionTags", "Cardano node version information") | ||
,("Cardano.Version.GitRevision", "Cardano node version information") | ||
,("Cardano.CompilerName", "Cardano compiler name") | ||
,("Cardano.CompilerMajor", "Cardano compiler version information") | ||
,("Cardano.CompilerMinor", "Cardano compiler version information") | ||
,("Cardano.CompilerPatch", "Cardano compiler version information") | ||
,("Cardano.CompilerTags", "Cardano compiler version information") | ||
,("Cardano.OSName", "Cardano node operating system information") | ||
,("Cardano.Architecture", "Cardano node architecture information") | ||
,("cardano_build_info", "Cardano node build info") | ||
,("haskell_build_info", "Haskell compiler build information") | ||
] | ||
allNamespaces = [Namespace [] ["NodeVersion"]] | ||
|
||
|
||
instance LogFormatting NodeVersionTrace where | ||
forHuman NodeVersionTrace {..} = mconcat | ||
[ "cardano-node ", pack (showVersion applicationVersion) | ||
, " - ", pack os, "-", pack arch | ||
, " - ", pack compilerName, "-", pack (showVersion compilerVersion) | ||
, "git rev ", gitRev | ||
] | ||
|
||
forMachine dtal NodeVersionTrace {..} = mconcat | ||
[ "applicationName" .= applicationName | ||
, "applicationVersion" .= toJSON applicationVersion | ||
, "osName" .= osName | ||
, "architecture" .= architecture | ||
, "compilerName" .= compilerName | ||
, "compilerVersion" .= toJSON compilerVersion | ||
, "gitRevision" .= gitRevision] | ||
|
||
asMetrics nvt@NodeVersionTrace {..} = mconcat | ||
[ IntM "Cardano.Version.Major" (fromIntegral (getMajor applicationVersion)) | ||
, IntM "Cardano.Version.Minor" (fromIntegral (getMinor applicationVersion)) | ||
, IntM "Cardano.Version.Patch" (fromIntegral (getPatch applicationVersion)) | ||
, IntM ("Cardano.Version.VersionTags " ++ getVersionTags applicationVersion) 1 | ||
, IntM ("Cardano.Version.GitRevision " ++ gitRevision) 1 | ||
, IntM ("Cardano.CompilerName " ++ compilerName) 1 | ||
, IntM ("Cardano.CompilerMajor " (fromIntegral (getMajor applicationVersion))) | ||
, IntM ("Cardano.CompilerMinor " (fromIntegral (getMinor applicationVersion))) | ||
, IntM ("Cardano.CompilerPatch " (fromIntegral (getPatch applicationVersion))) | ||
, IntM ("Cardano.CompilerTags " ++ getVersionTags applicationVersion) 1 | ||
, IntM ("Cardano.OSName " ++ osName) 1 | ||
, IntM ("Cardano.Architecture " ++ architecture) 1 | ||
, IntM ("cardano_build_info " ++ getCardanoBuildInfo nvt) 1 | ||
, IntM ("haskell_build_info " ++ getHaskellBuildInfo nvt) 1 | ||
] | ||
|
||
getCardanoBuildInfo :: NodeVersionTrace -> Text | ||
getCardanoBuildInfo NodeVersionTrace {..} = showVersion applicationVersion | ||
|
||
getHaskellBuildInfo :: NodeVersionTrace -> Text | ||
getHaskellBuildInfo NodeVersionTrace {..} = showVersion compilerVersion | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters