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

query-frontend: also extract Trace from TraceByIDResponse when returning protobuf #1025

Merged
merged 2 commits into from
Oct 12, 2021

Conversation

kvrhdn
Copy link
Member

@kvrhdn kvrhdn commented Oct 12, 2021

What this PR does:
Fixes a bug introduced by #1007 and reported in #1024.

When querying Tempo with Accept: application/protobuf (as Grafana does) the query-frontend will not unmarshal/marshal the response from other middleware but passes it directly to the caller. #1007 changes TraceByIDResponse to add metrics. To avoid passing this to the caller, we should also unmarshal and marshal protobuf responses.

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

Checklist

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

@kvrhdn
Copy link
Member Author

kvrhdn commented Oct 12, 2021

I dislike that we unmarshal and marshal TraceByIDResponse 2 times in the query-frontend. I.e.:

  • query-sharding combines responses and creates a TraceByIDResponse:

buff, err := proto.Marshal(&tempopb.TraceByIDResponse{
Trace: overallTrace,
Metrics: &tempopb.TraceByIDMetrics{
FailedBlocks: totalFailedBlocks,
},
})

  • frontend.go has to unmarshal this TraceByIDResponse again because we have to return TraceByIDResponse.Trace:

https://github.com/kvrhdn/tempo/blob/3b9d783f17cd4bc3420caae20ccf415ce86505ca/modules/frontend/frontend.go#L158-L182

I guess this is a limitation of building a processing pipeline with http.RoundTripper (and not something we want to fix in this PR)

@kvrhdn kvrhdn marked this pull request as ready for review October 12, 2021 14:37
@joe-elliott
Copy link
Member

joe-elliott commented Oct 12, 2021

I guess this is a limitation of building a processing pipeline with http.RoundTripper (and not something we want to fix in this PR)

Agree. For larger traces repeatedly marshalling/unmarshalling is very inefficient. However, for most queries, this won't even be noticeable so I'm fine with keeping as is for now.

@kvrhdn kvrhdn merged commit 3abcdb4 into grafana:main Oct 12, 2021
@kvrhdn kvrhdn deleted the query-frontend-protobuf-queries branch October 12, 2021 15:38
mdisibio pushed a commit to mdisibio/tempo that referenced this pull request Oct 13, 2021
…ing protobuf (grafana#1025)

* query-frontend: also extract Trace from TraceByIDResponse when returning protobuf

* Fix CHANGELOG.md
@mdisibio mdisibio mentioned this pull request Oct 13, 2021
3 tasks
mdisibio added a commit that referenced this pull request Oct 13, 2021
…ing protobuf (#1025) (#1031)

* query-frontend: also extract Trace from TraceByIDResponse when returning protobuf

* Fix CHANGELOG.md

Co-authored-by: Koenraad Verheyden <koenraad.verheyden@grafana.com>
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.

The example/docker-compose/local no longer works to query traces
2 participants