Commit 32639605 authored by Conner Fromknecht's avatar Conner Fromknecht Committed by GitHub

fix: correct FailedDatabase counter for upsert_disbursement, expose api-server metrics (#2548)

* fix: correct FailedDatabase counter for upsert_disbursement

Previously we would always increment the counter instead of adding the
number of failed upserts observed.

* feat: expose teleportr-api metrics server
Co-authored-by: default avatarmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent b7a04acf
---
'@eth-optimism/teleportr': patch
---
Fix teleportr FailedDatabaseOperations method for upsert_disbursement
---
'@eth-optimism/teleportr': patch
---
Expose metrics server
...@@ -18,6 +18,7 @@ import ( ...@@ -18,6 +18,7 @@ import (
bsscore "github.com/ethereum-optimism/optimism/bss-core" bsscore "github.com/ethereum-optimism/optimism/bss-core"
"github.com/ethereum-optimism/optimism/bss-core/dial" "github.com/ethereum-optimism/optimism/bss-core/dial"
"github.com/ethereum-optimism/optimism/bss-core/drivers" "github.com/ethereum-optimism/optimism/bss-core/drivers"
"github.com/ethereum-optimism/optimism/bss-core/metrics"
"github.com/ethereum-optimism/optimism/bss-core/txmgr" "github.com/ethereum-optimism/optimism/bss-core/txmgr"
"github.com/ethereum-optimism/optimism/teleportr/bindings/deposit" "github.com/ethereum-optimism/optimism/teleportr/bindings/deposit"
"github.com/ethereum-optimism/optimism/teleportr/db" "github.com/ethereum-optimism/optimism/teleportr/db"
...@@ -84,6 +85,10 @@ func Main(gitVersion string) func(*cli.Context) error { ...@@ -84,6 +85,10 @@ func Main(gitVersion string) func(*cli.Context) error {
} }
defer database.Close() defer database.Close()
if cfg.MetricsServerEnable {
go metrics.RunServer(cfg.MetricsHostname, cfg.MetricsPort)
}
server := NewServer( server := NewServer(
ctx, ctx,
l1Client, l1Client,
...@@ -135,6 +140,9 @@ type Config struct { ...@@ -135,6 +140,9 @@ type Config struct {
PostgresPassword string PostgresPassword string
PostgresDBName string PostgresDBName string
PostgresEnableSSL bool PostgresEnableSSL bool
MetricsServerEnable bool
MetricsHostname string
MetricsPort uint64
DisableHTTP2 bool DisableHTTP2 bool
} }
...@@ -151,6 +159,10 @@ func NewConfig(ctx *cli.Context) (Config, error) { ...@@ -151,6 +159,10 @@ func NewConfig(ctx *cli.Context) (Config, error) {
PostgresPassword: ctx.GlobalString(flags.PostgresPasswordFlag.Name), PostgresPassword: ctx.GlobalString(flags.PostgresPasswordFlag.Name),
PostgresDBName: ctx.GlobalString(flags.PostgresDBNameFlag.Name), PostgresDBName: ctx.GlobalString(flags.PostgresDBNameFlag.Name),
PostgresEnableSSL: ctx.GlobalBool(flags.PostgresEnableSSLFlag.Name), PostgresEnableSSL: ctx.GlobalBool(flags.PostgresEnableSSLFlag.Name),
MetricsServerEnable: ctx.GlobalBool(flags.MetricsServerEnableFlag.Name),
MetricsHostname: ctx.GlobalString(flags.MetricsHostnameFlag.Name),
MetricsPort: ctx.GlobalUint64(flags.MetricsPortFlag.Name),
DisableHTTP2: ctx.GlobalBool(flags.HTTP2DisableFlag.Name),
}, nil }, nil
} }
......
...@@ -436,7 +436,7 @@ func (d *Driver) processPendingTxs(ctx context.Context) error { ...@@ -436,7 +436,7 @@ func (d *Driver) processPendingTxs(ctx context.Context) error {
d.metrics.SuccessfulDisbursements.Add(float64(successfulDisbursements)) d.metrics.SuccessfulDisbursements.Add(float64(successfulDisbursements))
d.metrics.FailedDisbursements.Add(float64(failedDisbursements)) d.metrics.FailedDisbursements.Add(float64(failedDisbursements))
d.metrics.FailedDatabaseMethods.With(DBMethodUpsertDisbursement). d.metrics.FailedDatabaseMethods.With(DBMethodUpsertDisbursement).
Inc() Add(float64(failedUpserts))
// We have completed our post-processing once all of the disbursements are // We have completed our post-processing once all of the disbursements are
// written without failures. // written without failures.
......
...@@ -38,4 +38,8 @@ var APIFlags = []cli.Flag{ ...@@ -38,4 +38,8 @@ var APIFlags = []cli.Flag{
PostgresPasswordFlag, PostgresPasswordFlag,
PostgresDBNameFlag, PostgresDBNameFlag,
PostgresEnableSSLFlag, PostgresEnableSSLFlag,
MetricsServerEnableFlag,
MetricsHostnameFlag,
MetricsPortFlag,
HTTP2DisableFlag,
} }
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