github.com/newrelic/go-agent@v3.26.0+incompatible/internal/custom_events.go (about) 1 // Copyright 2020 New Relic Corporation. All rights reserved. 2 // SPDX-License-Identifier: Apache-2.0 3 4 package internal 5 6 import "time" 7 8 type customEvents struct { 9 *analyticsEvents 10 } 11 12 func newCustomEvents(max int) *customEvents { 13 return &customEvents{ 14 analyticsEvents: newAnalyticsEvents(max), 15 } 16 } 17 18 func (cs *customEvents) Add(e *CustomEvent) { 19 // For the Go Agent, customEvents are added to the application, not the transaction. 20 // As a result, customEvents do not inherit their priority from the transaction, though 21 // they are still sampled according to priority sampling. 22 priority := NewPriority() 23 cs.addEvent(analyticsEvent{priority, e}) 24 } 25 26 func (cs *customEvents) MergeIntoHarvest(h *Harvest) { 27 h.CustomEvents.mergeFailed(cs.analyticsEvents) 28 } 29 30 func (cs *customEvents) Data(agentRunID string, harvestStart time.Time) ([]byte, error) { 31 return cs.CollectorJSON(agentRunID) 32 } 33 34 func (cs *customEvents) EndpointMethod() string { 35 return cmdCustomEvents 36 }