Commit 05894239 authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

data-transport-layer: add new metrics (#2391)

Co-authored-by: default avatarmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent 917058e9
---
'@eth-optimism/data-transport-layer': patch
---
Add new metrics to the data-transport-layer
......@@ -6,7 +6,7 @@ import { BigNumber } from 'ethers'
import { LevelUp } from 'levelup'
import axios from 'axios'
import bfj from 'bfj'
import { Gauge } from 'prom-client'
import { Gauge, Histogram } from 'prom-client'
/* Imports: Internal */
import { handleSequencerBlock } from './handlers/transaction'
......@@ -16,6 +16,7 @@ import { L1DataTransportServiceOptions } from '../main/service'
interface L2IngestionMetrics {
highestSyncedL2Block: Gauge<string>
fetchBlocksRequestTime: Histogram<string>
}
const registerMetrics = ({
......@@ -27,6 +28,12 @@ const registerMetrics = ({
help: 'Highest Synced L2 Block Number',
registers: [registry],
}),
fetchBlocksRequestTime: new client.Histogram({
name: 'data_transport_layer_fetch_blocks_time',
help: 'Amount of time fetching remote L2 blocks takes',
buckets: [0.1, 5, 15, 50, 100, 500],
registers: [registry],
}),
})
export interface L2IngestionServiceOptions
......@@ -240,6 +247,8 @@ export class L2IngestionService extends BaseService<L2IngestionServiceOptions> {
)
}
const end = this.l2IngestionMetrics.fetchBlocksRequestTime.startTimer()
const resp = await axios.post(
this.state.l2RpcProvider.connection.url,
req,
......@@ -249,6 +258,8 @@ export class L2IngestionService extends BaseService<L2IngestionServiceOptions> {
yieldRate: 4096, // this yields abit more often than the default of 16384
})
end()
result = respJson.result
if (result === null) {
retry++
......
......@@ -89,6 +89,10 @@ export class L1DataTransportService extends BaseService<L1DataTransportServiceOp
}
})
this.state.metrics.client.collectDefaultMetrics({
prefix: 'data_transport_layer_'
})
this.state.failureCounter = new this.state.metrics.client.Counter({
name: 'data_transport_layer_main_service_failures',
help: 'Counts the number of times that the main service fails',
......
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