nrecho

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 5 Imported by: 22

README

v3/integrations/nrecho-v4 GoDoc

Package nrecho instruments applications using https://github.com/labstack/echo v4.

import "github.com/newrelic/go-agent/v3/integrations/nrecho-v4"

For more information, see godocs.

Documentation

Overview

Package nrecho instruments applications using https://github.com/labstack/echo v4.

Use this package to instrument inbound requests handled by an echo.Echo instance.

e := echo.New()
// Add the nrecho middleware before other middlewares or routes:
e.Use(nrecho.Middleware(app))

Example: https://github.com/newrelic/go-agent/tree/master/v3/integrations/nrecho-v4/example/main.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(c echo.Context) *newrelic.Transaction

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

func Middleware

func Middleware(app *newrelic.Application, opts ...ConfigOption) func(echo.HandlerFunc) echo.HandlerFunc

Middleware creates Echo middleware with provided config that instruments requests.

e := echo.New()
// Add the nrecho middleware before other middlewares or routes:
e.Use(nrecho.MiddlewareWithConfig(nrecho.Config{App: app}))

func WrapRouter added in v1.1.0

func WrapRouter(engine *echo.Echo)

WrapRouter extracts API endpoints from the echo instance passed to it which is used to detect application URL mapping(api-endpoints) for provable security. In this version of the integration, this wrapper is only necessary if you are using the New Relic security agent integration [https://github.com/newrelic/go-agent/tree/master/v3/integrations/nrsecurityagent], but it may be enhanced to provide additional functionality in future releases.

 e := echo.New()
 ....
 ....
 ....

nrecho.WrapRouter(e)

Types

type Config added in v1.0.3

type Config struct {
	// App contains newrelic application.
	App *newrelic.Application

	// Skipper defines a function to skip middleware.
	Skipper Skipper
}

Config defines the config for the middleware.

type ConfigOption added in v1.0.3

type ConfigOption func(*Config)

func WithSkipper added in v1.0.3

func WithSkipper(skipper Skipper) ConfigOption

type Skipper added in v1.0.3

type Skipper func(c echo.Context) bool

Skipper defines a function to skip middleware. Returning true skips processing the middleware.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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