From ed6ccef5cfcbb9f1be692b498b24c990f925a747 Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Mon, 1 Feb 2021 13:13:20 -0800 Subject: [PATCH] export metrics for lotus-gateway --- cmd/lotus-gateway/main.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmd/lotus-gateway/main.go b/cmd/lotus-gateway/main.go index bc8785923..5190ea798 100644 --- a/cmd/lotus-gateway/main.go +++ b/cmd/lotus-gateway/main.go @@ -6,7 +6,9 @@ import ( "net/http" "os" + "contrib.go.opencensus.io/exporter/prometheus" "github.com/filecoin-project/go-jsonrpc" + promclient "github.com/prometheus/client_golang/prometheus" "go.opencensus.io/tag" "github.com/filecoin-project/lotus/build" @@ -99,6 +101,17 @@ var runCmd = &cli.Command{ rpcServer.Register("Filecoin", metrics.MetricedGatewayAPI(NewGatewayAPI(api))) mux.Handle("/rpc/v0", rpcServer) + + registry := promclient.DefaultRegisterer.(*promclient.Registry) + exporter, err := prometheus.NewExporter(prometheus.Options{ + Registry: registry, + Namespace: "lotus_gw", + }) + if err != nil { + return err + } + mux.Handle("/debug/metrics", exporter) + mux.PathPrefix("/").Handler(http.DefaultServeMux) /*ah := &auth.Handler{