-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[api_v3][query] Change api_v3 http handler to use v2 query service #6459
Merged
Merged
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
bab92e8
Remove Helper Function Not Required
mahadzaryab1 976a0e5
Change api_v3 Handler To Use V2 Query Service
mahadzaryab1 cc103c9
Remove Double Translation
mahadzaryab1 19f8120
Merge branch 'main' into api-v3-http-qs
mahadzaryab1 e9bcd49
Fix Get Trace Success Unit Test
mahadzaryab1 adaf93d
Merge branch 'main' into api-v3-http-qs
mahadzaryab1 6595cc3
Remove Aggregation And Return Not Found Error
mahadzaryab1 48b851c
Fix Test Expectations
mahadzaryab1 39c435b
Fix Tests And Regenerate Snapshots
mahadzaryab1 d5c5a58
Move Common Logic To Helper
mahadzaryab1 a7eb115
Add TODO Comment
mahadzaryab1 a56567b
Fix Missing Code Coverage
mahadzaryab1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,15 +15,16 @@ import ( | |
"github.com/gogo/protobuf/jsonpb" | ||
"github.com/gogo/protobuf/proto" | ||
"github.com/gorilla/mux" | ||
"go.opentelemetry.io/collector/pdata/ptrace" | ||
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" | ||
"go.opentelemetry.io/otel/trace" | ||
"go.uber.org/zap" | ||
|
||
"github.com/jaegertracing/jaeger/cmd/query/app/querysvc" | ||
"github.com/jaegertracing/jaeger/cmd/query/app/querysvc/v2/querysvc" | ||
"github.com/jaegertracing/jaeger/internal/proto/api_v3" | ||
"github.com/jaegertracing/jaeger/model" | ||
"github.com/jaegertracing/jaeger/storage/spanstore" | ||
"github.com/jaegertracing/jaeger/storage_v2/tracestore" | ||
"github.com/jaegertracing/jaeger/storage_v2/v1adapter" | ||
) | ||
|
||
const ( | ||
|
@@ -109,15 +110,6 @@ func (h *HTTPGateway) tryParamError(w http.ResponseWriter, err error, paramName | |
} | ||
|
||
func (h *HTTPGateway) returnSpans(spans []*model.Span, w http.ResponseWriter) { | ||
// modelToOTLP does not easily return an error, so allow mocking it | ||
h.returnSpansTestable(spans, w, modelToOTLP) | ||
} | ||
|
||
func (h *HTTPGateway) returnSpansTestable( | ||
spans []*model.Span, | ||
w http.ResponseWriter, | ||
modelToOTLP func(_ []*model.Span) ptrace.Traces, | ||
) { | ||
td := modelToOTLP(spans) | ||
tracesData := api_v3.TracesData(td) | ||
response := &api_v3.GRPCGatewayWrapper{ | ||
|
@@ -137,9 +129,11 @@ func (h *HTTPGateway) getTrace(w http.ResponseWriter, r *http.Request) { | |
if h.tryParamError(w, err, paramTraceID) { | ||
return | ||
} | ||
request := querysvc.GetTraceParameters{ | ||
GetTraceParameters: spanstore.GetTraceParameters{ | ||
TraceID: traceID, | ||
request := querysvc.GetTraceParams{ | ||
TraceIDs: []tracestore.GetTraceParams{ | ||
{ | ||
TraceID: traceID.ToOTELTraceID(), | ||
}, | ||
}, | ||
} | ||
http_query := r.URL.Query() | ||
|
@@ -149,15 +143,15 @@ func (h *HTTPGateway) getTrace(w http.ResponseWriter, r *http.Request) { | |
if h.tryParamError(w, err, paramStartTime) { | ||
return | ||
} | ||
request.StartTime = timeParsed.UTC() | ||
request.TraceIDs[0].Start = timeParsed.UTC() | ||
} | ||
endTime := http_query.Get(paramEndTime) | ||
if endTime != "" { | ||
timeParsed, err := time.Parse(time.RFC3339Nano, endTime) | ||
if h.tryParamError(w, err, paramEndTime) { | ||
return | ||
} | ||
request.EndTime = timeParsed.UTC() | ||
request.TraceIDs[0].End = timeParsed.UTC() | ||
} | ||
if r := http_query.Get(paramRawTraces); r != "" { | ||
rawTraces, err := strconv.ParseBool(r) | ||
|
@@ -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) | ||
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? | ||
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. 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). |
||
return | ||
} | ||
h.returnSpans(trc[0].Spans, w) | ||
} | ||
|
||
func (h *HTTPGateway) findTraces(w http.ResponseWriter, r *http.Request) { | ||
|
@@ -179,7 +178,8 @@ func (h *HTTPGateway) findTraces(w http.ResponseWriter, r *http.Request) { | |
return | ||
} | ||
|
||
traces, err := h.QueryService.FindTraces(r.Context(), queryParams) | ||
findTracesIter := h.QueryService.FindTraces(r.Context(), *queryParams) | ||
traces, err := v1adapter.V1TracesFromSeq2(findTracesIter) | ||
// TODO how do we distinguish internal error from bad parameters for FindTrace? | ||
if h.tryHandleError(w, err, http.StatusInternalServerError) { | ||
return | ||
|
@@ -191,9 +191,9 @@ func (h *HTTPGateway) findTraces(w http.ResponseWriter, r *http.Request) { | |
h.returnSpans(spans, w) | ||
} | ||
|
||
func (h *HTTPGateway) parseFindTracesQuery(q url.Values, w http.ResponseWriter) (*querysvc.TraceQueryParameters, bool) { | ||
queryParams := &querysvc.TraceQueryParameters{ | ||
TraceQueryParameters: spanstore.TraceQueryParameters{ | ||
func (h *HTTPGateway) parseFindTracesQuery(q url.Values, w http.ResponseWriter) (*querysvc.TraceQueryParams, bool) { | ||
queryParams := &querysvc.TraceQueryParams{ | ||
TraceQueryParams: tracestore.TraceQueryParams{ | ||
ServiceName: q.Get(paramServiceName), | ||
OperationName: q.Get(paramOperationName), | ||
Tags: nil, // most curiously not supported by grpc-gateway | ||
|
@@ -262,7 +262,7 @@ func (h *HTTPGateway) getServices(w http.ResponseWriter, r *http.Request) { | |
|
||
func (h *HTTPGateway) getOperations(w http.ResponseWriter, r *http.Request) { | ||
query := r.URL.Query() | ||
queryParams := spanstore.OperationQueryParameters{ | ||
queryParams := tracestore.OperationQueryParams{ | ||
ServiceName: query.Get("service"), | ||
SpanKind: query.Get("span_kind"), | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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
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.
@yurishkuro yep - will fix. I was just trying to wire up the new query service first.