MM-9664 Add invalidation metrics for store caches (#8340)

* Add invalidation metrics for store caches

* Increment session invalidation metric

* Fix tests
Этот коммит содержится в:
Joram Wilander
2018-03-05 10:35:26 -05:00
коммит произвёл GitHub
родитель fbff94f3be
Коммит 4a1802c039
16 изменённых файлов: 130 добавлений и 36 удалений

Просмотреть файл

@@ -26,8 +26,12 @@ const (
var webhookCache = utils.NewLru(WEBHOOK_CACHE_SIZE)
func ClearWebhookCaches() {
func (s SqlWebhookStore) ClearCaches() {
webhookCache.Purge()
if s.metrics != nil {
s.metrics.IncrementMemCacheInvalidationCounter("Webhook - Purge")
}
}
func NewSqlWebhookStore(sqlStore SqlStore, metrics einterfaces.MetricsInterface) store.WebhookStore {
@@ -78,6 +82,9 @@ func (s SqlWebhookStore) CreateIndexesIfNotExists() {
func (s SqlWebhookStore) InvalidateWebhookCache(webhookId string) {
webhookCache.Remove(webhookId)
if s.metrics != nil {
s.metrics.IncrementMemCacheInvalidationCounter("Webhook - Remove by WebhookId")
}
}
func (s SqlWebhookStore) SaveIncoming(webhook *model.IncomingWebhook) store.StoreChannel {
@@ -164,7 +171,7 @@ func (s SqlWebhookStore) PermanentDeleteIncomingByUser(userId string) store.Stor
result.Err = model.NewAppError("SqlWebhookStore.DeleteIncomingByUser", "store.sql_webhooks.permanent_delete_incoming_by_user.app_error", nil, "id="+userId+", err="+err.Error(), http.StatusInternalServerError)
}
ClearWebhookCaches()
s.ClearCaches()
})
}
@@ -175,7 +182,7 @@ func (s SqlWebhookStore) PermanentDeleteIncomingByChannel(channelId string) stor
result.Err = model.NewAppError("SqlWebhookStore.DeleteIncomingByChannel", "store.sql_webhooks.permanent_delete_incoming_by_channel.app_error", nil, "id="+channelId+", err="+err.Error(), http.StatusInternalServerError)
}
ClearWebhookCaches()
s.ClearCaches()
})
}
@@ -322,7 +329,7 @@ func (s SqlWebhookStore) PermanentDeleteOutgoingByChannel(channelId string) stor
result.Err = model.NewAppError("SqlWebhookStore.DeleteOutgoingByChannel", "store.sql_webhooks.permanent_delete_outgoing_by_channel.app_error", nil, "id="+channelId+", err="+err.Error(), http.StatusInternalServerError)
}
ClearWebhookCaches()
s.ClearCaches()
})
}