Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ jobs:
echo "GOROOT=$HOME/gotip" >> $GITHUB_ENV
echo "$HOME/gotip/bin" >> $GITHUB_PATH


- name: Check out code into the Go module directory
uses: percona-platform/checkout@v2

Expand Down
16 changes: 13 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main

import (
"fmt"
"log"
"strings"

"github.com/alecthomas/kong"
Expand Down Expand Up @@ -72,6 +73,15 @@ func main() {
return
}

e, err := buildExporter(opts)
if err != nil {
log.Fatal(err)
}

e.Run()
}

func buildExporter(opts GlobalFlags) (*exporter.Exporter, error) {
log := logrus.New()

levels := map[string]logrus.Level{
Expand All @@ -95,7 +105,7 @@ func main() {
exporterOpts := &exporter.Opts{
CollStatsCollections: strings.Split(opts.CollStatsCollections, ","),
CompatibleMode: opts.CompatibleMode,
IndexStatsCollections: strings.Split(opts.CollStatsCollections, ","),
IndexStatsCollections: strings.Split(opts.IndexStatsCollections, ","),
Logger: log,
Path: opts.WebTelemetryPath,
URI: opts.URI,
Expand All @@ -107,8 +117,8 @@ func main() {

e, err := exporter.New(exporterOpts)
if err != nil {
log.Fatal(err)
return nil, err
}

e.Run()
return e, nil
}
27 changes: 27 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package main

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestBuildExporter(t *testing.T) {
opts := GlobalFlags{
CollStatsCollections: "c1,c2,c3",
IndexStatsCollections: "i1,i2,i3",
URI: "mongodb://usr:pwd@127.0.0.1/",
GlobalConnPool: false, // to avoid testing the connection
WebListenAddress: "localhost:12345",
WebTelemetryPath: "/mymetrics",
LogLevel: "debug",

DisableDiagnosticData: true,
DisableReplicasetStatus: true,

CompatibleMode: true,
}

_, err := buildExporter(opts)
assert.NoError(t, err)
}