Skip to content

Commit

Permalink
Merge pull request #462 from onflow/petera/auto-update-onflow-cadence…
Browse files Browse the repository at this point in the history
…-v0.40.0-rest-metrics-fix
  • Loading branch information
turbolent authored Aug 8, 2023
2 parents 02a44bf + 7da173a commit db6cfd9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ require (
github.com/psiemens/graceland v1.0.0
github.com/psiemens/sconfig v0.1.0
github.com/rs/zerolog v1.29.0
github.com/slok/go-http-metrics v0.10.0
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.8.4
golang.org/x/exp v0.0.0-20230321023759-10a507213a29
Expand Down Expand Up @@ -126,6 +125,7 @@ require (
github.com/rs/cors v1.8.0 // indirect
github.com/schollz/progressbar/v3 v3.13.1 // indirect
github.com/sethvargo/go-retry v0.2.3 // indirect
github.com/slok/go-http-metrics v0.10.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect
Expand Down
16 changes: 11 additions & 5 deletions server/access/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,20 @@ import (
"context"
"flag"
"fmt"
"github.com/onflow/flow-go/module"
"net"
"net/http"
"os"

"github.com/onflow/flow-emulator/adapters"
metricsProm "github.com/slok/go-http-metrics/metrics/prometheus"
"github.com/prometheus/client_golang/prometheus"
"github.com/rs/zerolog"

"github.com/onflow/flow-go/engine/access/rest"
"github.com/onflow/flow-go/engine/access/rest/routes"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/module"
"github.com/onflow/flow-go/module/metrics"
"github.com/rs/zerolog"

"github.com/onflow/flow-emulator/adapters"
)

type RestServer struct {
Expand Down Expand Up @@ -85,7 +87,11 @@ func NewRestServer(logger *zerolog.Logger, adapter *adapters.AccessAdapter, chai

// only collect metrics if not test
if flag.Lookup("test.v") == nil {
restCollector = metrics.NewRestCollector(metricsProm.Config{Prefix: "access_rest_api"})
var err error
restCollector, err = metrics.NewRestCollector(routes.URLToRoute, prometheus.DefaultRegisterer)
if err != nil {
return nil, err
}
}

srv, err := rest.NewServer(adapter, fmt.Sprintf("%s:3333", host), debugLogger, chain, restCollector)
Expand Down

0 comments on commit db6cfd9

Please sign in to comment.