MCPcopy Index your code
hub / github.com/coder/coder / TestRecordToolError

Function TestRecordToolError

coderd/x/chatd/chatloop/metrics_test.go:390–412  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

388}
389
390func TestRecordToolError(t *testing.T) {
391 t.Parallel()
392
393 t.Run("nil metrics does not panic", func(t *testing.T) {
394 t.Parallel()
395 var m *chatloop.Metrics
396 m.RecordToolError("anthropic", "claude-sonnet-4-5", "test")
397 })
398
399 t.Run("increments with correct labels", func(t *testing.T) {
400 t.Parallel()
401
402 reg := prometheus.NewRegistry()
403 m := chatloop.NewMetrics(reg)
404 m.RecordToolError("test-provider", "test-model", "read_file")
405
406 requireCounter(t, reg, "coderd_chatd_tool_errors_total", 1, map[string]string{
407 "provider": "test-provider",
408 "model": "test-model",
409 "tool_name": "read_file",
410 })
411 })
412}
413
414func TestRun_RecordsMetrics(t *testing.T) {
415 t.Parallel()

Callers

nothing calls this directly

Calls 4

RecordToolErrorMethod · 0.95
NewMetricsFunction · 0.92
requireCounterFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected