From 4c1287bf138c35de75ed8c14fbea85c86095f213 Mon Sep 17 00:00:00 2001 From: javiermolinar Date: Wed, 11 Dec 2024 10:48:44 +0100 Subject: [PATCH 1/3] include unscoped queries and default the batch size to 7 --- modules/frontend/config.go | 2 +- modules/frontend/pipeline/async_weight_middleware.go | 9 +++++++-- .../frontend/pipeline/async_weight_middleware_test.go | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/frontend/config.go b/modules/frontend/config.go index a6ac3d9f074..178324ae3bb 100644 --- a/modules/frontend/config.go +++ b/modules/frontend/config.go @@ -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{ diff --git a/modules/frontend/pipeline/async_weight_middleware.go b/modules/frontend/pipeline/async_weight_middleware.go index 7ba18cde2c6..bff6a944490 100644 --- a/modules/frontend/pipeline/async_weight_middleware.go +++ b/modules/frontend/pipeline/async_weight_middleware.go @@ -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 { + 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) } } diff --git a/modules/frontend/pipeline/async_weight_middleware_test.go b/modules/frontend/pipeline/async_weight_middleware_test.go index ae4f63f8b5a..cc553856543 100644 --- a/modules/frontend/pipeline/async_weight_middleware_test.go +++ b/modules/frontend/pipeline/async_weight_middleware_test.go @@ -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) From 05ce98bc7c370c67be175884835e05336c094897 Mon Sep 17 00:00:00 2001 From: javiermolinar Date: Wed, 11 Dec 2024 12:54:06 +0100 Subject: [PATCH 2/3] add manifest --- .github/workflows/ci.yml | 4 +-- Makefile | 3 +++ docs/sources/tempo/configuration/manifest.md | 2 +- pkg/docsgen/generate_manifest.go | 28 ++++++++++++-------- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e548a1d556e..065ef87e348 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -106,8 +106,8 @@ jobs: - name: Build Tempo run: make tempo - - name: generate-manifest - run: make generate-manifest + - name: check-generated-files + run: make check-generated-files - name: Build tempo-query run: make tempo-query diff --git a/Makefile b/Makefile index 24c5656c72e..d6ea376fae4 100644 --- a/Makefile +++ b/Makefile @@ -376,5 +376,8 @@ endif generate-manifest: GO111MODULE=on CGO_ENABLED=0 go run -v pkg/docsgen/generate_manifest.go +check-generated-files: + GO111MODULE=on CGO_ENABLED=0 go run -v pkg/docsgen/generate_manifest.go -diff + # Import fragments include build/tools.mk diff --git a/docs/sources/tempo/configuration/manifest.md b/docs/sources/tempo/configuration/manifest.md index 982bcf6d759..0b44a7187c3 100644 --- a/docs/sources/tempo/configuration/manifest.md +++ b/docs/sources/tempo/configuration/manifest.md @@ -297,7 +297,7 @@ querier: query_relevant_ingesters: false query_frontend: max_outstanding_per_tenant: 2000 - max_batch_size: 5 + max_batch_size: 7 log_query_request_headers: "" max_retries: 2 search: diff --git a/pkg/docsgen/generate_manifest.go b/pkg/docsgen/generate_manifest.go index 30f47cb43d1..8e4496e5048 100644 --- a/pkg/docsgen/generate_manifest.go +++ b/pkg/docsgen/generate_manifest.go @@ -1,6 +1,7 @@ package main import ( + "flag" "fmt" "log" "os" @@ -42,22 +43,27 @@ func main() { newConfig.Ingester.LifecyclerConfig.InfNames = []string{"eth0"} newConfig.Generator.Ring.InstanceID = hostname + diff := flag.Bool("diff", false, "diff manifest") + flag.Parse() + newConfigBytes, err := yaml.Marshal(newConfig) if err != nil { panic(err) } newManifest := Manifest + "```yaml\n" + string(newConfigBytes) + "```\n" - err = os.WriteFile(ManifestPath, []byte(newManifest), 0o644) - if err != nil { - panic(err) - } - - cmd := exec.Command("git", "diff", "--exit-code", ManifestPath) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - err = cmd.Run() - if err != nil { - log.Fatalf("The manifest with the default Tempo configuration has changed. Please run '%s' and commit the changes.", Cmd) + if *diff { + cmd := exec.Command("git", "diff", "--exit-code", newManifest) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + err = cmd.Run() + if err != nil { + log.Fatalf("The manifest with the default Tempo configuration has changed. Please run '%s' and commit the changes.", Cmd) + } + } else { + err = os.WriteFile(ManifestPath, []byte(newManifest), 0o644) + if err != nil { + panic(err) + } } } From 185c4fcff15ca6a2e7fd86c490391e1c2741ade2 Mon Sep 17 00:00:00 2001 From: javiermolinar Date: Wed, 11 Dec 2024 13:17:03 +0100 Subject: [PATCH 3/3] print the diff --- pkg/docsgen/generate_manifest.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/docsgen/generate_manifest.go b/pkg/docsgen/generate_manifest.go index 8e4496e5048..f05cc9b4ebc 100644 --- a/pkg/docsgen/generate_manifest.go +++ b/pkg/docsgen/generate_manifest.go @@ -5,10 +5,11 @@ import ( "fmt" "log" "os" - "os/exec" "github.com/grafana/tempo/cmd/tempo/app" "gopkg.in/yaml.v3" + + "github.com/google/go-cmp/cmp" ) const ManifestPath = "docs/sources/tempo/configuration/manifest.md" @@ -53,12 +54,14 @@ func main() { newManifest := Manifest + "```yaml\n" + string(newConfigBytes) + "```\n" if *diff { - cmd := exec.Command("git", "diff", "--exit-code", newManifest) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - err = cmd.Run() + b, err := os.ReadFile(ManifestPath) if err != nil { - log.Fatalf("The manifest with the default Tempo configuration has changed. Please run '%s' and commit the changes.", Cmd) + panic(err) + } + manifest := string(b) + diff := cmp.Diff(newManifest, manifest) + if diff != "" { + log.Fatalf(`The manifest with the default Tempo configuration has changed. Please run "make generate-manifest" and commit the changes. Diff:\n%s`, diff) } } else { err = os.WriteFile(ManifestPath, []byte(newManifest), 0o644)