Skip to content

Commit

Permalink
feat: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ToniRamirezM committed Jan 9, 2025
1 parent aab06f8 commit d89ed8e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/ecdsa"
"fmt"
"math/big"
"net/http"
"os"
"os/signal"
"runtime"
Expand All @@ -30,6 +31,7 @@ import (
"github.com/0xPolygon/cdk/l1infotreesync"
"github.com/0xPolygon/cdk/lastgersync"
"github.com/0xPolygon/cdk/log"
"github.com/0xPolygon/cdk/prometheus"
"github.com/0xPolygon/cdk/reorgdetector"
"github.com/0xPolygon/cdk/rpc"
"github.com/0xPolygon/cdk/sequencesender"
Expand All @@ -40,6 +42,7 @@ import (
"github.com/0xPolygon/zkevm-ethtx-manager/ethtxmanager"
ethtxlog "github.com/0xPolygon/zkevm-ethtx-manager/log"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/urfave/cli/v2"
)

Expand Down Expand Up @@ -803,3 +806,13 @@ func getL2RPCUrl(c *config.Config) string {

return c.AggOracle.EVMSender.URLRPCL2
}

func startMetricsHttpServer(c prometheus.Config) {
log.Info("serving metrics at %v:%v", c.Host, c.Port)
http.Handle("/metrics", promhttp.Handler())
err := http.ListenAndServe(":2223", nil) //nolint:gosec // Ignoring G114: Use of net/http serve function that has no support for setting timeouts.
if err != nil {
fmt.Printf("error serving http: %v", err)
return
}
}
11 changes: 11 additions & 0 deletions prometheus/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package prometheus

// Config represents the configuration of the metrics
type Config struct {
// Host is the address to bind the metrics server
Host string `mapstructure:"Host"`
// Port is the port to bind the metrics server
Port int `mapstructure:"Port"`
// Enabled is the flag to enable/disable the metrics server
Enabled bool `mapstructure:"Enabled"`
}
Empty file added prometheus/prometheus.go
Empty file.

0 comments on commit d89ed8e

Please sign in to comment.