ractogateway.telemetry._models

Telemetry data models — shared across tracer, metrics, and pricing.

class ractogateway.telemetry._models.ModelPricing(**data)[source]

Bases: BaseModel

USD cost per 1 million tokens for a specific model.

Parameters:
  • input_per_million (float) – Price in USD for 1 million input (prompt) tokens.

  • output_per_million (float) – Price in USD for 1 million output (completion) tokens.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

input_per_million: float
output_per_million: float
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ractogateway.telemetry._models.SpanRecord(**data)[source]

Bases: BaseModel

In-memory span record — captured when RactoTracer(in_memory=True).

Useful for unit tests: inspect .spans after a call and assert on attributes without requiring an external OTEL backend.

Parameters:
  • name (str) – OTEL span name ("llm.chat" or "llm.embed").

  • provider (str) – Provider string — "openai", "google", or "anthropic".

  • model (str) – Model identifier as passed to the kit (e.g. "gpt-4o").

  • operation (str) – Operation type — "chat", "stream", or "embed".

  • latency_ms (float) – Total wall-clock latency of the LLM call in milliseconds.

  • input_tokens (int) – Number of prompt / input tokens consumed.

  • output_tokens (int) – Number of completion / output tokens produced.

  • cost_usd (float) – Estimated cost in USD derived from the built-in pricing table.

  • cache_hit (str) – Which cache served the result: "exact", "semantic", or "miss" when the LLM API was actually called.

  • tool_calls (int) – Number of tool calls present in the response.

  • status (str) – "ok" on success, "error" on exception.

  • error_type (str | None) – Exception class name when status == "error", else None.

  • timestamp (float) – Unix timestamp (time.time()) when the span was recorded.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

name: str
provider: str
model: str
operation: str
latency_ms: float
input_tokens: int
output_tokens: int
cost_usd: float
cache_hit: str
tool_calls: int
status: str
error_type: str | None
timestamp: float
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].