nrzap
Description
New Relic Logs in context for the Go agent connects your logs and APM data in New Relic. but, official New Relic agent povides a plugin only for logurus.
nrzap is helper for go.uber.org/zap logger. nrzap helps to connect logs and APM data in New Relic.
Prerequisites
- Enable distributed tracing for your Go applications
- Enable log management in New Relic
Usage
GetNrMetadataFields
funcion generates zap typed fields for connect logs and APM in New Relic.
func ExampleHandler(w http.ResponseWriter, r *http.Request) {
logger, _ := zap.NewProduction()
defer logger.Sync()
nrfs := nrzap.GetNrMetadataFields(ctx)
logger.Info("failed to fetch URL",
// Structured context as strongly typed Field values.
zap.String("url", url),
zap.Int("attempt", 3),
zap.Duration("backoff", time.Second),
nrfs...,
)
}
Installation
$ go get -u github.com/budougumi0617/nrzap
License
MIT
Author
Yocihiro Shimizu(@budougumi0617)