Skip to content

Commit

Permalink
Install actions after setting up metrics. (#2717)
Browse files Browse the repository at this point in the history
Running Horizon with ADMIN_PORT enabled will cause a panic when trying
to fetch the metrics since it was being setup before initializing the
metrics registry.
  • Loading branch information
abuiles authored Jun 22, 2020
1 parent 72676e0 commit 28355c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions services/horizon/internal/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,6 @@ func (a *App) init() {
// This parameter will be removed soon.
a.web.mustInstallMiddlewares(a, a.config.ConnectionTimeout)

// web.actions
a.web.mustInstallActions(a.config, a.paths, a.historyQ.Session, a.metrics)

// metrics and log.metrics
a.metrics = metrics.NewRegistry()
for level, meter := range *logmetrics.DefaultMetrics {
Expand All @@ -488,6 +485,9 @@ func (a *App) init() {
// db-metrics
initDbMetrics(a)

// web.actions
a.web.mustInstallActions(a.config, a.paths, a.historyQ.Session, a.metrics)

// ingest.metrics
initIngestMetrics(a)

Expand Down
6 changes: 6 additions & 0 deletions services/horizon/internal/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package horizon
import (
"net/http"
"testing"

"github.com/stellar/go/services/horizon/internal/test"
)

func TestGenericHTTPFeatures(t *testing.T) {
Expand Down Expand Up @@ -37,6 +39,10 @@ func TestMetrics(t *testing.T) {
ht := StartHTTPTest(t, "base")
defer ht.Finish()

adminRouterRH := test.NewRequestHelper(ht.App.web.internalRouter)
w := adminRouterRH.Get("/metrics")
ht.Assert.Equal(200, w.Code)

hl := ht.App.historyLatestLedgerGauge
he := ht.App.historyElderLedgerGauge
cl := ht.App.coreLatestLedgerGauge
Expand Down

0 comments on commit 28355c0

Please sign in to comment.