Skip to content

Commit

Permalink
fix(otelbench): fix limits
Browse files Browse the repository at this point in the history
  • Loading branch information
ernado committed Nov 29, 2024
1 parent 936bc51 commit 4570c40
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions cmd/otelbench/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,28 @@ func newDumpCreateCommand() *cobra.Command {
}
fmt.Println("Clickhouse connection is ready")
tables := []string{
"logs",
"logs_attrs",
"migration",
"metrics_exemplars",
"metrics_exp_histograms",
"metrics_labels",
"metrics_points",
"traces_spans",
"traces_tags",
"migration",
"logs_attrs",
"logs",
}
var files []os.FileInfo
for _, table := range tables {
query := fmt.Sprintf("SELECT * FROM %s.%s", arg.Database, table)
query += " WHERE true"
switch table {
case "logs", "metrics_points", "traces_spans":
tsField := "timestamp"
if table == "traces_spans" {
tsField = "start"
}
if arg.LimitTime > 0 {
query += fmt.Sprintf(" AND timestamp > (now() - toIntervalSecond(%d))", int(arg.LimitTime.Seconds()))
query += fmt.Sprintf(" AND %s > (now() - toIntervalSecond(%d))", tsField, int(arg.LimitTime.Seconds()))
}
}
if arg.LimitCount > 0 {
Expand All @@ -153,10 +157,7 @@ func newDumpCreateCommand() *cobra.Command {
cmd.Stdout = os.Stdout
cmd.Stdin = os.Stdin

fmt.Println("Dumping table", table)
fmt.Println(" Query:", query)
fmt.Println(" Command:", cmd.String())

fmt.Println(">", table)
if err := cmd.Run(); err != nil {
return errors.Wrapf(err, "dump table %s", table)
}
Expand All @@ -169,15 +170,14 @@ func newDumpCreateCommand() *cobra.Command {
files = append(files, stat)
}

fmt.Println("Dumps:")
var totalBytes int64
for _, file := range files {
totalBytes += file.Size()
// Pad to 35 characters, align left.
fmt.Printf(" %35s %s\n", file.Name(), humanize.Bytes(uint64(file.Size())))
}

fmt.Println("--------")
fmt.Printf(" %35s \n", "--------")
fmt.Printf(" %35s %s\n", "Total", humanize.Bytes(uint64(totalBytes)))

return nil
Expand Down

0 comments on commit 4570c40

Please sign in to comment.