search-after-write: improve observability (#110288)

* Improve tracing and observability around updating of index during search.
This commit is contained in:
Peter Štibraný
2025-08-28 16:02:47 +02:00
committed by GitHub
parent f76ef1ca87
commit 7a8010be0c
2 changed files with 24 additions and 12 deletions
+8 -7
View File
@@ -1268,17 +1268,18 @@ func (b *bleveIndex) updateIndexWithLatestModifications(ctx context.Context, req
ctx, span := b.tracing.Start(ctx, tracingPrexfixBleve+"updateIndexWithLatestModifications")
defer span.End()
b.logger.Debug("Updating index", "sinceRV", b.resourceVersion, "requests", requests, "reasons", reasons)
sinceRV := b.resourceVersion
b.logger.Debug("Updating index", "sinceRV", sinceRV, "requests", requests, "reasons", reasons)
startTime := time.Now()
rv, docs, err := b.updaterFn(ctx, b, b.resourceVersion)
if err == nil && rv > 0 {
err = b.updateResourceVersion(rv)
listRV, docs, err := b.updaterFn(ctx, b, sinceRV)
if err == nil && listRV > 0 {
err = b.updateResourceVersion(listRV) // updates b.resourceVersion
}
elapsed := time.Since(startTime)
if err == nil {
b.logger.Debug("Finished updating index", "listRV", b.resourceVersion, "duration", elapsed, "docs", docs)
b.logger.Debug("Finished updating index", "sinceRV", sinceRV, "listRV", listRV, "duration", elapsed, "docs", docs, "reasons", reasons)
if b.updateLatency != nil {
b.updateLatency.Observe(elapsed.Seconds())
@@ -1287,9 +1288,9 @@ func (b *bleveIndex) updateIndexWithLatestModifications(ctx context.Context, req
b.updatedDocuments.Observe(float64(docs))
}
} else {
b.logger.Debug("Updating of index finished with error", "duration", elapsed, "err", err)
b.logger.Error("Updating of index finished with error", "duration", elapsed, "err", err)
}
return rv, err
return listRV, err
}
func safeInt64ToInt(i64 int64) (int, error) {