Skip to content

Commit

Permalink
Metrics: fix mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
0SkillAllLuck committed Apr 9, 2020
1 parent c2b56c0 commit 19eaece
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions server/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ var (
},
[]string{"route"},
)
metricsErrors = prometheus.NewCounterVec(
metricsErrorsTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "qumine_ingress_errors_total",
Help: "The total error count",
},
[]string{"error"},
)
metricsBytes = prometheus.NewCounterVec(
metricsBytesTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "qumine_ingress_bytes_total",
Help: "The total bytes transmitted",
Expand All @@ -30,5 +30,5 @@ var (

func init() {
prometheus.MustRegister(metricsConnections)
prometheus.MustRegister(metricsBytes)
prometheus.MustRegister(metricsBytesTotal)
}
6 changes: 3 additions & 3 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (server *Server) findAndConnectBackend(context context.Context, client net.
route, err := ReadRoute(hostname)
if err != nil {
logrus.WithError(err).Warn("no matching route found")
metricsConnections.With(prometheus.Labels{"error": "no route found"}).Inc()
metricsErrorsTotal.With(prometheus.Labels{"error": "no route found"}).Inc()
return
}
logrus.WithFields(logrus.Fields{
Expand All @@ -155,7 +155,7 @@ func (server *Server) findAndConnectBackend(context context.Context, client net.
"client": client.RemoteAddr(),
"route": route,
}).Error("connecting to upstream failed")
metricsConnections.With(prometheus.Labels{"error": "coonection failed"}).Inc()
metricsErrorsTotal.With(prometheus.Labels{"error": "coonection failed"}).Inc()
return
}
defer metricsConnections.With(prometheus.Labels{"route": route}).Dec()
Expand Down Expand Up @@ -221,7 +221,7 @@ func (server *Server) relayConnections(context context.Context, route string, cl

func (server *Server) relay(incoming io.Reader, outgoing io.Writer, errors chan<- error, direction string, route string, client net.Conn, upstream net.Conn) {
amount, err := io.Copy(outgoing, incoming)
metricsBytes.With(prometheus.Labels{"direction": direction, "route": route}).Add(float64(amount))
metricsBytesTotal.With(prometheus.Labels{"direction": direction, "route": route}).Add(float64(amount))
logrus.WithFields(logrus.Fields{
"client": client.RemoteAddr(),
"upstream": upstream.RemoteAddr(),
Expand Down

0 comments on commit 19eaece

Please sign in to comment.