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 26, 2022
1 parent d7b901d commit e310b9a
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
13 changes: 12 additions & 1 deletion pkg/jobs/jobspb/jobs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,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 +1021,7 @@ message Payload {
AutoSQLStatsCompactionDetails autoSQLStatsCompaction = 30;
StreamReplicationDetails streamReplication = 33;
RowLevelTTLDetails row_level_ttl = 34 [(gogoproto.customname)="RowLevelTTL"];
SchemaTelemetryDetails schema_telemetry = 37;
}
reserved 26;
// PauseReason is used to describe the reason that the job is currently paused
Expand All @@ -1038,7 +1045,7 @@ message Payload {
// to migrate or update the job.
roachpb.Version creation_cluster_version = 36 [(gogoproto.nullable) = false];

// NEXT ID: 37.
// NEXT ID: 38.
}

message Progress {
Expand All @@ -1065,9 +1072,12 @@ 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"];

// NEXT ID: 27.
}

enum Type {
Expand All @@ -1093,6 +1103,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 @@ -2300,6 +2300,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 e310b9a

Please sign in to comment.