Skip to content

Commit 8b80aef

Browse files
Merge release 0.20.2 into main (#228)
PMM-7470 Fixed indexstats params
1 parent 162eb5d commit 8b80aef

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

.github/workflows/go.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ jobs:
6060
echo "GOROOT=$HOME/gotip" >> $GITHUB_ENV
6161
echo "$HOME/gotip/bin" >> $GITHUB_PATH
6262
63-
6463
- name: Check out code into the Go module directory
6564
uses: percona-platform/checkout@v2
6665

main.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package main
1818

1919
import (
2020
"fmt"
21+
"log"
2122
"strings"
2223

2324
"github.com/alecthomas/kong"
@@ -72,6 +73,15 @@ func main() {
7273
return
7374
}
7475

76+
e, err := buildExporter(opts)
77+
if err != nil {
78+
log.Fatal(err)
79+
}
80+
81+
e.Run()
82+
}
83+
84+
func buildExporter(opts GlobalFlags) (*exporter.Exporter, error) {
7585
log := logrus.New()
7686

7787
levels := map[string]logrus.Level{
@@ -95,7 +105,7 @@ func main() {
95105
exporterOpts := &exporter.Opts{
96106
CollStatsCollections: strings.Split(opts.CollStatsCollections, ","),
97107
CompatibleMode: opts.CompatibleMode,
98-
IndexStatsCollections: strings.Split(opts.CollStatsCollections, ","),
108+
IndexStatsCollections: strings.Split(opts.IndexStatsCollections, ","),
99109
Logger: log,
100110
Path: opts.WebTelemetryPath,
101111
URI: opts.URI,
@@ -107,8 +117,8 @@ func main() {
107117

108118
e, err := exporter.New(exporterOpts)
109119
if err != nil {
110-
log.Fatal(err)
120+
return nil, err
111121
}
112122

113-
e.Run()
123+
return e, nil
114124
}

main_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package main
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func TestBuildExporter(t *testing.T) {
10+
opts := GlobalFlags{
11+
CollStatsCollections: "c1,c2,c3",
12+
IndexStatsCollections: "i1,i2,i3",
13+
URI: "mongodb://usr:[email protected]/",
14+
GlobalConnPool: false, // to avoid testing the connection
15+
WebListenAddress: "localhost:12345",
16+
WebTelemetryPath: "/mymetrics",
17+
LogLevel: "debug",
18+
19+
DisableDiagnosticData: true,
20+
DisableReplicasetStatus: true,
21+
22+
CompatibleMode: true,
23+
}
24+
25+
_, err := buildExporter(opts)
26+
assert.NoError(t, err)
27+
}

0 commit comments

Comments
 (0)