Commit 52d02b14 authored by Annie Ke's avatar Annie Ke Committed by GitHub

metrics[batch-submitter]: add new batch submitter metrics (#1074)

* metrics[batch-submitter]: add new batch submitter metrics

* chore: changeset

* account for failed submissions
parent c87e4c74
---
'@eth-optimism/batch-submitter': patch
---
Add failure metrics to batch submitter
/* External Imports */ /* External Imports */
import { Contract, Signer, utils, providers } from 'ethers' import { Contract, Signer, utils, providers } from 'ethers'
import { TransactionReceipt } from '@ethersproject/abstract-provider' import { TransactionReceipt } from '@ethersproject/abstract-provider'
import { Gauge, Histogram } from 'prom-client' import { Gauge, Histogram, Counter } from 'prom-client'
import * as ynatm from '@eth-optimism/ynatm' import * as ynatm from '@eth-optimism/ynatm'
import { RollupInfo } from '@eth-optimism/core-utils' import { RollupInfo } from '@eth-optimism/core-utils'
import { Logger, Metrics } from '@eth-optimism/common-ts' import { Logger, Metrics } from '@eth-optimism/common-ts'
...@@ -24,6 +24,9 @@ interface BatchSubmitterMetrics { ...@@ -24,6 +24,9 @@ interface BatchSubmitterMetrics {
numTxPerBatch: Histogram<string> numTxPerBatch: Histogram<string>
submissionTimestamp: Histogram<string> submissionTimestamp: Histogram<string>
submissionGasUsed: Histogram<string> submissionGasUsed: Histogram<string>
batchesSubmitted: Counter<string>
failedSubmissions: Counter<string>
malformedBatches: Counter<string>
} }
export abstract class BatchSubmitter { export abstract class BatchSubmitter {
...@@ -240,6 +243,7 @@ export abstract class BatchSubmitter { ...@@ -240,6 +243,7 @@ export abstract class BatchSubmitter {
this.logger this.logger
) )
} catch (err) { } catch (err) {
this.metrics.failedSubmissions.inc()
if (err.reason) { if (err.reason) {
this.logger.error(`Transaction invalid: ${err.reason}, aborting`, { this.logger.error(`Transaction invalid: ${err.reason}, aborting`, {
message: err.toString(), message: err.toString(),
...@@ -259,6 +263,7 @@ export abstract class BatchSubmitter { ...@@ -259,6 +263,7 @@ export abstract class BatchSubmitter {
this.logger.info('Received transaction receipt', { receipt }) this.logger.info('Received transaction receipt', { receipt })
this.logger.info(successMessage) this.logger.info(successMessage)
this.metrics.batchesSubmitted.inc()
this.metrics.submissionGasUsed.observe(receipt.gasUsed.toNumber()) this.metrics.submissionGasUsed.observe(receipt.gasUsed.toNumber())
this.metrics.submissionTimestamp.observe(Date.now()) this.metrics.submissionTimestamp.observe(Date.now())
return receipt return receipt
...@@ -293,6 +298,21 @@ export abstract class BatchSubmitter { ...@@ -293,6 +298,21 @@ export abstract class BatchSubmitter {
help: 'Gas used to submit each batch', help: 'Gas used to submit each batch',
registers: [metrics.registry], registers: [metrics.registry],
}), }),
batchesSubmitted: new metrics.client.Counter({
name: 'batches_submitted',
help: 'Count of batches submitted',
registers: [metrics.registry],
}),
failedSubmissions: new metrics.client.Counter({
name: 'failed_submissions',
help: 'Count of failed batch submissions',
registers: [metrics.registry],
}),
malformedBatches: new metrics.client.Counter({
name: 'malformed_batches',
help: 'Count of malformed batches',
registers: [metrics.registry],
}),
} }
} }
} }
...@@ -301,6 +301,7 @@ export class TransactionBatchSubmitter extends BatchSubmitter { ...@@ -301,6 +301,7 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
// Fix our batches if we are configured to. TODO: Remove this. // Fix our batches if we are configured to. TODO: Remove this.
batch = await this._fixBatch(batch) batch = await this._fixBatch(batch)
if (!(await this._validateBatch(batch))) { if (!(await this._validateBatch(batch))) {
this.metrics.malformedBatches.inc()
return return
} }
let sequencerBatchParams = await this._getSequencerBatchParams( let sequencerBatchParams = await this._getSequencerBatchParams(
......
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