File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed
apps/webapp/app/v3/eventRepository
internal-packages/llm-pricing/src Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -1379,6 +1379,11 @@ export class ClickhouseEventRepository implements IEventRepository {
13791379 }
13801380 }
13811381
1382+ // Parse attributes from the first record that has them, then re-parse for the
1383+ // completed SPAN record. The completed record's attributes are a superset of the
1384+ // partial's (includes enriched trigger.llm.* cost data added during ingestion).
1385+ // This means at most 2x JSON.parse per span detail query, but only on this
1386+ // read path (span detail view), not on ingestion.
13821387 if ( typeof record . attributes_text === "string" ) {
13831388 const shouldUpdate =
13841389 span . properties == null ||
Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ function compilePattern(pattern: string): RegExp {
2222export class ModelPricingRegistry {
2323 private _prisma : PrismaClient | PrismaReplicaClient ;
2424 private _patterns : CompiledPattern [ ] = [ ] ;
25+ // TODO: When we add project-based models (users adding their own), this cache grows unbounded
26+ // between reloads. Fine-tuned model IDs (e.g. "ft:gpt-3.5-turbo:org:name:id") create unique
27+ // entries per model string. Consider adding an LRU cap or size limit at that point.
2528 private _exactMatchCache : Map < string , LlmModelWithPricing | null > = new Map ( ) ;
2629 private _loaded = false ;
2730 private _readyResolve ! : ( ) => void ;
You can’t perform that action at this time.
0 commit comments