mv metrics to github.com/go-gost/x

This commit is contained in:
ginuerzh
2022-04-05 17:55:20 +08:00
parent d6e6efb093
commit c2f49e9444
9 changed files with 190 additions and 479 deletions

View File

@ -88,7 +88,10 @@ func (r *Route) connect(ctx context.Context) (conn net.Conn, err error) {
defer func() {
if err != nil && r.chain != nil {
metrics.ChainErrors(r.chain.name).Inc()
if v := metrics.GetCounter(metrics.MetricChainErrorsCounter,
metrics.Labels{"chain": r.chain.name}); v != nil {
v.Inc()
}
}
}()
@ -116,8 +119,10 @@ func (r *Route) connect(ctx context.Context) (conn net.Conn, err error) {
}
node.Marker.Reset()
metrics.ChainNodeConnectSeconds(r.chain.name, node.Name).
Observe(time.Since(start).Seconds())
if v := metrics.GetObserver(metrics.MetricNodeConnectDurationObserver,
metrics.Labels{"chain": r.chain.name, "node": node.Name}); v != nil {
v.Observe(time.Since(start).Seconds())
}
preNode := node
for _, node := range r.nodes[1:] {