nrfiber

package module
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

README ΒΆ

nrfiber

nrfiber is one of New Relic Go Agent integration packages. It instruments inbound requests through the Fiber framework.

Go Reference Go Report Card

πŸš€ Install

go get -u github.com/ichizero/nrfiber

🧐 Usage

package main

import (
	"log"
	"net/http"

	"github.com/gofiber/fiber/v2"
	"github.com/ichizero/nrfiber"
	"github.com/newrelic/go-agent/v3/newrelic"
)

func main() {
	nrApp, err := newrelic.NewApplication(
		newrelic.ConfigEnabled(true),
		newrelic.ConfigAppName("nrfiber-example"),
		newrelic.ConfigLicense("license-key"),
	)
	if err != nil {
		log.Fatal(err)
	}

	app := fiber.New()
	app.Use(nrfiber.Middleware(nrApp))

	app.Post("/echo", func(c *fiber.Ctx) error {
		return c.Status(http.StatusOK).Send(c.Request().Body())
	})

	if err := app.Listen(":8000"); err != nil {
		log.Fatal(err)
	}
}

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

This section is empty.

Functions ΒΆ

func FromContext ΒΆ

func FromContext(c *fiber.Ctx) *newrelic.Transaction

FromContext returns *newrelic.Transaction from *fiber.Ctx if present.

func Middleware ΒΆ

func Middleware(app *newrelic.Application, opts ...Option) fiber.Handler

Middleware creates Fiber middleware that instruments requests.

app := fiber.New()
// Add the nrfiber middleware before other middlewares or routes:
app.Use(nrfiber.Middleware(app))

Types ΒΆ

type Option ΒΆ

type Option func(cfg *config)

Option is an option for Middleware.

func WithTransactionNameFormatter ΒΆ

func WithTransactionNameFormatter(f func(c *fiber.Ctx) string) Option

WithTransactionNameFormatter takes a function that determine a transaction name for each request.

Directories ΒΆ

Path Synopsis

Jump to

Keyboard shortcuts

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