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 rule evaluation time #3491

Merged
merged 1 commit into from Nov 22, 2017
Merged

Add rule evaluation time #3491

merged 1 commit into from Nov 22, 2017

Conversation

conr
Copy link
Contributor

@conr conr commented Nov 17, 2017

Added evaluation time to both rule groups and rules on /rules.

This makes for easier debugging when trying to identify an expensive rule or rule group.

See screenshot for example:

screen shot 2017-11-17 at 15 49 53 3

Any thoughts?

}

// EvalTimeSeconds returns the time in seconds it took to evaluate the recording rule.
func (rule *RecordingRule) EvalTimeSeconds() float64 {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a race here that warrants a lock?

Copy link
Contributor Author

@conr conr Nov 20, 2017

Choose a reason for hiding this comment

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

Thanks for spotting! Added locks for reading and updating both the recording and alert rule's evaluation times.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gouthamve Is there any further changes to be made here?

<tr>
<td class="rule_cell">{{.HTMLSnippet pathPrefix}}</td>
<td>{{humanizeDuration .EvalTimeSeconds}}</td>
{{end}}
Copy link
Member

Choose a reason for hiding this comment

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

{{end}} should come after </tr>

rules/manager.go Outdated
@@ -176,6 +180,7 @@ func (g *Group) run() {
g.Eval(start)

iterationDuration.Observe(time.Since(start).Seconds())
g.EvaluationTimeSeconds = time.Since(start).Seconds()
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 another race here. When templating we are reading it without a lock.

Add a setter and accessor for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 👍

Copy link
Member

@gouthamve gouthamve left a comment

Choose a reason for hiding this comment

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

Final nit and after that 👍

rules/manager.go Outdated
@@ -115,19 +115,24 @@ type Rule interface {
Eval(context.Context, time.Time, *promql.Engine, *url.URL) (promql.Vector, error)
// String returns a human-readable string representation of the rule.
String() string

UpdateEvalTimeSeconds(float64)
Copy link
Member

Choose a reason for hiding this comment

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

Below we have GetEvaluationTimeSeconds and setEvaluationTimeSeconds while here the names are different for same functionality. Can we sync those?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it. Thanks for the review! 👍

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.

None yet

2 participants