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

Specify metric name/tags via annotation #1096

Merged
merged 4 commits into from
Oct 1, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Changes by Version

##### Breaking Changes

- Consolidate query metrics and include result tag ([#1075](https://github.com/jaegertracing/jaeger/pull/1075), [@objectiser](https://github.com/objectiser)
- Make the metrics produced by jaeger query scoped to the query component, and generated for all span readers (not just ES) ([#1074](https://github.com/jaegertracing/jaeger/pull/1074), [@objectiser](https://github.com/objectiser)
- Consolidate query metrics and include result tag ([#1075](https://github.com/jaegertracing/jaeger/pull/1075) and [#1096](https://github.com/jaegertracing/jaeger/pull/1096), [@objectiser](https://github.com/objectiser))
- Make the metrics produced by jaeger query scoped to the query component, and generated for all span readers (not just ES) ([#1074](https://github.com/jaegertracing/jaeger/pull/1074), [@objectiser](https://github.com/objectiser))


1.7.0 (2018-09-19)
Expand Down
19 changes: 7 additions & 12 deletions storage/spanstore/metrics/decorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ type ReadMetricsDecorator struct {
}

type queryMetrics struct {
Errors metrics.Counter
Successes metrics.Counter
Responses metrics.Timer //used as a histogram, not necessary for GetTrace
ErrLatency metrics.Timer
OKLatency metrics.Timer
Errors metrics.Counter `metric:"calls" tags:"result=err"`
Copy link
Member

Choose a reason for hiding this comment

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

i think we usually call this "requests"

Successes metrics.Counter `metric:"calls" tags:"result=ok"`
Responses metrics.Timer `metric:"responses"` //used as a histogram, not necessary for GetTrace
ErrLatency metrics.Timer `metric:"latency" tags:"result=err"`
OKLatency metrics.Timer `metric:"latency" tags:"result=ok"`
}

func (q *queryMetrics) emit(err error, latency time.Duration, responses int) {
Expand All @@ -64,14 +64,9 @@ func NewReadMetricsDecorator(spanReader spanstore.Reader, metricsFactory metrics
}

func buildQueryMetrics(namespace string, metricsFactory metrics.Factory) *queryMetrics {
qMetrics := &queryMetrics{}
scoped := metricsFactory.Namespace(namespace, nil)
qMetrics := &queryMetrics{
Errors: scoped.Counter("", map[string]string{"result": "err"}),
Successes: scoped.Counter("", 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"}),
}
metrics.Init(qMetrics, scoped, nil)
return qMetrics
}

Expand Down
32 changes: 16 additions & 16 deletions storage/spanstore/metrics/decorator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ func TestSuccessfulUnderlyingCalls(t *testing.T) {
mrs.FindTraces(context.Background(), &spanstore.TraceQueryParameters{})
counters, gauges := mf.Snapshot()
expecteds := map[string]int64{
"get_operations|result=ok": 1,
"get_operations|result=err": 0,
"get_trace|result=ok": 1,
"get_trace|result=err": 0,
"find_traces|result=ok": 1,
"find_traces|result=err": 0,
"get_services|result=ok": 1,
"get_services|result=err": 0,
"get_operations.calls|result=ok": 1,
"get_operations.calls|result=err": 0,
"get_trace.calls|result=ok": 1,
"get_trace.calls|result=err": 0,
"find_traces.calls|result=ok": 1,
"find_traces.calls|result=err": 0,
"get_services.calls|result=ok": 1,
"get_services.calls|result=err": 0,
Copy link
Member

Choose a reason for hiding this comment

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

what does the full name look like? Perhaps the operation name should be pushed into a tag as well: requests|operation=find_traces|result=ok

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good - the updated version is now:

jaeger_query_latency_bucket{operation="find_traces",result="err",le="0.005"} 0
jaeger_query_latency_bucket{operation="find_traces",result="ok",le="0.005"} 2
jaeger_query_requests{operation="find_traces",result="err"} 0
jaeger_query_requests{operation="find_traces",result="ok"} 2
jaeger_query_responses_bucket{operation="find_traces",le="0.005"} 2

}

existingKeys := []string{
Expand Down Expand Up @@ -96,14 +96,14 @@ func TestFailingUnderlyingCalls(t *testing.T) {
mrs.FindTraces(context.Background(), &spanstore.TraceQueryParameters{})
counters, gauges := mf.Snapshot()
expecteds := map[string]int64{
"get_operations|result=ok": 0,
"get_operations|result=err": 1,
"get_trace|result=ok": 0,
"get_trace|result=err": 1,
"find_traces|result=ok": 0,
"find_traces|result=err": 1,
"get_services|result=ok": 0,
"get_services|result=err": 1,
"get_operations.calls|result=ok": 0,
"get_operations.calls|result=err": 1,
"get_trace.calls|result=ok": 0,
"get_trace.calls|result=err": 1,
"find_traces.calls|result=ok": 0,
"find_traces.calls|result=err": 1,
"get_services.calls|result=ok": 0,
"get_services.calls|result=err": 1,
}

existingKeys := []string{
Expand Down