[MM-55595] Use annotated logger in search layer (#25468)

Этот коммит содержится в:
Ben Schumacher
2023-12-04 18:34:57 +01:00
коммит произвёл GitHub
родитель 5a4dba8809
Коммит b2ec1ff8ae
130 изменённых файлов: 2107 добавлений и 1930 удалений

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

@@ -631,10 +631,10 @@ func (s *TimerLayerChannelStore) AnalyticsTypeCount(teamID string, channelType m
return result, err
}
func (s *TimerLayerChannelStore) Autocomplete(userID string, term string, includeDeleted bool, isGuest bool) (model.ChannelListWithTeamData, error) {
func (s *TimerLayerChannelStore) Autocomplete(rctx request.CTX, userID string, term string, includeDeleted bool, isGuest bool) (model.ChannelListWithTeamData, error) {
start := time.Now()
result, err := s.ChannelStore.Autocomplete(userID, term, includeDeleted, isGuest)
result, err := s.ChannelStore.Autocomplete(rctx, userID, term, includeDeleted, isGuest)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -647,10 +647,10 @@ func (s *TimerLayerChannelStore) Autocomplete(userID string, term string, includ
return result, err
}
func (s *TimerLayerChannelStore) AutocompleteInTeam(teamID string, userID string, term string, includeDeleted bool, isGuest bool) (model.ChannelList, error) {
func (s *TimerLayerChannelStore) AutocompleteInTeam(rctx request.CTX, teamID string, userID string, term string, includeDeleted bool, isGuest bool) (model.ChannelList, error) {
start := time.Now()
result, err := s.ChannelStore.AutocompleteInTeam(teamID, userID, term, includeDeleted, isGuest)
result, err := s.ChannelStore.AutocompleteInTeam(rctx, teamID, userID, term, includeDeleted, isGuest)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -773,10 +773,10 @@ func (s *TimerLayerChannelStore) CountUrgentPostsAfter(channelID string, timesta
return result, err
}
func (s *TimerLayerChannelStore) CreateDirectChannel(userID *model.User, otherUserID *model.User, channelOptions ...model.ChannelOption) (*model.Channel, error) {
func (s *TimerLayerChannelStore) CreateDirectChannel(ctx request.CTX, userID *model.User, otherUserID *model.User, channelOptions ...model.ChannelOption) (*model.Channel, error) {
start := time.Now()
result, err := s.ChannelStore.CreateDirectChannel(userID, otherUserID, channelOptions...)
result, err := s.ChannelStore.CreateDirectChannel(ctx, userID, otherUserID, channelOptions...)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -1950,10 +1950,10 @@ func (s *TimerLayerChannelStore) MigrateChannelMembers(fromChannelID string, fro
return result, err
}
func (s *TimerLayerChannelStore) PermanentDelete(channelID string) error {
func (s *TimerLayerChannelStore) PermanentDelete(ctx request.CTX, channelID string) error {
start := time.Now()
err := s.ChannelStore.PermanentDelete(channelID)
err := s.ChannelStore.PermanentDelete(ctx, channelID)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -1982,10 +1982,10 @@ func (s *TimerLayerChannelStore) PermanentDeleteByTeam(teamID string) error {
return err
}
func (s *TimerLayerChannelStore) PermanentDeleteMembersByChannel(channelID string) error {
func (s *TimerLayerChannelStore) PermanentDeleteMembersByChannel(ctx request.CTX, channelID string) error {
start := time.Now()
err := s.ChannelStore.PermanentDeleteMembersByChannel(channelID)
err := s.ChannelStore.PermanentDeleteMembersByChannel(ctx, channelID)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -1998,10 +1998,10 @@ func (s *TimerLayerChannelStore) PermanentDeleteMembersByChannel(channelID strin
return err
}
func (s *TimerLayerChannelStore) PermanentDeleteMembersByUser(userID string) error {
func (s *TimerLayerChannelStore) PermanentDeleteMembersByUser(ctx request.CTX, userID string) error {
start := time.Now()
err := s.ChannelStore.PermanentDeleteMembersByUser(userID)
err := s.ChannelStore.PermanentDeleteMembersByUser(ctx, userID)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -2014,10 +2014,10 @@ func (s *TimerLayerChannelStore) PermanentDeleteMembersByUser(userID string) err
return err
}
func (s *TimerLayerChannelStore) RemoveAllDeactivatedMembers(channelID string) error {
func (s *TimerLayerChannelStore) RemoveAllDeactivatedMembers(ctx request.CTX, channelID string) error {
start := time.Now()
err := s.ChannelStore.RemoveAllDeactivatedMembers(channelID)
err := s.ChannelStore.RemoveAllDeactivatedMembers(ctx, channelID)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -2030,10 +2030,10 @@ func (s *TimerLayerChannelStore) RemoveAllDeactivatedMembers(channelID string) e
return err
}
func (s *TimerLayerChannelStore) RemoveMember(channelID string, userID string) error {
func (s *TimerLayerChannelStore) RemoveMember(ctx request.CTX, channelID string, userID string) error {
start := time.Now()
err := s.ChannelStore.RemoveMember(channelID, userID)
err := s.ChannelStore.RemoveMember(ctx, channelID, userID)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -2046,10 +2046,10 @@ func (s *TimerLayerChannelStore) RemoveMember(channelID string, userID string) e
return err
}
func (s *TimerLayerChannelStore) RemoveMembers(channelID string, userIds []string) error {
func (s *TimerLayerChannelStore) RemoveMembers(ctx request.CTX, channelID string, userIds []string) error {
start := time.Now()
err := s.ChannelStore.RemoveMembers(channelID, userIds)
err := s.ChannelStore.RemoveMembers(ctx, channelID, userIds)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -2110,10 +2110,10 @@ func (s *TimerLayerChannelStore) Save(channel *model.Channel, maxChannelsPerTeam
return result, err
}
func (s *TimerLayerChannelStore) SaveDirectChannel(channel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) (*model.Channel, error) {
func (s *TimerLayerChannelStore) SaveDirectChannel(ctx request.CTX, channel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) (*model.Channel, error) {
start := time.Now()
result, err := s.ChannelStore.SaveDirectChannel(channel, member1, member2)
result, err := s.ChannelStore.SaveDirectChannel(ctx, channel, member1, member2)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -2286,10 +2286,10 @@ func (s *TimerLayerChannelStore) SetShared(channelId string, shared bool) error
return err
}
func (s *TimerLayerChannelStore) Update(channel *model.Channel) (*model.Channel, error) {
func (s *TimerLayerChannelStore) Update(ctx request.CTX, channel *model.Channel) (*model.Channel, error) {
start := time.Now()
result, err := s.ChannelStore.Update(channel)
result, err := s.ChannelStore.Update(ctx, channel)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -2334,10 +2334,10 @@ func (s *TimerLayerChannelStore) UpdateLastViewedAtPost(unreadPost *model.Post,
return result, err
}
func (s *TimerLayerChannelStore) UpdateMember(member *model.ChannelMember) (*model.ChannelMember, error) {
func (s *TimerLayerChannelStore) UpdateMember(ctx request.CTX, member *model.ChannelMember) (*model.ChannelMember, error) {
start := time.Now()
result, err := s.ChannelStore.UpdateMember(member)
result, err := s.ChannelStore.UpdateMember(ctx, member)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -3277,10 +3277,10 @@ func (s *TimerLayerEmojiStore) Search(name string, prefixOnly bool, limit int) (
return result, err
}
func (s *TimerLayerFileInfoStore) AttachToPost(fileID string, postID string, channelID string, creatorID string) error {
func (s *TimerLayerFileInfoStore) AttachToPost(c request.CTX, fileID string, postID string, channelID string, creatorID string) error {
start := time.Now()
err := s.FileInfoStore.AttachToPost(fileID, postID, channelID, creatorID)
err := s.FileInfoStore.AttachToPost(c, fileID, postID, channelID, creatorID)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -3324,10 +3324,10 @@ func (s *TimerLayerFileInfoStore) CountAll() (int64, error) {
return result, err
}
func (s *TimerLayerFileInfoStore) DeleteForPost(postID string) (string, error) {
func (s *TimerLayerFileInfoStore) DeleteForPost(c request.CTX, postID string) (string, error) {
start := time.Now()
result, err := s.FileInfoStore.DeleteForPost(postID)
result, err := s.FileInfoStore.DeleteForPost(c, postID)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -3515,10 +3515,10 @@ func (s *TimerLayerFileInfoStore) InvalidateFileInfosForPostCache(postID string,
}
}
func (s *TimerLayerFileInfoStore) PermanentDelete(fileID string) error {
func (s *TimerLayerFileInfoStore) PermanentDelete(c request.CTX, fileID string) error {
start := time.Now()
err := s.FileInfoStore.PermanentDelete(fileID)
err := s.FileInfoStore.PermanentDelete(c, fileID)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -3531,10 +3531,10 @@ func (s *TimerLayerFileInfoStore) PermanentDelete(fileID string) error {
return err
}
func (s *TimerLayerFileInfoStore) PermanentDeleteBatch(endTime int64, limit int64) (int64, error) {
func (s *TimerLayerFileInfoStore) PermanentDeleteBatch(ctx request.CTX, endTime int64, limit int64) (int64, error) {
start := time.Now()
result, err := s.FileInfoStore.PermanentDeleteBatch(endTime, limit)
result, err := s.FileInfoStore.PermanentDeleteBatch(ctx, endTime, limit)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -3547,10 +3547,10 @@ func (s *TimerLayerFileInfoStore) PermanentDeleteBatch(endTime int64, limit int6
return result, err
}
func (s *TimerLayerFileInfoStore) PermanentDeleteByUser(userID string) (int64, error) {
func (s *TimerLayerFileInfoStore) PermanentDeleteByUser(ctx request.CTX, userID string) (int64, error) {
start := time.Now()
result, err := s.FileInfoStore.PermanentDeleteByUser(userID)
result, err := s.FileInfoStore.PermanentDeleteByUser(ctx, userID)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -3563,10 +3563,10 @@ func (s *TimerLayerFileInfoStore) PermanentDeleteByUser(userID string) (int64, e
return result, err
}
func (s *TimerLayerFileInfoStore) Save(info *model.FileInfo) (*model.FileInfo, error) {
func (s *TimerLayerFileInfoStore) Save(ctx request.CTX, info *model.FileInfo) (*model.FileInfo, error) {
start := time.Now()
result, err := s.FileInfoStore.Save(info)
result, err := s.FileInfoStore.Save(ctx, info)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -3579,10 +3579,10 @@ func (s *TimerLayerFileInfoStore) Save(info *model.FileInfo) (*model.FileInfo, e
return result, err
}
func (s *TimerLayerFileInfoStore) Search(paramsList []*model.SearchParams, userID string, teamID string, page int, perPage int) (*model.FileInfoList, error) {
func (s *TimerLayerFileInfoStore) Search(ctx request.CTX, paramsList []*model.SearchParams, userID string, teamID string, page int, perPage int) (*model.FileInfoList, error) {
start := time.Now()
result, err := s.FileInfoStore.Search(paramsList, userID, teamID, page, perPage)
result, err := s.FileInfoStore.Search(ctx, paramsList, userID, teamID, page, perPage)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -3595,10 +3595,10 @@ func (s *TimerLayerFileInfoStore) Search(paramsList []*model.SearchParams, userI
return result, err
}
func (s *TimerLayerFileInfoStore) SetContent(fileID string, content string) error {
func (s *TimerLayerFileInfoStore) SetContent(ctx request.CTX, fileID string, content string) error {
start := time.Now()
err := s.FileInfoStore.SetContent(fileID, content)
err := s.FileInfoStore.SetContent(ctx, fileID, content)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -3611,10 +3611,10 @@ func (s *TimerLayerFileInfoStore) SetContent(fileID string, content string) erro
return err
}
func (s *TimerLayerFileInfoStore) Upsert(info *model.FileInfo) (*model.FileInfo, error) {
func (s *TimerLayerFileInfoStore) Upsert(rctx request.CTX, info *model.FileInfo) (*model.FileInfo, error) {
start := time.Now()
result, err := s.FileInfoStore.Upsert(info)
result, err := s.FileInfoStore.Upsert(rctx, info)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -5530,10 +5530,10 @@ func (s *TimerLayerPostStore) ClearCaches() {
}
}
func (s *TimerLayerPostStore) Delete(postID string, timestamp int64, deleteByID string) error {
func (s *TimerLayerPostStore) Delete(rctx request.CTX, postID string, timestamp int64, deleteByID string) error {
start := time.Now()
err := s.PostStore.Delete(postID, timestamp, deleteByID)
err := s.PostStore.Delete(rctx, postID, timestamp, deleteByID)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -6025,10 +6025,10 @@ func (s *TimerLayerPostStore) InvalidateLastPostTimeCache(channelID string) {
}
}
func (s *TimerLayerPostStore) Overwrite(post *model.Post) (*model.Post, error) {
func (s *TimerLayerPostStore) Overwrite(rctx request.CTX, post *model.Post) (*model.Post, error) {
start := time.Now()
result, err := s.PostStore.Overwrite(post)
result, err := s.PostStore.Overwrite(rctx, post)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -6089,10 +6089,10 @@ func (s *TimerLayerPostStore) PermanentDeleteBatchForRetentionPolicies(now int64
return result, resultVar1, err
}
func (s *TimerLayerPostStore) PermanentDeleteByChannel(channelID string) error {
func (s *TimerLayerPostStore) PermanentDeleteByChannel(rctx request.CTX, channelID string) error {
start := time.Now()
err := s.PostStore.PermanentDeleteByChannel(channelID)
err := s.PostStore.PermanentDeleteByChannel(rctx, channelID)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -6105,10 +6105,10 @@ func (s *TimerLayerPostStore) PermanentDeleteByChannel(channelID string) error {
return err
}
func (s *TimerLayerPostStore) PermanentDeleteByUser(userID string) error {
func (s *TimerLayerPostStore) PermanentDeleteByUser(rctx request.CTX, userID string) error {
start := time.Now()
err := s.PostStore.PermanentDeleteByUser(userID)
err := s.PostStore.PermanentDeleteByUser(rctx, userID)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -6169,10 +6169,10 @@ func (s *TimerLayerPostStore) Search(teamID string, userID string, params *model
return result, err
}
func (s *TimerLayerPostStore) SearchPostsForUser(paramsList []*model.SearchParams, userID string, teamID string, page int, perPage int) (*model.PostSearchResults, error) {
func (s *TimerLayerPostStore) SearchPostsForUser(rctx request.CTX, paramsList []*model.SearchParams, userID string, teamID string, page int, perPage int) (*model.PostSearchResults, error) {
start := time.Now()
result, err := s.PostStore.SearchPostsForUser(paramsList, userID, teamID, page, perPage)
result, err := s.PostStore.SearchPostsForUser(rctx, paramsList, userID, teamID, page, perPage)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -6201,10 +6201,10 @@ func (s *TimerLayerPostStore) SetPostReminder(reminder *model.PostReminder) erro
return err
}
func (s *TimerLayerPostStore) Update(newPost *model.Post, oldPost *model.Post) (*model.Post, error) {
func (s *TimerLayerPostStore) Update(rctx request.CTX, newPost *model.Post, oldPost *model.Post) (*model.Post, error) {
start := time.Now()
result, err := s.PostStore.Update(newPost, oldPost)
result, err := s.PostStore.Update(rctx, newPost, oldPost)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -9047,10 +9047,10 @@ func (s *TimerLayerTeamStore) RemoveAllMembersByTeam(teamID string) error {
return err
}
func (s *TimerLayerTeamStore) RemoveAllMembersByUser(userID string) error {
func (s *TimerLayerTeamStore) RemoveAllMembersByUser(ctx request.CTX, userID string) error {
start := time.Now()
err := s.TeamStore.RemoveAllMembersByUser(userID)
err := s.TeamStore.RemoveAllMembersByUser(ctx, userID)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -9063,10 +9063,10 @@ func (s *TimerLayerTeamStore) RemoveAllMembersByUser(userID string) error {
return err
}
func (s *TimerLayerTeamStore) RemoveMember(teamID string, userID string) error {
func (s *TimerLayerTeamStore) RemoveMember(rctx request.CTX, teamID string, userID string) error {
start := time.Now()
err := s.TeamStore.RemoveMember(teamID, userID)
err := s.TeamStore.RemoveMember(rctx, teamID, userID)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -9079,10 +9079,10 @@ func (s *TimerLayerTeamStore) RemoveMember(teamID string, userID string) error {
return err
}
func (s *TimerLayerTeamStore) RemoveMembers(teamID string, userIds []string) error {
func (s *TimerLayerTeamStore) RemoveMembers(rctx request.CTX, teamID string, userIds []string) error {
start := time.Now()
err := s.TeamStore.RemoveMembers(teamID, userIds)
err := s.TeamStore.RemoveMembers(rctx, teamID, userIds)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -9255,10 +9255,10 @@ func (s *TimerLayerTeamStore) UpdateLastTeamIconUpdate(teamID string, curTime in
return err
}
func (s *TimerLayerTeamStore) UpdateMember(member *model.TeamMember) (*model.TeamMember, error) {
func (s *TimerLayerTeamStore) UpdateMember(rctx request.CTX, member *model.TeamMember) (*model.TeamMember, error) {
start := time.Now()
result, err := s.TeamStore.UpdateMember(member)
result, err := s.TeamStore.UpdateMember(rctx, member)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -10054,10 +10054,10 @@ func (s *TimerLayerUserStore) AnalyticsGetSystemAdminCount() (int64, error) {
return result, err
}
func (s *TimerLayerUserStore) AutocompleteUsersInChannel(teamID string, channelID string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, error) {
func (s *TimerLayerUserStore) AutocompleteUsersInChannel(rctx request.CTX, teamID string, channelID string, term string, options *model.UserSearchOptions) (*model.UserAutocompleteInChannel, error) {
start := time.Now()
result, err := s.UserStore.AutocompleteUsersInChannel(teamID, channelID, term, options)
result, err := s.UserStore.AutocompleteUsersInChannel(rctx, teamID, channelID, term, options)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -10930,10 +10930,10 @@ func (s *TimerLayerUserStore) Save(user *model.User) (*model.User, error) {
return result, err
}
func (s *TimerLayerUserStore) Search(teamID string, term string, options *model.UserSearchOptions) ([]*model.User, error) {
func (s *TimerLayerUserStore) Search(rctx request.CTX, teamID string, term string, options *model.UserSearchOptions) ([]*model.User, error) {
start := time.Now()
result, err := s.UserStore.Search(teamID, term, options)
result, err := s.UserStore.Search(rctx, teamID, term, options)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -11042,10 +11042,10 @@ func (s *TimerLayerUserStore) SearchWithoutTeam(term string, options *model.User
return result, err
}
func (s *TimerLayerUserStore) Update(user *model.User, allowRoleUpdate bool) (*model.UserUpdate, error) {
func (s *TimerLayerUserStore) Update(rctx request.CTX, user *model.User, allowRoleUpdate bool) (*model.UserUpdate, error) {
start := time.Now()
result, err := s.UserStore.Update(user, allowRoleUpdate)
result, err := s.UserStore.Update(rctx, user, allowRoleUpdate)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {