SQL Expressions: Fixes for Prometheus Metric Instrumentation (#106722)

* capture errors on metrics
* rename seconds to sql_command_duration_milliseconds to match unit that has been captured, and update buckets
* rename sql_command_errors_total to sql_command_count
This commit is contained in:
Kyle Brandt
2025-06-17 09:23:56 -04:00
committed by GitHub
parent 9ce207b472
commit 8b6329a224
3 changed files with 31 additions and 29 deletions

View File

@@ -136,11 +136,11 @@ func TestSQLCommandCellLimits(t *testing.T) {
}
}
_, err = cmd.Execute(context.Background(), time.Now(), vars, &testTracer{}, metrics.NewTestMetrics())
res, _ := cmd.Execute(context.Background(), time.Now(), vars, &testTracer{}, metrics.NewTestMetrics())
if tt.expectError {
require.Error(t, err)
require.Contains(t, err.Error(), tt.errorContains)
require.Error(t, res.Error)
require.ErrorContains(t, res.Error, tt.errorContains)
} else {
require.NoError(t, err)
}
@@ -161,7 +161,7 @@ func TestSQLCommandMetrics(t *testing.T) {
require.NoError(t, err)
// Verify error count was not incremented
require.Equal(t, 0, testutil.CollectAndCount(m.SqlCommandErrorCount), "Expected error metric not to be recorded")
require.Equal(t, 1, testutil.CollectAndCount(m.SqlCommandCount), "Expected error metric not to be recorded")
// Verify duration was recorded
require.Equal(t, 1, testutil.CollectAndCount(m.SqlCommandDuration), "Expected duration metric to be recorded")