Add mutex to prevent handler precision from changing during parse (#4373)

(cherry picked from commit 0ef12f87af)
This commit is contained in:
Daniel Nelson 2018-07-03 11:35:39 -07:00 committed by Daniel Nelson
parent e17bec720c
commit 7316e9dac3
No known key found for this signature in database
GPG Key ID: CAAD59C9444F6155
1 changed files with 3 additions and 0 deletions

View File

@ -343,6 +343,9 @@ func (h *HTTPListener) serveWrite(res http.ResponseWriter, req *http.Request) {
}
func (h *HTTPListener) parse(b []byte, t time.Time, precision string) error {
h.mu.Lock()
defer h.mu.Unlock()
h.handler.SetTimePrecision(getPrecisionMultiplier(precision))
h.handler.SetTimeFunc(func() time.Time { return t })
metrics, err := h.parser.Parse(b)