( config: Config, functionName: string, durationMs: number, success: boolean, decision?: 'accept' | 'reject' | 'modify' | 'auto_accept', )
| 115 | } |
| 116 | |
| 117 | export function recordToolCallMetrics( |
| 118 | config: Config, |
| 119 | functionName: string, |
| 120 | durationMs: number, |
| 121 | success: boolean, |
| 122 | decision?: 'accept' | 'reject' | 'modify' | 'auto_accept', |
| 123 | ): void { |
| 124 | if (!toolCallCounter || !toolCallLatencyHistogram || !isMetricsInitialized) |
| 125 | return; |
| 126 | |
| 127 | const metricAttributes: Attributes = { |
| 128 | ...getCommonAttributes(config), |
| 129 | function_name: functionName, |
| 130 | success, |
| 131 | decision, |
| 132 | }; |
| 133 | toolCallCounter.add(1, metricAttributes); |
| 134 | toolCallLatencyHistogram.record(durationMs, { |
| 135 | ...getCommonAttributes(config), |
| 136 | function_name: functionName, |
| 137 | }); |
| 138 | } |
| 139 | |
| 140 | export function recordTokenUsageMetrics( |
| 141 | config: Config, |
no test coverage detected