An open API service indexing awesome lists of open source software.

https://github.com/nitro/newrelic-logrus

Logrus logging hook to report errors via New Relic Go agent
https://github.com/nitro/newrelic-logrus

Last synced: about 1 year ago
JSON representation

Logrus logging hook to report errors via New Relic Go agent

Awesome Lists containing this project

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