diff --git a/pkg/services/playlist/playlistimpl/playlist.go b/pkg/services/playlist/playlistimpl/playlist.go index ee6a000c627..65dbdd35987 100644 --- a/pkg/services/playlist/playlistimpl/playlist.go +++ b/pkg/services/playlist/playlistimpl/playlist.go @@ -4,34 +4,47 @@ import ( "context" "github.com/grafana/grafana/pkg/infra/db" + "github.com/grafana/grafana/pkg/infra/tracing" "github.com/grafana/grafana/pkg/services/playlist" ) type Service struct { - store store + store store + tracer tracing.Tracer } var _ playlist.Service = &Service{} -func ProvideService(db db.DB) playlist.Service { - return &Service{store: &sqlStore{ - db: db, - }} +func ProvideService(db db.DB, tracer tracing.Tracer) playlist.Service { + return &Service{ + tracer: tracer, + store: &sqlStore{ + db: db, + }, + } } func (s *Service) Create(ctx context.Context, cmd *playlist.CreatePlaylistCommand) (*playlist.Playlist, error) { + ctx, span := s.tracer.Start(ctx, "playlists.Create") + defer span.End() return s.store.Insert(ctx, cmd) } func (s *Service) Update(ctx context.Context, cmd *playlist.UpdatePlaylistCommand) (*playlist.PlaylistDTO, error) { + ctx, span := s.tracer.Start(ctx, "playlists.Update") + defer span.End() return s.store.Update(ctx, cmd) } func (s *Service) GetWithoutItems(ctx context.Context, q *playlist.GetPlaylistByUidQuery) (*playlist.Playlist, error) { + ctx, span := s.tracer.Start(ctx, "playlists.GetWithoutItems") + defer span.End() return s.store.Get(ctx, q) } func (s *Service) Get(ctx context.Context, q *playlist.GetPlaylistByUidQuery) (*playlist.PlaylistDTO, error) { + ctx, span := s.tracer.Start(ctx, "playlists.Get") + defer span.End() v, err := s.store.Get(ctx, q) if err != nil { return nil, err @@ -66,9 +79,13 @@ func (s *Service) Get(ctx context.Context, q *playlist.GetPlaylistByUidQuery) (* } func (s *Service) Search(ctx context.Context, q *playlist.GetPlaylistsQuery) (playlist.Playlists, error) { + ctx, span := s.tracer.Start(ctx, "playlists.Search") + defer span.End() return s.store.List(ctx, q) } func (s *Service) Delete(ctx context.Context, cmd *playlist.DeletePlaylistCommand) error { + ctx, span := s.tracer.Start(ctx, "playlists.Delete") + defer span.End() return s.store.Delete(ctx, cmd) }