Commit b36419d
committed
feat: report funnel metrics on channel mcp
## Changed
- Tool calls now emit a call_success or call_error, reported from inside
CallTool's own try/catch so the original SDK error is still available to
classify before it is rewritten
- Shutdown flushes the queued events before exiting, capped at 2s
- The cast through the SDK's protected `client` moved to a single guarded
accessor, reused by the existing X-Lara-Client headers
## New
- src/metrics.ts: batched, fire-and-forget event reporting to the
integrations monitoring backend. Buys a token from /auth/issue-token,
posts to /metrics/ingest-events every 2s, retries once on 401, requeues
on 429/5xx, drops on any other rejection, queue capped at 10 000. A
backend that is down never delays or fails a translation
- Events: install (first run only), auth_success (deduplicated per account
per process, since the HTTP transport builds a Translator per request),
call_success, call_error, and auth_fail beside a call_error Lara answered
with 401/403. Both transports report
- accountId is the Lara account behind the credentials, read from the id
claim of the token the SDK holds. No token means no event: a made-up id
would be a fake account in every dashboard
- Installation id persisted at ${LARA_HOME:-~/.lara}/installation-id, with
a per-process fallback when the home is not writable
- Opt-out via DO_NOT_TRACK: nothing is measured, queued, written to disk or
sent. METRICS_URL / METRICS_API_KEY override the compiled-in defaults,
which are empty until the backend is deployed
- 60 tests covering the client in isolation and the server wiring1 parent 2a1c076 commit b36419d
11 files changed
Lines changed: 1639 additions & 13 deletions
File tree
- src
- __tests__
- server
- mcp
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
134 | 137 | | |
135 | 138 | | |
136 | 139 | | |
| |||
145 | 148 | | |
146 | 149 | | |
147 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
148 | 188 | | |
149 | 189 | | |
150 | 190 | | |
151 | 191 | | |
152 | 192 | | |
153 | 193 | | |
154 | 194 | | |
155 | | - | |
156 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
157 | 198 | | |
158 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
159 | 206 | | |
160 | 207 | | |
161 | 208 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
237 | 281 | | |
238 | 282 | | |
239 | 283 | | |
| |||
0 commit comments