newrelic_logrus

package module
v0.0.0-...-5f55d4f Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2017 License: MIT Imports: 3 Imported by: 0

README

New Relic Logrus Hook

This is a simple logrus hook that lets existing logrus applications hook into New Relic error reporting using the New Relic Go Agent.

New Relic relies on having errors associated witha transaction. But logrus doesn't know which transaction its being called from. So currently this hook plugin just creates a new transaction called errorTxn and reports logged errors under that transaction. They show up just like any other reported errors. If any fields are supplied to the log line via WithFields, they are reported as custom attributes on the errorTxn and will be visible in New Relic.

Usage

You can install this like any other logrus hook. Assuming that application is your newrelic.Application from the Go agent, you can "hook" it up like this:

log.AddHook(
	newrelic_logrus.NewNewRelicLogrusHook(
		application,
		[]log.Level{log.ErrorLevel, log.FatalLevel},
	),
)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NewRelicLogrusHook

type NewRelicLogrusHook struct {
	Application newrelic.Application
	LogLevels   []logrus.Level
	// contains filtered or unexported fields
}

func NewNewRelicLogrusHook

func NewNewRelicLogrusHook(app newrelic.Application, levels []logrus.Level) *NewRelicLogrusHook

func (*NewRelicLogrusHook) Fire

func (n *NewRelicLogrusHook) Fire(entry *logrus.Entry) error

func (*NewRelicLogrusHook) Levels

func (n *NewRelicLogrusHook) Levels() []logrus.Level

Jump to

Keyboard shortcuts

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