What one RAG query cost, stage by stage (#2734): on every RAGAnswerResult as metrics, and in the TraceEvent.RAGOperationCompleted a traced RAG emits, so an application gets them with or without a tracer.
Value parameters
- answerDuration
-
generating the answer, for a query that answers
- candidatesRetrieved
-
how many results the search returned (
rerankTopKof them with a reranker) - chunksUsed
-
how many results were kept: the contexts the answer was generated from
- completionTokens
-
the answer's completion tokens, when the provider reports them
- costUsd
-
the answer's estimated cost, when known. The rewrite and LLM-rerank calls are not in these totals: with a tracer they are traced on their own, tagged
rag.rewriteandrag.rerank. - embeddingDuration
-
embedding the query
- embeddingTokens
-
the query embedding's tokens, when the provider reports them
- promptTokens
-
the answer's prompt tokens, when the provider reports them
- rerankDuration
-
the reranker, when one is configured
- rewriteDuration
-
the configured query transformers (zero with none)
- searchDuration
-
the vector and keyword search and their fusion, not the embedding or the reranking
- totalDuration
-
the whole call, from the query to the answer
Attributes
- Companion
- object
- Source
- RAGQueryMetrics.scala
- Graph
-
- Supertypes
