Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EKG counter for number of forks seen #3305

Merged
merged 1 commit into from
Oct 25, 2021
Merged

Conversation

karknu
Copy link
Contributor

@karknu karknu commented Oct 21, 2021

Add cardano_node_metrics_forks_int for counting the number of forks seen
by the node.

@karknu karknu marked this pull request as ready for review October 21, 2021 08:48
@karknu karknu requested a review from nfrisby October 21, 2021 08:49
Copy link
Contributor

@nfrisby nfrisby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The semantics of the changes look good to me! 👍

I suggested a simplification, but I would understand if Karl isn't comfortable with it -- feel free to respond saying as much. (Notably this PR introduces enough information for us to gather empirical evidence in the mean-time that will let us later conclude that the suggested simplification is sound, in which case we could do the simplification later.)

I'm not Approving only because my review by itself isn't sufficient to unblock merge.

@@ -686,6 +686,7 @@ instance ( ConvertRawHash blk
[ "kind" .= String "TraceAddBlockEvent.SwitchedToAFork"
, "newtip" .= renderPointForVerbosity verb (AF.headPoint new)
, "chainLengthDelta" .= new `chainLengthΔ` old
, "realFork" .= not (AF.withinFragmentBounds (AF.headPoint old) new)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename this to "sanityCheck"? Or add a comment explaining that we're just double-checking that the SwitchedToAFork event really was incurred by a proper fork.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a comment.

traceChainMetrics Nothing _ _ _ = nullTracer
traceChainMetrics (Just _ekgDirect) _blockConfig _fStats tr = do
traceChainMetrics Nothing _ _ _ _ = nullTracer
traceChainMetrics (Just _ekgDirect) tForks _blockConfig _fStats tr = do
Tracer $ \ev ->
fromMaybe (pure ()) $ doTrace <$> chainTipInformation ev
where
chainTipInformation :: ChainDB.TraceEvent blk -> Maybe ChainInformation
chainTipInformation = \case
ChainDB.TraceAddBlockEvent ev -> case ev of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we generally trust that SwitchedToAFork is only emitted when it should be, then the changes to this case expression could be simpler; we just need to pass a True to chainInformation in one branch and a False in the other.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 will make that change.

{ slots = unSlotNo $ fromWithOrigin 0 (AF.headSlot frag)
, blocks = unBlockNo $ fromWithOrigin (BlockNo 1) (AF.headBlockNo frag)
, density = fragmentChainDensity frag
chainInformation newTipInfo oldFrag_m newFrag blocksUncoupledDelta = ChainInformation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my related comment in traceChainMetrics: we could get by with just a new Bool argument instead.

Add cardano_node_metrics_forks_int for counting the number of forks seen
by the node.
@karknu
Copy link
Contributor Author

karknu commented Oct 25, 2021

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 25, 2021

Build succeeded:

@iohk-bors iohk-bors bot merged commit 7bcafb1 into master Oct 25, 2021
@iohk-bors iohk-bors bot deleted the karknu/forks_counter branch October 25, 2021 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants