Skip to content

fix: Avoid parsing telemetry URL when telemetry is disabled #4881

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

Merged
merged 2 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix: Change trace env var back and avoid URL error when disabled
  • Loading branch information
mafredri committed Nov 3, 2022
commit 24b55dbe147357d67d7b28fea9041acb6a6bacbb
2 changes: 1 addition & 1 deletion cli/deployment/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func newConfig() *codersdk.DeploymentConfig {

Telemetry: &codersdk.TelemetryConfig{
Enable: &codersdk.DeploymentConfigField[bool]{
Name: "Telemetry Enable",
Name: "Telemetry",
Usage: "Whether telemetry is enabled or not. Coder collects anonymized usage data to help improve our product.",
Flag: "telemetry",
Default: flag.Lookup("test.v") == nil,
Expand Down
11 changes: 6 additions & 5 deletions cli/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,16 +468,17 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
}
}

// Parse the raw telemetry URL!
telemetryURL, err := parseURL(cfg.Telemetry.URL.Value)
if err != nil {
return xerrors.Errorf("parse telemetry url: %w", err)
}
// Disable telemetry if the in-memory database is used unless explicitly defined!
if cfg.InMemoryDatabase.Value && !cmd.Flags().Changed(cfg.Telemetry.Enable.Flag) {
cfg.Telemetry.Enable.Value = false
}
if cfg.Telemetry.Enable.Value {
// Parse the raw telemetry URL!
telemetryURL, err := parseURL(cfg.Telemetry.URL.Value)
if err != nil {
return xerrors.Errorf("parse telemetry url: %w", err)
}

options.Telemetry, err = telemetry.New(telemetry.Options{
BuiltinPostgres: builtinPostgres,
DeploymentID: deploymentID,
Expand Down