Skip to content

Commit 4dfeb67

Browse files
committed
Add traces to POSIX
1 parent 7658feb commit 4dfeb67

4 files changed

Lines changed: 341 additions & 299 deletions

File tree

storage/gcp/gcp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ func (s *spannerCoordinator) assignEntries(ctx context.Context, entries []*tesse
913913
}
914914

915915
return nil
916-
}, trace.WithAttributes(otel.PeriodicKey.Bool(true)))
916+
}, trace.WithAttributes(otel.PeriodicKey.Bool(true)))
917917
}
918918

919919
// addSeqMutation returns a mutation to the Seq table for the given sequence number and entries.

storage/posix/antispam/badger.go

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -121,27 +121,30 @@ func NewAntispam(ctx context.Context, badgerPath string, opts AntispamOpts) (*An
121121
case <-ticker.C:
122122
}
123123

124-
runsInTick = 0
125-
again:
126-
start := time.Now()
127-
runsInTick++
128-
err := db.RunValueLogGC(0.7)
129-
status := "success"
130-
if err != nil {
131-
// We're done, export the number of runs we did.
132-
gcRunsPerTick.Record(ctx, runsInTick)
133-
if errors.Is(err, badger.ErrNoRewrite) {
134-
status = "no_rewrite"
135-
} else {
136-
status = "failure"
124+
_ = otel.TraceErr(ctx, "tessera.antispam.badger.garbage_collect", tracer, func(ctx context.Context, span trace.Span) error {
125+
runsInTick = 0
126+
127+
var err error
128+
for err == nil {
129+
start := time.Now()
130+
runsInTick++
131+
err = db.RunValueLogGC(0.7)
132+
status := "success"
133+
if err != nil {
134+
// We're done, export the number of runs we did.
135+
gcRunsPerTick.Record(ctx, runsInTick)
136+
if errors.Is(err, badger.ErrNoRewrite) {
137+
status = "no_rewrite"
138+
} else {
139+
status = "failure"
140+
}
141+
}
142+
attr := metric.WithAttributes(gcStatusKey.String(status))
143+
gcCounter.Add(ctx, 1, attr)
144+
gcDuration.Record(ctx, float64(time.Since(start).Milliseconds()), attr)
137145
}
138-
}
139-
attr := metric.WithAttributes(gcStatusKey.String(status))
140-
gcCounter.Add(ctx, 1, attr)
141-
gcDuration.Record(ctx, float64(time.Since(start).Milliseconds()), attr)
142-
if err == nil {
143-
goto again
144-
}
146+
return nil
147+
}, trace.WithAttributes(otel.PeriodicKey.Bool(true)))
145148
}
146149
}()
147150

0 commit comments

Comments
 (0)