Skip to content

Backward compatibility for Prometheus metrics names #4955

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

Merged
merged 6 commits into from
Mar 22, 2023

Conversation

jutaro
Copy link
Contributor

@jutaro jutaro commented Mar 8, 2023

With configuration entries
metricsComp = {
"a" = "b";
...
};
metrics with name a as well appear with name b in Prometheus. The names in the configuration has to be specified as in the original message, and not as in the Prometheus export (Where e.g. a '.' becomes an '_').

@jutaro jutaro self-assigned this Mar 8, 2023
@jutaro jutaro requested a review from deepfire March 8, 2023 13:41
@jutaro jutaro force-pushed the jutaro/metrics-mapping branch 3 times, most recently from ace06c3 to cc2e142 Compare March 15, 2023 09:56
@jutaro jutaro marked this pull request as ready for review March 15, 2023 09:57
@jutaro jutaro requested review from Jimbo4350, newhoggy, coot, a team, mgmeier and fmaste as code owners March 15, 2023 09:57
Copy link
Contributor

@deepfire deepfire left a comment

Choose a reason for hiding this comment

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

Jurgen, thank you!

# Just an example for metrics compatibility mapping
# metricsComp = {
# "Mempool.TxsInMempool" = "Mempool.TxsInMempool.Mapped";
# "ChainDB.SlotNum" = "ChainDB.SlotNum.Mapped";
Copy link
Contributor

Choose a reason for hiding this comment

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

@jutaro, just one thing -- can we change names in this example to make it more clear -- what metric already exists, and what will be created? If I didn't have the context, I'd be a bit confused by it.

Also, another question -- can we flip the order?
It's a bit weird that the created metrics are on the right of what reads like an assignment operator.

Copy link
Contributor Author

@jutaro jutaro Mar 15, 2023

Choose a reason for hiding this comment

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

What names to you think make it clearer. I thought adding the ".Mapped" postfix makes it clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a mapping from current name to new name. I think this is pretty straightforward, and reversing it would not make it clearer in my view ?!?

Copy link
Contributor

@mgmeier mgmeier Mar 15, 2023

Choose a reason for hiding this comment

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

It all hinges on how you read the assignment operator; its meaning for ("X" = "Y") being

"X" has alias "Y"

right?
Without knowing how the resulting Map Text Text is applied in code, it's not straightforward; it would be nice to have that clarification in the comment, for someone just wanting to adjust the .nix service definition.

Copy link
Contributor

@deepfire deepfire Mar 15, 2023

Choose a reason for hiding this comment

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

There is a lot of mathematical baggage, where we define:

  • something on the left
  • to be equal to something on the right

..which, on the surface might feel like it's imperative PL bullshit, but it actually runs deeper.

Can you think of a single definition where the "new thing" appears on the right?

Copy link
Contributor

@deepfire deepfire Mar 15, 2023

Choose a reason for hiding this comment

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

There are further reasons:

  • maps are asymmetric -- the thing on the left is unique, the thing on the right not so
  • it makes sense to allow multiple aliases for the same source metric
  • it doesn't make sense to have a single alias to be related to several source metrics

The status quo allows the strange thing and disallows the silly-but-meaningful thing.

Nothing -> p' : accu
Just rep -> p' : (rep,mv) : accu)
[]
metricsList
Copy link
Contributor

Choose a reason for hiding this comment

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

Has metricsList to be ordered somehow (e.g. identical mvs must be subsequent)?
I was wondering about the fold...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only one mapping per entry is supported, and then order doesn't matter.

# Just an example for metrics compatibility mapping
# metricsComp = {
# "Mempool.TxsInMempool" = "Mempool.TxsInMempool.Mapped";
# "ChainDB.SlotNum" = "ChainDB.SlotNum.Mapped";
Copy link
Contributor

@mgmeier mgmeier Mar 15, 2023

Choose a reason for hiding this comment

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

It all hinges on how you read the assignment operator; its meaning for ("X" = "Y") being

"X" has alias "Y"

right?
Without knowing how the resulting Map Text Text is applied in code, it's not straightforward; it would be nice to have that clarification in the comment, for someone just wanting to adjust the .nix service definition.

@jutaro jutaro force-pushed the jutaro/metrics-mapping branch 3 times, most recently from 0de686a to 964bafd Compare March 16, 2023 11:24
@jutaro jutaro force-pushed the jutaro/metrics-mapping branch from 5c36b7a to a30f5ca Compare March 20, 2023 11:23
@jutaro
Copy link
Contributor Author

jutaro commented Mar 21, 2023

bors r+

iohk-bors bot added a commit that referenced this pull request Mar 21, 2023
4955: Backward compatibility for Prometheus metrics names r=jutaro a=jutaro

With configuration entries
metricsComp = {
            "a" = "b";
            ...
        };
metrics with name a as well appear with name b in Prometheus. The names in the configuration has to be specified as in the original message, and not as in the Prometheus export (Where e.g. a '.' becomes an '_'). 

Co-authored-by: Yupanqui <[email protected]>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Mar 21, 2023

This PR was included in a batch that successfully built, but then failed to merge into master. It will not be retried.

Additional information:

{"message":"Validation Failed","documentation_url":"https://docs.github.com/articles/about-protected-branches"}

@deepfire deepfire added this pull request to the merge queue Mar 22, 2023
@deepfire deepfire merged commit 3888d54 into master Mar 22, 2023
@iohk-bors iohk-bors bot deleted the jutaro/metrics-mapping branch March 22, 2023 06:54
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