nrgin

package module
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

README

v3/integrations/nrgin GoDoc

Package nrgin instruments https://github.com/gin-gonic/gin applications.

import "github.com/Easypay/go-agent/v3/integrations/nrgin"

For more information, see godocs.

Documentation

Overview

Package nrgin instruments https://github.com/gin-gonic/gin applications.

Use this package to instrument inbound requests handled by a gin.Engine. Call nrgin.Middleware to get a gin.HandlerFunc which can be added to your application as a middleware:

router := gin.Default()
// Add the nrgin middleware before other middlewares or routes:
router.Use(nrgin.Middleware(app))

Example: https://github.com/Easypay/go-agent/tree/master/v3/integrations/nrgin/example/main.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(app *newrelic.Application) gin.HandlerFunc

Middleware creates a Gin middleware that instruments requests.

router := gin.Default()
// Add the nrgin middleware before other middlewares or routes:
router.Use(nrgin.Middleware(app))

Gin v1.5.0 introduced the gin.Context.FullPath method which allows for much improved transaction naming. This Middleware will use that gin.Context.FullPath if available and fall back to the original gin.Context.HandlerName if not. If you are using Gin v1.5.0 and wish to continue using the old transaction names, use nrgin.MiddlewareHandlerTxnNames.

func MiddlewareHandlerTxnNames

func MiddlewareHandlerTxnNames(app *newrelic.Application) gin.HandlerFunc

MiddlewareHandlerTxnNames creates a Gin middleware that instruments requests.

router := gin.Default()
// Add the nrgin middleware before other middlewares or routes:
router.Use(nrgin.MiddlewareHandlerTxnNames(app))

The use of gin.Context.HandlerName for naming transactions will be removed in a future release. Available in Gin v1.5.0 and newer is the gin.Context.FullPath method which allows for much improved transaction names. Use nrgin.Middleware to take full advantage of this new naming!

func Transaction

func Transaction(c Context) *newrelic.Transaction

Transaction returns the transaction stored inside the context, or nil if not found.

Types

type Context

type Context interface {
	Value(key interface{}) interface{}
}

Context avoids making this package 1.7+ specific.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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