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

[refactor][query] Propagate RawTraces flag to query service #6438

Merged
merged 17 commits into from
Dec 28, 2024

Conversation

mahadzaryab1
Copy link
Collaborator

@mahadzaryab1 mahadzaryab1 commented Dec 28, 2024

Which problem is this PR solving?

Description of the changes

  • This PR defines GetTraceParamaters and TraceQueryParameters inside package querysvc that are currently just wrappers around their package spanstore counterparts.
  • This is done so that additional parameters can be passed into the query service, like the RawTraces flag, without having to extend the parameters that are passed into the storage implementations.

How was this change tested?

  • CI

Checklist

Copy link

codecov bot commented Dec 28, 2024

Codecov Report

Attention: Patch coverage is 98.13084% with 2 lines in your changes missing coverage. Please review.

Project coverage is 96.26%. Comparing base (e7a0205) to head (aa57f7d).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/query/app/apiv3/http_gateway.go 91.30% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6438      +/-   ##
==========================================
+ Coverage   96.23%   96.26%   +0.02%     
==========================================
  Files         368      368              
  Lines       20978    21028      +50     
==========================================
+ Hits        20189    20242      +53     
+ Misses        604      602       -2     
+ Partials      185      184       -1     
Flag Coverage Δ
badger_v1 10.56% <0.00%> (ø)
badger_v2 2.42% <0.00%> (ø)
cassandra-4.x-v1-manual 16.45% <0.00%> (ø)
cassandra-4.x-v2-auto 2.36% <0.00%> (ø)
cassandra-4.x-v2-manual 2.36% <0.00%> (ø)
cassandra-5.x-v1-manual 16.45% <0.00%> (ø)
cassandra-5.x-v2-auto 2.36% <0.00%> (ø)
cassandra-5.x-v2-manual 2.36% <0.00%> (ø)
elasticsearch-6.x-v1 20.20% <0.00%> (+<0.01%) ⬆️
elasticsearch-7.x-v1 20.27% <0.00%> (+<0.01%) ⬆️
elasticsearch-8.x-v1 20.43% <0.00%> (+<0.01%) ⬆️
elasticsearch-8.x-v2 2.42% <0.00%> (+<0.01%) ⬆️
grpc_v1 12.23% <0.00%> (+<0.01%) ⬆️
grpc_v2 8.82% <0.00%> (+<0.01%) ⬆️
kafka-3.x-v1 10.40% <0.00%> (ø)
kafka-3.x-v2 2.42% <0.00%> (ø)
memory_v2 2.42% <0.00%> (ø)
opensearch-1.x-v1 20.32% <0.00%> (ø)
opensearch-2.x-v1 20.32% <0.00%> (ø)
opensearch-2.x-v2 2.42% <0.00%> (+<0.01%) ⬆️
tailsampling-processor 0.39% <0.00%> (ø)
unittests 95.12% <98.13%> (+0.02%) ⬆️

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.

Signed-off-by: Mahad Zaryab <[email protected]>
@mahadzaryab1 mahadzaryab1 changed the title [refactor][query] Define GetTraceParameters and TraceQueryParameters in query service [refactor][query] Propagate RawTraces flag to query service Dec 28, 2024
Signed-off-by: Mahad Zaryab <[email protected]>
{
name: "TestGetTraceWithInvalidRawTraces",
requestUrl: "/api/v3/traces/123?query.raw_traces=foobar",
expectedError: "malformed parameter query.raw_traces",
Copy link
Member

Choose a reason for hiding this comment

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

curious - why above error messages did not include query. prefix for param name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

It's confusing to me why that's the case (this can be seen in the swagger file). But, regardless, according to swagger.json, when the url is traces/?... it's interpreted as FindTraces and all params have the query. prefix, but if the url is traces/{traceID}?... then it's the GetTrace method and the params don't have the prefix. Meaning that the above example is an invalid query.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Got it! Thanks for the explanation - I fixed this now to have two constants.

var response structuredResponse
err := getJSON(ts.server.URL+`/api/traces/`+mockTraceID.String()+`?raw=true`, &response)
require.NoError(t, err)
assert.Empty(t, response.Errors)
Copy link
Member

Choose a reason for hiding this comment

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

the more accurate test would be to use a mock trace that has a known issue that adjusters would fix (e.g. same ID for client/server spans), run the query twice with raw=true|false, and observe the difference in the output.

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 Agreed. But this PR doesn't actually implement the differentiating logic but rather just passes the flag down. That will happen in #6423.

return false, true
}

func (aH *APIHandler) parseGetTraceParameters(w http.ResponseWriter, r *http.Request) (querysvc.GetTraceParameters, bool) {
Copy link
Member

Choose a reason for hiding this comment

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

Side note: this function is poorly designed. A better design is query_parser.parseTraceQueryParams, which simply returns errors. The aH.handleError should really be used only rarely, directly in the handler function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

do we want to address this in a future PR?

Copy link
Member

Choose a reason for hiding this comment

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

it's one of these nice to have clean-ups, I'd rather have it as good-first-issue for someone other than you spending time on it.

}

// ArchiveTrace is the queryService utility to archive traces.
func (qs QueryService) ArchiveTrace(ctx context.Context, query spanstore.GetTraceParameters) error {
func (qs QueryService) ArchiveTrace(ctx context.Context, query GetTraceParameters) error {
Copy link
Member

Choose a reason for hiding this comment

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

should this remain spanstore.GetTraceParameters? Or ArchiveTraceParameters, but Get with raw doesn't apply here.

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 Thanks for catching. This was an oversight - I reverted it back for now. We can always create a separate type here if we need to in the future.

@mahadzaryab1
Copy link
Collaborator Author

mahadzaryab1 commented Dec 28, 2024

@yurishkuro I think there are two lines that are missing code coverage at the moment in the http_gateway.go. It should be taken care of in the next PR as I will add tests to all the handlers to ensure that the RawTraces flag is being respected but let me know if you prefer adding some boilerplate tests in this PR to get codecov up to 100%.

@yurishkuro yurishkuro merged commit a6616fb into jaegertracing:main Dec 28, 2024
54 checks passed
@mahadzaryab1 mahadzaryab1 deleted the query-service-params 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