Commit cfcf93d
feat: add cached token metrics support for Amazon Bedrock (#531)
* feat: add cached token metrics support for Amazon Bedrock
- Add optional cacheReadInputTokens and cacheWriteInputTokens fields to Usage TypedDict
- Update EventLoopMetrics to accumulate cached token metrics
- Add OpenTelemetry instrumentation for cached token telemetry
- Enhance metrics summary display to show cached token information
- Maintain 100% backward compatibility with existing Usage objects
- Add comprehensive test coverage for cached token functionality
Resolves #529
* feat: updated cached read/write input token metrics
---------
Co-authored-by: poshinchen <pschen@amazon.com>1 parent b1df148 commit cfcf93d
File tree
5 files changed
+66
-17
lines changed- src/strands
- telemetry
- types
- tests/strands
- event_loop
- telemetry
5 files changed
+66
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
267 | 282 | | |
268 | 283 | | |
269 | 284 | | |
| |||
325 | 340 | | |
326 | 341 | | |
327 | 342 | | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
333 | 358 | | |
334 | 359 | | |
335 | 360 | | |
| |||
421 | 446 | | |
422 | 447 | | |
423 | 448 | | |
| 449 | + | |
| 450 | + | |
424 | 451 | | |
425 | 452 | | |
426 | 453 | | |
| |||
474 | 501 | | |
475 | 502 | | |
476 | 503 | | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | | - | |
18 | | - | |
19 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
280 | 292 | | |
281 | 293 | | |
282 | 294 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| |||
315 | 316 | | |
316 | 317 | | |
317 | 318 | | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
| 319 | + | |
323 | 320 | | |
324 | 321 | | |
325 | 322 | | |
326 | 323 | | |
327 | 324 | | |
328 | 325 | | |
| 326 | + | |
329 | 327 | | |
330 | 328 | | |
331 | 329 | | |
| |||
0 commit comments