Applies to:
- Plan -
- Deployment -
Summary
The Total LLM cost preset chart in Monitor can show no data if the token-reporting spans are missing a recognizedmetadata.model or LLM token metrics, even when traces include metrics.estimated_cost.
The preset prices spans from token metrics plus a recognized metadata.model on the same span. If you log costs directly in metrics.estimated_cost, you can use a custom chart with sum(estimated_cost()).
What is happening
The preset derives cost from token metrics andmetadata.model using Braintrust’s pricing registry. It will ignore spans when the model is null, missing, or unrecognized, even if metrics.estimated_cost is present.
For a span to contribute to the preset cost calculation, it must include:
span_attributes.type = 'llm'.metrics.prompt_tokensormetrics.completion_tokens(or both).metadata.modelset to a model Braintrust can price.
metadata.model should be on the spans that contain the token metrics. It does not need to be on the root span unless the root span also reports the token metrics. Preset charts sum cost per span (not per trace) and automatically exclude internal scorer spans.
Fix or suggestion
Option 1: Log model on token-reporting spans
Addmetadata.model to the LLM spans that record token usage (typically child LLM call spans).
Option 2: Use a custom chart
If you already log explicit cost inmetrics.estimated_cost, you can create a custom Monitor chart with:
estimated_cost() uses metrics.estimated_cost when present and otherwise falls back to token metrics plus model pricing.
To match the preset’s scorer exclusion, add a filter like:
How to confirm it worked
- The Total LLM cost preset chart shows data after new spans are ingested.
- Sample spans used by the chart include token metrics and a non-null, recognized
metadata.model. - A custom chart using
sum(estimated_cost())returns the expected cost whenmetrics.estimated_costis logged directly.
Notes
- The preset excludes internal scorer spans automatically. Add filters to your custom chart if you need the same exclusion.