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

Function recordToolResultMetrics

coderd/x/chatd/chatloop/chatloop.go:1467–1481  ·  view source on GitHub ↗

recordToolResultMetrics observes tool result size and increments tool_errors_total when the result carries an error output. Mirrors the metric-recording defer in executeSingleTool so that synthetic results (e.g. exclusive-tool policy errors) contribute to operator visibility.

(metrics *Metrics, provider, model string, tr fantasy.ToolResultContent)

Source from the content-addressed store, hash-verified

1465// results (e.g. exclusive-tool policy errors) contribute to operator
1466// visibility.
1467func recordToolResultMetrics(metrics *Metrics, provider, model string, tr fantasy.ToolResultContent) {
1468 if metrics == nil {
1469 return
1470 }
1471 label := tr.ToolName
1472 if label == "" {
1473 label = "unknown"
1474 }
1475 metrics.ToolResultSizeBytes.WithLabelValues(provider, model, label).Observe(
1476 float64(ToolResultSize(tr)),
1477 )
1478 if _, ok := tr.Result.(fantasy.ToolResultOutputContentError); ok {
1479 metrics.RecordToolError(provider, model, label)
1480 }
1481}
1482
1483func firstExclusiveToolName(
1484 toolCalls []fantasy.ToolCallContent,

Callers 1

applyExclusiveToolPolicyFunction · 0.85

Calls 3

ToolResultSizeFunction · 0.85
WithLabelValuesMethod · 0.80
RecordToolErrorMethod · 0.80

Tested by

no test coverage detected