ginnewrelic

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: MIT Imports: 3 Imported by: 0

README

NewRelic Middleware for Gin

Gin middleware for tracking NewRelic web requests.


    r := gin.New()

    appName := viper.GetString("NEW_RELIC_APP_NAME")
	licenseKey := viper.GetString("NEW_RELIC_LICENSE_KEY")

	app, err := newrelic.NewApplication(
		newrelic.ConfigAppName(appName),
		newrelic.ConfigLicense(licenseKey),
		newrelic.ConfigDistributedTracerEnabled(true),
		func(cfg *newrelic.Config) {
			cfg.ErrorCollector.RecordPanics = true
		},
	) 

    r.Use(ginnewrelic.NewRelicMiddleware(app))

    r.GET("/", func(c *gin.Context) {
        txn := newrelic.FromContext(c.Request.Context())

        // code...
    })

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRelicMiddleware

func NewRelicMiddleware(client *newrelic.Application) gin.HandlerFunc

NewRelicMiddleware the Gin Handler the same way NewRelic wraps a raw HTTP request https://github.com/newrelic/go-agent/blob/v3.15.2/v3/newrelic/instrumentation.go#L31-L46

Types

This section is empty.

Jump to

Keyboard shortcuts

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