diff --git a/docs/generated/eventlog.md b/docs/generated/eventlog.md index 1cb987f34c95..17cfa5fa35a0 100644 --- a/docs/generated/eventlog.md +++ b/docs/generated/eventlog.md @@ -2463,7 +2463,6 @@ contains common SQL event/execution details. | `Database` | Name of the database that initiated the query. | no | | `StatementID` | Statement ID of the query. | no | | `TransactionID` | Transaction ID of the query. | no | -| `DatabaseID` | Database ID of the query. | no | | `StatementFingerprintID` | Statement fingerprint ID of the query. | no | | `MaxFullScanRowsEstimate` | Maximum number of rows scanned by a full scan, as estimated by the optimizer. | no | | `TotalScanRowsEstimate` | Total number of rows read by all scans in the query, as estimated by the optimizer. | no | diff --git a/pkg/sql/exec_log.go b/pkg/sql/exec_log.go index a2add4538cf8..8acf25f4962b 100644 --- a/pkg/sql/exec_log.go +++ b/pkg/sql/exec_log.go @@ -389,7 +389,6 @@ func (p *planner) maybeLogStatementInternal( } if telemetryMetrics.maybeUpdateLastEmittedTime(telemetryMetrics.timeNow(), requiredTimeElapsed) { skippedQueries := telemetryMetrics.resetSkippedQueryCount() - databaseName := p.CurrentDatabase() sampledQuery := eventpb.SampledQuery{ CommonSQLExecDetails: execDetails, SkippedQueries: skippedQueries, @@ -397,7 +396,7 @@ func (p *planner) maybeLogStatementInternal( Distribution: p.curPlan.instrumentation.distribution.String(), PlanGist: p.curPlan.instrumentation.planGist.String(), SessionID: p.extendedEvalCtx.SessionID.String(), - Database: databaseName, + Database: p.CurrentDatabase(), StatementID: p.stmt.QueryID.String(), TransactionID: p.txn.ID().String(), StatementFingerprintID: uint64(stmtFingerprintID), @@ -410,10 +409,6 @@ func (p *planner) maybeLogStatementInternal( RowsRead: queryStats.rowsRead, RowsWritten: queryStats.rowsWritten, } - db, _ := p.Descriptors().GetImmutableDatabaseByName(ctx, p.txn, databaseName, tree.DatabaseLookupFlags{Required: true}) - if db != nil { - sampledQuery.DatabaseID = uint32(db.GetID()) - } p.logOperationalEventsOnlyExternally(ctx, eventLogEntry{event: &sampledQuery}) } else { telemetryMetrics.incSkippedQueryCount() diff --git a/pkg/sql/telemetry_logging_test.go b/pkg/sql/telemetry_logging_test.go index ed15c6ad1f96..f1b485ae15f9 100644 --- a/pkg/sql/telemetry_logging_test.go +++ b/pkg/sql/telemetry_logging_test.go @@ -12,7 +12,6 @@ package sql import ( "context" - gosql "database/sql" "fmt" "math" "regexp" @@ -97,14 +96,10 @@ func TestTelemetryLogging(t *testing.T) { var sessionID string var databaseName string - var dbID uint32 db := sqlutils.MakeSQLRunner(sqlDB) - conn := db.DB.(*gosql.DB) - db.QueryRow(t, `SHOW session_id`).Scan(&sessionID) db.QueryRow(t, `SHOW database`).Scan(&databaseName) - dbID = sqlutils.QueryDatabaseID(t, conn, databaseName) db.Exec(t, `SET application_name = 'telemetry-logging-test'`) db.Exec(t, `SET CLUSTER SETTING sql.telemetry.query_sampling.enabled = true;`) db.Exec(t, "CREATE TABLE t();") @@ -345,9 +340,6 @@ func TestTelemetryLogging(t *testing.T) { if !strings.Contains(e.Message, "\"Database\":\""+databaseName+"\"") { t.Errorf("expected to find Database: %s", databaseName) } - if !strings.Contains(e.Message, "\"DatabaseID\":"+strconv.Itoa(int(dbID))) { - t.Errorf("expected to find DatabaseID: %v", dbID) - } stmtFingerprintID := roachpb.ConstructStatementFingerprintID(tc.queryNoConstants, false, true, databaseName) if !strings.Contains(e.Message, "\"StatementFingerprintID\":"+strconv.FormatUint(uint64(stmtFingerprintID), 10)) { t.Errorf("expected to find StatementFingerprintID: %v", stmtFingerprintID) diff --git a/pkg/util/log/eventpb/gen.go b/pkg/util/log/eventpb/gen.go index 9a42e493c7a4..c58bed91f5b1 100644 --- a/pkg/util/log/eventpb/gen.go +++ b/pkg/util/log/eventpb/gen.go @@ -343,6 +343,11 @@ func readInput( return errors.Newf("field definition must not span multiple lines: %q", line) } + // Skip reserved fields. + if reservedDefRe.MatchString(line) { + continue + } + // A field. if strings.HasPrefix(line, "repeated") { line = "array_of_" + strings.TrimSpace(strings.TrimPrefix(line, "repeated")) @@ -448,6 +453,8 @@ var fieldDefRe = regexp.MustCompile(`\s*(?P[a-z._A-Z0-9]+)` + `(.*"redact:\\"safeif:(?P([^\\]|\\[^"])+)\\"")?` + `).*$`) +var reservedDefRe = regexp.MustCompile(`\s*(reserved ([1-9][0-9]*);)`) + func camelToSnake(typeName string) string { var res strings.Builder res.WriteByte(typeName[0] + 'a' - 'A') diff --git a/pkg/util/log/eventpb/json_encode_generated.go b/pkg/util/log/eventpb/json_encode_generated.go index e0d135ed3c3f..7090cb1e274d 100644 --- a/pkg/util/log/eventpb/json_encode_generated.go +++ b/pkg/util/log/eventpb/json_encode_generated.go @@ -3335,15 +3335,6 @@ func (m *SampledQuery) AppendJSONFields(printComma bool, b redact.RedactableByte b = append(b, '"') } - if m.DatabaseID != 0 { - if printComma { - b = append(b, ',') - } - printComma = true - b = append(b, "\"DatabaseID\":"...) - b = strconv.AppendUint(b, uint64(m.DatabaseID), 10) - } - if m.StatementFingerprintID != 0 { if printComma { b = append(b, ',') diff --git a/pkg/util/log/eventpb/telemetry.proto b/pkg/util/log/eventpb/telemetry.proto index 80b24562a960..4f575bd51f5b 100644 --- a/pkg/util/log/eventpb/telemetry.proto +++ b/pkg/util/log/eventpb/telemetry.proto @@ -59,9 +59,6 @@ message SampledQuery { // Transaction ID of the query. string transaction_id = 11 [(gogoproto.customname) = "TransactionID", (gogoproto.jsontag) = ',omitempty', (gogoproto.moretags) = "redact:\"nonsensitive\""]; - // Database ID of the query. - uint32 database_id = 12 [(gogoproto.customname) = "DatabaseID", (gogoproto.jsontag) = ",omitempty"]; - // Statement fingerprint ID of the query. uint64 statement_fingerprint_id = 13 [(gogoproto.customname) = "StatementFingerprintID", (gogoproto.jsontag) = ',omitempty']; @@ -92,6 +89,8 @@ message SampledQuery { // The number of rows written. int64 rows_written = 21 [(gogoproto.jsontag) = ",omitempty"]; + + reserved 12; } // CapturedIndexUsageStats