-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Consolidate query metrics and include result tag #1075
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,16 +34,15 @@ type ReadMetricsDecorator struct { | |
} | ||
|
||
type queryMetrics struct { | ||
Errors metrics.Counter `metric:"errors"` | ||
Attempts metrics.Counter `metric:"attempts"` | ||
Successes metrics.Counter `metric:"successes"` | ||
Responses metrics.Timer `metric:"responses"` //used as a histogram, not necessary for GetTrace | ||
ErrLatency metrics.Timer `metric:"errLatency"` | ||
OKLatency metrics.Timer `metric:"okLatency"` | ||
Errors metrics.Counter | ||
Attempts metrics.Counter | ||
Successes metrics.Counter | ||
Responses metrics.Timer //used as a histogram, not necessary for GetTrace | ||
ErrLatency metrics.Timer | ||
OKLatency metrics.Timer | ||
} | ||
|
||
func (q *queryMetrics) emit(err error, latency time.Duration, responses int) { | ||
q.Attempts.Inc(1) | ||
if err != nil { | ||
q.Errors.Inc(1) | ||
q.ErrLatency.Record(latency) | ||
|
@@ -66,9 +65,14 @@ func NewReadMetricsDecorator(spanReader spanstore.Reader, metricsFactory metrics | |
} | ||
|
||
func buildQueryMetrics(namespace string, metricsFactory metrics.Factory) *queryMetrics { | ||
qMetrics := &queryMetrics{} | ||
scoped := metricsFactory.Namespace(namespace, nil) | ||
metrics.Init(qMetrics, scoped, nil) | ||
qMetrics := &queryMetrics{ | ||
Errors: scoped.Counter("requests", map[string]string{"result": "err"}), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a better name than There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
what items? traces, spans? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It depends on which operation: find traces, get operations, get services and get trace. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On reflection, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems this discussion has finished already, but how about "operations" and "results"? Even though "requests/responses" is probably OK as well, I would avoid it as it's a bit of a loaded term. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have removed the additional part of the name for those counters, so now it is just:
|
||
Successes: scoped.Counter("requests", map[string]string{"result": "ok"}), | ||
Responses: scoped.Timer("responses", nil), | ||
ErrLatency: scoped.Timer("latency", map[string]string{"result": "err"}), | ||
OKLatency: scoped.Timer("latency", map[string]string{"result": "ok"}), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not use the annotation-based initialization as before? It keeps declaration of the struct and metrics name in a single place. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in #1096 |
||
} | ||
return qMetrics | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
Attempts
being used elsewhere?