Skip to content

Commit

Permalink
feat(zetaclient): remove metrics server prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
gartnera committed Apr 17, 2024
1 parent 637c62e commit 30cd8ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
16 changes: 6 additions & 10 deletions zetaclient/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,16 @@ var (
)

func NewMetrics() (*Metrics, error) {
server := http.NewServeMux()

server.Handle("/metrics",
promhttp.InstrumentMetricHandler(
prometheus.DefaultRegisterer,
promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{
Timeout: 30 * time.Second,
}),
),
handler := promhttp.InstrumentMetricHandler(
prometheus.DefaultRegisterer,
promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{
Timeout: 30 * time.Second,
}),
)

s := &http.Server{
Addr: ":8886",
Handler: server,
Handler: handler,
ReadTimeout: 5 * time.Second,
ReadHeaderTimeout: 5 * time.Second,
}
Expand Down
6 changes: 6 additions & 0 deletions zetaclient/metrics/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ func (ms *MetricsSuite) TestMetrics(c *C) {
time.Sleep(1 * time.Second)
res, err := http.Get("http://127.0.0.1:8886/metrics")
c.Assert(err, IsNil)
c.Assert(res.StatusCode, Equals, http.StatusOK)
defer res.Body.Close()
//out, err := ioutil.ReadAll(res.Body)
//fmt.Println(string(out))

res, err = http.Get("http://127.0.0.1:8886")
c.Assert(err, IsNil)
c.Assert(res.StatusCode, Equals, http.StatusOK)
defer res.Body.Close()
}

0 comments on commit 30cd8ce

Please sign in to comment.