Skip to content

brokeyourbike/nrlogrus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

3d9d1e4 · Mar 13, 2025

History

35 Commits
Mar 13, 2025
Mar 13, 2025
Nov 11, 2022
Mar 13, 2025
Nov 11, 2022
May 9, 2023
May 9, 2023
May 9, 2023
Mar 13, 2025
Mar 13, 2025

Repository files navigation

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