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 initial metrics to Churn server #11

Merged
merged 4 commits into from
Nov 14, 2023
Merged

Add initial metrics to Churn server #11

merged 4 commits into from
Nov 14, 2023

Conversation

wmb-software-consulting
Copy link
Contributor

@wmb-software-consulting wmb-software-consulting commented Nov 13, 2023

Why are these changes needed?

Add couple of metrics to Churn server

Related issue number

Checks

  • I've made sure the lint is passing in this PR.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, in that case, please comment that they are not relevant.
  • Testing Strategy
    • Unit tests
    • Integration tests
    • This PR is not tested :(

Signed-off-by: Wellington Barbosa <[email protected]>
Name: "requests",
Help: "the number of requests",
},
[]string{"status", "reason", "method"},
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need a "reason" to "success" request?

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 want 2 METRICS a part?

Copy link
Contributor

Choose a reason for hiding this comment

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

One is sufficient, I am mostly looking at why NumFailedRequests is needed, since NumRequests already has a status label that can indicate if it's success or failure.

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 overlooked the metric "NumFailedRequests" in the code, and it shouldn't be there.

// IncrementSuccessfulRequestNum increments the number of successful requests
func (g *Metrics) IncrementSuccessfulRequestNum(method string) {
g.NumRequests.With(prometheus.Labels{
"status": "success",
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as "reason", if this is always "success", why it needs to be a label?

And how do you tell the total requests that the churner received easily if there are two metrics (one for success and one for failed)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean?
We can filter, isn't it?

eigenda_churner_ requests({status ="success"})

eigenda_churner_ requests({status ="failed", reason="XPTO"})

Copy link
Contributor

Choose a reason for hiding this comment

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

Then there is no need to have NumFailedRequests

s.logger.Info("Received request: ", "QuorumIds", req.GetQuorumIds())

now := time.Now()
// check that we are after the previous approval's expiry
if now.Unix() < latestExpiry {
s.metrics.IncrementFailedRequestNum("Churn", "Expiry: previous approval hasn't expired")
Copy link
Contributor

Choose a reason for hiding this comment

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

The "reason" part should be made concise as an Enum, rather than a sentence.

@@ -192,6 +195,7 @@ func (c *churner) getOperatorsToChurn(ctx context.Context, quorumIDs []uint8, op
// verify the lowest stake against the registering operator's stake
// make sure that: lowestStake * churnBIPsOfOperatorStake < operatorToRegisterStake * bipMultiplier
if new(big.Int).Mul(lowestStake, churnBIPsOfOperatorStake).Cmp(new(big.Int).Mul(operatorToRegisterStake, bipMultiplier)) >= 0 {
c.metrics.IncrementFailedRequestNum("getOperatorsToChurn", "Insufficient stake: operator doesn't have enough stake")
return nil, errors.New("registering operator has less than churnBIPsOfOperatorStake")
}

Copy link
Contributor

Choose a reason for hiding this comment

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

There is another case which fails to pass the stake check below

Signed-off-by: Wellington Barbosa <[email protected]>
Copy link
Contributor

@jianoaix jianoaix left a comment

Choose a reason for hiding this comment

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

mostly LG after address the two metrics comment

// IncrementSuccessfulRequestNum increments the number of successful requests
func (g *Metrics) IncrementSuccessfulRequestNum(method string) {
g.NumRequests.With(prometheus.Labels{
"status": "success",
Copy link
Contributor

Choose a reason for hiding this comment

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

Then there is no need to have NumFailedRequests

Signed-off-by: Wellington Barbosa <[email protected]>
FailReasonRateLimitExceeded FailReason = "rate_limit_exceeded" // Rate limited: per operator rate limiting
FailReasonInsufficientStakeToRegister FailReason = "insufficient_stake_to_register" // Operator doesn't have enough stake to be registered
FailReasonInsufficientStakeToChurn FailReason = "insufficient_stake_to_churn" // Operator doesn't have enough stake to be churned
FailReasonQuorumIdOutOfRange FailReason = "quorum_id_out_of_range" // Quorum ID out of range: quorum is not in the range of [0, 255]
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: 255 -> QuorumCount, which is a value gotten from the chain and used to the validation

@wmb-software-consulting wmb-software-consulting merged commit 90f6169 into Layr-Labs:master Nov 14, 2023
4 checks passed
teddyknox pushed a commit that referenced this pull request Nov 16, 2023
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