-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
37 lines (28 loc) · 804 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"log"
"net/http"
"os"
"github.com/ethereum/go-ethereum/rpc"
"github.com/namikmesic/evm_rpc_exporter/internal/collector"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
func main() {
endpoint := os.Getenv("RPC_ENDPOINT")
provider := os.Getenv("RPC_PROVIDER")
rpc, err := rpc.Dial(endpoint)
if err != nil {
log.Fatal(err)
}
registry := prometheus.NewPedanticRegistry()
registry.MustRegister(
collector.NewEthBlockNumber(rpc, provider),
)
handler := promhttp.HandlerFor(registry, promhttp.HandlerOpts{
ErrorLog: log.New(os.Stderr, log.Prefix(), log.Flags()),
ErrorHandling: promhttp.ContinueOnError,
})
http.Handle("/metrics", handler)
log.Fatal(http.ListenAndServe(":9368", nil))
}