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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase Prometheus not found metric on tempo-vulture #301

Merged
merged 5 commits into from
Nov 2, 2020

Conversation

dgzlopes
Copy link
Member

@dgzlopes dgzlopes commented Nov 1, 2020

What this PR does:
This PR adds some things:

  • Return a not found error in case we don't find the traceID.
  • Increase Prometheus not found metric on tempo-vulture.

I'm not a Go expert, but this approach seemed "reasonable" 馃槃

Which issue(s) this PR fixes:
Fixes #286

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@dgzlopes dgzlopes changed the title Add trace not found error Increase Prometheus not found metric on tempo-vulture Nov 1, 2020
@@ -115,6 +115,11 @@ func queryTempoAndAnalyze(baseURL string, backoff time.Duration, traceIDs []stri
glog.Error("tempo url ", baseURL+"/api/traces/"+id)
trace, err := util.QueryTrace(baseURL, id, tempoOrgID)
if err != nil {
if strings.Contains(err.Error(), "not found") {
Copy link
Member

Choose a reason for hiding this comment

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

It would be preferred to define and export an error from the util package like:

var ErrTraceNotFound = errors.New("trace not found")

The calling code can then compare using simple equality instead of a string.Contains method

if err == util.ErrTraceNotFound {
}

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Member Author

@dgzlopes dgzlopes Nov 2, 2020

Choose a reason for hiding this comment

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

Thanks for the review! Yep, that way it's cleaner. I'll update the PR :)

Signed-off-by: Daniel Gonz谩lez Lopes <danielgonzalezlopes@gmail.com>
Signed-off-by: Daniel Gonz谩lez Lopes <danielgonzalezlopes@gmail.com>
Signed-off-by: Daniel Gonz谩lez Lopes <danielgonzalezlopes@gmail.com>
Signed-off-by: Daniel Gonz谩lez Lopes <danielgonzalezlopes@gmail.com>
@@ -115,6 +115,11 @@ func queryTempoAndAnalyze(baseURL string, backoff time.Duration, traceIDs []stri
glog.Error("tempo url ", baseURL+"/api/traces/"+id)
trace, err := util.QueryTrace(baseURL, id, tempoOrgID)
if err != nil {
if err == util.ErrTraceNotFound {
Copy link
Member

Choose a reason for hiding this comment

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

one final nit. let's reduce nesting here:

if err == util.ErrTraceNotFound {
   ...
}
if err != nil {
   ...
}

Signed-off-by: Daniel Gonz谩lez Lopes <danielgonzalezlopes@gmail.com>
@joe-elliott
Copy link
Member

Thanks again!

@joe-elliott joe-elliott merged commit eb987a8 into grafana:master Nov 2, 2020
@dgzlopes dgzlopes deleted the add-trace-not-found-error branch November 2, 2020 14:33
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.

tempo-vulture doesn't correctly metric 404s
3 participants