Skip to content

Commit 81ffdaf

Browse files
committed
export assign/integrate latency
1 parent ebb1588 commit 81ffdaf

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

storage/aws/aws.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,11 @@ func (a *Appender) integrateEntriesJob(ctx context.Context) {
301301
}
302302

303303
if err := otel.TraceErr(ctx, "tessera.storage.aws.integrateEntriesJob", tracer, func(ctx context.Context, span trace.Span) error {
304+
start := time.Now()
305+
defer func() {
306+
opsHistogram.Record(ctx, time.Since(start).Milliseconds(), metric.WithAttributes(opNameKey.String("integrateEntries")))
307+
}()
308+
304309
ctx, cancel := context.WithTimeout(ctx, defaultIntegrationTimeout)
305310
defer cancel() // Note: ok because we're in a func passed to TraceErr here!
306311

@@ -1058,7 +1063,13 @@ func (s *mySQLSequencer) initDB(ctx context.Context) error {
10581063
// index assigned to the first entry in the batch.
10591064
func (s *mySQLSequencer) assignEntries(ctx context.Context, entries []*tessera.Entry) error {
10601065
return otel.TraceErr(ctx, "tessera.storage.gcp.assignEntries", tracer, func(ctx context.Context, span trace.Span) error {
1066+
start := time.Now()
1067+
defer func() {
1068+
opsHistogram.Record(ctx, time.Since(start).Milliseconds(), metric.WithAttributes(opNameKey.String("assignEntries")))
1069+
}()
1070+
10611071
span.SetAttributes(numEntriesKey.Int(len(entries)))
1072+
10621073
// First grab the treeSize in a non-locking read-only fashion (we don't want to block/collide with integration).
10631074
// We'll use this value to determine whether we need to apply back-pressure.
10641075
var treeSize uint64

storage/gcp/gcp.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,11 @@ func (a *Appender) integrateEntriesJob(ctx context.Context) {
349349
}
350350

351351
if err := otel.TraceErr(ctx, "tessera.storage.gcp.integrateEntriesJob", tracer, func(ctx context.Context, span trace.Span) error {
352+
start := time.Now()
353+
defer func() {
354+
opsHistogram.Record(ctx, time.Since(start).Milliseconds(), metric.WithAttributes(opNameKey.String("integrateEntries")))
355+
}()
356+
352357
ctx, cancel := context.WithTimeout(ctx, defaultIntegrationTimeout)
353358
defer cancel() // Note: ok because we're in a func passed to TraceErr here!
354359

@@ -837,6 +842,11 @@ func (s *spannerCoordinator) checkDataCompatibility(ctx context.Context) error {
837842
// index assigned to the first entry in the batch.
838843
func (s *spannerCoordinator) assignEntries(ctx context.Context, entries []*tessera.Entry) error {
839844
return otel.TraceErr(ctx, "tessera.storage.gcp.assignEntries", tracer, func(ctx context.Context, span trace.Span) error {
845+
start := time.Now()
846+
defer func() {
847+
opsHistogram.Record(ctx, time.Since(start).Milliseconds(), metric.WithAttributes(opNameKey.String("assignEntries")))
848+
}()
849+
840850
span.SetAttributes(numEntriesKey.Int(len(entries)))
841851

842852
span.AddEvent("Reading IntCoord:seq")

storage/posix/files.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,11 @@ func (l *logResourceStorage) NextIndex(ctx context.Context) (uint64, error) {
306306
// than one-by-one.
307307
func (a *appender) sequenceBatch(ctx context.Context, entries []*tessera.Entry) error {
308308
return otel.TraceErr(ctx, "tessera.storage.posix.assignEntries", tracer, func(ctx context.Context, span trace.Span) error {
309-
span.SetAttributes(numEntriesKey.Int(len(entries)))
309+
start := time.Now()
310+
defer func() {
311+
posixOpsHistogram.Record(ctx, time.Since(start).Milliseconds(), metric.WithAttributes(opNameKey.String("assignIntegrateBatch")))
312+
span.SetAttributes(numEntriesKey.Int(len(entries)))
313+
}()
310314

311315
// Double locking:
312316
// - The mutex `Lock()` ensures that multiple concurrent calls to this function within a task are serialised.

0 commit comments

Comments
 (0)