logs

package
v2.44.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

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

type BatchConfigOption func(*Logs) error

func BatchConfigQueueSize

func BatchConfigQueueSize(size int) BatchConfigOption

BatchConfigQueueSize is how many logs 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 logs 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 logs as they are queued

type Logs

type Logs struct {
	// contains filtered or unexported fields
}

func New

func New(cfg config.Config) Logs

New is used to create a new Logs client instance.

func (*Logs) BatchMode

func (e *Logs) BatchMode(ctx context.Context, accountID int, opts ...BatchConfigOption) (err error)

BatchMode enables the Logs client to accept, queue, and post Logs on behalf of the consuming application

func (*Logs) CreateLogEntry

func (l *Logs) CreateLogEntry(logEntry interface{}) error

CreateLogEntry reports a log entry to New Relic. It's up to the caller to send a valid Log API payload, no checking done here

func (*Logs) EnqueueLogEntry

func (e *Logs) EnqueueLogEntry(ctx context.Context, msg interface{}) (err error)

EnqueueLogEntry handles the queueing. Only works in batch mode. If you wish to be able to avoid blocking forever until the log 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 (*Logs) Flush

func (e *Logs) 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