From c633d130bf49a9a38b9e95e47fe1b60d00d1f338 Mon Sep 17 00:00:00 2001 From: Thomas Hardy Date: Mon, 11 Jul 2022 15:07:39 -0400 Subject: [PATCH] sql: Add database ID to sampled query log This change adds a database ID field to the sampled query telemetry log. Release note (sql change): Sampled query telemetry log includes new database ID field. --- docs/generated/eventlog.md | 1 + pkg/sql/exec_log.go | 10 +- pkg/sql/telemetry_logging_test.go | 9 ++ pkg/util/log/eventpb/json_encode_generated.go | 9 ++ pkg/util/log/eventpb/telemetry.pb.go | 119 +++++++++++------- pkg/util/log/eventpb/telemetry.proto | 3 + 6 files changed, 105 insertions(+), 46 deletions(-) diff --git a/docs/generated/eventlog.md b/docs/generated/eventlog.md index 16f1bc091298..643acdcb18d9 100644 --- a/docs/generated/eventlog.md +++ b/docs/generated/eventlog.md @@ -2244,6 +2244,7 @@ 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 | #### Common fields diff --git a/pkg/sql/exec_log.go b/pkg/sql/exec_log.go index c56dcfc942a4..570e7a617fdf 100644 --- a/pkg/sql/exec_log.go +++ b/pkg/sql/exec_log.go @@ -377,7 +377,8 @@ func (p *planner) maybeLogStatementInternal( } if telemetryMetrics.maybeUpdateLastEmittedTime(telemetryMetrics.timeNow(), requiredTimeElapsed) { skippedQueries := telemetryMetrics.resetSkippedQueryCount() - p.logOperationalEventsOnlyExternally(ctx, eventLogEntry{event: &eventpb.SampledQuery{ + databaseName := p.CurrentDatabase() + sampledQuery := eventpb.SampledQuery{ CommonSQLExecDetails: execDetails, SkippedQueries: skippedQueries, CostEstimate: p.curPlan.instrumentation.costEstimate, @@ -386,7 +387,12 @@ func (p *planner) maybeLogStatementInternal( Database: p.CurrentDatabase(), StatementID: p.stmt.QueryID.String(), TransactionID: p.txn.ID().String(), - }}) + } + 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 16b0e0f54db5..481f890fe449 100644 --- a/pkg/sql/telemetry_logging_test.go +++ b/pkg/sql/telemetry_logging_test.go @@ -12,9 +12,11 @@ package sql import ( "context" + gosql "database/sql" "fmt" "math" "regexp" + "strconv" "strings" "testing" "time" @@ -94,10 +96,14 @@ 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();") @@ -263,6 +269,9 @@ 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) + } } } if logCount != expectedLogCount { diff --git a/pkg/util/log/eventpb/json_encode_generated.go b/pkg/util/log/eventpb/json_encode_generated.go index ee3c5e026146..986d075d5f84 100644 --- a/pkg/util/log/eventpb/json_encode_generated.go +++ b/pkg/util/log/eventpb/json_encode_generated.go @@ -2900,6 +2900,15 @@ 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) + } + return printComma, b } diff --git a/pkg/util/log/eventpb/telemetry.pb.go b/pkg/util/log/eventpb/telemetry.pb.go index fb68af1f1761..6a2ddc9c02ab 100644 --- a/pkg/util/log/eventpb/telemetry.pb.go +++ b/pkg/util/log/eventpb/telemetry.pb.go @@ -47,6 +47,8 @@ type SampledQuery struct { StatementID string `protobuf:"bytes,10,opt,name=statement_id,json=statementId,proto3" json:",omitempty" redact:"nonsensitive"` // Transaction ID of the query. TransactionID string `protobuf:"bytes,11,opt,name=transaction_id,json=transactionId,proto3" json:",omitempty" redact:"nonsensitive"` + // Database ID of the query. + DatabaseID uint32 `protobuf:"varint,12,opt,name=database_id,json=databaseId,proto3" json:",omitempty"` } func (m *SampledQuery) Reset() { *m = SampledQuery{} } @@ -135,51 +137,53 @@ func init() { func init() { proto.RegisterFile("util/log/eventpb/telemetry.proto", fileDescriptor_3d317b4ad74be4f7) } var fileDescriptor_3d317b4ad74be4f7 = []byte{ - // 700 bytes of a gzipped FileDescriptorProto + // 725 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x95, 0xcb, 0x6e, 0xdb, 0x46, - 0x14, 0x86, 0xc5, 0x5a, 0xd6, 0x65, 0x74, 0x69, 0x31, 0x68, 0x51, 0xc2, 0x40, 0x49, 0x41, 0x8b, - 0x5a, 0x45, 0x0b, 0xa9, 0xad, 0x83, 0x24, 0xc8, 0x52, 0x92, 0x03, 0x10, 0x31, 0x02, 0xe8, 0xe2, - 0x45, 0xb2, 0x21, 0x46, 0x9c, 0x03, 0x65, 0x60, 0x92, 0x43, 0x71, 0x86, 0x86, 0xf5, 0x16, 0x79, - 0x80, 0xbc, 0x45, 0x5e, 0xc2, 0x4b, 0x2f, 0xbd, 0x22, 0x12, 0x7a, 0xe7, 0x65, 0x9e, 0x20, 0x98, - 0x11, 0x7d, 0x83, 0x72, 0x91, 0x16, 0x59, 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d4, 0x5d, 0x24, 0x10, - 0x33, 0x10, 0x66, 0xb1, 0x65, 0x74, 0x8a, 0xfd, 0xe6, 0x75, 0x6a, 0xa3, 0x7f, 0x78, 0xc0, 0x24, - 0x04, 0x91, 0x5c, 0x8e, 0x9b, 0x39, 0x36, 0x5a, 0x51, 0xf8, 0x00, 0x35, 0x3c, 0x2e, 0xa4, 0x0b, - 0x42, 0xb2, 0x80, 0x48, 0x30, 0x77, 0x5b, 0x46, 0xc7, 0x58, 0x8b, 0xd5, 0x15, 0x74, 0x98, 0x33, - 0xf8, 0x05, 0xaa, 0x53, 0x26, 0x64, 0xcc, 0x66, 0x89, 0x64, 0x3c, 0x34, 0x4b, 0x2d, 0xa3, 0x53, - 0xed, 0xef, 0x3f, 0xcc, 0x7c, 0x4a, 0xed, 0xdf, 0x62, 0xa0, 0xc4, 0x93, 0xcf, 0xda, 0x21, 0x0f, - 0x05, 0x84, 0x82, 0x49, 0x76, 0x0a, 0xed, 0xf1, 0x83, 0x30, 0x9e, 0x20, 0x24, 0x40, 0x08, 0xc6, - 0x43, 0x97, 0x51, 0xb3, 0xa2, 0x55, 0x8f, 0xb2, 0xd4, 0xae, 0x4e, 0x56, 0x55, 0x67, 0xb8, 0xa9, - 0xb7, 0x9a, 0x7b, 0x1c, 0x8a, 0x07, 0xa8, 0x42, 0x89, 0x24, 0x33, 0x22, 0xc0, 0xac, 0x6e, 0x37, - 0xdd, 0x6d, 0x10, 0xbf, 0x42, 0x75, 0x21, 0x89, 0x84, 0x00, 0x42, 0xa9, 0x66, 0x43, 0x5a, 0xf4, - 0x38, 0x4b, 0xed, 0xda, 0xe4, 0xa6, 0xbe, 0xf9, 0x74, 0xb5, 0x5b, 0x97, 0x43, 0xb1, 0x8b, 0x9a, - 0x32, 0x26, 0xa1, 0x20, 0x9e, 0xcc, 0xbf, 0x78, 0x4d, 0xcb, 0x9f, 0x66, 0xa9, 0xdd, 0x98, 0xde, - 0x75, 0x36, 0xd7, 0x37, 0xee, 0xf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 0x10, 0x4b, 0x58, 0x5d, - 0xf1, 0x75, 0x1c, 0x31, 0xe1, 0xe4, 0x44, 0xff, 0xaf, 0xf3, 0x8f, 0x56, 0xe1, 0x3c, 0xb3, 0x8c, - 0x8b, 0xcc, 0x32, 0x2e, 0x33, 0xcb, 0xf8, 0x90, 0x59, 0xc6, 0xdb, 0x2b, 0xab, 0x70, 0x71, 0x65, - 0x15, 0x2e, 0xaf, 0xac, 0xc2, 0xeb, 0x72, 0x7e, 0x2f, 0x67, 0x25, 0xfd, 0x37, 0x70, 0xf0, 0x39, - 0x00, 0x00, 0xff, 0xff, 0x35, 0xac, 0x03, 0xe6, 0xa4, 0x06, 0x00, 0x00, + 0x14, 0x86, 0xc5, 0x5a, 0xd6, 0x65, 0x74, 0x69, 0x31, 0x68, 0x51, 0xc2, 0x68, 0x49, 0x41, 0x8b, + 0x5a, 0x45, 0x0b, 0xa9, 0xad, 0x8b, 0x24, 0x08, 0x90, 0x8d, 0x24, 0x07, 0x20, 0x62, 0x04, 0x10, + 0x25, 0x2f, 0x92, 0x0d, 0x31, 0xe2, 0x1c, 0x28, 0x03, 0x93, 0x1c, 0x8a, 0x33, 0x34, 0xac, 0xb7, + 0xc8, 0xbb, 0xe4, 0x25, 0xbc, 0xf4, 0xd2, 0x40, 0x00, 0x22, 0xa1, 0x77, 0x5e, 0xe6, 0x09, 0x02, + 0x8e, 0x28, 0x5f, 0xa2, 0x5c, 0xa4, 0x45, 0x56, 0x92, 0xce, 0xf9, 0xfe, 0x0f, 0x67, 0x46, 0x3a, + 0x22, 0x6a, 0xc5, 0x92, 0x79, 0x3d, 0x8f, 0xcf, 0x7a, 0x70, 0x0a, 0x81, 0x0c, 0xa7, 0x3d, 0x09, + 0x1e, 0xf8, 0x20, 0xa3, 0x45, 0x37, 0x8c, 0xb8, 0xe4, 0x78, 0xcf, 0xe5, 0xee, 0x49, 0xc4, 0x89, + 0xfb, 0xaa, 0x9b, 0xb1, 0x5d, 0x8f, 0xcf, 0xba,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 0x86, 0x76, 0x99, 0x1a, 0xda, 0xbb, + 0xd4, 0xd0, 0x5e, 0x5f, 0x19, 0x85, 0x8b, 0x2b, 0xa3, 0x70, 0x79, 0x65, 0x14, 0x5e, 0x96, 0xf3, + 0xdf, 0xe5, 0xb4, 0xa4, 0x9e, 0x22, 0x07, 0x1f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x50, 0xad, 0x05, + 0x38, 0xe3, 0x06, 0x00, 0x00, } func (m *SampledQuery) Marshal() (dAtA []byte, err error) { @@ -202,6 +206,11 @@ func (m *SampledQuery) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.DatabaseID != 0 { + i = encodeVarintTelemetry(dAtA, i, uint64(m.DatabaseID)) + i-- + dAtA[i] = 0x60 + } if len(m.TransactionID) > 0 { i -= len(m.TransactionID) copy(dAtA[i:], m.TransactionID) @@ -433,6 +442,9 @@ func (m *SampledQuery) Size() (n int) { if l > 0 { n += 1 + l + sovTelemetry(uint64(l)) } + if m.DatabaseID != 0 { + n += 1 + sovTelemetry(uint64(m.DatabaseID)) + } return n } @@ -806,6 +818,25 @@ func (m *SampledQuery) Unmarshal(dAtA []byte) error { } m.TransactionID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 12: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DatabaseID", wireType) + } + m.DatabaseID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTelemetry + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DatabaseID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTelemetry(dAtA[iNdEx:]) diff --git a/pkg/util/log/eventpb/telemetry.proto b/pkg/util/log/eventpb/telemetry.proto index 1432ed0324a0..5fa26b4b6795 100644 --- a/pkg/util/log/eventpb/telemetry.proto +++ b/pkg/util/log/eventpb/telemetry.proto @@ -55,6 +55,9 @@ 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"]; } // CapturedIndexUsageStats