summaryrefslogtreecommitdiffstats
path: root/api4/post.go
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2017-09-25 21:44:44 +0100
committerChristopher Speller <crspeller@gmail.com>2017-09-25 13:44:44 -0700
commite8ca3d64f46d08dbdc3c0d8921ffc1a798104a32 (patch)
tree35cb0339dae9a6d6be4159d6bf82717796fdf810 /api4/post.go
parent81c18a01bd22437457da04b6cdb8d409beb54446 (diff)
downloadchat-e8ca3d64f46d08dbdc3c0d8921ffc1a798104a32.tar.gz
chat-e8ca3d64f46d08dbdc3c0d8921ffc1a798104a32.tar.bz2
chat-e8ca3d64f46d08dbdc3c0d8921ffc1a798104a32.zip
PLT-7470: Add metrics for searches. (#7507)
Diffstat (limited to 'api4/post.go')
-rw-r--r--api4/post.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/api4/post.go b/api4/post.go
index 297c70a87..0cd791c6f 100644
--- a/api4/post.go
+++ b/api4/post.go
@@ -6,8 +6,10 @@ package api4
import (
"net/http"
"strconv"
+ "time"
l4g "github.com/alecthomas/log4go"
+
"github.com/mattermost/mattermost-server/app"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
@@ -299,7 +301,17 @@ func searchPosts(c *Context, w http.ResponseWriter, r *http.Request) {
isOrSearch, _ := props["is_or_search"].(bool)
+ startTime := time.Now()
+
posts, err := c.App.SearchPostsInTeam(terms, c.Session.UserId, c.Params.TeamId, isOrSearch)
+
+ elapsedTime := float64(time.Since(startTime)) / float64(time.Second)
+ metrics := c.App.Metrics
+ if metrics != nil {
+ metrics.IncrementPostsSearchCounter()
+ metrics.ObservePostsSearchDuration(elapsedTime)
+ }
+
if err != nil {
c.Err = err
return