TraceEvent

org.llm4s.trace.TraceEvent
See theTraceEvent companion trait
object TraceEvent

Attributes

Companion
trait
Graph
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
TraceEvent.type

Members list

Type members

Classlikes

case class AgentInitialized(query: String, tools: Vector[String], timestamp: Instant) extends TraceEvent

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait TraceEvent
class Object
trait Matchable
class Any
Show all
case class AgentStateUpdated(status: String, messageCount: Int, logCount: Int, timestamp: Instant) extends TraceEvent

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait TraceEvent
class Object
trait Matchable
class Any
Show all
case class CacheHit(similarity: Double, threshold: Double, timestamp: Instant) extends TraceEvent

Cache hit event for semantic caching

Cache hit event for semantic caching

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait TraceEvent
class Object
trait Matchable
class Any
Show all
case class CacheMiss(reason: CacheMissReason, timestamp: Instant) extends TraceEvent

Cache miss event for semantic caching

Cache miss event for semantic caching

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait TraceEvent
class Object
trait Matchable
class Any
Show all

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait CacheMissReason

Cache miss reason ADT

Cache miss reason ADT

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
case class CompletionReceived(id: String, model: String, toolCalls: Int, content: String, timestamp: Instant) extends TraceEvent

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait TraceEvent
class Object
trait Matchable
class Any
Show all
case class CostRecorded(costUsd: Double, model: String, operation: String, tokenCount: Int, costType: String, timestamp: Instant) extends TraceEvent

Tracks cost in USD for any model operation.

Tracks cost in USD for any model operation.

Value parameters

costType

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

costUsd

Estimated cost in US dollars

model

Model name used for pricing lookup

operation

Type of operation: "embedding", "completion", "evaluation"

tokenCount

Total tokens consumed

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait TraceEvent
class Object
trait Matchable
class Any
Show all
case class CustomEvent(name: String, data: Value, timestamp: Instant) extends TraceEvent

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait TraceEvent
class Object
trait Matchable
class Any
Show all
case class EmbeddingUsageRecorded(usage: EmbeddingUsage, model: String, operation: String, inputCount: Int, timestamp: Instant) extends TraceEvent

Tracks embedding token usage for cost analysis.

Tracks embedding token usage for cost analysis.

Value parameters

inputCount

Number of texts embedded in this operation

model

Embedding model name (e.g., "text-embedding-3-small")

operation

Type of operation: "indexing", "query", "evaluation"

usage

Token usage statistics from embedding operation

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait TraceEvent
class Object
trait Matchable
class Any
Show all
case class ErrorOccurred(error: Throwable, context: String, timestamp: Instant) extends TraceEvent

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait TraceEvent
class Object
trait Matchable
class Any
Show all
case class RAGOperationCompleted(operation: String, durationMs: Long, embeddingTokens: Option[Int], llmPromptTokens: Option[Int], llmCompletionTokens: Option[Int], totalCostUsd: Option[Double], timestamp: Instant) extends TraceEvent

Tracks completion of a RAG operation with full metrics.

Tracks completion of a RAG operation with full metrics.

Value parameters

durationMs

Wall-clock duration in milliseconds

embeddingTokens

Optional token count for embedding operations

llmCompletionTokens

Optional completion tokens for LLM operations

llmPromptTokens

Optional prompt tokens for LLM operations

operation

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

totalCostUsd

Optional accumulated cost in USD

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait TraceEvent
class Object
trait Matchable
class Any
Show all
case class TokenUsageRecorded(usage: TokenUsage, model: String, operation: String, timestamp: Instant) extends TraceEvent

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait TraceEvent
class Object
trait Matchable
class Any
Show all
case class ToolExecuted(name: String, input: String, output: String, duration: Long, success: Boolean, timestamp: Instant) extends TraceEvent

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait TraceEvent
class Object
trait Matchable
class Any
Show all

Inherited and Abstract types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Attributes

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type

The name of the type

Attributes

Inherited from:
Mirror

Value members

Concrete methods

def createTraceEvent(traceId: String, now: String, environment: String, release: String, version: String, traceInput: String, traceOutput: String, modelName: String, messageCount: Int): Obj

Builds a Langfuse "trace-create" batch-envelope object.

Builds a Langfuse "trace-create" batch-envelope object.

The resulting JSON is suitable for inclusion in the batch array sent to the Langfuse ingest endpoint. A new random UUID is generated for the outer envelope "id" on every call; the trace identity is carried by traceId. The "sessionId" field is derived from System.currentTimeMillis() and therefore reflects wall-clock time at call time, not the event timestamp.

Value parameters

environment

Deployment environment label forwarded to Langfuse metadata

messageCount

Conversation length forwarded to Langfuse metadata

modelName

Model name forwarded to the Langfuse "model" field

now

ISO-8601 timestamp string for both envelope and body "timestamp" fields

release

Application release string forwarded to Langfuse metadata

traceId

Stable identifier for the trace; correlates spans across calls

traceInput

The user query or agent input recorded as the trace input

traceOutput

The agent's final response recorded as the trace output

version

Framework version string forwarded to Langfuse metadata

Attributes