Skip to content

Commit

Permalink
jobspb: add schema telemetry job type
Browse files Browse the repository at this point in the history
Informs cockroachdb#84284.

Release note: None
  • Loading branch information
Marius Posta committed Jul 28, 2022
1 parent e52ca86 commit 2d73faf
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 11 deletions.
21 changes: 11 additions & 10 deletions pkg/jobs/jobspb/jobs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ message StreamIngestionDetails {

// Stream of tenant data will be ingested as a new tenant with 'new_tenant_id'.
roachpb.TenantID new_tenant_id = 7 [(gogoproto.customname) = "NewTenantID", (gogoproto.nullable) = false];
// NEXT ID: 8.
}

message StreamIngestionCheckpoint {
Expand Down Expand Up @@ -234,8 +233,6 @@ message BackupDetails {
repeated uint32 resolved_complete_dbs = 18 [
(gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb.ID"
];

// NEXT ID: 20;
}

message BackupProgress {
Expand Down Expand Up @@ -357,8 +354,6 @@ message RestoreDetails {
// RestoreValidation determines whether to skip certain parts of the restore
// job if its only purpose is to validate the user's restore command.
RestoreValidation validation = 24;

// NEXT ID: 25.
}

enum RestoreValidation {
Expand Down Expand Up @@ -727,8 +722,6 @@ message SchemaChangeDetails {
// WriteTimestamp is the timestamp at which a backfill may want to write, e.g.
// a time that has been identified via a scan as safe for writing.
util.hlc.Timestamp write_timestamp = 10 [(gogoproto.nullable) = false];

// NEXT ID: 11.
}

message SchemaChangeProgress {
Expand Down Expand Up @@ -831,7 +824,6 @@ message ChangefeedDetails {
string select = 10;
reserved 1, 2, 5;
reserved "targets";
// NEXT ID: 11
}

message ResolvedSpan {
Expand Down Expand Up @@ -968,6 +960,12 @@ message RowLevelTTLProgress {
int64 row_count = 1;
}

message SchemaTelemetryDetails {
}

message SchemaTelemetryProgress {
}

message Payload {
string description = 1;
// If empty, the description is assumed to be the statement.
Expand Down Expand Up @@ -1015,6 +1013,9 @@ message Payload {
AutoSQLStatsCompactionDetails autoSQLStatsCompaction = 30;
StreamReplicationDetails streamReplication = 33;
RowLevelTTLDetails row_level_ttl = 34 [(gogoproto.customname)="RowLevelTTL"];
// SchemaTelemetry jobs collect a snapshot of the cluster's SQL schema
// and publish it to the telemetry event log.
SchemaTelemetryDetails schema_telemetry = 37;
}
reserved 26;
// PauseReason is used to describe the reason that the job is currently paused
Expand All @@ -1037,8 +1038,6 @@ message Payload {
// cluster version, in case a job resuming later needs to use this information
// to migrate or update the job.
roachpb.Version creation_cluster_version = 36 [(gogoproto.nullable) = false];

// NEXT ID: 37.
}

message Progress {
Expand All @@ -1065,6 +1064,7 @@ message Progress {
AutoSQLStatsCompactionProgress autoSQLStatsCompaction = 23;
StreamReplicationProgress streamReplication = 24;
RowLevelTTLProgress row_level_ttl = 25 [(gogoproto.customname)="RowLevelTTL"];
SchemaTelemetryProgress schema_telemetry = 26;
}

uint64 trace_id = 21 [(gogoproto.nullable) = false, (gogoproto.customname) = "TraceID", (gogoproto.customtype) = "github.com/cockroachdb/cockroach/pkg/util/tracing/tracingpb.TraceID"];
Expand Down Expand Up @@ -1093,6 +1093,7 @@ enum Type {
AUTO_SQL_STATS_COMPACTION = 14 [(gogoproto.enumvalue_customname) = "TypeAutoSQLStatsCompaction"];
STREAM_REPLICATION = 15 [(gogoproto.enumvalue_customname) = "TypeStreamReplication"];
ROW_LEVEL_TTL = 16 [(gogoproto.enumvalue_customname) = "TypeRowLevelTTL"];
AUTO_SCHEMA_TELEMETRY = 17 [(gogoproto.enumvalue_customname) = "TypeAutoSchemaTelemetry"];
}

message Job {
Expand Down
15 changes: 14 additions & 1 deletion pkg/jobs/jobspb/wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var (
_ Details = ImportDetails{}
_ Details = StreamReplicationDetails{}
_ Details = RowLevelTTLDetails{}
_ Details = SchemaTelemetryDetails{}
)

// ProgressDetails is a marker interface for job progress details proto structs.
Expand All @@ -65,6 +66,7 @@ var (
_ ProgressDetails = AutoSpanConfigReconciliationDetails{}
_ ProgressDetails = StreamReplicationProgress{}
_ ProgressDetails = RowLevelTTLProgress{}
_ ProgressDetails = SchemaTelemetryProgress{}
)

// Type returns the payload's job type.
Expand All @@ -90,6 +92,7 @@ var AutomaticJobTypes = [...]Type{
TypeAutoCreateStats,
TypeAutoSpanConfigReconciliation,
TypeAutoSQLStatsCompaction,
TypeAutoSchemaTelemetry,
}

// DetailsType returns the type for a payload detail.
Expand Down Expand Up @@ -129,6 +132,8 @@ func DetailsType(d isPayload_Details) Type {
return TypeStreamReplication
case *Payload_RowLevelTTL:
return TypeRowLevelTTL
case *Payload_SchemaTelemetry:
return TypeAutoSchemaTelemetry
default:
panic(errors.AssertionFailedf("Payload.Type called on a payload with an unknown details type: %T", d))
}
Expand Down Expand Up @@ -173,6 +178,8 @@ func WrapProgressDetails(details ProgressDetails) interface {
return &Progress_StreamReplication{StreamReplication: &d}
case RowLevelTTLProgress:
return &Progress_RowLevelTTL{RowLevelTTL: &d}
case SchemaTelemetryProgress:
return &Progress_SchemaTelemetry{SchemaTelemetry: &d}
default:
panic(errors.AssertionFailedf("WrapProgressDetails: unknown details type %T", d))
}
Expand Down Expand Up @@ -212,6 +219,8 @@ func (p *Payload) UnwrapDetails() Details {
return *d.StreamReplication
case *Payload_RowLevelTTL:
return *d.RowLevelTTL
case *Payload_SchemaTelemetry:
return *d.SchemaTelemetry
default:
return nil
}
Expand Down Expand Up @@ -251,6 +260,8 @@ func (p *Progress) UnwrapDetails() ProgressDetails {
return *d.StreamReplication
case *Progress_RowLevelTTL:
return *d.RowLevelTTL
case *Progress_SchemaTelemetry:
return *d.SchemaTelemetry
default:
return nil
}
Expand Down Expand Up @@ -303,6 +314,8 @@ func WrapPayloadDetails(details Details) interface {
return &Payload_StreamReplication{StreamReplication: &d}
case RowLevelTTLDetails:
return &Payload_RowLevelTTL{RowLevelTTL: &d}
case SchemaTelemetryDetails:
return &Payload_SchemaTelemetry{SchemaTelemetry: &d}
default:
panic(errors.AssertionFailedf("jobs.WrapPayloadDetails: unknown details type %T", d))
}
Expand Down Expand Up @@ -338,7 +351,7 @@ const (
func (Type) SafeValue() {}

// NumJobTypes is the number of jobs types.
const NumJobTypes = 17
const NumJobTypes = 18

// MarshalJSONPB implements jsonpb.JSONPBMarshaller to redact sensitive sink URI
// parameters from ChangefeedDetails.
Expand Down
23 changes: 23 additions & 0 deletions pkg/ts/catalog/chart_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -2311,6 +2311,29 @@ var charts = []sectionDescription{
},
},
},
{
Organization: [][]string{{SQLLayer, "Schema Telemetry"}},
Charts: []chartDescription{
{
Title: "Jobs Running",
Metrics: []string{
"jobs.auto_schema_telemetry.currently_running",
"jobs.auto_schema_telemetry.currently_idle",
},
},
{
Title: "Jobs Statistics",
Metrics: []string{
"jobs.auto_schema_telemetry.fail_or_cancel_completed",
"jobs.auto_schema_telemetry.fail_or_cancel_failed",
"jobs.auto_schema_telemetry.fail_or_cancel_retry_error",
"jobs.auto_schema_telemetry.resume_completed",
"jobs.auto_schema_telemetry.resume_failed",
"jobs.auto_schema_telemetry.resume_retry_error",
},
},
},
},
{
Organization: [][]string{{SQLLayer, "SQL Memory", "Internal"}},
Charts: []chartDescription{
Expand Down

0 comments on commit 2d73faf

Please sign in to comment.