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 metrics to hystrix #768

Merged
merged 4 commits into from
Jun 21, 2021
Merged

Add metrics to hystrix #768

merged 4 commits into from
Jun 21, 2021

Conversation

nkonjeti
Copy link
Contributor

@nkonjeti nkonjeti commented Jun 17, 2021

Goal: Time the hystrics.Doc function called in all the client template codegen file. This is to check that hystrix.Doc isn't slow and isn't taking time from the actual request. This problem was stated in this ticket: https://t3.uberinternal.com/browse/EDGE-7509 . A dashboard will be created to graph time taken by hystrix for each client in Grafana.
From baz_metrics_test.go (client: baz, method: call) :
Screen Shot 2021-06-20 at 10 28 12 PM

  • Add metric for timing hystrix.DoC function called "hystrix-timer"
  • Add "client" and "methodName" tags to scope
  • Test that the "hystrix-timer" metric is included in baz_metrics_test.go

@CLAassistant
Copy link

CLAassistant commented Jun 17, 2021

CLA assistant check
All committers have signed the CLA.

@nkonjeti nkonjeti marked this pull request as draft June 17, 2021 20:58
@coveralls
Copy link

coveralls commented Jun 19, 2021

Coverage Status

Coverage increased (+0.1%) to 69.374% when pulling df90a20 on timer into 69e319b on master.

@nkonjeti nkonjeti marked this pull request as ready for review June 19, 2021 19:48
Comment on lines 275 to 276
t := time.Now()
elapsed := t.Sub(start)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can be refactored to time.Now().Sub(start). Having t as a var doesn't add extra clarity here.

@@ -266,7 +267,15 @@ type {{$clientName}} struct {
} else {
// We want hystrix ckt-breaker to count errors only for system issues
var clientErr error
scope := c.defaultDeps.Scope.Tagged(map[string]string{
"client" : "{{$svc.Name}}",
Copy link
Contributor

Choose a reason for hiding this comment

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

we should add the methodName too

err = hystrix.DoC(ctx, "{{$clientID}}", func(ctx context.Context) error {
t := time.Now()
elapsed := t.Sub(start)
size := scope.Timer("hystrix-timer")
Copy link
Contributor

Choose a reason for hiding this comment

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

size doesn't suit here, probably timer. You may even just do scope.Timer("hystrix-timer").Record(elapsed) without requiring a new var.

Copy link
Contributor

@tejaswiagarwal tejaswiagarwal left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for adding the new test cases!

@nkonjeti nkonjeti merged commit 2660c5f into master Jun 21, 2021
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.

5 participants