nrfiber

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

README

nrfiber

Provides auto instrumentation for NewRelic and GoFiber.

Install

go get -u github.com/erkanzileli/nrfiber

Usage

Register the middleware and use created transaction to add another segments. Basic usage is below

package main

import (
	"github.com/erkanzileli/nrfiber"
	"github.com/gofiber/fiber/v2"
	"github.com/newrelic/go-agent/v3/newrelic"
	"log"
)

func main() {
	app := fiber.New()
	nr, err := newrelic.NewApplication(newrelic.ConfigEnabled(true), newrelic.ConfigAppName("demo"), newrelic.ConfigLicense("license-key"))
	if err != nil {
		log.Fatal(err)
	}

	// Add the nrfiber middleware before other middlewares or routes
	app.Use(nrfiber.Middleware(nr))

	// Use created transaction to create custom segments
	app.Get("/cart", func(ctx *fiber.Ctx) error {
		txn := nrfiber.FromContext(ctx)
		segment := txn.StartSegment("Price Calculation")
		defer segment.End()

		// calculate the price

		return nil
	})
	app.Listen(":3000")
}

Guides

Contributing

Feel free to add anything useful or fix something.

Documentation

Overview

Package nrfiber provides New Relic instrumentation for the Fiber web framework.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigCustomTransactionNameFunc added in v0.1.3

func ConfigCustomTransactionNameFunc(customTransactionNameFunc func(c *fiber.Ctx) string) *config

func ConfigNoticeErrorEnabled

func ConfigNoticeErrorEnabled(enabled bool) *config

func ConfigStatusCodeIgnored

func ConfigStatusCodeIgnored(statusCode []int) *config

func FromContext

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

FromContext returns the Transaction from the context if present, and nil otherwise.

func Middleware

func Middleware(app *newrelic.Application, configs ...*config) fiber.Handler

Middleware creates Fiber middleware that instrument's requests.

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

func Send added in v0.1.2

func Send(c *fiber.Ctx, segmentName string)

Types

This section is empty.

Jump to

Keyboard shortcuts

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