org.llm4s.trace.ConsoleTracing
Console-based Tracing implementation with colored, formatted output.
Prints trace events to standard output with ANSI color formatting for improved readability during development and debugging. Returns Result[Unit] to support functional composition.
== Features ==
Color-coded output by event type (errors in red, success in green, etc.)
Visual separators and headers for different trace sections
Formatted display of all TraceEvent types
Truncation of long JSON content for readability
Timestamps on all events
== Usage ==
val tracing: Tracing = new ConsoleTracing()
// Trace events functionally
for {
_ <- tracing.traceEvent(TraceEvent.AgentInitialized("query", Vector("tool1")))
_ <- tracing.traceTokenUsage(TokenUsage(100, 50, 150), "gpt-4", "completion")
} yield ()
Attributes
See also
Graph
Reset zoom Hide graph Show graph
Supertypes
class Object
trait Matchable
class Any
Members list
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
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
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
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