Skip to content

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

Merged
yvrhdn merged 2 commits intografana:mainfrom
yvrhdn:query-frontend-protobuf-queries
Oct 12, 2021
Merged

query-frontend: also extract Trace from TraceByIDResponse when returning protobuf#1025
yvrhdn merged 2 commits intografana:mainfrom
yvrhdn:query-frontend-protobuf-queries

Conversation

@yvrhdn
Copy link
Copy Markdown
Contributor

@yvrhdn yvrhdn 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]

@yvrhdn
Copy link
Copy Markdown
Contributor Author

yvrhdn 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)

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

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.

@yvrhdn yvrhdn merged commit 3abcdb4 into grafana:main Oct 12, 2021
@yvrhdn yvrhdn 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