nrzap

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2021 License: MIT Imports: 4 Imported by: 0

README

nrzap

Go Reference MIT License test reviewdog

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

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)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNrMetadataFields

func GetNrMetadataFields(ctx context.Context) []zap.Field

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL