PLT-7810 Track if an APIv3 endpoint was used in the last day (#7744)
* Track if an APIv3 endpoint was used in the last day * Make it atomic
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
709ef99eca
Коммит
23e4b4a27d
@@ -8,6 +8,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
l4g "github.com/alecthomas/log4go"
|
l4g "github.com/alecthomas/log4go"
|
||||||
@@ -216,6 +217,10 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
c.CheckTeamId()
|
c.CheckTeamId()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if h.isApi {
|
||||||
|
atomic.StoreInt32(model.UsedApiV3, 1)
|
||||||
|
}
|
||||||
|
|
||||||
if c.Err == nil {
|
if c.Err == nil {
|
||||||
h.handleFunc(c, w, r)
|
h.handleFunc(c, w, r)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"sync/atomic"
|
||||||
|
|
||||||
"github.com/mattermost/mattermost-server/model"
|
"github.com/mattermost/mattermost-server/model"
|
||||||
"github.com/mattermost/mattermost-server/utils"
|
"github.com/mattermost/mattermost-server/utils"
|
||||||
@@ -171,7 +172,10 @@ func (a *App) trackActivity() {
|
|||||||
"public_channels_deleted": deletedPublicChannelCount,
|
"public_channels_deleted": deletedPublicChannelCount,
|
||||||
"private_channels_deleted": deletedPrivateChannelCount,
|
"private_channels_deleted": deletedPrivateChannelCount,
|
||||||
"posts": postsCount,
|
"posts": postsCount,
|
||||||
|
"used_apiv3": atomic.LoadInt32(model.UsedApiV3) == 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
atomic.StoreInt32(model.UsedApiV3, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) trackConfig() {
|
func (a *App) trackConfig() {
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import (
|
|||||||
l4g "github.com/alecthomas/log4go"
|
l4g "github.com/alecthomas/log4go"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var UsedApiV3 *int32 = new(int32)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
HEADER_REQUEST_ID = "X-Request-ID"
|
HEADER_REQUEST_ID = "X-Request-ID"
|
||||||
HEADER_VERSION_ID = "X-Version-ID"
|
HEADER_VERSION_ID = "X-Version-ID"
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user