Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AggregationType ¶
type AggregationType string
AggregationType controls how meter events are aggregated.
const ( AggSum AggregationType = "sum" AggCount AggregationType = "count" AggLast AggregationType = "last" )
type Meter ¶
type Meter struct {
mixin.Model
Name string `json:"name"`
EventName string `json:"eventName"`
AggregationType AggregationType `json:"aggregationType"`
Currency currency.Type `json:"currency"`
// JSON-encoded list of dimension names, e.g. ["model","region"]
Dimensions []string `json:"dimensions,omitempty" datastore:"-"`
Dimensions_ string `json:"-" datastore:",noindex"`
Metadata Map `json:"metadata,omitempty" datastore:"-"`
Metadata_ string `json:"-" datastore:",noindex"`
}
Meter defines a named usage metric with a specific aggregation strategy. Each meter has a unique EventName per org (e.g. "input_tokens", "api_calls").
type MeterEvent ¶
type MeterEvent struct {
mixin.Model
MeterId string `json:"meterId"`
UserId string `json:"userId"`
Value int64 `json:"value"`
Timestamp time.Time `json:"timestamp"`
// Idempotency key for deduplication
Idempotency string `json:"idempotency,omitempty"`
// JSON-encoded dimension values, e.g. {"model":"gpt-4","region":"us"}
Dimensions Map `json:"dimensions,omitempty" datastore:"-"`
Dimensions_ string `json:"-" datastore:",noindex"`
Metadata Map `json:"metadata,omitempty" datastore:"-"`
Metadata_ string `json:"-" datastore:",noindex"`
}
MeterEvent records a single usage data point for a meter.
func NewEvent ¶
func NewEvent(db *datastore.Datastore) *MeterEvent
func (*MeterEvent) Defaults ¶
func (e *MeterEvent) Defaults()
func (*MeterEvent) Init ¶
func (e *MeterEvent) Init(db *datastore.Datastore)
func (MeterEvent) Kind ¶
func (e MeterEvent) Kind() string
func (*MeterEvent) Validator ¶
func (e *MeterEvent) Validator() *val.Validator
Click to show internal directories.
Click to hide internal directories.