Skip to content

Commit 1dfc50a

Browse files
committed
committer metrics server
1 parent fc2ca72 commit 1dfc50a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

cmd/committer.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ package cmd
22

33
import (
44
"fmt"
5+
"net/http"
56

7+
"github.com/prometheus/client_golang/prometheus/promhttp"
8+
"github.com/rs/zerolog/log"
69
"github.com/spf13/cobra"
710
"github.com/thirdweb-dev/indexer/internal/committer"
811
)
@@ -16,6 +19,16 @@ var committerCmd = &cobra.Command{
1619

1720
func RunCommitter(cmd *cobra.Command, args []string) {
1821
fmt.Println("running committer")
22+
23+
// Start Prometheus metrics server
24+
log.Info().Msg("Starting Metrics Server on port 2112")
25+
go func() {
26+
http.Handle("/metrics", promhttp.Handler())
27+
if err := http.ListenAndServe(":2112", nil); err != nil {
28+
log.Error().Err(err).Msg("Metrics server error")
29+
}
30+
}()
31+
1932
committer.Init()
2033
committer.CommitStreaming()
2134
}

0 commit comments

Comments
 (0)