Skip to content

Commit a9a482b

Browse files
PMM-7961 update exporter shared (#300)
* Updated exporter shared * Made test reliable * mod tidy * Ran gofumpt Co-authored-by: Andrii Skomorokhov <[email protected]>
1 parent d88f7d3 commit a9a482b

File tree

6 files changed

+25
-35
lines changed

6 files changed

+25
-35
lines changed

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ env:
6464
@echo $(TEST_ENV) | tr ' ' '\n' >.env
6565

6666
init: ## Install linters.
67-
go build -modfile=tools/go.mod -o bin/goimports golang.org/x/tools/cmd/goimports
67+
go build -modfile=tools/go.mod -o bin/gofumports mvdan.cc/gofumpt/gofumports
68+
go build -modfile=tools/go.mod -o bin/gofumpt mvdan.cc/gofumpt
6869
go build -modfile=tools/go.mod -o bin/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint
6970
go build -modfile=tools/go.mod -o bin/reviewdog github.com/reviewdog/reviewdog/cmd/reviewdog
7071

@@ -81,8 +82,8 @@ FILES = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
8182

8283
format: ## Format source code.
8384
go mod tidy
84-
gofmt -w -s $(FILES)
85-
bin/goimports -local github.com/percona/mongodb_exporter -l -w $(FILES)
85+
bin/gofumpt -w -s $(FILES)
86+
bin/gofumports -local github.com/percona/mongodb_exporter -l -w $(FILES)
8687

8788
check: ## Run checks/linters
8889
bin/golangci-lint run

exporter/replset_status_collector_test.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,14 @@ func TestReplsetStatusCollector(t *testing.T) {
5151
mongodb_myState 1
5252
# HELP mongodb_ok ok
5353
# TYPE mongodb_ok untyped
54-
mongodb_ok 1
55-
# HELP mongodb_optimes_appliedOpTime_t optimes.appliedOpTime.
56-
# TYPE mongodb_optimes_appliedOpTime_t untyped
57-
mongodb_optimes_appliedOpTime_t 1
58-
# HELP mongodb_optimes_durableOpTime_t optimes.durableOpTime.
59-
# TYPE mongodb_optimes_durableOpTime_t untyped
60-
mongodb_optimes_durableOpTime_t 1` + "\n")
54+
mongodb_ok 1` + "\n")
6155
// Filter metrics for 2 reasons:
6256
// 1. The result is huge
6357
// 2. We need to check against know values. Don't use metrics that return counters like uptime
6458
// or counters like the number of transactions because they won't return a known value to compare
6559
filter := []string{
6660
"mongodb_myState",
6761
"mongodb_ok",
68-
"mongodb_optimes_appliedOpTime_t",
69-
"mongodb_optimes_durableOpTime_t",
7062
}
7163
err := testutil.CollectAndCompare(c, expected, filter...)
7264
assert.NoError(t, err)

exporter/secondary_lag_test.go

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,25 @@ type RSConfig struct {
2626
ProtocolVersion int `bson:"protocolVersion"`
2727
WriteConcernMajorityJournalDefault bool `bson:"writeConcernMajorityJournalDefault"`
2828
Members []struct {
29-
ID int `bson:"_id"`
30-
Host string `bson:"host"`
31-
ArbiterOnly bool `bson:"arbiterOnly"`
32-
BuildIndexes bool `bson:"buildIndexes"`
33-
Hidden bool `bson:"hidden"`
34-
Priority int `bson:"priority"`
35-
Tags struct {
36-
} `bson:"tags"`
37-
SlaveDelay int `bson:"slaveDelay"`
38-
Votes int `bson:"votes"`
29+
ID int `bson:"_id"`
30+
Host string `bson:"host"`
31+
ArbiterOnly bool `bson:"arbiterOnly"`
32+
BuildIndexes bool `bson:"buildIndexes"`
33+
Hidden bool `bson:"hidden"`
34+
Priority int `bson:"priority"`
35+
Tags struct{} `bson:"tags"`
36+
SlaveDelay int `bson:"slaveDelay"`
37+
Votes int `bson:"votes"`
3938
} `bson:"members"`
4039
Settings struct {
41-
ChainingAllowed bool `bson:"chainingAllowed"`
42-
HeartbeatIntervalMillis int `bson:"heartbeatIntervalMillis"`
43-
HeartbeatTimeoutSecs int `bson:"heartbeatTimeoutSecs"`
44-
ElectionTimeoutMillis int `bson:"electionTimeoutMillis"`
45-
CatchUpTimeoutMillis int `bson:"catchUpTimeoutMillis"`
46-
CatchUpTakeoverDelayMillis int `bson:"catchUpTakeoverDelayMillis"`
47-
GetLastErrorModes struct {
48-
} `bson:"getLastErrorModes"`
49-
GetLastErrorDefaults struct {
40+
ChainingAllowed bool `bson:"chainingAllowed"`
41+
HeartbeatIntervalMillis int `bson:"heartbeatIntervalMillis"`
42+
HeartbeatTimeoutSecs int `bson:"heartbeatTimeoutSecs"`
43+
ElectionTimeoutMillis int `bson:"electionTimeoutMillis"`
44+
CatchUpTimeoutMillis int `bson:"catchUpTimeoutMillis"`
45+
CatchUpTakeoverDelayMillis int `bson:"catchUpTakeoverDelayMillis"`
46+
GetLastErrorModes struct{} `bson:"getLastErrorModes"`
47+
GetLastErrorDefaults struct {
5048
W int `bson:"w"`
5149
Wtimeout int `bson:"wtimeout"`
5250
} `bson:"getLastErrorDefaults"`

exporter/v1_compatibility.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,6 @@ func oplogStatus(ctx context.Context, client *mongo.Client) ([]prometheus.Metric
856856
tailMetric := prometheus.MustNewConstMetric(tailDesc, prometheus.GaugeValue, float64(tail.Timestamp.T))
857857

858858
return []prometheus.Metric{headMetric, tailMetric}, nil
859-
860859
}
861860

862861
func replSetMetrics(m bson.M) []prometheus.Metric {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ go 1.15
88
require (
99
github.com/AlekSi/pointer v1.1.0
1010
github.com/alecthomas/kong v0.2.17
11-
github.com/percona/exporter_shared v0.7.2
11+
github.com/percona/exporter_shared v0.7.3
1212
github.com/percona/percona-toolkit v0.0.0-20210503082911-610ab8c66a81
1313
github.com/pkg/errors v0.9.1
1414
github.com/prometheus/client_golang v1.11.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ github.com/pborman/getopt v0.0.0-20190409184431-ee0cd42419d3/go.mod h1:85jBQOZwp
306306
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
307307
github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo=
308308
github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE=
309-
github.com/percona/exporter_shared v0.7.2 h1:8eNBht83bgFagdiIm3b4HbsOFc5du6OUBCUVenTumdw=
310-
github.com/percona/exporter_shared v0.7.2/go.mod h1:AWk9lgTPzI7tC5PzpeBGvhhqjSJNxpPNFaF7qLIJqmo=
309+
github.com/percona/exporter_shared v0.7.3 h1:TX4LisZ08jo8KIlekBTwPX13JlM6gOOKgmwg7QEf+r8=
310+
github.com/percona/exporter_shared v0.7.3/go.mod h1:AWk9lgTPzI7tC5PzpeBGvhhqjSJNxpPNFaF7qLIJqmo=
311311
github.com/percona/go-mysql v0.0.0-20190903141930-197f4ad8db8d/go.mod h1:/SGLf9OMxlnK6jq4mkFiImBcJXXk5jwD+lDrwDaGXcw=
312312
github.com/percona/percona-toolkit v0.0.0-20210503082911-610ab8c66a81 h1:3BEeXQbahNJpMioM2PGDpf1RqGQt3UNe0xOPkP93Bco=
313313
github.com/percona/percona-toolkit v0.0.0-20210503082911-610ab8c66a81/go.mod h1:uGrhLglXccEIplDyzQSJfv3UWG5J7ACFjaZebntKStQ=

0 commit comments

Comments
 (0)