MetricsMiddleware

org.llm4s.llmconnect.middleware.MetricsMiddleware
class MetricsMiddleware(collector: MetricsCollector, providerName: String, modelName: String) extends LLMMiddleware

Middleware that collects metrics for LLM operations.

Replaces the provider-baked MetricsRecording trait with a composable layer. Records request duration, success/failure counts, token usage, and costs.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override def name: String

Human-readable name for logging/debugging.

Human-readable name for logging/debugging.

Attributes

Definition Classes
override def wrap(client: LLMClient): LLMClient

Wrap the given LLMClient, returning a new client with added behavior.

Wrap the given LLMClient, returning a new client with added behavior.

Implementations should delegate all LLMClient methods to next, adding behavior before/after delegation as needed.

Value parameters

next

the next client in the pipeline

Attributes

Returns

a new LLMClient with this middleware's behavior added

Definition Classes