| 962 | } |
| 963 | |
| 964 | export function setMeter( |
| 965 | meter: Meter, |
| 966 | createCounter: (name: string, options: MetricOptions) => AttributedCounter, |
| 967 | ): void { |
| 968 | STATE.meter = meter |
| 969 | |
| 970 | // Initialize all counters using the provided factory |
| 971 | STATE.sessionCounter = createCounter('ncode.session.count', { |
| 972 | description: 'Count of CLI sessions started', |
| 973 | }) |
| 974 | STATE.locCounter = createCounter('ncode.lines_of_code.count', { |
| 975 | description: |
| 976 | "Count of lines of code modified, with the 'type' attribute indicating whether lines were added or removed", |
| 977 | }) |
| 978 | STATE.prCounter = createCounter('ncode.pull_request.count', { |
| 979 | description: 'Number of pull requests created', |
| 980 | }) |
| 981 | STATE.commitCounter = createCounter('ncode.commit.count', { |
| 982 | description: 'Number of git commits created', |
| 983 | }) |
| 984 | STATE.costCounter = createCounter('ncode.cost.usage', { |
| 985 | description: 'Cost of the NCode session', |
| 986 | unit: 'USD', |
| 987 | }) |
| 988 | STATE.tokenCounter = createCounter('ncode.token.usage', { |
| 989 | description: 'Number of tokens used', |
| 990 | unit: 'tokens', |
| 991 | }) |
| 992 | STATE.codeEditToolDecisionCounter = createCounter( |
| 993 | 'ncode.code_edit_tool.decision', |
| 994 | { |
| 995 | description: |
| 996 | 'Count of code editing tool permission decisions (accept/reject) for Edit, Write, and NotebookEdit tools', |
| 997 | }, |
| 998 | ) |
| 999 | STATE.activeTimeCounter = createCounter('ncode.active_time.total', { |
| 1000 | description: 'Total active time in seconds', |
| 1001 | unit: 's', |
| 1002 | }) |
| 1003 | } |
| 1004 | |
| 1005 | export function getMeter(): Meter | null { |
| 1006 | return STATE.meter |