Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: include sampled stats in TestSampledStatsCollection #60424

Merged
merged 1 commit into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/sql/app_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ func (a *appStats) recordTransaction(
if collectedExecStats {
s.mu.data.ExecStats.Count++
s.mu.data.ExecStats.NetworkBytes.Record(s.mu.data.ExecStats.Count, float64(execStats.NetworkBytesSent))
s.mu.data.ExecStats.NetworkBytes.Record(s.mu.data.ExecStats.Count, float64(execStats.NetworkBytesSent))
s.mu.data.ExecStats.MaxMemUsage.Record(s.mu.data.ExecStats.Count, float64(execStats.MaxMemUsage))
s.mu.data.ExecStats.ContentionTime.Record(s.mu.data.ExecStats.Count, execStats.ContentionTime.Seconds())
}
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/sql/instrumentation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func TestSampledStatsCollection(t *testing.T) {
require.Equal(t, int64(2), stats.mu.data.Count, "expected to have collected two sets of general stats")
require.Equal(t, int64(1), stats.mu.data.ExecStatCollectionCount, "expected to have collected exactly one set of execution stats")
require.Greater(t, stats.mu.data.RowsRead.Mean, float64(0), "expected statement to have read at least one row")
require.Greater(t, stats.mu.data.MaxMemUsage.Mean, float64(0), "expected statement to have used RAM")
})

t.Run("ExplicitTxn", func(t *testing.T) {
Expand Down Expand Up @@ -107,12 +108,14 @@ func TestSampledStatsCollection(t *testing.T) {
require.Equal(t, int64(2), aggStats.mu.data.Count, "expected to have collected two sets of general stats")
require.Equal(t, int64(1), aggStats.mu.data.ExecStatCollectionCount, "expected to have collected exactly one set of execution stats")
require.Greater(t, aggStats.mu.data.RowsRead.Mean, float64(0), "expected statement to have read at least one row")
require.Greater(t, aggStats.mu.data.MaxMemUsage.Mean, float64(0), "expected statement to have used RAM")

selectStats.mu.Lock()
defer selectStats.mu.Unlock()
require.Equal(t, int64(2), selectStats.mu.data.Count, "expected to have collected two sets of general stats")
require.Equal(t, int64(1), selectStats.mu.data.ExecStatCollectionCount, "expected to have collected exactly one set of execution stats")
require.Greater(t, selectStats.mu.data.RowsRead.Mean, float64(0), "expected statement to have read at least one row")
require.Greater(t, selectStats.mu.data.MaxMemUsage.Mean, float64(0), "expected statement to have used RAM")

key := util.MakeFNV64()
key.Add(uint64(aggID))
Expand All @@ -134,5 +137,6 @@ func TestSampledStatsCollection(t *testing.T) {
txStats.mu.data.RowsRead.Mean,
"expected txn to report having read the sum of rows read in both its statements",
)
require.Greater(t, txStats.mu.data.ExecStats.MaxMemUsage.Mean, float64(0), "expected MaxMemUsage to be set on the txn")
})
}