Skip to main content

Definition

class Trace(CamelModel):
    id: str
    name: str
    spans: list[Span]
    start_time: int
    end_time: int | None
    tags: list[str]
    metadata: dict
    user_id: str | None
    session_id: str | None
    version: str | None  # stored in metadata["version"]

Fields

id
string
Unique identifier for the trace. Auto-generated UUID if not provided.
name
string
required
Name describing the operation being traced.
spans
list[Span]
List of spans belonging to this trace.
start_time
integer
Unix timestamp in milliseconds when the trace started.
end_time
integer
Unix timestamp in milliseconds when the trace ended. None if still running.
tags
list[string]
Tags for categorizing the trace.
metadata
dict
Arbitrary metadata attached to the trace. The version field from @observe is stored here as metadata["version"].
user_id
string
Optional user identifier.
session_id
string
Optional session identifier.

JSON Serialization

Traces serialize with camelCase field names:
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "customer-support",
  "spans": [...],
  "startTime": 1708444800000,
  "endTime": null,
  "tags": ["production"],
  "metadata": {"channel": "web", "version": "2.1.0"},
  "userId": "user_123",
  "sessionId": "session_abc"
}

See Also