From de0c35b0321a9e82eac85f6fffe6ce9d36caf725 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Mon, 9 Mar 2026 15:27:14 +0100 Subject: [PATCH 1/4] Added size metrics --- sqlitestore.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/sqlitestore.go b/sqlitestore.go index 3669a45..5589bc4 100644 --- a/sqlitestore.go +++ b/sqlitestore.go @@ -29,8 +29,11 @@ var ( metricOperationStarted = metrics.NewRegisteredCounter("arkiv_store/operations_started", nil) metricOperationSuccessful = metrics.NewRegisteredCounter("arkiv_store/operations_successful", nil) metricCreates = metrics.NewRegisteredCounter("arkiv_store/creates", nil) + metricCreatesBytes = metrics.NewRegisteredCounter("arkiv_store/creates_bytes", nil) metricUpdates = metrics.NewRegisteredCounter("arkiv_store/updates", nil) + metricUpdatesBytes = metrics.NewRegisteredCounter("arkiv_store/updates_bytes", nil) metricDeletes = metrics.NewRegisteredCounter("arkiv_store/deletes", nil) + metricDeletesBytes = metrics.NewRegisteredCounter("arkiv_store/deletes_bytes", nil) metricExtends = metrics.NewRegisteredCounter("arkiv_store/extends", nil) metricOwnerChanges = metrics.NewRegisteredCounter("arkiv_store/owner_changes", nil) // Tracks operation duration (ms) using an exponential decay sample so the histogram @@ -117,8 +120,11 @@ func (s *SQLiteStore) GetLastBlock(ctx context.Context) (uint64, error) { type blockStats struct { creates int + createsBytes int updates int + updatesBytes int deletes int + deletesBytes int extends int ownerChanges int } @@ -193,6 +199,7 @@ func (s *SQLiteStore) FollowEvents(ctx context.Context, iterator arkivevents.Bat case operation.Create != nil: // expiresAtBlock := blockNumber + operation.Create.BTL blockStat.creates++ + blockStat.createsBytes += len(operation.Create.Content) key := operation.Create.Key stringAttributes := maps.Clone(operation.Create.StringAttributes) @@ -255,6 +262,7 @@ func (s *SQLiteStore) FollowEvents(ctx context.Context, iterator arkivevents.Bat continue operationLoop } blockStat.updates++ + blockStat.updatesBytes += len(operation.Update.Content) key := operation.Update.Key.Bytes() @@ -353,6 +361,7 @@ func (s *SQLiteStore) FollowEvents(ctx context.Context, iterator arkivevents.Bat if err != nil { return fmt.Errorf("failed to get latest payload: %w", err) } + blockStat.deletesBytes += len(latestPayload.Payload) oldStringAttributes := latestPayload.StringAttributes @@ -493,8 +502,11 @@ func (s *SQLiteStore) FollowEvents(ctx context.Context, iterator arkivevents.Bat // Calculate batch totals for logging and update metrics PER BLOCK var ( totalCreates int + totalCreatesBytes int totalUpdates int + totalUpdatesBytes int totalDeletes int + totalDeletesBytes int totalExtends int totalOwnerChanges int ) @@ -503,8 +515,11 @@ func (s *SQLiteStore) FollowEvents(ctx context.Context, iterator arkivevents.Bat for _, block := range batch.Batch.Blocks { if stat, ok := stats[block.Number]; ok { totalCreates += stat.creates + totalCreatesBytes += stat.createsBytes totalUpdates += stat.updates + totalUpdatesBytes += stat.updatesBytes totalDeletes += stat.deletes + totalDeletesBytes += stat.deletesBytes totalExtends += stat.extends totalOwnerChanges += stat.ownerChanges @@ -512,12 +527,21 @@ func (s *SQLiteStore) FollowEvents(ctx context.Context, iterator arkivevents.Bat if stat.creates > 0 { metricCreates.Inc(int64(stat.creates)) } + if stat.createsBytes > 0 { + metricCreatesBytes.Inc(int64(stat.createsBytes)) + } if stat.updates > 0 { metricUpdates.Inc(int64(stat.updates)) } + if stat.updatesBytes > 0 { + metricUpdatesBytes.Inc(int64(stat.updatesBytes)) + } if stat.deletes > 0 { metricDeletes.Inc(int64(stat.deletes)) } + if stat.deletesBytes > 0 { + metricDeletesBytes.Inc(int64(stat.deletesBytes)) + } if stat.extends > 0 { metricExtends.Inc(int64(stat.extends)) } @@ -535,8 +559,11 @@ func (s *SQLiteStore) FollowEvents(ctx context.Context, iterator arkivevents.Bat "lastBlock", lastBlock, "processingTime", time.Since(startTime).Milliseconds(), "creates", totalCreates, + "createsBytes", totalCreatesBytes, "updates", totalUpdates, + "updatesBytes", totalUpdatesBytes, "deletes", totalDeletes, + "deletesBytes", totalDeletesBytes, "extends", totalExtends, "ownerChanges", totalOwnerChanges) From 2873335cdec013c5bffb1eb494388b2b75538d02 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Mon, 9 Mar 2026 15:47:39 +0100 Subject: [PATCH 2/4] int64 type fix --- sqlitestore.go | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/sqlitestore.go b/sqlitestore.go index 5589bc4..92c9802 100644 --- a/sqlitestore.go +++ b/sqlitestore.go @@ -119,14 +119,14 @@ func (s *SQLiteStore) GetLastBlock(ctx context.Context) (uint64, error) { } type blockStats struct { - creates int - createsBytes int - updates int - updatesBytes int - deletes int - deletesBytes int - extends int - ownerChanges int + creates int64 + createsBytes int64 + updates int64 + updatesBytes int64 + deletes int64 + deletesBytes int64 + extends int64 + ownerChanges int64 } func (s *SQLiteStore) FollowEvents(ctx context.Context, iterator arkivevents.BatchIterator) error { @@ -199,7 +199,7 @@ func (s *SQLiteStore) FollowEvents(ctx context.Context, iterator arkivevents.Bat case operation.Create != nil: // expiresAtBlock := blockNumber + operation.Create.BTL blockStat.creates++ - blockStat.createsBytes += len(operation.Create.Content) + blockStat.createsBytes += int64(len(operation.Create.Content)) key := operation.Create.Key stringAttributes := maps.Clone(operation.Create.StringAttributes) @@ -262,7 +262,7 @@ func (s *SQLiteStore) FollowEvents(ctx context.Context, iterator arkivevents.Bat continue operationLoop } blockStat.updates++ - blockStat.updatesBytes += len(operation.Update.Content) + blockStat.updatesBytes += int64(len(operation.Update.Content)) key := operation.Update.Key.Bytes() @@ -361,7 +361,7 @@ func (s *SQLiteStore) FollowEvents(ctx context.Context, iterator arkivevents.Bat if err != nil { return fmt.Errorf("failed to get latest payload: %w", err) } - blockStat.deletesBytes += len(latestPayload.Payload) + blockStat.deletesBytes += int64(len(latestPayload.Payload)) oldStringAttributes := latestPayload.StringAttributes @@ -501,14 +501,14 @@ func (s *SQLiteStore) FollowEvents(ctx context.Context, iterator arkivevents.Bat // Calculate batch totals for logging and update metrics PER BLOCK var ( - totalCreates int - totalCreatesBytes int - totalUpdates int - totalUpdatesBytes int - totalDeletes int - totalDeletesBytes int - totalExtends int - totalOwnerChanges int + totalCreates int64 + totalCreatesBytes int64 + totalUpdates int64 + totalUpdatesBytes int64 + totalDeletes int64 + totalDeletesBytes int64 + totalExtends int64 + totalOwnerChanges int64 ) // Iterate blocks again to preserve order and update metrics per block From c698a4ce26664573bbe4527f29f06aa6523d43a4 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Mon, 9 Mar 2026 15:55:04 +0100 Subject: [PATCH 3/4] unused int64 --- sqlitestore.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sqlitestore.go b/sqlitestore.go index 92c9802..e72718c 100644 --- a/sqlitestore.go +++ b/sqlitestore.go @@ -525,25 +525,25 @@ func (s *SQLiteStore) FollowEvents(ctx context.Context, iterator arkivevents.Bat // Update metrics specifically per block if stat.creates > 0 { - metricCreates.Inc(int64(stat.creates)) + metricCreates.Inc(stat.creates) } if stat.createsBytes > 0 { - metricCreatesBytes.Inc(int64(stat.createsBytes)) + metricCreatesBytes.Inc(stat.createsBytes) } if stat.updates > 0 { - metricUpdates.Inc(int64(stat.updates)) + metricUpdates.Inc(stat.updates) } if stat.updatesBytes > 0 { - metricUpdatesBytes.Inc(int64(stat.updatesBytes)) + metricUpdatesBytes.Inc(stat.updatesBytes) } if stat.deletes > 0 { - metricDeletes.Inc(int64(stat.deletes)) + metricDeletes.Inc(stat.deletes) } if stat.deletesBytes > 0 { - metricDeletesBytes.Inc(int64(stat.deletesBytes)) + metricDeletesBytes.Inc(stat.deletesBytes) } if stat.extends > 0 { - metricExtends.Inc(int64(stat.extends)) + metricExtends.Inc(stat.extends) } if stat.ownerChanges > 0 { metricOwnerChanges.Inc(int64(stat.ownerChanges)) From a72b930a3519bb52e5941b07a76f5cfcaf8eecb9 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Mon, 9 Mar 2026 16:00:17 +0100 Subject: [PATCH 4/4] unused int64 --- sqlitestore.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlitestore.go b/sqlitestore.go index e72718c..ca631b7 100644 --- a/sqlitestore.go +++ b/sqlitestore.go @@ -546,7 +546,7 @@ func (s *SQLiteStore) FollowEvents(ctx context.Context, iterator arkivevents.Bat metricExtends.Inc(stat.extends) } if stat.ownerChanges > 0 { - metricOwnerChanges.Inc(int64(stat.ownerChanges)) + metricOwnerChanges.Inc(stat.ownerChanges) } } }