custom_events.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package internal
  2. import (
  3. "time"
  4. )
  5. type customEvents struct {
  6. events *analyticsEvents
  7. }
  8. func newCustomEvents(max int) *customEvents {
  9. return &customEvents{
  10. events: newAnalyticsEvents(max),
  11. }
  12. }
  13. func (cs *customEvents) Add(e *CustomEvent) {
  14. // For the Go Agent, customEvents are added to the application, not the transaction.
  15. // As a result, customEvents do not inherit their priority from the transaction, though
  16. // they are still sampled according to priority sampling.
  17. priority := NewPriority()
  18. cs.events.addEvent(analyticsEvent{priority, e})
  19. }
  20. func (cs *customEvents) MergeIntoHarvest(h *Harvest) {
  21. h.CustomEvents.events.mergeFailed(cs.events)
  22. }
  23. func (cs *customEvents) Data(agentRunID string, harvestStart time.Time) ([]byte, error) {
  24. return cs.events.CollectorJSON(agentRunID)
  25. }
  26. func (cs *customEvents) numSeen() float64 { return cs.events.NumSeen() }
  27. func (cs *customEvents) numSaved() float64 { return cs.events.NumSaved() }
  28. func (cs *customEvents) EndpointMethod() string {
  29. return cmdCustomEvents
  30. }