Commit 961dfe25 authored by Conner Fromknecht's avatar Conner Fromknecht

feat: only log batch tx size once

Previously it was being logged every time we modified the gas price.
Additionally, we log the raw byte length rather than tx.Size(). The
latter returns a float value of type StorageSize, which explains why the
metrics haven't been indicating actual byte values.
parent 11a6a988
package batchsubmitter package batchsubmitter
import ( import (
"bytes"
"context" "context"
"math/big" "math/big"
"sync" "sync"
...@@ -183,6 +184,14 @@ func (s *Service) eventLoop() { ...@@ -183,6 +184,14 @@ func (s *Service) eventLoop() {
batchTxBuildTime := time.Since(batchTxBuildStart) / time.Millisecond batchTxBuildTime := time.Since(batchTxBuildStart) / time.Millisecond
s.metrics.BatchTxBuildTime.Set(float64(batchTxBuildTime)) s.metrics.BatchTxBuildTime.Set(float64(batchTxBuildTime))
// Record the size of the batch transaction.
var txBuf bytes.Buffer
if err := tx.EncodeRLP(&txBuf); err != nil {
log.Error(name+" unable to encode batch tx", "err", err)
continue
}
s.metrics.BatchSizeInBytes.Observe(float64(len(txBuf.Bytes())))
// Construct the transaction submission clousure that will attempt // Construct the transaction submission clousure that will attempt
// to send the next transaction at the given nonce and gas price. // to send the next transaction at the given nonce and gas price.
sendTx := func( sendTx := func(
...@@ -207,8 +216,6 @@ func (s *Service) eventLoop() { ...@@ -207,8 +216,6 @@ func (s *Service) eventLoop() {
"gasPrice", gasPrice, "gasPrice", gasPrice,
) )
s.metrics.BatchSizeInBytes.Observe(float64(tx.Size()))
return tx, nil return tx, nil
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment