(config: Config)
| 57 | } |
| 58 | |
| 59 | export function initializeMetrics(config: Config): void { |
| 60 | if (isMetricsInitialized) return; |
| 61 | |
| 62 | const meter = getMeter(); |
| 63 | if (!meter) return; |
| 64 | |
| 65 | toolCallCounter = meter.createCounter(METRIC_TOOL_CALL_COUNT, { |
| 66 | description: 'Counts tool calls, tagged by function name and success.', |
| 67 | valueType: ValueType.INT, |
| 68 | }); |
| 69 | toolCallLatencyHistogram = meter.createHistogram(METRIC_TOOL_CALL_LATENCY, { |
| 70 | description: 'Latency of tool calls in milliseconds.', |
| 71 | unit: 'ms', |
| 72 | valueType: ValueType.INT, |
| 73 | }); |
| 74 | apiRequestCounter = meter.createCounter(METRIC_API_REQUEST_COUNT, { |
| 75 | description: 'Counts API requests, tagged by model and status.', |
| 76 | valueType: ValueType.INT, |
| 77 | }); |
| 78 | apiRequestLatencyHistogram = meter.createHistogram( |
| 79 | METRIC_API_REQUEST_LATENCY, |
| 80 | { |
| 81 | description: 'Latency of API requests in milliseconds.', |
| 82 | unit: 'ms', |
| 83 | valueType: ValueType.INT, |
| 84 | }, |
| 85 | ); |
| 86 | tokenUsageCounter = meter.createCounter(METRIC_TOKEN_USAGE, { |
| 87 | description: 'Counts the total number of tokens used.', |
| 88 | valueType: ValueType.INT, |
| 89 | }); |
| 90 | fileOperationCounter = meter.createCounter(METRIC_FILE_OPERATION_COUNT, { |
| 91 | description: 'Counts file operations (create, read, update).', |
| 92 | valueType: ValueType.INT, |
| 93 | }); |
| 94 | chatCompressionCounter = meter.createCounter(EVENT_CHAT_COMPRESSION, { |
| 95 | description: 'Counts chat compression events.', |
| 96 | valueType: ValueType.INT, |
| 97 | }); |
| 98 | const sessionCounter = meter.createCounter(METRIC_SESSION_COUNT, { |
| 99 | description: 'Count of CLI sessions started.', |
| 100 | valueType: ValueType.INT, |
| 101 | }); |
| 102 | sessionCounter.add(1, getCommonAttributes(config)); |
| 103 | isMetricsInitialized = true; |
| 104 | } |
| 105 | |
| 106 | export function recordChatCompressionMetrics( |
| 107 | config: Config, |
no test coverage detected