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

feat: include unscoped queries and default the batch size to 7 #4436

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/frontend/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (cfg *Config) RegisterFlagsAndApplyDefaults(string, *flag.FlagSet) {
}

cfg.Config.MaxOutstandingPerTenant = 2000
cfg.Config.MaxBatchSize = 5
cfg.Config.MaxBatchSize = 7
cfg.MaxRetries = 2
cfg.ResponseConsumers = 10
cfg.Search = SearchConfig{
Expand Down
9 changes: 7 additions & 2 deletions modules/frontend/pipeline/async_weight_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,17 @@ func (c weightRequestWare) setTraceQLWeight(req Request) {
if c.Op != traceql.OpNone {
conditions++
}

if c.Attribute.Intrinsic == traceql.IntrinsicNone && c.Attribute.Scope == traceql.AttributeScopeNone {
Copy link
Member

Choose a reason for hiding this comment

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

what are we trying to catch here?

Copy link
Member

Choose a reason for hiding this comment

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

oh, you are looking for unscoped attributes. it may be safer to test spanRequest.AllConditions at the bottom?

i'm fine with this, but perhaps do a bit of testing before we merge?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean something like?:

if heavyQuery  && !spanRequest.AllConditions{
		req.SetWeight(c.weights.TraceQLSearchWeight + 1)
	}

Copy link
Member

Choose a reason for hiding this comment

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

apologies, i meant to edit this comment and got sidetracked. AllConditions will only be true if its a single spanset selector will all conditions &&'ed. It will be true even with unscoped attributes, so it will be true on both of these:

{ span.foo = "bar" && resource.baz = "bat" }
{  .foo = "bar" && .baz = "bat" }

If AllConditions is false -OR- there are unscoped attributes the querier is a heavier query b/c it cannot be evaluated in the fetch layer and requires the engine.

It's possible that both unscoped attributes and AllConditions false should result in TraceQLSerachWeight + 1 but would need some testing.

conditions++
}

if c.Op == traceql.OpRegex || c.Op == traceql.OpNotRegex {
regexConditions++
}
}
complexQuery := regexConditions >= c.weights.MaxRegexConditions || conditions >= c.weights.MaxTraceQLConditions
if complexQuery {
heavyQuery := regexConditions >= c.weights.MaxRegexConditions || conditions >= c.weights.MaxTraceQLConditions
if heavyQuery {
req.SetWeight(c.weights.TraceQLSearchWeight + 1)
}
}
5 changes: 5 additions & 0 deletions modules/frontend/pipeline/async_weight_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ func TestWeightMiddlewareForTraceQLRequest(t *testing.T) {
req: "http://localhost:8080/api/search?query={span.http.method = \"DELETE\" || status != ok || span.http.status_code >= 200 || span.http.status_code < 300 }",
expected: TraceQLSearchWeight + 1,
},
{
// unscoped query, complex query
req: "http://localhost:8080/api/search?query={status != ok || .http.status_code >= 200 || .http.status_code < 300 }",
expected: TraceQLSearchWeight + 1,
},
}
for _, c := range cases {
actual := DoWeightedRequest(t, c.req, roundTrip)
Expand Down
Loading