Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/olive-planets-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/batch-submitter': patch
---

Add failure metrics to batch submitter
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -24,6 +24,9 @@ interface BatchSubmitterMetrics {
numTxPerBatch: Histogram<string>
submissionTimestamp: Histogram<string>
submissionGasUsed: Histogram<string>
batchesSubmitted: Counter<string>
failedSubmissions: Counter<string>
malformedBatches: Counter<string>
}

export abstract class BatchSubmitter {
Expand Down Expand Up @@ -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(),
Expand All @@ -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
Expand Down Expand Up @@ -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({
annieke marked this conversation as resolved.
Show resolved Hide resolved
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],
}),
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down