Skip to content

Logrus logging hook to report errors via New Relic Go agent

License

Notifications You must be signed in to change notification settings

Nitro/newrelic-logrus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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},
	),
)

About

Logrus logging hook to report errors via New Relic Go agent

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages