prometheus handle metrics
This commit is contained in:
parent
8970730ec9
commit
e7602a164a
@ -38,7 +38,7 @@ var (
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
if *flagVersion {
|
||||
fmt.Println(app.VersionDescription())
|
||||
return
|
||||
|
||||
@ -50,8 +50,9 @@ func (m *metric) Run(ctx context.Context) (err error) {
|
||||
}
|
||||
if m.config.Addr != "" {
|
||||
var errCh = make(chan error)
|
||||
http.Handle("/metrics", promhttp.HandlerFor(m.registry, promhttp.HandlerOpts{}))
|
||||
go func() {
|
||||
errCh <- http.ListenAndServe(m.config.Addr, promhttp.HandlerFor(m.registry, promhttp.HandlerOpts{}))
|
||||
errCh <- http.ListenAndServe(m.config.Addr, nil)
|
||||
}()
|
||||
select {
|
||||
case err = <-errCh:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user