brokeyourbike / nrlogrus

NewRelic hook for Logrus, with logcontext support.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nrlogrus

Go Reference Go Report Card Maintainability Test Coverage

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

Authors

License

Apache-2.0 License

About

NewRelic hook for Logrus, with logcontext support.

License:Apache License 2.0


Languages

Language:Go 100.0%