Skip to content

Commit

Permalink
Merge pull request #136917 from cockroachdb/blathers/backport-release…
Browse files Browse the repository at this point in the history
…-24.3.1-rc-136850

release-24.3.1-rc: diagnostics: store telemetry ping on construction
  • Loading branch information
dhartunian authored Dec 9, 2024
2 parents 45aad22 + 742c2d8 commit f9b40bb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/server/diagnostics/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import (
// TelemetryHttpTimeout allows for configuration of the client timeout
// for sending telemetry reports. It is not expected that customers
// would tweak this.
var TelemetryHttpTimeout = envutil.EnvOrDefaultDuration("COCKROACH_TELEMETRY_HTTP_CLIENT_TIMEOUT", 5*time.Minute)
var TelemetryHttpTimeout = envutil.EnvOrDefaultDuration("COCKROACH_TELEMETRY_HTTP_CLIENT_TIMEOUT", 1*time.Minute)

// NodeStatusGenerator abstracts the status.MetricRecorder for read access.
type NodeStatusGenerator interface {
Expand Down Expand Up @@ -134,8 +134,8 @@ func NewDiagnosticReporter(
timeout = 3 * time.Second
}

return &Reporter{
StartTime: timeutil.Now(),
r := &Reporter{
StartTime: startTime,
AmbientCtx: ambientCtx,
Config: config,
Settings: settings,
Expand All @@ -150,6 +150,9 @@ func NewDiagnosticReporter(
Locality: locality,
client: httputil.NewClientWithTimeout(timeout),
}
r.LastSuccessfulTelemetryPing.Store(r.now().Unix())

return r
}

// shouldReportDiagnostics determines using the diagnostics report setting in
Expand Down Expand Up @@ -178,9 +181,6 @@ func shouldReportDiagnostics(ctx context.Context, st *cluster.Settings) bool {
// PeriodicallyReportDiagnostics starts a background worker that periodically
// phones home to report usage and diagnostics.
func (r *Reporter) PeriodicallyReportDiagnostics(ctx context.Context, stopper *stop.Stopper) {
// Prior to starting the periodic report job, we store the current
// timestamp to initialize to a valid value.
r.LastSuccessfulTelemetryPing.Store(r.now().Unix())
_ = stopper.RunAsyncTaskEx(ctx, stop.TaskOpts{TaskName: "diagnostics", SpanOpt: stop.SterileRootSpan}, func(ctx context.Context) {
defer logcrash.RecoverAndReportNonfatalPanic(ctx, &r.Settings.SV)
nextReport := r.StartTime
Expand Down

0 comments on commit f9b40bb

Please sign in to comment.