NewRelic Integration middleware for Fiber.
func New(config ...Config) fiber.Handler
First import the middleware,
import (
"github.com/gofiber/fiber/v2"
"github.com/nobuyo/nrfiber"
)
Then create a Fiber app with app := fiber.New()
.
nrapp, err := newrelic.NewApplication(
newrelic.ConfigAppName("Application Name"),
newrelic.ConfigLicense(os.Getenv("NEW_RELIC_LICENSE_KEY")),
newrelic.ConfigDebugLogger(os.Stdout),
)
app.Use(nrfiber.New(nrfiber.Config{
NewRelicApp: nrapp
}))
// Config defines the config for middleware.
type Config struct {
// Next defines a function to skip this middleware when returned true.
//
// Optional. Default: nil
Next func(c *fiber.Ctx) bool
// NewRelicApp is newrelic.Application
//
// Required.
NewRelicApp *newrelic.Application
}
var ConfigDefault = Config{
Next: nil,
NewRelicApp: &newrelic.Application{},
}