diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-16 04:34:44 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-16 04:34:44 +0200 |
| commit | 409cec495ae619fa874e0e827ac620b881f84941 (patch) | |
| tree | e54c1c1ddd4cf1dbb72617fb1662635107c71fe3 | |
| parent | 95b0a9962861b2aef4a3e9538dd38608aca4bcfc (diff) | |
Extract LLM stats counters into llmStatsSubsystem
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| -rw-r--r-- | internal/lsp/server.go | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/internal/lsp/server.go b/internal/lsp/server.go index 0cede98..9c476ed 100644 --- a/internal/lsp/server.go +++ b/internal/lsp/server.go @@ -42,12 +42,7 @@ type Server struct { cfg appconfig.App codeActionSubsystem chatSubsystem - // LLM request stats — atomic to avoid taking the server-wide mu lock. - llmReqTotal atomic.Int64 - llmSentBytesTotal atomic.Int64 - llmRespTotal atomic.Int64 - llmRespBytesTotal atomic.Int64 - startTime time.Time + llmStatsSubsystem completionSubsystem configLoadOpts appconfig.LoadOptions // Outgoing JSON-RPC id counter for server-initiated requests @@ -72,6 +67,16 @@ type codeActionSubsystem struct { llmClientRegistry } +// llmStatsSubsystem holds atomic LLM request counters. All fields are +// lock-free (atomic.Int64), so no mutex is needed. +type llmStatsSubsystem struct { + llmReqTotal atomic.Int64 + llmSentBytesTotal atomic.Int64 + llmRespTotal atomic.Int64 + llmRespBytesTotal atomic.Int64 + startTime time.Time +} + // StatusSink receives status updates from the LSP server. type StatusSink interface { SetLLMStart(provider, model string) error |
