Skip to content

Commit 7adf582

Browse files
committed
disable report on close when reporting telemetry disabled
1 parent 9455ca5 commit 7adf582

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

cli/server.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -822,10 +822,11 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
822822

823823
if !vals.Telemetry.Enable.Value() {
824824
reporter, err := telemetry.New(telemetry.Options{
825-
DeploymentID: deploymentID,
826-
Database: options.Database,
827-
Logger: logger.Named("telemetry"),
828-
URL: vals.Telemetry.URL.Value(),
825+
DeploymentID: deploymentID,
826+
Database: options.Database,
827+
Logger: logger.Named("telemetry"),
828+
URL: vals.Telemetry.URL.Value(),
829+
DisableReportOnClose: true,
829830
})
830831
if err != nil {
831832
logger.Debug(ctx, "create telemetry reporter (disabled)", slog.Error(err))

coderd/telemetry/telemetry.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ type Options struct {
4747
// URL is an endpoint to direct telemetry towards!
4848
URL *url.URL
4949

50-
DeploymentID string
51-
DeploymentConfig *codersdk.DeploymentValues
52-
BuiltinPostgres bool
53-
Tunnel bool
50+
DeploymentID string
51+
DeploymentConfig *codersdk.DeploymentValues
52+
BuiltinPostgres bool
53+
Tunnel bool
54+
DisableReportOnClose bool
5455

5556
SnapshotFrequency time.Duration
5657
ParseLicenseJWT func(lic *License) error
@@ -175,10 +176,12 @@ func (r *remoteReporter) Close() {
175176
close(r.closed)
176177
now := dbtime.Now()
177178
r.shutdownAt = &now
178-
// Report a final collection of telemetry prior to close!
179-
// This could indicate final actions a user has taken, and
180-
// the time the deployment was shutdown.
181-
r.reportWithDeployment()
179+
if !r.options.DisableReportOnClose {
180+
// Report a final collection of telemetry prior to close!
181+
// This could indicate final actions a user has taken, and
182+
// the time the deployment was shutdown.
183+
r.reportWithDeployment()
184+
}
182185
r.closeFunc()
183186
}
184187

0 commit comments

Comments
 (0)