TraceCollectorTracing

org.llm4s.trace.TraceCollectorTracing
See theTraceCollectorTracing companion object
class TraceCollectorTracing[F[_]](store: TraceStore[F], initialTraceId: Option[TraceId])(implicit lift: LiftToResult[F]) extends Tracing

A Tracing implementation that converts every TraceEvent into a Span and persists it in the given TraceStore[F].

Composable with other backends via TracingComposer.combine(). The traceId field exposes the identifier assigned to this run so callers can retrieve spans from the store after execution completes.

Type parameters

F

effect type of the backing store; an implicit org.llm4s.util.LiftToResult instance must be available to bridge F[A] into Result[A]

Value parameters

initialTraceId

optional fixed trace ID; a random UUID is used when absent

store

destination for all recorded spans

Attributes

Companion
object
Graph
Supertypes
trait Tracing
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override def traceAgentState(state: AgentState): Result[Unit]

Attributes

Definition Classes
override def traceCompletion(completion: Completion, model: String): Result[Unit]

Attributes

Definition Classes
override def traceError(error: Throwable, context: String): Result[Unit]

Attributes

Definition Classes
override def traceEvent(event: TraceEvent): Result[Unit]

Attributes

Definition Classes
override def traceTokenUsage(usage: TokenUsage, model: String, operation: String): Result[Unit]

Attributes

Definition Classes
override def traceToolCall(toolName: String, input: String, output: String): Result[Unit]

Attributes

Definition Classes

Inherited methods

def shutdown(): Unit

Shutdown the tracing backend. Alias for close() to maintain terminology consistency.

Shutdown the tracing backend. Alias for close() to maintain terminology consistency.

Attributes

Inherited from:
Tracing
final def traceCost(costUsd: Double, model: String, operation: String, tokenCount: Int, costType: String): Result[Unit]

Trace cost in USD for any operation.

Trace cost in USD for any operation.

Value parameters

costType

Category: "embedding", "completion", "total"

costUsd

Cost in US dollars

model

Model name

operation

Type: "embedding", "completion", "evaluation"

tokenCount

Total tokens used

Attributes

Inherited from:
Tracing
final def traceEmbeddingUsage(usage: EmbeddingUsage, model: String, operation: String, inputCount: Int): Result[Unit]

Trace embedding token usage for cost tracking.

Trace embedding token usage for cost tracking.

Value parameters

inputCount

Number of texts embedded

model

Embedding model name

operation

Type: "indexing", "query", "evaluation"

usage

Token usage from embedding operation

Attributes

Inherited from:
Tracing
final def traceEvent(event: String): Result[Unit]

Emits a named CustomEvent with no additional data payload.

Emits a named CustomEvent with no additional data payload.

Wraps the string in a TraceEvent.CustomEvent with an empty JSON object as its data field before delegating to traceEvent(TraceEvent). Use the typed overload for events that carry structured data.

Value parameters

event

Human-readable event name forwarded as CustomEvent.name

Attributes

Inherited from:
Tracing
final def traceRAGOperation(operation: String, durationMs: Long, embeddingTokens: Option[Int], llmPromptTokens: Option[Int], llmCompletionTokens: Option[Int], totalCostUsd: Option[Double]): Result[Unit]

Trace completion of a RAG operation with metrics.

Trace completion of a RAG operation with metrics.

Value parameters

durationMs

Duration in milliseconds

embeddingTokens

Optional embedding token count

llmCompletionTokens

Optional LLM completion tokens

llmPromptTokens

Optional LLM prompt tokens

operation

Type: "index", "search", "answer", "evaluate"

totalCostUsd

Optional total cost in USD

Attributes

Inherited from:
Tracing

Concrete fields