README
¶
nrlogrus
NewRelic hook for Logrus, with logcontext support.
Why
Official hooks are not covering cases when NewRelic client is not yet created, or failed, but we still want logs for this entity to be connected to the APM. Turns out for this we need to only send the entity.name
and entity.type
.
Install
go get github.com/brokeyourbike/nrlogrus
Use
You can pass the application name to the function:
log.SetFormatter(nrlogrus.NewFormatter("my-app", &logrus.JSONFormatter{}))
or read it from environment variable NEW_RELIC_APP_NAME
:
log.SetFormatter(nrlogrus.NewFormatterFromEnvironment(&logrus.JSONFormatter{}))
Thanks
Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextFormatter ¶
type ContextFormatter struct {
// contains filtered or unexported fields
}
ContextFormatter is a `logrus.Formatter` that will format logs for sending to New Relic.
func NewFormatter ¶
func NewFormatter(appName string, formatter logrus.Formatter) ContextFormatter
NewFormatter creates a new `logrus.Formatter` that will format logs for sending to New Relic.
func NewFormatterFromEnvironment ¶
func NewFormatterFromEnvironment(formatter logrus.Formatter) ContextFormatter
NewFormatterFromEnvironment creates a new `logrus.Formatter` that will format logs for sending to New Relic. The application name is read from the `NEW_RELIC_APP_NAME` environment variable.