NewRelic hook for Logrus, with logcontext support.
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
.
go get github.com/brokeyourbike/nrlogrus
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{}))
- Ivan Stasiuk | Twitter | LinkedIn | stasi.uk