new metric in postgres_driver to estimate payload stats (#3596)

This commit is contained in:
Ivan FB 2025-11-24 10:16:37 +01:00 committed by GitHub
parent 088e3108c8
commit 454b098ac5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,6 +5,7 @@ import
stew/[byteutils, arrayops],
results,
chronos,
metrics,
db_connector/[postgres, db_common],
chronicles
import
@ -16,6 +17,9 @@ import
./postgres_healthcheck,
./partitions_manager
declarePublicGauge postgres_payload_size_bytes,
"Payload size in bytes of correctly stored messages"
type PostgresDriver* = ref object of ArchiveDriver
## Establish a separate pools for read/write operations
writeConnPool: PgAsyncPool
@ -333,7 +337,7 @@ method put*(
return err("could not put msg in messages table: " & $error)
## Now add the row to messages_lookup
return await s.writeConnPool.runStmt(
let ret = await s.writeConnPool.runStmt(
InsertRowInMessagesLookupStmtName,
InsertRowInMessagesLookupStmtDefinition,
@[messageHash, timestamp],
@ -341,6 +345,10 @@ method put*(
@[int32(0), int32(0)],
)
if ret.isOk():
postgres_payload_size_bytes.set(message.payload.len)
return ret
method getAllMessages*(
s: PostgresDriver
): Future[ArchiveDriverResult[seq[ArchiveRow]]] {.async.} =