Commit fd75549
authored
feat: system query_metrics table uses timestamps, and improve session metrics output (#241)
## What Changed?
- start_ts and end_ts in fenic fenic_system.query_metrics are datetimes
with UTC timezone instead of strings (TIMESTAMPTZ in duckdb)
- Unit test for above
- optionally include LM and RM stats in session stop metrics printout.
e.g., if any LM calls, include request count and token usage
- improve formatting to show 6 decimal places if they matter, otherwise
fewer decimal places.
## Testing and outputs
### query_metrics table
```
(Pdb) session.table("fenic_system.query_metrics").select("start_ts", "end_ts").show()
┌────────────────────────────────┬────────────────────────────────┐
│ start_ts ┆ end_ts │
╞════════════════════════════════╪════════════════════════════════╡
│ 2025-10-01 10:30:47.978108 UTC ┆ 2025-10-01 10:30:47.979987 UTC │
│ 2025-10-01 10:30:47.985357 UTC ┆ 2025-10-01 10:30:47.985617 UTC │
│ 2025-10-01 10:31:22.398716 UTC ┆ 2025-10-01 10:31:22.402193 UTC │
...
```
```
(Pdb) pp session.table("fenic_system.query_metrics").select("start_ts", "end_ts").schema
Schema(column_fields=[ColumnField(name='start_ts',
data_type=_TimestampType(timezone='UTC')),
ColumnField(name='end_ts',
data_type=_TimestampType(timezone='UTC'))])
```
### Metrics after session with no LM:
Session Usage Summary:
App Name: test_app
Session ID: a2a2d3a7-6023-40b6-bbb1-ced868d19282
Total queries executed: 4
Total execution time: 3.64ms
Total rows processed: 11
Total language model cost: $0.00
Total embedding model cost: $0.00
Total cost: $0.00
### Metrics after session with LM costs:
Session Usage Summary:
App Name: document_extraction
Session ID: efba1fb1-3c90-45cc-8380-033fe90ca4e2
Total queries executed: 3
Total execution time: 3045.72ms
Total rows processed: 15
Total language model cost: $0.000682
Total language model requests: 5
Total language model tokens: 2,960 input tokens, 0 cached input tokens,
398 output tokens
Total embedding model cost: $0.00
Total cost: $0.0006821 parent c6167d9 commit fd75549
File tree
3 files changed
+57
-11
lines changed- src/fenic/_backends/local
- tests/_backends/local/catalog
3 files changed
+57
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
122 | 123 | | |
123 | 124 | | |
124 | 125 | | |
125 | | - | |
126 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
127 | 134 | | |
128 | | - | |
| 135 | + | |
129 | 136 | | |
130 | 137 | | |
131 | 138 | | |
132 | 139 | | |
| 140 | + | |
133 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
630 | 631 | | |
631 | 632 | | |
632 | 633 | | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
633 | 640 | | |
634 | 641 | | |
635 | 642 | | |
| |||
643 | 650 | | |
644 | 651 | | |
645 | 652 | | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
646 | 659 | | |
647 | 660 | | |
648 | 661 | | |
| |||
651 | 664 | | |
652 | 665 | | |
653 | 666 | | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
658 | 677 | | |
659 | 678 | | |
660 | 679 | | |
| |||
713 | 732 | | |
714 | 733 | | |
715 | 734 | | |
716 | | - | |
717 | | - | |
| 735 | + | |
| 736 | + | |
718 | 737 | | |
719 | 738 | | |
720 | 739 | | |
| |||
733 | 752 | | |
734 | 753 | | |
735 | 754 | | |
736 | | - | |
737 | | - | |
| 755 | + | |
| 756 | + | |
738 | 757 | | |
739 | 758 | | |
740 | 759 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
2 | 4 | | |
3 | 5 | | |
4 | 6 | | |
| |||
117 | 119 | | |
118 | 120 | | |
119 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
120 | 131 | | |
121 | 132 | | |
122 | 133 | | |
| |||
0 commit comments