Skip to content

Commit

Permalink
added statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
eze-kiel committed Mar 10, 2021
1 parent 5717674 commit 43e352c
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion cmd/slowql-digest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import (
"flag"
"io"
"os"
"time"

"github.com/devops-works/slowql"
"github.com/sirupsen/logrus"
)

Expand All @@ -17,6 +19,29 @@ type options struct {
quiet bool
}

type statistics struct {
hash string
fingerprint string
schema string
calls int
cumErrored int
cumKilled int
cumQueryTime time.Time
cumLockTime time.Time
cumRowsSent int
cumRowsExamined int
cumBytesSent int
concurrency float64
minTime time.Time
maxTime time.Time
meanTime time.Time
p50Time time.Time
p95Time time.Time
stddevTime time.Time
}

type results map[string]statistics

func main() {
var opt options
flag.StringVar(&opt.filepath, "file", "", "Slow query log file")
Expand All @@ -32,8 +57,20 @@ func main() {
if err != nil {
logrus.Fatal(err)
}
logrus.Infof("file has %d lines", lines)

p := slowql.NewParser(slowql.PCX, opt.file)
logrus.Debug("slowql parser created successfully")

logrus.Infof("%d lines found", lines)
for {
q := p.GetNext()

// If the query is empty, there is no more queries to get
if q == (slowql.Query{}) {
logrus.Debug("no more queries to get from the slow query log file")
break
}
}
}

// parse parses the different flags
Expand Down

0 comments on commit 43e352c

Please sign in to comment.