diff --git a/docs/generated/metrics/metrics.html b/docs/generated/metrics/metrics.html index 99c54a96d2fd..322cf53ac390 100644 --- a/docs/generated/metrics/metrics.html +++ b/docs/generated/metrics/metrics.html @@ -1473,6 +1473,7 @@ APPLICATIONsql.stats.flush.done_signals.ignoredNumber of times the SQL Stats activity update job ignored the signal sent to it indicating a flush has completedflush done signals ignoredCOUNTERCOUNTAVGNON_NEGATIVE_DERIVATIVE APPLICATIONsql.stats.flush.durationTime took to in nanoseconds to complete SQL Stats flushSQL Stats FlushHISTOGRAMNANOSECONDSAVGNONE APPLICATIONsql.stats.flush.errorNumber of errors encountered when flushing SQL StatsSQL Stats FlushCOUNTERCOUNTAVGNON_NEGATIVE_DERIVATIVE +APPLICATIONsql.stats.flush.fingerprint.countThe number of unique statement and transaction fingerprints included in the SQL Stats flushstatement & transaction fingerprintsCOUNTERCOUNTAVGNON_NEGATIVE_DERIVATIVE APPLICATIONsql.stats.mem.currentCurrent memory usage for fingerprint storageMemoryGAUGEBYTESAVGNONE APPLICATIONsql.stats.mem.maxMemory usage for fingerprint storageMemoryHISTOGRAMBYTESAVGNONE APPLICATIONsql.stats.reported.mem.currentCurrent memory usage for reported fingerprint storageMemoryGAUGEBYTESAVGNONE diff --git a/pkg/sql/conn_executor.go b/pkg/sql/conn_executor.go index f3128abd4872..e3ee3063d2bc 100644 --- a/pkg/sql/conn_executor.go +++ b/pkg/sql/conn_executor.go @@ -490,6 +490,7 @@ func NewServer(cfg *ExecutorConfig, pool *mon.BytesMonitor) *Server { Knobs: cfg.SQLStatsTestingKnobs, FlushCounter: serverMetrics.StatsMetrics.SQLStatsFlushStarted, FlushDoneSignalsIgnored: serverMetrics.StatsMetrics.SQLStatsFlushDoneSignalsIgnored, + FlushedFingerprintCount: serverMetrics.StatsMetrics.SQLStatsFlushFingerprintCount, FailureCounter: serverMetrics.StatsMetrics.SQLStatsFlushFailure, FlushDuration: serverMetrics.StatsMetrics.SQLStatsFlushDuration, }, memSQLStats) @@ -590,6 +591,7 @@ func makeServerMetrics(cfg *ExecutorConfig) ServerMetrics { DiscardedStatsCount: metric.NewCounter(MetaDiscardedSQLStats), SQLStatsFlushStarted: metric.NewCounter(MetaSQLStatsFlushStarted), SQLStatsFlushDoneSignalsIgnored: metric.NewCounter(MetaSQLStatsFlushDoneSignalsIgnored), + SQLStatsFlushFingerprintCount: metric.NewCounter(MetaSQLStatsFlushFingerprintCount), SQLStatsFlushFailure: metric.NewCounter(MetaSQLStatsFlushFailure), SQLStatsFlushDuration: metric.NewHistogram(metric.HistogramOptions{ diff --git a/pkg/sql/exec_util.go b/pkg/sql/exec_util.go index 84759a418956..41e6835e2f05 100644 --- a/pkg/sql/exec_util.go +++ b/pkg/sql/exec_util.go @@ -1094,6 +1094,12 @@ var ( Measurement: "SQL Stats Flush", Unit: metric.Unit_COUNT, } + MetaSQLStatsFlushFingerprintCount = metric.Metadata{ + Name: "sql.stats.flush.fingerprint.count", + Help: "The number of unique statement and transaction fingerprints included in the SQL Stats flush", + Measurement: "statement & transaction fingerprints", + Unit: metric.Unit_COUNT, + } MetaSQLStatsFlushDoneSignalsIgnored = metric.Metadata{ Name: "sql.stats.flush.done_signals.ignored", Help: "Number of times the SQL Stats activity update job ignored the signal sent to it indicating " + diff --git a/pkg/sql/executor_statement_metrics.go b/pkg/sql/executor_statement_metrics.go index cb7f8314c346..7a796e5dab4a 100644 --- a/pkg/sql/executor_statement_metrics.go +++ b/pkg/sql/executor_statement_metrics.go @@ -77,6 +77,7 @@ type StatsMetrics struct { SQLStatsFlushStarted *metric.Counter SQLStatsFlushDoneSignalsIgnored *metric.Counter + SQLStatsFlushFingerprintCount *metric.Counter SQLStatsFlushFailure *metric.Counter SQLStatsFlushDuration metric.IHistogram SQLStatsRemovedRows *metric.Counter diff --git a/pkg/sql/sqlstats/persistedsqlstats/flush.go b/pkg/sql/sqlstats/persistedsqlstats/flush.go index c14684f89678..81655ba4eb5a 100644 --- a/pkg/sql/sqlstats/persistedsqlstats/flush.go +++ b/pkg/sql/sqlstats/persistedsqlstats/flush.go @@ -62,9 +62,11 @@ func (s *PersistedSQLStats) Flush(ctx context.Context, stopper *stop.Stopper) { return } + fingerprintCount := s.SQLStats.GetTotalFingerprintCount() + s.cfg.FlushedFingerprintCount.Inc(fingerprintCount) if log.V(1) { log.Infof(ctx, "flushing %d stmt/txn fingerprints (%d bytes) after %s", - s.SQLStats.GetTotalFingerprintCount(), s.SQLStats.GetTotalFingerprintBytes(), timeutil.Since(s.lastFlushStarted)) + fingerprintCount, s.SQLStats.GetTotalFingerprintBytes(), timeutil.Since(s.lastFlushStarted)) } s.lastFlushStarted = now diff --git a/pkg/sql/sqlstats/persistedsqlstats/provider.go b/pkg/sql/sqlstats/persistedsqlstats/provider.go index 5f038501396b..b06d467c3c96 100644 --- a/pkg/sql/sqlstats/persistedsqlstats/provider.go +++ b/pkg/sql/sqlstats/persistedsqlstats/provider.go @@ -50,6 +50,7 @@ type Config struct { FlushDuration metric.IHistogram FlushDoneSignalsIgnored *metric.Counter FailureCounter *metric.Counter + FlushedFingerprintCount *metric.Counter // Testing knobs. Knobs *sqlstats.TestingKnobs