diff --git a/chain/route.go b/chain/route.go index c42f516..cf86bfd 100644 --- a/chain/route.go +++ b/chain/route.go @@ -86,18 +86,18 @@ func (r *Route) connect(ctx context.Context) (conn net.Conn, err error) { return nil, ErrEmptyRoute } + network := "ip" + node := r.nodes[0] + defer func() { if err != nil && r.chain != nil { if v := metrics.GetCounter(metrics.MetricChainErrorsCounter, - metrics.Labels{"chain": r.chain.name}); v != nil { + metrics.Labels{"chain": r.chain.name, "node": node.Name}); v != nil { v.Inc() } } }() - network := "ip" - node := r.nodes[0] - addr, err := resolve(ctx, network, node.Addr, node.Resolver, node.Hosts, r.logger) if err != nil { node.Marker.Mark() diff --git a/metrics/metrics.go b/metrics/metrics.go index 79277e5..ca6b3d9 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -3,15 +3,24 @@ package metrics type MetricName string const ( - MetricServicesGauge MetricName = "gost_services" - MetricServiceRequestsCounter MetricName = "gost_service_requests_total" - MetricServiceRequestsInFlightGauge MetricName = "gost_service_requests_in_flight" - MetricServiceRequestsDurationObserver MetricName = "gost_service_request_duration_seconds" - MetricServiceTransferInputBytesCounter MetricName = "gost_service_transfer_input_bytes_total" + // Number of services. Labels: host. + MetricServicesGauge MetricName = "gost_services" + // Total service requests. Labels: host, service. + MetricServiceRequestsCounter MetricName = "gost_service_requests_total" + // Number of in-flight requests. Labels: host, service. + MetricServiceRequestsInFlightGauge MetricName = "gost_service_requests_in_flight" + // Request duration historgram. Labels: host, service. + MetricServiceRequestsDurationObserver MetricName = "gost_service_request_duration_seconds" + // Total service input data transfer size in bytes. Labels: host, service. + MetricServiceTransferInputBytesCounter MetricName = "gost_service_transfer_input_bytes_total" + // Total service output data transfer size in bytes. Labels: host, service. MetricServiceTransferOutputBytesCounter MetricName = "gost_service_transfer_output_bytes_total" - MetricNodeConnectDurationObserver MetricName = "gost_chain_node_connect_duration_seconds" - MetricServiceHandlerErrorsCounter MetricName = "gost_service_handler_errors_total" - MetricChainErrorsCounter MetricName = "gost_chain_errors_total" + // Chain node connect duration histogram. Labels: host, chain, node. + MetricNodeConnectDurationObserver MetricName = "gost_chain_node_connect_duration_seconds" + // Total service handler errors. Labels: host, service. + MetricServiceHandlerErrorsCounter MetricName = "gost_service_handler_errors_total" + // Total chain connect errors. Labels: host, chain, node. + MetricChainErrorsCounter MetricName = "gost_chain_errors_total" ) type Labels map[string]string