[MM-54132] Use annotated logger for log messages from jobs (#24275)

Этот коммит содержится в:
Ben Schumacher
2023-09-07 08:50:22 +02:00
коммит произвёл GitHub
родитель fcfcbd9909
Коммит 30b12f199b
120 изменённых файлов: 1064 добавлений и 1111 удалений

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

@@ -11,6 +11,7 @@ import (
"time"
"github.com/mattermost/mattermost/server/public/model"
"github.com/mattermost/mattermost/server/public/shared/request"
"github.com/mattermost/mattermost/server/v8/channels/store"
"github.com/mattermost/mattermost/server/v8/einterfaces"
)
@@ -4480,10 +4481,10 @@ func (s *TimerLayerJobStore) Delete(id string) (string, error) {
return result, err
}
func (s *TimerLayerJobStore) Get(id string) (*model.Job, error) {
func (s *TimerLayerJobStore) Get(c *request.Context, id string) (*model.Job, error) {
start := time.Now()
result, err := s.JobStore.Get(id)
result, err := s.JobStore.Get(c, id)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -4496,10 +4497,10 @@ func (s *TimerLayerJobStore) Get(id string) (*model.Job, error) {
return result, err
}
func (s *TimerLayerJobStore) GetAllByStatus(status string) ([]*model.Job, error) {
func (s *TimerLayerJobStore) GetAllByStatus(c *request.Context, status string) ([]*model.Job, error) {
start := time.Now()
result, err := s.JobStore.GetAllByStatus(status)
result, err := s.JobStore.GetAllByStatus(c, status)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -4512,10 +4513,10 @@ func (s *TimerLayerJobStore) GetAllByStatus(status string) ([]*model.Job, error)
return result, err
}
func (s *TimerLayerJobStore) GetAllByType(jobType string) ([]*model.Job, error) {
func (s *TimerLayerJobStore) GetAllByType(c *request.Context, jobType string) ([]*model.Job, error) {
start := time.Now()
result, err := s.JobStore.GetAllByType(jobType)
result, err := s.JobStore.GetAllByType(c, jobType)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -4528,10 +4529,10 @@ func (s *TimerLayerJobStore) GetAllByType(jobType string) ([]*model.Job, error)
return result, err
}
func (s *TimerLayerJobStore) GetAllByTypeAndStatus(jobType string, status string) ([]*model.Job, error) {
func (s *TimerLayerJobStore) GetAllByTypeAndStatus(c *request.Context, jobType string, status string) ([]*model.Job, error) {
start := time.Now()
result, err := s.JobStore.GetAllByTypeAndStatus(jobType, status)
result, err := s.JobStore.GetAllByTypeAndStatus(c, jobType, status)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -4544,10 +4545,10 @@ func (s *TimerLayerJobStore) GetAllByTypeAndStatus(jobType string, status string
return result, err
}
func (s *TimerLayerJobStore) GetAllByTypePage(jobType string, offset int, limit int) ([]*model.Job, error) {
func (s *TimerLayerJobStore) GetAllByTypePage(c *request.Context, jobType string, offset int, limit int) ([]*model.Job, error) {
start := time.Now()
result, err := s.JobStore.GetAllByTypePage(jobType, offset, limit)
result, err := s.JobStore.GetAllByTypePage(c, jobType, offset, limit)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -4560,10 +4561,10 @@ func (s *TimerLayerJobStore) GetAllByTypePage(jobType string, offset int, limit
return result, err
}
func (s *TimerLayerJobStore) GetAllByTypesPage(jobTypes []string, offset int, limit int) ([]*model.Job, error) {
func (s *TimerLayerJobStore) GetAllByTypesPage(c *request.Context, jobTypes []string, offset int, limit int) ([]*model.Job, error) {
start := time.Now()
result, err := s.JobStore.GetAllByTypesPage(jobTypes, offset, limit)
result, err := s.JobStore.GetAllByTypesPage(c, jobTypes, offset, limit)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
@@ -4576,22 +4577,6 @@ func (s *TimerLayerJobStore) GetAllByTypesPage(jobTypes []string, offset int, li
return result, err
}
func (s *TimerLayerJobStore) GetAllPage(offset int, limit int) ([]*model.Job, error) {
start := time.Now()
result, err := s.JobStore.GetAllPage(offset, limit)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
success := "false"
if err == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("JobStore.GetAllPage", success, elapsed)
}
return result, err
}
func (s *TimerLayerJobStore) GetCountByStatusAndType(status string, jobType string) (int64, error) {
start := time.Now()