Move LongQueryTime to Cluster

This commit is contained in:
Alan Bernstein 2017-04-24 11:31:50 -05:00
parent 6a162c4be2
commit 615c830ecc
3 changed files with 6 additions and 7 deletions

View file

@ -3,6 +3,7 @@ package pilosa
import (
"encoding/binary"
"hash/fnv"
"time"
)
const (
@ -97,6 +98,9 @@ type Cluster struct {
// The number of replicas a partition has.
ReplicaN int
// Threshold for logging long-running queries
LongQueryTime time.Duration
}
// NewCluster returns a new instance of Cluster with defaults.

View file

@ -41,9 +41,6 @@ type Handler struct {
// The writer for any logging.
LogOutput io.Writer
// Threshold for logging long-running queries
LongQueryTime time.Duration
}
// externalPrefixFlag denotes endpoints that are intended to be exposed to clients.
@ -120,9 +117,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Handle some stats tagging
statsTags := make([]string, 0, 3)
fmt.Printf("long query time: %v\n", h.LongQueryTime)
if h.LongQueryTime > 0 && dif > h.LongQueryTime {
if h.Cluster.LongQueryTime > 0 && dif > h.Cluster.LongQueryTime {
h.logger().Printf("%s %s %.03fs", r.Method, r.URL.String(), float64(dif))
statsTags = append(statsTags, "slow_query")
}

View file

@ -174,7 +174,7 @@ func (m *Command) SetupServer() error {
// Set configuration options.
m.Server.AntiEntropyInterval = time.Duration(m.Config.AntiEntropy.Interval)
m.Server.Handler.LongQueryTime = time.Duration(m.Config.LongQueryTime)
m.Server.Cluster.LongQueryTime = time.Duration(m.Config.LongQueryTime)
return nil
}