Skip to content

Commit

Permalink
add fingerprint function
Browse files Browse the repository at this point in the history
  • Loading branch information
eze-kiel committed Feb 24, 2021
1 parent 003c1bb commit ef9b7a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func main() {
if q.Query == "" {
break
}
fmt.Printf("Time: %s\nUser: %s\nHost: %s\nID: %d\nSchema: %s\nLast_errno: %d\nKilled: %d\nQuery_time: %s\nLock_time: %s\nRows_sent: %d\nRows_examined: %d\nRows_affected: %d\nBytes_sent: %d\nQuery: %s\n\n",
fmt.Printf("Time: %s\nUser: %s\nHost: %s\nID: %d\nSchema: %s\nLast_errno: %d\nKilled: %d\nQuery_time: %s\nLock_time: %s\nRows_sent: %d\nRows_examined: %d\nRows_affected: %d\nBytes_sent: %d\nQuery: %s\n",
q.Time,
q.User,
q.Host,
Expand Down
8 changes: 6 additions & 2 deletions slowql.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package slowql

import (
"bufio"
"crypto/md5"
"fmt"
"io"
"regexp"
"strconv"
Expand Down Expand Up @@ -57,8 +59,10 @@ func (p Parser) GetNext() (Query, error) {
}

// Fingerprint returns Query.query's MD5 fingerprint
func (q *Query) Fingerprint() {

func (q Query) Fingerprint() string {
h := md5.New()
io.WriteString(h, q.Query)
return fmt.Sprintf("%x", h.Sum(nil))
}

// NewParser creates the stack channel and launches background goroutines
Expand Down

0 comments on commit ef9b7a9

Please sign in to comment.