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

Integrate nim-metrics and add some metrics from the ETH2 spec #394

Merged
merged 1 commit into from
Sep 7, 2019

Conversation

zah
Copy link
Contributor

@zah zah commented Sep 6, 2019

No description provided.

@@ -17,19 +17,20 @@ bin = @[

### Dependencies
requires "nim >= 0.19.0",
Copy link
Member

Choose a reason for hiding this comment

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

==0.19.6 really ;)

proc toGaugeValue*(hash: Eth2Digest): int64 =
# Only the last 8 bytes are taken into consideration in accordance
# to the ETH2 metrics spec:
# https://github.com/ethereum/eth2.0-metrics/blob/6a79914cb31f7d54858c7dd57eee75b6162ec737/metrics.md#interop-metrics
Copy link
Member

Choose a reason for hiding this comment

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

this is certainly unique 😳

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean the long URL?

Copy link
Member

Choose a reason for hiding this comment

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

no, the spec using a signed integer like this

@@ -23,6 +23,28 @@ const
genesisFile = "genesis.json"
testnetsBaseUrl = "https://serenity-testnets.status.im"

declareGauge beacon_slot, "Latest slot of the beacon chain state"
Copy link
Member

Choose a reason for hiding this comment

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

from experience, metrics have bigger chances of staying recent when they're declared close to where they're updated.

as an example, since we have a function that advances slot time, declare the metric in that function, else it's easy to let the metric and the underlying data go out of sync when the code changes, and you end up with a graveyard of metrics representing what the code once did.

In this they are similar to log statements: you would never ever consider making a central repository of all log strings in the application - it is local information that deserves to be kept local.

at the very least, we should think about how to spread them to the relevant module (ie the BlockPool is responsible for keeping track of the head block, so all related metrics should be in there - then it's easier to make sure that the metric tracks the actual "source of truth"

Copy link
Contributor Author

@zah zah Sep 7, 2019

Choose a reason for hiding this comment

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

Have you noticed the comment two lines below which suggests exactly this :)

It was easier to put the metrics in this file as a starting point, because I used some vim editing tricks to copy paste the metric names and descriptions from the spec and to reformat them as Nim code.

Copy link
Member

Choose a reason for hiding this comment

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

ah whoops, missed the todo

@zah
Copy link
Contributor Author

zah commented Sep 7, 2019

Some of the metrics are not implemented yet and the declarations have to be moved to their respective modules, but I prefer if we address this in follow-up PRs. Does anyone have objections against merging this as a starting point?

@arnetheduck arnetheduck merged commit 93cdb43 into master Sep 7, 2019
@delete-merged-branch delete-merged-branch bot deleted the eth2-metrics branch September 7, 2019 17:48
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.

2 participants