From c5c799a0a253fdd91cc9855074d71e54bd6bfc69 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Tue, 26 Nov 2024 18:45:29 +0100 Subject: [PATCH 1/2] Fix e2e tests after soroban-rpc -> stellar-rpc rename --- .github/workflows/e2e.yml | 7 +++---- .github/workflows/stellar-rpc.yml | 8 ++++---- Makefile | 4 ++-- cmd/stellar-rpc/docker/Dockerfile.release | 6 +++--- cmd/stellar-rpc/docker/Makefile | 20 +++++++++---------- cmd/stellar-rpc/internal/config/options.go | 6 +++--- cmd/stellar-rpc/internal/daemon/daemon.go | 2 +- .../internal/daemon/interfaces/noOpDaemon.go | 2 +- .../integrationtest/infrastructure/test.go | 14 ++++++------- .../internal/integrationtest/metrics_test.go | 4 ++-- .../internal/preflight/preflight_test.go | 2 +- 11 files changed, 37 insertions(+), 38 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index d4008209..8e08f050 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -23,7 +23,7 @@ jobs: # the soroban CLI & RPC source code to compile and run from system test # refers to checked out source of current git hub ref context SYSTEM_TEST_SOROBAN_CLI_REF: https://github.com/stellar/soroban-cli.git\#main - SYSTEM_TEST_SOROBAN_RPC_REF: ${{ github.workspace }}/stellar-rpc + SYSTEM_TEST_STELLAR_RPC_REF: ${{ github.workspace }}/stellar-rpc # core git ref should be latest commit for stable soroban functionality # the core bin can either be compiled in-line here as part of ci, @@ -54,8 +54,7 @@ jobs: # system test will build quickstart image internally to use for running the service stack # configured in standalone network mode(core, rpc) - SYSTEM_TEST_QUICKSTART_GIT_REF: https://github.com/stellar/quickstart.git#ae7fdb07283a0af836d4cd51ff09b02db93fb12c - + SYSTEM_TEST_QUICKSTART_GIT_REF: https://github.com/stellar/quickstart.git#1a831b2350dd3928b60eb745d0862ee19dd2aaaa # triggers system test to log out details from quickstart's logs and test steps SYSTEM_TEST_VERBOSE_OUTPUT: "true" @@ -104,7 +103,7 @@ jobs: CORE_COMPILE_CONFIGURE_FLAGS="$SYSTEM_TEST_CORE_COMPILE_CONFIGURE_FLAGS" \ CORE_IMAGE=$SYSTEM_TEST_CORE_IMAGE \ CORE_IMAGE_BIN_PATH=$SYSTEM_TEST_CORE_IMAGE_BIN_PATH \ - SOROBAN_RPC_GIT_REF=$SYSTEM_TEST_SOROBAN_RPC_REF \ + STELLAR_RPC_GIT_REF=$SYSTEM_TEST_STELLAR_RPC_REF \ SOROBAN_CLI_GIT_REF=$SYSTEM_TEST_SOROBAN_CLI_REF \ RUST_TOOLCHAIN_VERSION=$SYSTEM_TEST_RUST_TOOLCHAIN_VERSION \ RS_XDR_GIT_REF=$SYSTEM_TEST_RS_XDR_GIT_REF \ diff --git a/.github/workflows/stellar-rpc.yml b/.github/workflows/stellar-rpc.yml index 2906ac30..6b515d2d 100644 --- a/.github/workflows/stellar-rpc.yml +++ b/.github/workflows/stellar-rpc.yml @@ -101,9 +101,9 @@ jobs: protocol-version: [ 21, 22 ] runs-on: ${{ matrix.os }} env: - SOROBAN_RPC_INTEGRATION_TESTS_ENABLED: true - SOROBAN_RPC_INTEGRATION_TESTS_CORE_MAX_SUPPORTED_PROTOCOL: ${{ matrix.protocol-version }} - SOROBAN_RPC_INTEGRATION_TESTS_CAPTIVE_CORE_BIN: /usr/bin/stellar-core + STELLAR_RPC_INTEGRATION_TESTS_ENABLED: true + STELLAR_RPC_INTEGRATION_TESTS_CORE_MAX_SUPPORTED_PROTOCOL: ${{ matrix.protocol-version }} + STELLAR_RPC_INTEGRATION_TESTS_CAPTIVE_CORE_BIN: /usr/bin/stellar-core PROTOCOL_21_CORE_DEBIAN_PKG_VERSION: 22.0.0-2138.721fd0a65.focal PROTOCOL_21_CORE_DOCKER_IMG: stellar/stellar-core:22.0.0-2138.721fd0a65.focal PROTOCOL_22_CORE_DEBIAN_PKG_VERSION: 22.0.0-2138.721fd0a65.focal @@ -124,7 +124,7 @@ jobs: shell: bash run: | docker pull "$PROTOCOL_${{ matrix.protocol-version }}_CORE_DOCKER_IMG" - echo SOROBAN_RPC_INTEGRATION_TESTS_DOCKER_IMG="$PROTOCOL_${{ matrix.protocol-version }}_CORE_DOCKER_IMG" >> $GITHUB_ENV + echo STELLAR_RPC_INTEGRATION_TESTS_DOCKER_IMG="$PROTOCOL_${{ matrix.protocol-version }}_CORE_DOCKER_IMG" >> $GITHUB_ENV - name: Install Captive Core shell: bash diff --git a/Makefile b/Makefile index 39502cd1..2f5a96db 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ endif # (libpreflight.a is put at target/release-with-panic-unwind/ when not cross compiling) CARGO_BUILD_TARGET ?= $(shell rustc -vV | sed -n 's|host: ||p') -SOROBAN_RPC_BINARY := stellar-rpc +STELLAR_RPC_BINARY := stellar-rpc STELLAR_RPC_BINARY := stellar-rpc @@ -86,7 +86,7 @@ clean: # https://github.com/stellar/pipelines/blob/master/stellar-rpc/Jenkinsfile-stellar-rpc-package-builder # as part of the package building. build-stellar-rpc: build-libs - go build -ldflags="${GOLDFLAGS}" ${MACOS_MIN_VER} -o ${SOROBAN_RPC_BINARY} -trimpath -v ./cmd/stellar-rpc + go build -ldflags="${GOLDFLAGS}" ${MACOS_MIN_VER} -o ${STELLAR_RPC_BINARY} -trimpath -v ./cmd/stellar-rpc # the build-stellar-rpc build target is an optimized build target used by # https://github.com/stellar/pipelines/blob/master/stellar-rpc/Jenkinsfile-stellar-rpc-package-builder diff --git a/cmd/stellar-rpc/docker/Dockerfile.release b/cmd/stellar-rpc/docker/Dockerfile.release index e627ae5a..5b03b7a9 100644 --- a/cmd/stellar-rpc/docker/Dockerfile.release +++ b/cmd/stellar-rpc/docker/Dockerfile.release @@ -1,8 +1,8 @@ FROM ubuntu:22.04 ARG STELLAR_CORE_VERSION ENV STELLAR_CORE_VERSION=${STELLAR_CORE_VERSION:-*} -ARG SOROBAN_RPC_VERSION -ENV SOROBAN_RPC_VERSION=${SOROBAN_RPC_VERSION:-*} +ARG STELLAR_RPC_VERSION +ENV STELLAR_RPC_VERSION=${STELLAR_RPC_VERSION:-*} ENV STELLAR_CORE_BINARY_PATH /usr/bin/stellar-core ENV DEBIAN_FRONTEND=noninteractive @@ -14,7 +14,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates echo "deb https://apt.stellar.org focal testing" >/etc/apt/sources.list.d/SDF-testing.list && \ echo "deb https://apt.stellar.org focal unstable" >/etc/apt/sources.list.d/SDF-unstable.list && \ apt-get update && \ - apt-get install -y stellar-core=${STELLAR_CORE_VERSION} stellar-stellar-rpc=${SOROBAN_RPC_VERSION} && \ + apt-get install -y stellar-core=${STELLAR_CORE_VERSION} stellar-stellar-rpc=${STELLAR_RPC_VERSION} && \ apt-get clean ENTRYPOINT ["/usr/bin/stellar-stellar-rpc"] diff --git a/cmd/stellar-rpc/docker/Makefile b/cmd/stellar-rpc/docker/Makefile index c461792c..2f28c0f0 100644 --- a/cmd/stellar-rpc/docker/Makefile +++ b/cmd/stellar-rpc/docker/Makefile @@ -4,18 +4,18 @@ SUDO := $(shell docker version >/dev/null 2>&1 || echo "sudo") BUILD_DATE := $(shell date -u +%FT%TZ) # Extract latest release semver from GitHub -SOROBAN_RPC_LATEST_RELEASE := $(shell curl -sS https://api.github.com/repos/stellar/stellar-rpc/releases/latest|jq -r ".tag_name"| tr -d "v" ) +STELLAR_RPC_LATEST_RELEASE := $(shell curl -sS https://api.github.com/repos/stellar/stellar-rpc/releases/latest|jq -r ".tag_name"| tr -d "v" ) -# If deb version was provided via the SOROBAN_RPC_VERSION variable use it. +# If deb version was provided via the STELLAR_RPC_VERSION variable use it. # If not get latest deb build matching release from GitHub -ifndef SOROBAN_RPC_VERSION - SOROBAN_RPC_VERSION_PACKAGE_VERSION := $(shell curl -sS https://apt.stellar.org/dists/focal/unstable/binary-amd64/Packages|grep -A 18 stellar-stellar-rpc|grep Version|grep $(SOROBAN_RPC_LATEST_RELEASE)|head -1|cut -d' ' -f2 ) +ifndef STELLAR_RPC_VERSION + STELLAR_RPC_VERSION_PACKAGE_VERSION := $(shell curl -sS https://apt.stellar.org/dists/focal/unstable/binary-amd64/Packages|grep -A 18 stellar-stellar-rpc|grep Version|grep $(STELLAR_RPC_LATEST_RELEASE)|head -1|cut -d' ' -f2 ) else - SOROBAN_RPC_VERSION_PACKAGE_VERSION := $(SOROBAN_RPC_VERSION) + STELLAR_RPC_VERSION_PACKAGE_VERSION := $(STELLAR_RPC_VERSION) endif -ifndef SOROBAN_RPC_VERSION_PACKAGE_VERSION - $(error Couldn't establish deb build from version $(SOROBAN_RPC_LATEST_RELEASE). Has the package been built?) +ifndef STELLAR_RPC_VERSION_PACKAGE_VERSION + $(error Couldn't establish deb build from version $(STELLAR_RPC_LATEST_RELEASE). Has the package been built?) endif ifndef STELLAR_CORE_VERSION @@ -28,9 +28,9 @@ BINARY_NAME ?= stellar-rpc ifndef TAG # Set the TAG based on the value of BINARY_NAME ifeq ($(BINARY_NAME),stellar-rpc) - TAG := stellar/stellar-rpc:$(SOROBAN_RPC_VERSION_PACKAGE_VERSION) + TAG := stellar/stellar-rpc:$(STELLAR_RPC_VERSION_PACKAGE_VERSION) else - TAG := stellar/stellar-stellar-rpc:$(SOROBAN_RPC_VERSION_PACKAGE_VERSION) + TAG := stellar/stellar-stellar-rpc:$(STELLAR_RPC_VERSION_PACKAGE_VERSION) endif endif # TAG @@ -38,7 +38,7 @@ endif # TAG docker-build: $(SUDO) docker build --pull --platform linux/amd64 $(DOCKER_OPTS) \ --label org.opencontainers.image.created="$(BUILD_DATE)" \ - --build-arg STELLAR_CORE_VERSION=$(STELLAR_CORE_VERSION) --build-arg SOROBAN_RPC_VERSION=$(SOROBAN_RPC_VERSION_PACKAGE_VERSION) \ + --build-arg STELLAR_CORE_VERSION=$(STELLAR_CORE_VERSION) --build-arg STELLAR_RPC_VERSION=$(STELLAR_RPC_VERSION_PACKAGE_VERSION) \ --build-arg BINARY_NAME=$(BINARY_NAME) \ -t $(TAG) -f Dockerfile.release . diff --git a/cmd/stellar-rpc/internal/config/options.go b/cmd/stellar-rpc/internal/config/options.go index 1a906c80..0720ab73 100644 --- a/cmd/stellar-rpc/internal/config/options.go +++ b/cmd/stellar-rpc/internal/config/options.go @@ -34,14 +34,14 @@ func (cfg *Config) options() Options { cfg.optionsCache = &Options{ { Name: "config-path", - EnvVar: "SOROBAN_RPC_CONFIG_PATH", + EnvVar: "STELLAR_RPC_CONFIG_PATH", TomlKey: "-", Usage: "File path to the toml configuration file", ConfigKey: &cfg.ConfigPath, }, { Name: "config-strict", - EnvVar: "SOROBAN_RPC_CONFIG_STRICT", + EnvVar: "STELLAR_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, @@ -200,7 +200,7 @@ func (cfg *Config) options() Options { Name: "db-path", Usage: "SQLite DB path", ConfigKey: &cfg.SQLiteDBPath, - DefaultValue: "soroban_rpc.sqlite", + DefaultValue: "stellar_rpc.sqlite", }, { Name: "ingestion-timeout", diff --git a/cmd/stellar-rpc/internal/daemon/daemon.go b/cmd/stellar-rpc/internal/daemon/daemon.go index e087c47c..6f97588d 100644 --- a/cmd/stellar-rpc/internal/daemon/daemon.go +++ b/cmd/stellar-rpc/internal/daemon/daemon.go @@ -35,7 +35,7 @@ import ( ) const ( - prometheusNamespace = "soroban_rpc" + prometheusNamespace = "stellar_rpc" maxLedgerEntryWriteBatchSize = 150 defaultReadTimeout = 5 * time.Second defaultShutdownGracePeriod = 10 * time.Second diff --git a/cmd/stellar-rpc/internal/daemon/interfaces/noOpDaemon.go b/cmd/stellar-rpc/internal/daemon/interfaces/noOpDaemon.go index 255cc4b2..1a3014be 100644 --- a/cmd/stellar-rpc/internal/daemon/interfaces/noOpDaemon.go +++ b/cmd/stellar-rpc/internal/daemon/interfaces/noOpDaemon.go @@ -21,7 +21,7 @@ type NoOpDaemon struct { func MakeNoOpDeamon() *NoOpDaemon { return &NoOpDaemon{ metricsRegistry: prometheus.NewRegistry(), - metricsNamespace: "soroban_rpc", + metricsNamespace: "stellar_rpc", coreClient: noOpCoreClient{}, } } diff --git a/cmd/stellar-rpc/internal/integrationtest/infrastructure/test.go b/cmd/stellar-rpc/internal/integrationtest/infrastructure/test.go index 9d93dced..b132b239 100644 --- a/cmd/stellar-rpc/internal/integrationtest/infrastructure/test.go +++ b/cmd/stellar-rpc/internal/integrationtest/infrastructure/test.go @@ -112,8 +112,8 @@ type Test struct { } func NewTest(t *testing.T, cfg *TestConfig) *Test { - if os.Getenv("SOROBAN_RPC_INTEGRATION_TESTS_ENABLED") == "" { - t.Skip("skipping integration test: SOROBAN_RPC_INTEGRATION_TESTS_ENABLED not set") + if os.Getenv("STELLAR_RPC_INTEGRATION_TESTS_ENABLED") == "" { + t.Skip("skipping integration test: STELLAR_RPC_INTEGRATION_TESTS_ENABLED not set") } i := &Test{t: t} @@ -137,7 +137,7 @@ func NewTest(t *testing.T, cfg *TestConfig) *Test { } if i.sqlitePath == "" { - i.sqlitePath = path.Join(i.t.TempDir(), "soroban_rpc.sqlite") + i.sqlitePath = path.Join(i.t.TempDir(), "stellar_rpc.sqlite") } if parallel { @@ -276,9 +276,9 @@ func (i *Test) getRPConfigForContainer() rpcConfig { } func (i *Test) getRPConfigForDaemon() rpcConfig { - coreBinaryPath := os.Getenv("SOROBAN_RPC_INTEGRATION_TESTS_CAPTIVE_CORE_BIN") + coreBinaryPath := os.Getenv("STELLAR_RPC_INTEGRATION_TESTS_CAPTIVE_CORE_BIN") if coreBinaryPath == "" { - i.t.Fatal("missing SOROBAN_RPC_INTEGRATION_TESTS_CAPTIVE_CORE_BIN") + i.t.Fatal("missing STELLAR_RPC_INTEGRATION_TESTS_CAPTIVE_CORE_BIN") } return rpcConfig{ // Allocate port dynamically and then figure out what the port is @@ -479,7 +479,7 @@ func (i *Test) getComposeCommand(args ...string) *exec.Cmd { cmd = exec.Command("docker", cmdline...) } - if img := os.Getenv("SOROBAN_RPC_INTEGRATION_TESTS_DOCKER_IMG"); img != "" { + if img := os.Getenv("STELLAR_RPC_INTEGRATION_TESTS_DOCKER_IMG"); img != "" { cmd.Env = append( cmd.Env, "CORE_IMAGE="+img, @@ -722,7 +722,7 @@ func (i *Test) fillContainerPorts() { } func GetCoreMaxSupportedProtocol() uint32 { - str := os.Getenv("SOROBAN_RPC_INTEGRATION_TESTS_CORE_MAX_SUPPORTED_PROTOCOL") + str := os.Getenv("STELLAR_RPC_INTEGRATION_TESTS_CORE_MAX_SUPPORTED_PROTOCOL") if str == "" { return MaxSupportedProtocolVersion } diff --git a/cmd/stellar-rpc/internal/integrationtest/metrics_test.go b/cmd/stellar-rpc/internal/integrationtest/metrics_test.go index 4857c3f3..49f7289e 100644 --- a/cmd/stellar-rpc/internal/integrationtest/metrics_test.go +++ b/cmd/stellar-rpc/internal/integrationtest/metrics_test.go @@ -23,7 +23,7 @@ func TestMetrics(t *testing.T) { require.NoError(t, err) metrics := getMetrics(t, metricsURL) buildMetric := fmt.Sprintf( - "soroban_rpc_build_info{branch=\"%s\",build_timestamp=\"%s\",commit=\"%s\",goversion=\"%s\",version=\"%s\"} 1", + "stellar_rpc_build_info{branch=\"%s\",build_timestamp=\"%s\",commit=\"%s\",goversion=\"%s\",version=\"%s\"} 1", config.Branch, config.BuildTimestamp, config.CommitHash, @@ -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() == "soroban_rpc_log_error_total" { + if mf.GetName() == "stellar_rpc_log_error_total" { metric = mf break } diff --git a/cmd/stellar-rpc/internal/preflight/preflight_test.go b/cmd/stellar-rpc/internal/preflight/preflight_test.go index 75cfb1b7..aaef58df 100644 --- a/cmd/stellar-rpc/internal/preflight/preflight_test.go +++ b/cmd/stellar-rpc/internal/preflight/preflight_test.go @@ -313,7 +313,7 @@ func createLedger(ledgerSequence uint32) xdr.LedgerCloseMeta { } func getDB(t testing.TB, restartDB bool) *db.DB { - dbPath := path.Join(t.TempDir(), "soroban_rpc.sqlite") + dbPath := path.Join(t.TempDir(), "stellar_rpc.sqlite") dbInstance, err := db.OpenSQLiteDB(dbPath) require.NoError(t, err) From 43e083e88e44d6176d4d67227caf6aedcf21b671 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Tue, 26 Nov 2024 21:39:39 +0100 Subject: [PATCH 2/2] Revert breaking changes --- cmd/stellar-rpc/internal/config/options.go | 19 +++++++++++-------- cmd/stellar-rpc/internal/daemon/daemon.go | 5 +++-- .../internal/daemon/interfaces/noOpDaemon.go | 5 ++++- cmd/stellar-rpc/internal/daemon/metrics.go | 10 +++++----- .../internal/integrationtest/metrics_test.go | 4 ++-- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/cmd/stellar-rpc/internal/config/options.go b/cmd/stellar-rpc/internal/config/options.go index 0720ab73..07acd6ca 100644 --- a/cmd/stellar-rpc/internal/config/options.go +++ b/cmd/stellar-rpc/internal/config/options.go @@ -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, @@ -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", diff --git a/cmd/stellar-rpc/internal/daemon/daemon.go b/cmd/stellar-rpc/internal/daemon/daemon.go index 6f97588d..e9de64d9 100644 --- a/cmd/stellar-rpc/internal/daemon/daemon.go +++ b/cmd/stellar-rpc/internal/daemon/daemon.go @@ -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" @@ -35,7 +36,6 @@ import ( ) const ( - prometheusNamespace = "stellar_rpc" maxLedgerEntryWriteBatchSize = 150 defaultReadTimeout = 5 * time.Second defaultShutdownGracePeriod = 10 * time.Second @@ -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") } diff --git a/cmd/stellar-rpc/internal/daemon/interfaces/noOpDaemon.go b/cmd/stellar-rpc/internal/daemon/interfaces/noOpDaemon.go index 1a3014be..ca66802a 100644 --- a/cmd/stellar-rpc/internal/daemon/interfaces/noOpDaemon.go +++ b/cmd/stellar-rpc/internal/daemon/interfaces/noOpDaemon.go @@ -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 { @@ -21,7 +24,7 @@ type NoOpDaemon struct { func MakeNoOpDeamon() *NoOpDaemon { return &NoOpDaemon{ metricsRegistry: prometheus.NewRegistry(), - metricsNamespace: "stellar_rpc", + metricsNamespace: PrometheusNamespace, coreClient: noOpCoreClient{}, } } diff --git a/cmd/stellar-rpc/internal/daemon/metrics.go b/cmd/stellar-rpc/internal/daemon/metrics.go index c7d9dd6d..db799a59 100644 --- a/cmd/stellar-rpc/internal/daemon/metrics.go +++ b/cmd/stellar-rpc/internal/daemon/metrics.go @@ -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{ @@ -49,7 +49,7 @@ func (d *Daemon) MetricsRegistry() *prometheus.Registry { } func (d *Daemon) MetricsNamespace() string { - return prometheusNamespace + return interfaces.PrometheusNamespace } type CoreClientWithMetrics struct { @@ -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"}) diff --git a/cmd/stellar-rpc/internal/integrationtest/metrics_test.go b/cmd/stellar-rpc/internal/integrationtest/metrics_test.go index 49f7289e..4857c3f3 100644 --- a/cmd/stellar-rpc/internal/integrationtest/metrics_test.go +++ b/cmd/stellar-rpc/internal/integrationtest/metrics_test.go @@ -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, @@ -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 }