From 52d02b1480d4c1c98f61f65ed7757881d6c239de Mon Sep 17 00:00:00 2001 From: Annie Ke Date: Tue, 15 Jun 2021 12:38:29 -0700 Subject: [PATCH] metrics[batch-submitter]: add new batch submitter metrics (#1074) * metrics[batch-submitter]: add new batch submitter metrics * chore: changeset * account for failed submissions --- .changeset/olive-planets-clean.md | 5 +++++ .../src/batch-submitter/batch-submitter.ts | 22 ++++++++++++++++++- .../src/batch-submitter/tx-batch-submitter.ts | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 .changeset/olive-planets-clean.md diff --git a/.changeset/olive-planets-clean.md b/.changeset/olive-planets-clean.md new file mode 100644 index 000000000000..27ddbce53227 --- /dev/null +++ b/.changeset/olive-planets-clean.md @@ -0,0 +1,5 @@ +--- +'@eth-optimism/batch-submitter': patch +--- + +Add failure metrics to batch submitter diff --git a/packages/batch-submitter/src/batch-submitter/batch-submitter.ts b/packages/batch-submitter/src/batch-submitter/batch-submitter.ts index ffe2674e2c7b..c487d86dfac9 100644 --- a/packages/batch-submitter/src/batch-submitter/batch-submitter.ts +++ b/packages/batch-submitter/src/batch-submitter/batch-submitter.ts @@ -1,7 +1,7 @@ /* External Imports */ import { Contract, Signer, utils, providers } from 'ethers' 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 { RollupInfo } from '@eth-optimism/core-utils' import { Logger, Metrics } from '@eth-optimism/common-ts' @@ -24,6 +24,9 @@ interface BatchSubmitterMetrics { numTxPerBatch: Histogram submissionTimestamp: Histogram submissionGasUsed: Histogram + batchesSubmitted: Counter + failedSubmissions: Counter + malformedBatches: Counter } export abstract class BatchSubmitter { @@ -240,6 +243,7 @@ export abstract class BatchSubmitter { this.logger ) } catch (err) { + this.metrics.failedSubmissions.inc() if (err.reason) { this.logger.error(`Transaction invalid: ${err.reason}, aborting`, { message: err.toString(), @@ -259,6 +263,7 @@ export abstract class BatchSubmitter { this.logger.info('Received transaction receipt', { receipt }) this.logger.info(successMessage) + this.metrics.batchesSubmitted.inc() this.metrics.submissionGasUsed.observe(receipt.gasUsed.toNumber()) this.metrics.submissionTimestamp.observe(Date.now()) return receipt @@ -293,6 +298,21 @@ export abstract class BatchSubmitter { help: 'Gas used to submit each batch', 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], + }), } } } diff --git a/packages/batch-submitter/src/batch-submitter/tx-batch-submitter.ts b/packages/batch-submitter/src/batch-submitter/tx-batch-submitter.ts index 8a8a041337fe..b6aae4c980d5 100644 --- a/packages/batch-submitter/src/batch-submitter/tx-batch-submitter.ts +++ b/packages/batch-submitter/src/batch-submitter/tx-batch-submitter.ts @@ -301,6 +301,7 @@ export class TransactionBatchSubmitter extends BatchSubmitter { // Fix our batches if we are configured to. TODO: Remove this. batch = await this._fixBatch(batch) if (!(await this._validateBatch(batch))) { + this.metrics.malformedBatches.inc() return } let sequencerBatchParams = await this._getSequencerBatchParams(