github.com/lulzWill/go-agent@v2.1.2+incompatible/internal/custom_events.go (about) 1 package internal 2 3 import ( 4 "math/rand" 5 "time" 6 ) 7 8 type customEvents struct { 9 events *analyticsEvents 10 } 11 12 func newCustomEvents(max int) *customEvents { 13 return &customEvents{ 14 events: newAnalyticsEvents(max), 15 } 16 } 17 18 func (cs *customEvents) Add(e *CustomEvent) { 19 stamp := eventStamp(rand.Float32()) 20 cs.events.addEvent(analyticsEvent{stamp, e}) 21 } 22 23 func (cs *customEvents) MergeIntoHarvest(h *Harvest) { 24 h.CustomEvents.events.mergeFailed(cs.events) 25 } 26 27 func (cs *customEvents) Data(agentRunID string, harvestStart time.Time) ([]byte, error) { 28 return cs.events.CollectorJSON(agentRunID) 29 } 30 31 func (cs *customEvents) numSeen() float64 { return cs.events.NumSeen() } 32 func (cs *customEvents) numSaved() float64 { return cs.events.NumSaved() }