Skip to content

Commit

Permalink
pkg/routine: Drop span
Browse files Browse the repository at this point in the history
  • Loading branch information
monstermunchkin committed Nov 27, 2024
1 parent 4597413 commit 8899ea8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 0 additions & 6 deletions pkg/routine/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"time"

"github.com/getsentry/sentry-go"
"github.com/pace/bricks/maintenance/errors"
"github.com/pace/bricks/pkg/lock/redis"

Expand Down Expand Up @@ -58,11 +57,6 @@ func (r *routineThatKeepsRunningOneInstance) Run(ctx context.Context) {
// until it returns. Return the backoff duration after which another single run
// should be performed.
func (r *routineThatKeepsRunningOneInstance) singleRun(ctx context.Context) time.Duration {
span := sentry.StartSpan(ctx, "function", sentry.WithDescription(fmt.Sprintf("Routine %s", r.Name)))
defer span.Finish()

ctx = span.Context()

l := redis.NewLock("routine:lock:"+r.Name, redis.SetTTL(r.lockTTL))
lockCtx, cancel, err := l.AcquireAndKeepUp(ctx)
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion pkg/routine/routine.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func Run(parentCtx context.Context, routine func(context.Context)) (cancel conte
num := atomic.AddInt64(&ctr, 1)

span := sentry.StartTransaction(ctx, fmt.Sprintf("Routine %d", num), sentry.WithOpName("function"))
defer span.Finish()

ctx = span.Context()

Expand All @@ -110,6 +109,8 @@ func Run(parentCtx context.Context, routine func(context.Context)) (cancel conte
contextsMx.Unlock()
// deregister the above if context is done
go func() {
defer span.Finish()

<-ctx.Done()
// In case of a shutdown, this will block forever. But it doesn't hurt,
// because the program is about to exit anyway.
Expand All @@ -118,6 +119,7 @@ func Run(parentCtx context.Context, routine func(context.Context)) (cancel conte
delete(contexts, num)
}()
go func() {
defer span.Finish()
defer errors.HandleWithCtx(ctx, fmt.Sprintf("routine %d", num)) // handle panics
defer cancel()
routine(ctx)
Expand Down

0 comments on commit 8899ea8

Please sign in to comment.