Documentation ¶
Overview ¶
Package events provides a programmatic API for creating custom events in New Relic.
Authentication ¶
You will need a valid Insights insert key to communicate with the backend New Relic API that provides this functionality. See the API key documentation below for more information on how to locate this key:
https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys
Index ¶
- Constants
- type BatchConfigOption
- type Events
- func (e *Events) BatchMode(ctx context.Context, accountID int, opts ...BatchConfigOption) (err error)
- func (e *Events) CreateEvent(accountID int, event interface{}) error
- func (e *Events) CreateEventWithContext(ctx context.Context, accountID int, event interface{}) error
- func (e *Events) EnqueueEvent(ctx context.Context, event interface{}) (err error)
- func (e *Events) Flush() error
- type EventsAPI
Constants ¶
const ( DefaultBatchWorkers = 1 DefaultBatchSize = 900 DefaultBatchTimeout = 60 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchConfigOption ¶
func BatchConfigQueueSize ¶
func BatchConfigQueueSize(size int) BatchConfigOption
BatchConfigQueueSize is how many events to queue before sending to New Relic. If this limit is hit before the Timeout, the queue is flushed.
func BatchConfigTimeout ¶
func BatchConfigTimeout(seconds int) BatchConfigOption
BatchConfigTimeout is the maximum amount of time to queue events before sending to New Relic. If this is reached before the Size limit, the queue is flushed.
func BatchConfigWorkers ¶
func BatchConfigWorkers(count int) BatchConfigOption
BatchConfigWorkers sets how many background workers will process events as they are queued
type Events ¶
type Events struct {
// contains filtered or unexported fields
}
Events is used to send custom events to NRDB.
func NewEventsService ¶ added in v2.22.2
func NewEventsService(opts ...config.ConfigOption) (*Events, error)
Provides the EventsAPI operations for *Events
func (*Events) BatchMode ¶
func (e *Events) BatchMode(ctx context.Context, accountID int, opts ...BatchConfigOption) (err error)
BatchMode enables the Events client to accept, queue, and post Events on behalf of the consuming application
func (*Events) CreateEvent ¶
CreateEvent reports a custom event to New Relic.
func (*Events) CreateEventWithContext ¶
func (e *Events) CreateEventWithContext(ctx context.Context, accountID int, event interface{}) error
CreateEventWithContext reports a custom event to New Relic.
func (*Events) EnqueueEvent ¶
EnqueueEventContext handles the queueing. Only works in batch mode. If you wish to be able to avoid blocking forever until the event can be queued, provide a ctx with a deadline or timeout as this function will bail when ctx.Done() is closed and return and error.
type EventsAPI ¶ added in v2.22.2
type EventsAPI interface { CreateEvent(accountID int, event interface{}) error CreateEventWithContext(ctx context.Context, accountID int, event interface{}) error }
EventsAPI provides an interface to enable mocking the service implementation. You should use this interface to invoke methods and substitute with a mock having a compatible implementation for unit testing your usages.