Skip to content

Commit

Permalink
add -no-column-filters flag
Browse files Browse the repository at this point in the history
  • Loading branch information
tsenart committed Jun 12, 2024
1 parent dfc189e commit 93fd5d1
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions axiom/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,17 @@ func runCmd() command {
iters := fs.Int("iters", 3, "Number of iterations to run each query")
failfast := fs.Bool("failfast", false, "Exit on first error")
noCache := fs.Bool("no-cache", true, "Do not use axiom results caching")
noColumnFilters := fs.Bool("no-column-filters", false, "Do not use axiom column filters")
version := fs.String("version", firstNonZero(gitSha(), "dev"), "Version of the benchmarking client code")
label := fs.String("label", "", "Profile label")

return command{fs, func(args []string) error {
fs.Parse(args)
return run(*version, *apiURL, *traceURL, *org, *token, *label, *iters, *failfast, *noCache)
return run(*version, *apiURL, *traceURL, *org, *token, *label, *iters, *failfast, *noCache, *noColumnFilters)
}}
}

func run(version, apiURL, traceURL, org, token, label string, iters int, failfast, noCache bool) error {
func run(version, apiURL, traceURL, org, token, label string, iters int, failfast, noCache, noColumnFilters bool) error {
if apiURL == "" {
return fmt.Errorf("api-url cannot be empty")
}
Expand Down Expand Up @@ -74,7 +75,7 @@ func run(version, apiURL, traceURL, org, token, label string, iters int, failfas
for sc.Scan() {
query := sc.Text()
if !strings.HasPrefix(query, "//") {
if err := benchmark(ctx, cli, id, query, iters, noCache, enc); err != nil {
if err := benchmark(ctx, cli, id, query, iters, noCache, noColumnFilters, enc); err != nil {
if failfast {
return err
}
Expand All @@ -95,9 +96,9 @@ func gitSha() string {
return strings.TrimSpace(string(sha))
}

func benchmark(ctx context.Context, cli *axiomClient, id int, query string, iters int, noCache bool, enc *json.Encoder) error {
func benchmark(ctx context.Context, cli *axiomClient, id int, query string, iters int, noCache, noColumnFilters bool, enc *json.Encoder) error {
for i := 1; i <= iters; i++ {
result, err := cli.Query(ctx, id, query, noCache)
result, err := cli.Query(ctx, id, query, noCache, noColumnFilters)
if err != nil {
return fmt.Errorf("failed query #%d, iter %d: %w", id, i, err)
}
Expand Down Expand Up @@ -237,10 +238,10 @@ func (c *axiomClient) do(ctx context.Context, rawURL string, id int, body, v any
return resp, nil
}

func (c *axiomClient) query(ctx context.Context, id int, aplQuery string, noCache bool) (*aplQueryResponse, *http.Response, error) {
func (c *axiomClient) query(ctx context.Context, id int, aplQuery string, noCache, noColumnFilters bool) (*aplQueryResponse, *http.Response, error) {
uri := *c.apiURL
uri.Path = path.Join(uri.Path, "v1/datasets/_apl")
uri.RawQuery = fmt.Sprintf("nocache=%t&format=tabular", noCache)
uri.RawQuery = fmt.Sprintf("nocache=%t&nocolumnfilters=%t&format=tabular", noCache, noColumnFilters)

body := struct {
APL string `json:"apl"`
Expand All @@ -257,7 +258,7 @@ func (c *axiomClient) query(ctx context.Context, id int, aplQuery string, noCach
return &r, resp, nil
}

func (c *axiomClient) Query(ctx context.Context, id int, aplQuery string, noCache bool) (*QueryResult, error) {
func (c *axiomClient) Query(ctx context.Context, id int, aplQuery string, noCache, noColumnFilters bool) (*QueryResult, error) {
began := time.Now().UTC()

result := &QueryResult{
Expand All @@ -268,7 +269,7 @@ func (c *axiomClient) Query(ctx context.Context, id int, aplQuery string, noCach
}

var httpErr *httpError
r, httpResp, err := c.query(ctx, id, aplQuery, noCache)
r, httpResp, err := c.query(ctx, id, aplQuery, noCache, noColumnFilters)
if err != nil && !errors.As(err, &httpErr) {
return nil, err
}
Expand Down

0 comments on commit 93fd5d1

Please sign in to comment.