@@ -12,6 +12,7 @@ import (
1212 "github.com/coder/coder/v2/coderd/database"
1313 "github.com/coder/coder/v2/coderd/database/dbauthz"
1414 "github.com/coder/coder/v2/coderd/database/dbtime"
15+ "github.com/coder/coder/v2/coderd/pproflabel"
1516 "github.com/coder/quartz"
1617)
1718
@@ -38,7 +39,7 @@ func New(ctx context.Context, logger slog.Logger, db database.Store, clk quartz.
3839
3940 // Start the ticker with the initial delay.
4041 ticker := clk .NewTicker (delay )
41- doTick := func (start time.Time ) {
42+ doTick := func (ctx context. Context , start time.Time ) {
4243 defer ticker .Reset (delay )
4344 // Start a transaction to grab advisory lock, we don't want to run
4445 // multiple purges at the same time (multiple replicas).
@@ -85,21 +86,21 @@ func New(ctx context.Context, logger slog.Logger, db database.Store, clk quartz.
8586 }
8687 }
8788
88- go func () {
89+ pproflabel . Go ( ctx , pproflabel . Service ( pproflabel . ServiceDBPurge ), func (ctx context. Context ) {
8990 defer close (closed )
9091 defer ticker .Stop ()
9192 // Force an initial tick.
92- doTick (dbtime .Time (clk .Now ()).UTC ())
93+ doTick (ctx , dbtime .Time (clk .Now ()).UTC ())
9394 for {
9495 select {
9596 case <- ctx .Done ():
9697 return
9798 case tick := <- ticker .C :
9899 ticker .Stop ()
99- doTick (dbtime .Time (tick ).UTC ())
100+ doTick (ctx , dbtime .Time (tick ).UTC ())
100101 }
101102 }
102- }( )
103+ })
103104 return & instance {
104105 cancel : cancelFunc ,
105106 closed : closed ,
0 commit comments