telemetry

package
v0.9.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CatItemDrop     = "item_drop"
	CatItemPickup   = "item_pickup"
	CatMobKill      = "mob_kill"
	CatPlayerDeath  = "player_death"
	CatItemPurchase = "item_purchase"
	CatCharCreated  = "char_created"
	CatHelpTopic    = "help_topic"
	CatPlayerLogin  = "player_login"
)

Variables

This section is empty.

Functions

func Clear

func Clear(category, zone, date, dateTo string, itemId, mobId, roomId, raceId int, topic string)

Clear removes all in-memory records matching the given filters and marks the affected dates dirty so Save() will update or remove their files. Pass empty/zero values to match any value for that field.

func GetMemoryUsage

func GetMemoryUsage() map[string]util.MemoryResult

func Len

func Len() int

Len returns the total number of records currently in memory.

func Load

func Load(dataFilesPath string)

Load reads all YYYYMMDD.json files from <dataFilesPath>/telemetry/ and rebuilds the in-memory index. Any legacy YYYYMMDD.yaml files found are migrated to JSON and then deleted. Safe to call when the directory does not exist yet.

func RegisterListeners

func RegisterListeners()

RegisterListeners wires all telemetry event listeners. Called once at startup.

func Save

func Save() error

Save writes one JSON file per dirty date to the telemetry directory. Dates whose records were all cleared have their file deleted. Clean dates are not touched.

func Track

func Track(category, zone string, itemId, mobId, roomId int)

Track increments the counter for the given combination. Zero values for numeric fields and empty strings mean "not applicable" for that field.

func TrackFull

func TrackFull(category, zone string, itemId, mobId, roomId, raceId int, topic string)

TrackFull is like Track but also accepts the optional raceId and topic dimensions used by char_created and help_topic records.

Types

type GroupByField

type GroupByField uint8

GroupByField names the dimension used by GroupBy.

const (
	GroupByMobId GroupByField = iota
	GroupByItemId
	GroupByZone
	GroupByRoomId
	GroupByDate
	GroupByCategory
	GroupByRaceId
	GroupByTopic
)

type QueryBuilder

type QueryBuilder struct {
	// contains filtered or unexported fields
}

QueryBuilder builds a filtered, optionally sorted query over telemetry records. All filter methods return the same pointer for chaining.

func Query

func Query() *QueryBuilder

Query returns a new QueryBuilder over the current records.

func (*QueryBuilder) Category

func (q *QueryBuilder) Category(c string) *QueryBuilder

func (*QueryBuilder) Date

func (q *QueryBuilder) Date(d string) *QueryBuilder

Date filters to an exact YYYYMMDD date.

func (*QueryBuilder) DateFrom

func (q *QueryBuilder) DateFrom(d string) *QueryBuilder

DateFrom filters to records on or after d (YYYYMMDD).

func (*QueryBuilder) DateTo

func (q *QueryBuilder) DateTo(d string) *QueryBuilder

DateTo filters to records on or before d (YYYYMMDD).

func (*QueryBuilder) GroupBy

func (q *QueryBuilder) GroupBy(field GroupByField) *QueryBuilder

GroupBy collapses all matching records into one row per unique value of the given field, summing their counts. Date, Zone, RoomId, and other fields on the rolled-up record are left blank/zero because they are no longer meaningful across multiple source records.

func (*QueryBuilder) ItemId

func (q *QueryBuilder) ItemId(id int) *QueryBuilder

func (*QueryBuilder) MobId

func (q *QueryBuilder) MobId(id int) *QueryBuilder

func (*QueryBuilder) RaceId

func (q *QueryBuilder) RaceId(id int) *QueryBuilder

func (*QueryBuilder) Results

func (q *QueryBuilder) Results() []Record

Results returns a copy of all records matching the configured filters. If GroupBy was called, records are rolled up by that field before sorting.

func (*QueryBuilder) RoomId

func (q *QueryBuilder) RoomId(id int) *QueryBuilder

func (*QueryBuilder) SortAsc

func (q *QueryBuilder) SortAsc() *QueryBuilder

SortAsc sorts results by Count ascending.

func (*QueryBuilder) SortDesc

func (q *QueryBuilder) SortDesc() *QueryBuilder

SortDesc sorts results by Count descending.

func (*QueryBuilder) Topic

func (q *QueryBuilder) Topic(t string) *QueryBuilder

func (*QueryBuilder) Total

func (q *QueryBuilder) Total() int

Total returns the sum of Count across all matching records.

func (*QueryBuilder) Zone

func (q *QueryBuilder) Zone(z string) *QueryBuilder

type Record

type Record struct {
	Date     string `yaml:"date"             json:"date"`
	Category string `yaml:"category"         json:"category"`
	ItemId   int    `yaml:"itemid,omitempty" json:"itemid,omitempty"`
	MobId    int    `yaml:"mobid,omitempty"  json:"mobid,omitempty"`
	RoomId   int    `yaml:"roomid,omitempty" json:"roomid,omitempty"`
	Zone     string `yaml:"zone,omitempty"   json:"zone,omitempty"`
	RaceId   int    `yaml:"raceid,omitempty" json:"raceid,omitempty"`
	Topic    string `yaml:"topic,omitempty"  json:"topic,omitempty"`
	Count    int    `yaml:"count"            json:"count"`
}

Record holds a single aggregated counter for a unique combination of (Date, Category, ItemId, MobId, RoomId, Zone, RaceId, Topic).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL