What is an Event?
An event is a record of a single operation in your application. Events use a generic structure with values (numeric data) and dimensions (categorical data).| Field | Description | Example |
|---|---|---|
customerId | Who made the request | "cust_123" |
eventType | Type of operation | "llm.completion" |
values | Numeric measurements | {"tokens": 500, "cost_cents": 25} |
dimensions | Categorical attributes | {"model": "gpt-4", "feature": "chat"} |
timestamp | When it occurred | Auto-set or custom |
Recording Events
Useevents.record after each operation:
Values vs Dimensions
Values (Numeric)
Values are numbers that can be aggregated by meters:- Sum up (total tokens, total cost)
- Find the max (peak usage)
- Track over time (daily usage)
Dimensions (Categorical)
Dimensions are strings used for filtering and grouping:- Filtering in meters (
sum tokens where model = gpt-4) - Filtering in limits (limit only GPT-4 usage)
- Breakdowns in analytics (usage by model)
Event Types
Use descriptive event types to categorize operations:| Event Type | Use Case |
|---|---|
llm.completion | Chat/text completions |
llm.embedding | Text embedding generation |
image.generation | Image creation |
agent.run | Agent execution |
feature.usage | Feature access tracking |
resource.created | Resource creation (for counting) |
resource.deleted | Resource deletion |
Examples
LLM Completion
Image Generation
Resource Count (Gauge)
For tracking current resource counts, uselatest aggregation in your meter: