Skip to content

Commit

Permalink
Merge pull request #11254 from jingyih/strip_patch_version_in_cluster…
Browse files Browse the repository at this point in the history
…_version_metrics

etcdserver: strip patch version in cluster version metrics
  • Loading branch information
gyuho committed Oct 15, 2019
2 parents 1b041a5 + 1333abc commit bcc1471
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
4 changes: 2 additions & 2 deletions etcdserver/api/membership/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,9 @@ func (c *RaftCluster) SetVersion(ver *semver.Version, onSet func(*zap.Logger, *s
mustSaveClusterVersionToBackend(c.be, ver)
}
if oldVer != nil {
ClusterVersionMetrics.With(prometheus.Labels{"cluster_version": oldVer.String()}).Set(0)
ClusterVersionMetrics.With(prometheus.Labels{"cluster_version": version.Cluster(oldVer.String())}).Set(0)
}
ClusterVersionMetrics.With(prometheus.Labels{"cluster_version": ver.String()}).Set(1)
ClusterVersionMetrics.With(prometheus.Labels{"cluster_version": version.Cluster(ver.String())}).Set(1)
onSet(c.lg, ver)
}

Expand Down
7 changes: 1 addition & 6 deletions tests/e2e/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package e2e

import (
"fmt"
"strings"
"testing"

"go.etcd.io/etcd/version"
Expand All @@ -40,10 +39,6 @@ func metricsTest(cx ctlCtx) {
if err := ctlV3Put(cx, "k", "v", ""); err != nil {
cx.t.Fatal(err)
}
ver := version.Version
if strings.HasSuffix(ver, "-pre") {
ver = strings.Replace(ver, "-pre", "", 1)
}

i := 0
for _, test := range []struct {
Expand All @@ -53,7 +48,7 @@ func metricsTest(cx ctlCtx) {
{"/metrics", fmt.Sprintf("etcd_debugging_mvcc_keys_total 1")},
{"/metrics", fmt.Sprintf("etcd_mvcc_delete_total 3")},
{"/metrics", fmt.Sprintf(`etcd_server_version{server_version="%s"} 1`, version.Version)},
{"/metrics", fmt.Sprintf(`etcd_cluster_version{cluster_version="%s"} 1`, ver)},
{"/metrics", fmt.Sprintf(`etcd_cluster_version{cluster_version="%s"} 1`, version.Cluster(version.Version))},
{"/health", `{"health":"true"}`},
} {
i++
Expand Down

0 comments on commit bcc1471

Please sign in to comment.