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 Prometheus metrics for slot_no #537

Merged
merged 1 commit into from
Mar 8, 2021
Merged

Add Prometheus metrics for slot_no #537

merged 1 commit into from
Mar 8, 2021

Conversation

ksaric
Copy link
Contributor

@ksaric ksaric commented Mar 2, 2021

https://jira.iohk.io/browse/CAD-2547

Also removed the direct dependency, Prometheus is optional and we now have the option to simply ignore Prometheus (for example, tests).

@DavidEichmann If you are the owner of cardano-db-tool, it currently doesn't start Prometheus.

Also, changed the names of the metrics, so I guess I have to inform DevOps after this is merged.

@ksaric ksaric requested a review from erikd March 2, 2021 13:30
@ksaric ksaric marked this pull request as draft March 2, 2021 13:33
@ksaric ksaric marked this pull request as ready for review March 2, 2021 13:34
@ksaric ksaric force-pushed the ksaric/CAD-2547 branch from 8a3a55e to 41f3684 Compare March 2, 2021 13:57
@DavidEichmann
Copy link
Contributor

@ksaric, I'm not the owner of cardano-db-tool.

cardano-db-sync/src/Cardano/DbSync/Metrics.hs Outdated Show resolved Hide resolved
cardano-db-sync-extended/app/cardano-db-sync-extended.hs Outdated Show resolved Hide resolved
-- The metrics we use.
-- PLEASE do not put this into ENV, it's defeating the purpose
-- of these constructs.
data MetricsLayer = MetricsLayer
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this a "Layer"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like a DataLayer, we used names Layer to describe such interfaces. I think the wallet does a similar thing, it's not a first. I think the name fits quite well. It's a layer that can be cascaded (like the caching layer on top of a db layer), and it's an interface, a small surface that "touches" the world.

Copy link
Contributor

@erikd erikd Mar 7, 2021

Choose a reason for hiding this comment

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

The name MetricsSetters is a much better name. It removes the confusing "layer" from the name and "setters" describes exactly what the components of this struct do.

Yes, naming things in hard. The old name had been bugging me since last week and the new name just came to me now.

emptyMetricsLayer :: MetricsLayer
emptyMetricsLayer =
MetricsLayer
{ mlSetNodeBlockHeight = \_ -> pure ()
Copy link
Contributor

Choose a reason for hiding this comment

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

const ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is much clearer to me than const.

cardano-sync/src/Cardano/Sync.hs Outdated Show resolved Hide resolved
@ksaric
Copy link
Contributor Author

ksaric commented Mar 3, 2021

@ksaric, I'm not the owner of cardano-db-tool.

I know you were creating some tool, not sure where is it actually, so 🤷‍♂️

@ksaric ksaric force-pushed the ksaric/CAD-2547 branch 3 times, most recently from 521694c to ed0e0ba Compare March 4, 2021 07:35
@ksaric
Copy link
Contributor Author

ksaric commented Mar 4, 2021

bors try+

iohk-bors bot added a commit that referenced this pull request Mar 4, 2021
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Mar 4, 2021



-- |The metrics we use for Prometheus.
data Metrics = Metrics
Copy link
Contributor

@erikd erikd Mar 7, 2021

Choose a reason for hiding this comment

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

Why is it a layer? To me "layer" implies that if we have say 3 layers, A, B and C, that A calls into B and then B calls into C. That is not the case here. Its not a layer, its a Metrics component.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -66,3 +67,16 @@ newtype BlockId = BlockId Int
-- @Word64@ is valid as well.
newtype MetaId = MetaId Int
deriving (Eq, Show)
Copy link
Contributor

Choose a reason for hiding this comment

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

What are MetaId and BlockId . Are they used anywhere else in this repo? I am pretty sure they are not because the names clash with identifiers that are generated by Persisitent in cardano-db/src/Cardano/Db/Schema.hs.

Copy link
Contributor

@erikd erikd Mar 7, 2021

Choose a reason for hiding this comment

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

Same applies to Block and Meta in this same file.

Copy link
Contributor

Choose a reason for hiding this comment

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

If I remove BlockId, Meta and Block, everything still compiles. So why are they here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They were supposed to be here and used by some other functions in the CardanoDataLayer. For now, they are not used anywhere so if you want, you can drop them.

@erikd erikd force-pushed the ksaric/CAD-2547 branch 3 times, most recently from 58c5fc9 to 0c2888b Compare March 8, 2021 00:59
* Allows metrics to be used from cardano-sync package.
* Add a metric for slot_no.

https://jira.iohk.io/browse/CAD-2547

Co-authored-by: Erik de Castro Lopo <erikd@mega-nerd.com>
@erikd erikd force-pushed the ksaric/CAD-2547 branch from 0c2888b to 208bd07 Compare March 8, 2021 01:02
@erikd erikd changed the title [CAD-2547] Add Prometheus metrics for slot_no. Add Prometheus metrics for slot_no Mar 8, 2021
@erikd
Copy link
Contributor

erikd commented Mar 8, 2021

@DavidEichmann If you are the owner of cardano-db-tool, it currently doesn't start Prometheus.

There is no point in having Prometheus metrics in cardano-db-tool .

@erikd erikd merged commit 8d306c9 into master Mar 8, 2021
@iohk-bors iohk-bors bot deleted the ksaric/CAD-2547 branch March 8, 2021 05:41
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.

4 participants