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

[api_v3][query] Change api_v3 http handler to use v2 query service #6459

Merged
merged 12 commits into from
Jan 3, 2025

Conversation

mahadzaryab1
Copy link
Collaborator

@mahadzaryab1 mahadzaryab1 commented Jan 1, 2025

Which problem is this PR solving?

Description of the changes

  • This PR migrates the v3_api HTTP handler to use the new v2 query service.

How was this change tested?

  • Added unit tests

Checklist

Copy link

codecov bot commented Jan 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.27%. Comparing base (d796192) to head (a56567b).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6459      +/-   ##
==========================================
- Coverage   96.29%   96.27%   -0.03%     
==========================================
  Files         371      370       -1     
  Lines       21173    21182       +9     
==========================================
+ Hits        20389    20393       +4     
- Misses        600      604       +4     
- Partials      184      185       +1     
Flag Coverage Δ
badger_v1 10.74% <ø> (ø)
badger_v2 2.80% <ø> (ø)
cassandra-4.x-v1-manual 16.62% <ø> (ø)
cassandra-4.x-v2-auto 2.73% <ø> (ø)
cassandra-4.x-v2-manual 2.73% <ø> (ø)
cassandra-5.x-v1-manual 16.62% <ø> (ø)
cassandra-5.x-v2-auto 2.73% <ø> (ø)
cassandra-5.x-v2-manual 2.73% <ø> (ø)
elasticsearch-6.x-v1 20.31% <ø> (ø)
elasticsearch-7.x-v1 20.38% <ø> (ø)
elasticsearch-8.x-v1 20.55% <ø> (+<0.01%) ⬆️
elasticsearch-8.x-v2 2.79% <ø> (ø)
grpc_v1 12.39% <ø> (ø)
grpc_v2 9.15% <ø> (ø)
kafka-3.x-v1 10.58% <ø> (ø)
kafka-3.x-v2 2.80% <ø> (ø)
memory_v2 2.79% <ø> (-0.01%) ⬇️
opensearch-1.x-v1 20.43% <ø> (+<0.01%) ⬆️
opensearch-2.x-v1 20.43% <ø> (-0.01%) ⬇️
opensearch-2.x-v2 2.79% <ø> (ø)
tailsampling-processor 0.52% <ø> (ø)
unittests 95.14% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -166,11 +160,16 @@ func (h *HTTPGateway) getTrace(w http.ResponseWriter, r *http.Request) {
}
request.RawTraces = rawTraces
}
trc, err := h.QueryService.GetTrace(r.Context(), request)
getTracesIter := h.QueryService.GetTraces(r.Context(), request)
trc, err := v1adapter.V1TracesFromSeq2(getTracesIter)
Copy link
Member

Choose a reason for hiding this comment

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

it doesn't make sense to convert to v1 model only to convert it back to OTLP in L113. The benefit of v2 storage here is that we can avoid any unnecessary transforms

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@yurishkuro yep - will fix. I was just trying to wire up the new query service first.

if h.tryHandleError(w, err, http.StatusInternalServerError) {
return
}
h.returnSpans(trc.Spans, w)
if len(trc) == 0 {
// TODO: should we return 404 if trace 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.

yes, I think this is the contract of v3 API (which is unfortunate since it doesn't match the Storage v2 API contract, but we'll keep it for backwards compatibility).

@@ -166,11 +161,18 @@ func (h *HTTPGateway) getTrace(w http.ResponseWriter, r *http.Request) {
}
request.RawTraces = rawTraces
}
trc, err := h.QueryService.GetTrace(r.Context(), request)
getTracesIter := h.QueryService.GetTraces(r.Context(), request)
aggrTracesIter := jptrace.AggregateTraces(getTracesIter)
Copy link
Member

Choose a reason for hiding this comment

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

why do we need to aggregate here? If QS needs to apply adjustments it would already aggregate, otherwise it will return raw chunks, and this API can just pass them through to the caller, it's not require to recombine them.

// TODO how do we distinguish internal error from bad parameters for FindTrace?
if h.tryHandleError(w, err, http.StatusInternalServerError) {
return
}
var spans []*model.Span
combinedTrace := ptrace.NewTraces()
Copy link
Member

Choose a reason for hiding this comment

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

this should have a serious TODO, since it's clearly the wrong thing todo now.

@yurishkuro
Copy link
Member

I added a sketch of the issue for chunked encoding #6467

Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
@@ -8,16 +8,14 @@
"scope": {},
"spans": [
{
"endTimeUnixNano": "11651379494838206464",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@yurishkuro do you know where this timestamp was coming from before?

@mahadzaryab1 mahadzaryab1 changed the title [WIP][api_v3][query] Change api_v3 http handler to use query service v2 [api_v3][query] Change api_v3 http handler to use v2 query service Jan 3, 2025
@mahadzaryab1 mahadzaryab1 marked this pull request as ready for review January 3, 2025 03:31
@mahadzaryab1 mahadzaryab1 requested a review from a team as a code owner January 3, 2025 03:31
@mahadzaryab1 mahadzaryab1 requested a review from jkowall January 3, 2025 03:31
@dosubot dosubot bot added the v2 label Jan 3, 2025
@yurishkuro yurishkuro merged commit 0790c2f into jaegertracing:main Jan 3, 2025
56 checks passed
@mahadzaryab1 mahadzaryab1 deleted the api-v3-http-qs branch January 6, 2025 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants