Repository navigation
Commit 4973cae
committed
fix(genkit): demote every gen_ai.cost.* / llm.cost.* key on non-LLM spans
Installed-review N3. isPromotedUsageKey matched only gen_ai.cost.total and
llm.cost.total exactly, so cost parts (gen_ai.cost.input/output,
llm.cost.prompt/completion) set through fi-core context attributes or Genkit
telemetryLabels stayed unprefixed on flow/step/generate/tool spans, where
fi-collector would sum them into the trace cost again. Match the cost
families by prefix (gen_ai.cost., llm.cost.), like the token families. Model
spans keep the keys unprefixed.
Tests (written first), mapping.test.ts:
- every gen_ai.cost.* / llm.cost.* key is promoted (parts and totals);
look-alikes (gen_ai.costs, llm.costing, genkit.usage.*) are not.
- cost parts on a flow span, from span and from context attributes, move to
genkit.usage.<key>.
- a model span keeps them unprefixed (control).
RED on b5cb204: the first two failed (2 failed, 37 passed in the file).
GREEN: jest 68 passed; contract 20 passed (Node 26.8.1). The contract
helper's promoted-key check now uses the same prefixes.
README: the promoted-key list names the cost prefixes.
approved: Nikhil 2026-10-03 blanket
Refs: TH-82401 parent b5cb204 commit 4973cae
4 files changed
Lines changed: 42 additions & 6 deletions
File tree
- typescript/packages/traceai_genkit
- contract
- src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | | - | |
70 | 68 | | |
71 | | - | |
| 69 | + | |
72 | 70 | | |
73 | 71 | | |
74 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
191 | 227 | | |
192 | 228 | | |
193 | 229 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| 175 | + | |
| 176 | + | |
175 | 177 | | |
176 | 178 | | |
177 | 179 | | |
| |||
181 | 183 | | |
182 | 184 | | |
183 | 185 | | |
184 | | - | |
185 | | - | |
| 186 | + | |
| 187 | + | |
186 | 188 | | |
187 | 189 | | |
0 commit comments