package metrics
import (
"context"
"net"
"net/http"
"strconv"
"github.com/ethereum-optimism/optimism/op-service/httputil"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
func ListenAndServe(ctx context.Context, r *prometheus.Registry, hostname string, port int) error {
addr := net.JoinHostPort(hostname, strconv.Itoa(port))
server := &http.Server{
Addr: addr,
Handler: promhttp.InstrumentMetricHandler(
r, promhttp.HandlerFor(r, promhttp.HandlerOpts{}),
),
}
return httputil.ListenAndServeContext(ctx, server)
}
-
Matthew Slipper authored
* op-batcher op-proposer op-service: Introduce op-service op-service is a utilities library that automates much of the boilerplate setup we've been duplicating across different daemons. This PR adds the following to op-batcher: - Common setup utilities for logging, metrics, pprof, and RPC. - For each of the above functions, a set of CLI flags and configs that can be used to parse + validate CLI configuration for that module. - A base RPC server that implementers can extend. - HTTP metrics utilities. * update dockerfiles * code review updates * op-service: temporary replace, until op-service go module is canonical and can be resolved Co-authored-by:
protolambda <proto@protolambda.com>
8ed8d4ec