events

package
v0.42.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2020 License: Apache-2.0 Imports: 11 Imported by: 2

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

View Source
const (
	DefaultBatchWorkers = 1
	DefaultBatchSize    = 900
	DefaultBatchTimeout = 60 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchConfigOption added in v0.35.0

type BatchConfigOption func(*Events) error

func BatchConfigQueueSize added in v0.35.0

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 added in v0.35.0

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 added in v0.35.0

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 New

func New(cfg config.Config) Events

New is used to create a new Events client instance.

func (*Events) BatchMode added in v0.35.0

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

func (e *Events) CreateEvent(accountID int, event interface{}) error

CreateEvent reports a custom event to New Relic.

func (*Events) EnqueueEvent added in v0.35.0

func (e *Events) EnqueueEvent(ctx context.Context, event interface{}) (err error)

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.

func (*Events) Flush added in v0.35.0

func (e *Events) Flush() error

Flush gives the user a way to manually flush the queue in the foreground. This is also used by watchdog when the timer expires.

Jump to

Keyboard shortcuts

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