Skip to content

Commit

Permalink
Revert breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio committed Nov 26, 2024
1 parent c5c799a commit 43e083e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
19 changes: 11 additions & 8 deletions cmd/stellar-rpc/internal/config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ func (cfg *Config) options() Options {
defaultStellarCoreBinaryPath, _ := exec.LookPath("stellar-core")
cfg.optionsCache = &Options{
{
Name: "config-path",
EnvVar: "STELLAR_RPC_CONFIG_PATH",
Name: "config-path",
// TODO: deprecate and rename to STELLAR_RPC_
EnvVar: "SOROBAN_RPC_CONFIG_PATH",
TomlKey: "-",
Usage: "File path to the toml configuration file",
ConfigKey: &cfg.ConfigPath,
},
{
Name: "config-strict",
EnvVar: "STELLAR_RPC_CONFIG_STRICT",
Name: "config-strict",
// TODO: deprecate and rename to STELLAR_RPC_
EnvVar: "SOROBAN_RPC_CONFIG_STRICT",
TomlKey: "STRICT",
Usage: "Enable strict toml configuration file parsing. This will prevent unknown fields in the config toml from being parsed.",
ConfigKey: &cfg.Strict,
Expand Down Expand Up @@ -197,10 +199,11 @@ func (cfg *Config) options() Options {
Validate: required,
},
{
Name: "db-path",
Usage: "SQLite DB path",
ConfigKey: &cfg.SQLiteDBPath,
DefaultValue: "stellar_rpc.sqlite",
Name: "db-path",
Usage: "SQLite DB path",
ConfigKey: &cfg.SQLiteDBPath,
// TODO: deprecate and rename to stellar_rpc.sqlite
DefaultValue: "soroban_rpc.sqlite",
},
{
Name: "ingestion-timeout",
Expand Down
5 changes: 3 additions & 2 deletions cmd/stellar-rpc/internal/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

"github.com/stellar/stellar-rpc/cmd/stellar-rpc/internal"
"github.com/stellar/stellar-rpc/cmd/stellar-rpc/internal/config"
"github.com/stellar/stellar-rpc/cmd/stellar-rpc/internal/daemon/interfaces"
"github.com/stellar/stellar-rpc/cmd/stellar-rpc/internal/db"
"github.com/stellar/stellar-rpc/cmd/stellar-rpc/internal/feewindow"
"github.com/stellar/stellar-rpc/cmd/stellar-rpc/internal/ingest"
Expand All @@ -35,7 +36,6 @@ import (
)

const (
prometheusNamespace = "stellar_rpc"
maxLedgerEntryWriteBatchSize = 150
defaultReadTimeout = 5 * time.Second
defaultShutdownGracePeriod = 10 * time.Second
Expand Down Expand Up @@ -220,7 +220,8 @@ func mustCreateHistoryArchive(cfg *config.Config, logger *supportlog.Entry) *his
}

func mustOpenDatabase(cfg *config.Config, logger *supportlog.Entry, metricsRegistry *prometheus.Registry) *db.DB {
dbConn, err := db.OpenSQLiteDBWithPrometheusMetrics(cfg.SQLiteDBPath, prometheusNamespace, "db", metricsRegistry)
dbConn, err := db.OpenSQLiteDBWithPrometheusMetrics(
cfg.SQLiteDBPath, interfaces.PrometheusNamespace, "db", metricsRegistry)
if err != nil {
logger.WithError(err).Fatal("could not open database")
}
Expand Down
5 changes: 4 additions & 1 deletion cmd/stellar-rpc/internal/daemon/interfaces/noOpDaemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import (
proto "github.com/stellar/go/protocols/stellarcore"
)

// TODO: deprecate and rename to stellar_rpc
const PrometheusNamespace = "soroban_rpc"

// NoOpDaemon The noOpDeamon is a dummy daemon implementation, supporting the Daemon interface.
// Used only in testing.
type NoOpDaemon struct {
Expand All @@ -21,7 +24,7 @@ type NoOpDaemon struct {
func MakeNoOpDeamon() *NoOpDaemon {
return &NoOpDaemon{
metricsRegistry: prometheus.NewRegistry(),
metricsNamespace: "stellar_rpc",
metricsNamespace: PrometheusNamespace,
coreClient: noOpCoreClient{},
}
}
Expand Down
10 changes: 5 additions & 5 deletions cmd/stellar-rpc/internal/daemon/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import (

func (d *Daemon) registerMetrics() {
// LogMetricsHook is a metric which counts log lines emitted by stellar rpc
logMetricsHook := logmetrics.New(prometheusNamespace)
logMetricsHook := logmetrics.New(interfaces.PrometheusNamespace)
d.logger.AddHook(logMetricsHook)
for _, counter := range logMetricsHook {
d.metricsRegistry.MustRegister(counter)
}

buildInfoGauge := prometheus.NewGaugeVec(
prometheus.GaugeOpts{Namespace: prometheusNamespace, Subsystem: "build", Name: "info"},
prometheus.GaugeOpts{Namespace: interfaces.PrometheusNamespace, Subsystem: "build", Name: "info"},
[]string{"version", "goversion", "commit", "branch", "build_timestamp"},
)
buildInfoGauge.With(prometheus.Labels{
Expand All @@ -49,7 +49,7 @@ func (d *Daemon) MetricsRegistry() *prometheus.Registry {
}

func (d *Daemon) MetricsNamespace() string {
return prometheusNamespace
return interfaces.PrometheusNamespace
}

type CoreClientWithMetrics struct {
Expand All @@ -60,12 +60,12 @@ type CoreClientWithMetrics struct {

func newCoreClientWithMetrics(client stellarcore.Client, registry *prometheus.Registry) *CoreClientWithMetrics {
submitMetric := prometheus.NewSummaryVec(prometheus.SummaryOpts{
Namespace: prometheusNamespace, Subsystem: "txsub", Name: "submission_duration_seconds",
Namespace: interfaces.PrometheusNamespace, Subsystem: "txsub", Name: "submission_duration_seconds",
Help: "submission durations to Stellar-Core, sliding window = 10m",
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}, //nolint:mnd
}, []string{"status"})
opCountMetric := prometheus.NewSummaryVec(prometheus.SummaryOpts{
Namespace: prometheusNamespace, Subsystem: "txsub", Name: "operation_count",
Namespace: interfaces.PrometheusNamespace, Subsystem: "txsub", Name: "operation_count",
Help: "number of operations included in a transaction, sliding window = 10m",
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}, //nolint:mnd
}, []string{"status"})
Expand Down
4 changes: 2 additions & 2 deletions cmd/stellar-rpc/internal/integrationtest/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestMetrics(t *testing.T) {
require.NoError(t, err)
metrics := getMetrics(t, metricsURL)
buildMetric := fmt.Sprintf(
"stellar_rpc_build_info{branch=\"%s\",build_timestamp=\"%s\",commit=\"%s\",goversion=\"%s\",version=\"%s\"} 1",
"soroban_rpc_build_info{branch=\"%s\",build_timestamp=\"%s\",commit=\"%s\",goversion=\"%s\",version=\"%s\"} 1",
config.Branch,
config.BuildTimestamp,
config.CommitHash,
Expand All @@ -42,7 +42,7 @@ func TestMetrics(t *testing.T) {
assert.NoError(t, err)
var metric *io_prometheus_client.MetricFamily
for _, mf := range metricFamilies {
if mf.GetName() == "stellar_rpc_log_error_total" {
if mf.GetName() == "soroban_rpc_log_error_total" {
metric = mf
break
}
Expand Down

0 comments on commit 43e083e

Please sign in to comment.