Skip to content

Commit 150308a

Browse files
committed
backup: remove useless fields in telemetry events
Epic: none Release note: none
1 parent dcad761 commit 150308a

File tree

8 files changed

+9
-183
lines changed

8 files changed

+9
-183
lines changed

docs/generated/eventlog.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3371,25 +3371,20 @@ logged whenever a BACKUP and RESTORE job completes or fails.
33713371
| `TargetScope` | TargetScope is the largest scope of the targets that the user is backing up or restoring based on the following order: table < schema < database < full cluster. | no |
33723372
| `IsMultiregionTarget` | IsMultiregionTarget is true if any of the targets contain objects with multi-region primitives. | no |
33733373
| `TargetCount` | TargetCount is the number of targets the in the BACKUP/RESTORE. | no |
3374-
| `DestinationSubdirType` | DestinationSubdirType is - latest: if using the latest subdir - standard: if using a date-based subdir - custom: if using a custom subdir that's not date-based | no |
33753374
| `DestinationStorageTypes` | DestinationStorageTypes are the types of storage that the user is backing up to or restoring from. | no |
33763375
| `DestinationAuthTypes` | DestinationAuthTypes are the types of authentication methods that the user is using to access the destination storage. | no |
33773376
| `IsLocalityAware` | IsLocalityAware indicates if the BACKUP or RESTORE is locality aware. | no |
3378-
| `AsOfInterval` | AsOfInterval is the time interval in nanoseconds between the statement timestamp and the timestamp resolved by the AS OF SYSTEM TIME expression. The interval is expressed in nanoseconds. | no |
33793377
| `WithRevisionHistory` | WithRevisionHistory is true if the BACKUP includes revision history. | no |
33803378
| `HasEncryptionPassphrase` | HasEncryptionPassphrase is true if the user provided an encryption passphrase to encrypt/decrypt their backup. | no |
33813379
| `KMSType` | KMSType is the type of KMS the user is using to encrypt/decrypt their backup. | no |
33823380
| `KMSCount` | KMSCount is the number of KMS the user is using. | no |
33833381
| `Options` | Options contain all the names of the options specified by the user in the BACKUP or RESTORE statement. For options that are accompanied by a value, only those with non-empty values will be present.<br><br>It's important to note that there are no option values anywhere in the event payload. Future changes to telemetry should refrain from adding values to the payload unless they are properly redacted. | no |
3384-
| `DebugPauseOn` | DebugPauseOn is the type of event that the restore should pause on for debugging purposes. Currently only "error" is supported. | no |
33853382
| `JobID` | JobID is the ID of the BACKUP/RESTORE job. | no |
33863383
| `ResultStatus` | ResultStatus indicates whether the job succeeded or failed. | no |
33873384
| `ErrorText` | ErrorText is the text of the error that caused the job to fail. | partially |
33883385
| `RecurringCron` | RecurringCron is the crontab for the incremental backup. | no |
33893386
| `FullBackupCron` | FullBackupCron is the crontab for the full backup. | no |
33903387
| `CustomFirstRunTime` | CustomFirstRunTime is the timestamp for the user configured first run time. Expressed as nanoseconds since the Unix epoch. | no |
3391-
| `OnExecutionFailure` | OnExecutionFailure describes the desired behavior if the schedule fails to execute. | no |
3392-
| `OnPreviousRunning` | OnPreviousRunning describes the desired behavior if the previously scheduled BACKUP is still running. | no |
33933388
| `IgnoreExistingBackup` | IgnoreExistingBackup is true iff the BACKUP schedule should still be created even if a backup is already present in its destination. | no |
33943389
| `ApplicationName` | The application name for the session where recovery event was created. | no |
33953390
| `NumRows` | NumRows is the number of rows successfully imported, backed up or restored. | no |

pkg/backup/backup_job.go

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ func (b *backupResumer) Resume(ctx context.Context, execCtx interface{}) error {
674674
}
675675

676676
// Collect telemetry, once per backup after resolving its destination.
677-
collectTelemetry(ctx, backupManifest, initialDetails, details, true, b.job.ID())
677+
collectTelemetry(ctx, backupManifest, initialDetails, details, b.job.ID())
678678
}
679679

