infra/op-conductor-mon/pkg/service/metrics_server.go
felipe 28bb7461e9
feat: op-conductor-mon (#1)
* feat: op-conductor-mon

* Update CODEOWNERS
2024-05-24 14:34:07 -07:00

28 lines
483 B
Go

package service
import (
"context"
"net/http"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
type MetricsServer struct {
ctx context.Context
server *http.Server
}
func (m *MetricsServer) Start(ctx context.Context, addr string) error {
server := &http.Server{
Handler: promhttp.Handler(),
Addr: addr,
}
m.server = server
m.ctx = ctx
return m.server.ListenAndServe()
}
func (m *MetricsServer) Shutdown() error {
return m.server.Shutdown(m.ctx)
}