Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting "package" variable with a testing flag #2357

Merged
merged 4 commits into from
Apr 4, 2023
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
14 changes: 2 additions & 12 deletions build/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ func init() {
panic(msg)
}

info.BuildEnvironment.Set("go.version", buildInfo.GoVersion)

for _, s := range buildInfo.Settings {
switch s.Key {
case "vcs.revision":
Expand All @@ -173,18 +175,6 @@ func init() {
case "vcs.modified":
info.Dirty = must.NotFail(strconv.ParseBool(s.Value))

case "-compiler":
info.BuildEnvironment.Set("compiler", s.Value)

case "-race":
info.BuildEnvironment.Set("race", s.Value)

case "-tags":
info.BuildEnvironment.Set("buildtags", s.Value)

case "-trimpath":
info.BuildEnvironment.Set("trimpath", s.Value)

default:
info.BuildEnvironment.Set(s.Key, s.Value)
}
Expand Down
16 changes: 11 additions & 5 deletions cmd/ferretdb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ var cli struct {
DisablePushdown bool `default:"false" help:"Experimental: disable query pushdown."`
EnableCursors bool `default:"false" help:"Experimental: enable cursors."`

//nolint:lll // for readability
Telemetry struct {
URL string `default:"https://beacon.ferretdb.io/" help:"Experimental: telemetry: reporting URL."`
UndecidedDelay time.Duration `default:"1h" help:"${help_telemetry_undecided_delay}"`
ReportInterval time.Duration `default:"24h" hidden:"" help:"Experimental: telemetry: report interval."`
ReportTimeout time.Duration `default:"5s" hidden:"" help:"Experimental: telemetry: report timeout."`
ReportInterval time.Duration `default:"24h" help:"Experimental: telemetry: report interval."`
ReportTimeout time.Duration `default:"5s" help:"Experimental: telemetry: report timeout."`
Package string `default:"" help:"Experimental: telemetry: custom package type."`
} `embed:"" prefix:"telemetry-"`
} `embed:"" prefix:"test-"`
}
Expand Down Expand Up @@ -259,9 +261,13 @@ func dumpMetrics() {

// run sets up environment based on provided flags and runs FerretDB.
func run() {
if cli.Version {
info := version.Get()
info := version.Get()

if p := cli.Test.Telemetry.Package; p != "" {
info.Package = p
}

if cli.Version {
fmt.Fprintln(os.Stdout, "version:", info.Version)
fmt.Fprintln(os.Stdout, "commit:", info.Commit)
fmt.Fprintln(os.Stdout, "branch:", info.Branch)
Expand Down Expand Up @@ -370,7 +376,7 @@ func run() {

wg.Wait()

if version.Get().DebugBuild {
if info.DebugBuild {
dumpMetrics()
}
}
3 changes: 2 additions & 1 deletion website/docs/telemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ The following data is collected:
cloud provider region, or country derived from IP address (but the IP address itself)
* Uptime
* Backend (PostgreSQL or Tigris) version
* Build configuration and installation type (Docker, package, self-built)
* Installation type (Docker, package, cloud provider marketplace, self-built)
* Build configuration (Go version, build flags and tags)
* Command statistics:
* protocol operation codes (e.g. `OP_MSG`, `OP_QUERY`);
* command names (e.g. `find`, `aggregate`);
Expand Down