mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-02 14:03:06 +00:00
new metric in postgres_driver to estimate payload stats (#3596)
This commit is contained in:
parent
088e3108c8
commit
454b098ac5
@ -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.} =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user