-
Notifications
You must be signed in to change notification settings - Fork 454
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 jaeger/opentracing tracing to m3query #1321
Changes from 2 commits
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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
## Metrics | ||
|
||
TODO | ||
|
||
## Logs | ||
|
||
TODO | ||
|
||
## Tracing | ||
|
||
M3DB is integrated with [opentracing](https://opentracing.io/) to provide | ||
insight into query performance and errors. | ||
|
||
### Configuration | ||
Currently, only https://www.jaegertracing.io/ is supported as a backend. | ||
andrewmains12 marked this conversation as resolved.
Show resolved
Hide resolved
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. nit: maybe |
||
|
||
To enable it, set tracing.backend to "jaeger": | ||
|
||
``` | ||
tracing: | ||
andrewmains12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
backend: jaeger # enables jaeger with default configs | ||
jaeger: | ||
# optional configuration for jaeger -- see | ||
# https://github.com/jaegertracing/jaeger-client-go/blob/master/config/config.go#L37 | ||
# for options | ||
andrewmains12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
... | ||
``` | ||
|
||
Jaeger can be run locally with docker as described in | ||
https://www.jaegertracing.io/docs/1.9/getting-started/. | ||
|
||
The default configuration will report traces via udp to localhost:6831; | ||
using the all-in-one jaeger container, they will be accessible at | ||
|
||
http://localhost:16686 | ||
|
||
|
||
#### Alternative backends | ||
|
||
If you'd like additional backends, we'd love to support them! | ||
|
||
File an issue against M3 and we can work with you on how best to add | ||
the backend. The first time's going to be a little rough--opentracing | ||
unfortunately doesn't support Go plugins (yet--see | ||
https://github.com/opentracing/opentracing-go/issues/133), and `glide`'s | ||
update model means that adding dependencies directly will update | ||
*everything*, which isn't ideal for an isolated dependency change. | ||
These problems are all solvable though, | ||
and we'll work with you to make it happen! | ||
|
||
### Use cases | ||
|
||
Note: all URLs assume a local jaeger setup as described in Jaeger's | ||
[docs](https://www.jaegertracing.io/docs/1.9/getting-started/). | ||
|
||
|
||
#### Finding slow queries | ||
|
||
To find prom queries longer than <threshold>, filter for `minDuration >= <threshold>` on | ||
`operation="GET /api/v1/query_range"`. | ||
|
||
Sample query: | ||
http://localhost:16686/search?end=1548876672544000&limit=20&lookback=1h&maxDuration&minDuration=1ms&operation=GET%20%2Fapi%2Fv1%2Fquery_range&service=m3query&start=1548873072544000 | ||
andrewmains12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#### Finding queries with errors | ||
|
||
Search for `error=true` on `operation="GET /api/v1/query_range"` | ||
http://localhost:16686/search?operation=GET%20%2Fapi%2Fv1%2Fquery_range&service=m3query&tags=%7B%22error%22%3A%22true%22%7D | ||
|
||
#### Finding 500 (Internal Server Error) responses | ||
|
||
Search for `http.status_code=500`. | ||
|
||
http://localhost:16686/search?limit=20&lookback=24h&maxDuration&minDuration&operation=GET%20%2Fapi%2Fv1%2Fquery_range&service=m3query&start=1548802430108000&tags=%7B"http.status_code"%3A"500"%7D | ||
andrewmains12 marked this conversation as resolved.
Show resolved
Hide resolved
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,9 +32,12 @@ import ( | |
"github.com/m3db/m3/src/query/executor" | ||
"github.com/m3db/m3/src/query/models" | ||
"github.com/m3db/m3/src/query/ts" | ||
"github.com/m3db/m3/src/query/util/httperrors" | ||
"github.com/m3db/m3/src/query/util/logging" | ||
xhttp "github.com/m3db/m3/src/x/net/http" | ||
opentracingutil "github.com/m3db/m3/src/query/util/opentracing" | ||
|
||
opentracingext "github.com/opentracing/opentracing-go/ext" | ||
opentracinglog "github.com/opentracing/opentracing-go/log" | ||
"github.com/uber-go/tally" | ||
"go.uber.org/zap" | ||
) | ||
|
@@ -124,7 +127,7 @@ func (h *PromReadHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |
|
||
result, params, respErr := h.ServeHTTPWithEngine(w, r, h.engine) | ||
if respErr != nil { | ||
xhttp.Error(w, respErr.Err, respErr.Code) | ||
httperrors.ErrorWithReqID(w, r, respErr.Err, respErr.Code) | ||
return | ||
} | ||
|
||
|
@@ -167,6 +170,9 @@ func (h *PromReadHandler) ServeHTTPWithEngine( | |
|
||
result, err := read(ctx, engine, h.tagOpts, w, params) | ||
if err != nil { | ||
sp := opentracingutil.SpanFromContextOrRoot(ctx) | ||
sp.LogFields(opentracinglog.Error(err)) | ||
opentracingext.Error.Set(sp, true) | ||
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. Should you have 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. In this case, no; that function is intended to extract the span from context if it exists, and return a noop/dummy if not. In the first case, the calling function is already in charge of calling I updated the function to be |
||
logger.Error("unable to fetch data", zap.Error(err)) | ||
h.promReadMetrics.fetchErrorsServer.Inc(1) | ||
return nil, emptyReqParams, &RespError{Err: err, Code: http.StatusInternalServerError} | ||
|
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.
Probably better to remove these?
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.
Eh I don't see much harm in having stubs. I switched it to "TODO: document how to retrieve metrics for M3DB components." so that people don't think the metrics themselves are TODO.