From 615c830ecc7965afced33607d6aa444815c753e7 Mon Sep 17 00:00:00 2001 From: Alan Bernstein Date: Mon, 24 Apr 2017 11:31:50 -0500 Subject: [PATCH] Move LongQueryTime to Cluster --- cluster.go | 4 ++++ handler.go | 7 +------ server/server.go | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cluster.go b/cluster.go index f92b8c6e9..0d9b60fe3 100644 --- a/cluster.go +++ b/cluster.go @@ -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. diff --git a/handler.go b/handler.go index 3083d4695..d75a60290 100644 --- a/handler.go +++ b/handler.go @@ -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") } diff --git a/server/server.go b/server/server.go index 9ce842376..88ac54296 100644 --- a/server/server.go +++ b/server/server.go @@ -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 }