680680
// For all backups, partitioned or not, the main BACKUP manifest is stored at
@@ -992,7 +992,6 @@ func collectTelemetry(
992992
ctx context.Context,
993993
backupManifest *backuppb.BackupManifest,
994994
initialDetails, backupDetails jobspb.BackupDetails,
995-
licensed bool,
996995
jobID jobspb.JobID,
997996
) {
998997
// sourceSuffix specifies if this schedule was created by a schedule.
@@ -1008,14 +1007,6 @@ func collectTelemetry(
10081007
}
10091008

10101009
countSource("backup.total.started")
1011-
if backupManifest.IsIncremental() || backupDetails.EncryptionOptions != nil {
1012-
countSource("backup.using-enterprise-features")
1013-
}
1014-
if licensed {
1015-
countSource("backup.licensed")
1016-
} else {
1017-
countSource("backup.free")
1018-
}
10191010
if backupDetails.StartTime.IsEmpty() {
10201011
countSource("backup.span.full")
10211012
} else {
@@ -1039,33 +1030,6 @@ func collectTelemetry(
10391030
countSource("backup.encryption.kms")
10401031
}
10411032
}
1042-
if backupDetails.CollectionURI != "" {
1043-
countSource("backup.nested")
1044-
timeBaseSubdir := true
1045-
if _, err := time.Parse(backupbase.DateBasedIntoFolderName,
1046-
initialDetails.Destination.Subdir); err != nil {
1047-
timeBaseSubdir = false
1048-
}
1049-
if backupDetails.StartTime.IsEmpty() {
1050-
if !timeBaseSubdir {
1051-
countSource("backup.deprecated-full-nontime-subdir")
1052-
} else if initialDetails.Destination.Exists {
1053-
countSource("backup.deprecated-full-time-subdir")
1054-
} else {
1055-
countSource("backup.full-no-subdir")
1056-
}
1057-
} else {
1058-
if initialDetails.Destination.Subdir == backupbase.LatestFileName {
1059-
countSource("backup.incremental-latest-subdir")
1060-
} else if !timeBaseSubdir {
1061-
countSource("backup.deprecated-incremental-nontime-subdir")
1062-
} else {
1063-
countSource("backup.incremental-explicit-subdir")
1064-
}
1065-
}
1066-
} else {
1067-
countSource("backup.deprecated-non-collection")
1068-
}
10691033
if backupManifest.DescriptorCoverage == tree.AllDescriptors {
10701034
countSource("backup.targets.full_cluster")
10711035
}

pkg/backup/backup_telemetry.go

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ import (
99
"context"
1010
"net/url"
1111
"sort"
12-
"strings"
1312
"time"
1413

15-
"github.com/cockroachdb/cockroach/pkg/backup/backupbase"
1614
"github.com/cockroachdb/cockroach/pkg/backup/backupdest"
1715
"github.com/cockroachdb/cockroach/pkg/cloud"
1816
"github.com/cockroachdb/cockroach/pkg/jobs/jobspb"
@@ -47,10 +45,6 @@ const (
4745
scheduledBackupJobEventType eventpb.RecoveryEventType = "scheduled_backup_job"
4846
restoreJobEventType eventpb.RecoveryEventType = "restore_job"
4947

50-
latestSubdirType = "latest"
51-
standardSubdirType = "standard"
52-
customSubdirType = "custom"
53-
5448
// Currently the telemetry event payload only contains keys of options. Future
5549
// changes to telemetry should refrain from adding values to the payload
5650
// unless they are properly redacted.
@@ -100,21 +94,6 @@ func createBackupRecoveryEvent(
10094
}
10195
}
10296

103-
timeBaseSubdir := true
104-
var subdirType string
105-
if _, err := time.Parse(backupbase.DateBasedIntoFolderName,
106-
initialDetails.Destination.Subdir); err != nil {
107-
timeBaseSubdir = false
108-
}
109-
110-
if strings.EqualFold(initialDetails.Destination.Subdir, backupbase.LatestFileName) {
111-
subdirType = latestSubdirType
112-
} else if !timeBaseSubdir {
113-
subdirType = customSubdirType
114-
} else {
115-
subdirType = standardSubdirType
116-
}
117-
11897
authTypes := make(map[string]struct{})
11998
storageTypes := make(map[string]struct{})
12099
defaultURI, urisByLocalityKV, err := backupdest.GetURIsByLocalityKV(initialDetails.Destination.To, "")
@@ -156,14 +135,12 @@ func createBackupRecoveryEvent(
156135
TargetScope: largestScope.String(),
157136
IsMultiregionTarget: multiRegion,
158137
TargetCount: uint32(targetCount),
159-
DestinationSubdirType: subdirType,
160138
IsLocalityAware: isLocalityAware,
161139
WithRevisionHistory: initialDetails.RevisionHistory,
162140
HasEncryptionPassphrase: passphrase,
163141
KMSType: kms,
164142
KMSCount: uint32(kmsCount),
165143
JobID: uint64(jobID),
166-
AsOfInterval: initialDetails.AsOfInterval,
167144
Options: options,
168145
ApplicationName: initialDetails.ApplicationName,
169146
}
@@ -245,25 +222,6 @@ func parseStorageAndAuth(uri string) (string, string, error) {
245222
return storageType, authType, nil
246223
}
247224

248-
func loggedSubdirType(subdir string) string {
249-
timeBaseSubdir := true
250-
var subdirType string
251-
if _, err := time.Parse(backupbase.DateBasedIntoFolderName,
252-
subdir); err != nil {
253-
timeBaseSubdir = false
254-
}
255-
256-
if strings.EqualFold(subdir, backupbase.LatestFileName) {
257-
subdirType = latestSubdirType
258-
} else if !timeBaseSubdir {
259-
subdirType = customSubdirType
260-
} else {
261-
subdirType = standardSubdirType
262-
}
263-
264-
return subdirType
265-
}
266-
267225
// logCreateScheduleTelemetry publishes an eventpb.RecoveryEvent about a created
268226
// backup schedule.
269227
func logCreateScheduleTelemetry(
@@ -296,8 +254,6 @@ func logCreateScheduleTelemetry(
296254
backupEvent.RecurringCron = recurringCron
297255
backupEvent.FullBackupCron = fullCron
298256
backupEvent.CustomFirstRunTime = firstRunNanos
299-
backupEvent.OnPreviousRunning = jobspb.ScheduleDetails_WaitBehavior_name[int32(details.Wait)]
300-
backupEvent.OnExecutionFailure = jobspb.ScheduleDetails_ErrorHandlingBehavior_name[int32(details.OnError)]
301257
backupEvent.IgnoreExistingBackup = ignoreExisting
302258

303259
log.StructuredEvent(ctx, severity.INFO, &backupEvent)
@@ -312,7 +268,6 @@ func logRestoreTelemetry(
312268
intoDB string,
313269
newDBName string,
314270
subdir string,
315-
asOfInterval int64,
316271
opts tree.RestoreOptions,
317272
descsByTablePattern map[tree.TablePattern]catalog.Descriptor,
318273
restoreDBs []catalog.DatabaseDescriptor,
@@ -410,9 +365,7 @@ func logRestoreTelemetry(
410365
TargetScope: largestScope.String(),
411366
TargetCount: uint32(targetCount),
412367
IsMultiregionTarget: multiRegion,
413-
DestinationSubdirType: loggedSubdirType(subdir),
414368
IsLocalityAware: localityAware,
415-
AsOfInterval: asOfInterval,
416369
HasEncryptionPassphrase: passphrase,
417370
KMSType: kmsType,
418371
KMSCount: uint32(kmsCount),

pkg/backup/backup_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10301,11 +10301,9 @@ func TestBackupRestoreTelemetryEvents(t *testing.T) {
1030110301
RecoveryType: backupEventType,
1030210302
TargetScope: databaseScope.String(),
1030310303
TargetCount: 2,
10304-
DestinationSubdirType: standardSubdirType,
1030510304
DestinationStorageTypes: []string{"nodelocal", "userfile"},
1030610305
DestinationAuthTypes: []string{"specified"},
1030710306
IsLocalityAware: true,
10308-
AsOfInterval: -1 * time.Millisecond.Nanoseconds(),
1030910307
WithRevisionHistory: true,
1031010308
ApplicationName: "backup_test",
1031110309
}
@@ -10336,11 +10334,9 @@ func TestBackupRestoreTelemetryEvents(t *testing.T) {
1033610334
RecoveryType: restoreEventType,
1033710335
TargetScope: tableScope.String(),
1033810336
TargetCount: 1,
10339-
DestinationSubdirType: latestSubdirType,
1034010337
DestinationStorageTypes: []string{"nodelocal", "userfile"},
1034110338
DestinationAuthTypes: []string{"specified"},
1034210339
IsLocalityAware: true,
10343-
AsOfInterval: 0,
1034410340
Options: []string{telemetryOptionIntoDB, telemetryOptionSkipMissingFK},
1034510341
ApplicationName: "backup_test",
1034610342
}

pkg/backup/create_scheduled_backup_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,15 +1432,13 @@ func TestCreateScheduledBackupTelemetry(t *testing.T) {
14321432

14331433
th, cleanup := newTestHelper(t)
14341434
defer cleanup()
1435-
var asOfInterval int64
14361435

14371436
// We'll be manipulating schedule time via th.env, but we can't fool actual backup
14381437
// when it comes to AsOf time. So, override AsOf backup clause to be the current time.
14391438
useRealTimeAOST := func() func() {
14401439
knobs := th.cfg.TestingKnobs.(*jobs.TestingKnobs)
14411440
knobs.OverrideAsOfClause = func(clause *tree.AsOfClause, stmtTimestamp time.Time) {
14421441
expr, err := tree.MakeDTimestampTZ(th.cfg.DB.KV().Clock().PhysicalTime(), time.Microsecond)
1443-
asOfInterval = expr.Time.UnixNano() - stmtTimestamp.UnixNano()
14441442
require.NoError(t, err)
14451443
clause.Expr = expr
14461444
}
@@ -1472,15 +1470,11 @@ WITH SCHEDULE OPTIONS on_execution_failure = 'pause', ignore_existing_backups, f
14721470
RecoveryType: createdScheduleEventType,
14731471
TargetScope: clusterScope.String(),
14741472
TargetCount: 1,
1475-
DestinationSubdirType: standardSubdirType,
14761473
DestinationStorageTypes: []string{"userfile"},
14771474
DestinationAuthTypes: []string{"specified"},
1478-
AsOfInterval: asOfInterval,
14791475
Options: []string{telemetryOptionDetached},
14801476
RecurringCron: "@hourly",
14811477
FullBackupCron: "@daily",
1482-
OnExecutionFailure: "PAUSE_SCHED",
1483-
OnPreviousRunning: "WAIT",
14841478
IgnoreExistingBackup: true,
14851479
CustomFirstRunTime: firstRun.UnixNano(),
14861480
ApplicationName: "backup_test",
@@ -1501,10 +1495,8 @@ WITH SCHEDULE OPTIONS on_execution_failure = 'pause', ignore_existing_backups, f
15011495
RecoveryType: scheduledBackupEventType,
15021496
TargetScope: clusterScope.String(),
15031497
TargetCount: 1,
1504-
DestinationSubdirType: standardSubdirType,
15051498
DestinationStorageTypes: []string{"userfile"},
15061499
DestinationAuthTypes: []string{"specified"},
1507-
AsOfInterval: asOfInterval,
15081500
Options: []string{telemetryOptionDetached},
15091501
}
15101502
requireRecoveryEvent(t, beforeBackup.UnixNano(), scheduledBackupEventType, expectedScheduledBackup)

pkg/backup/restore_planning.go

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,11 +1964,6 @@ func doRestorePlan(
19641964
}
19651965
}
19661966

1967-
var asOfInterval int64
1968-
if !endTime.IsEmpty() {
1969-
asOfInterval = endTime.WallTime - p.ExtendedEvalContext().StmtTimestamp.UnixNano()
1970-
}
1971-
19721967
filteredTablesByID, err := maybeFilterMissingViews(
19731968
tablesByID,
19741969
typesByID,
@@ -2144,7 +2139,7 @@ func doRestorePlan(
21442139
}
21452140
resultsCh <- tree.Datums{tree.NewDInt(tree.DInt(jobID))}
21462141
collectRestoreTelemetry(ctx, jobID, restoreDetails, intoDB, newDBName, subdir, restoreStmt,
2147-
descsByTablePattern, restoreDBs, asOfInterval, p.SessionData().ApplicationName)
2142+
descsByTablePattern, restoreDBs, p.SessionData().ApplicationName)
21482143
return nil
21492144
}
21502145

@@ -2191,7 +2186,7 @@ func doRestorePlan(
21912186
// execution.
21922187
p.InternalSQLTxn().Descriptors().ReleaseAll(ctx)
21932188
collectRestoreTelemetry(ctx, sj.ID(), restoreDetails, intoDB, newDBName, subdir, restoreStmt,
2194-
descsByTablePattern, restoreDBs, asOfInterval, p.SessionData().ApplicationName)
2189+
descsByTablePattern, restoreDBs, p.SessionData().ApplicationName)
21952190
if err := sj.Start(ctx); err != nil {
21962191
return err
21972192
}
@@ -2211,20 +2206,13 @@ func collectRestoreTelemetry(
22112206
restoreStmt *tree.Restore,
22122207
descsByTablePattern map[tree.TablePattern]catalog.Descriptor,
22132208
restoreDBs []catalog.DatabaseDescriptor,
2214-
asOfInterval int64,
22152209
applicationName string,
22162210
) {
22172211
telemetry.Count("restore.total.started")
22182212
if restoreStmt.DescriptorCoverage == tree.AllDescriptors {
22192213
telemetry.Count("restore.full-cluster")
22202214
}
2221-
if restoreStmt.Subdir == nil {
2222-
telemetry.Count("restore.deprecated-subdir-syntax")
2223-
} else {
2224-
telemetry.Count("restore.collection")
2225-
}
2226-
2227-
logRestoreTelemetry(ctx, jobID, details, intoDB, newDBName, subdir, asOfInterval, restoreStmt.Options,
2215+
logRestoreTelemetry(ctx, jobID, details, intoDB, newDBName, subdir, restoreStmt.Options,
22282216
descsByTablePattern, restoreDBs, applicationName)
22292217
}
22302218

pkg/util/log/eventpb/json_encode_generated.go

Lines changed: 0 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)