echorelic

package module
v3.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2020 License: MIT Imports: 2 Imported by: 0

README

echo-relic

Echo middleware for New Relic

GoDoc Build Status Coverage Status

install

go get github.com/jessie-codes/echo-relic

Usage

Echo Relic starts a new transaction for each request, binds the transaction to the request context, and end the transaction after handling has been completed. It uses the following convention for naming transaction: <Method> <Path>. It automatically adds attributes for RealIP, IsTLS, IsWebSocket, and Query. See go-agent's documentation for how to use the transaction interface.


package main

import (
	"github.com/labstack/echo"
	"github.com/newrelic/go-agent"
	"github.com/jessie-codes/echo-relic/v3"
)

func main() {
	e := echo.New()
	relic = echorelic.New("__APP_NAME__", "__NEW_RELIC_LICENSE_KEY__")
	e.Use(relic.Transaction)

	e.GET("/", func(c echo.Context) error {
		txn := c.Get("newRelicTransaction")
		//route handle code
		return c.JSON(http.StatusOK, result)
	})
	e.Start(":8080")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EchoRelic

type EchoRelic struct {
	// contains filtered or unexported fields
}

EchoRelic stores the configured newrelic.Application

func New

func New(appName, licenseKey string) (*EchoRelic, error)

New creates an instance of type EchoRelic

func (*EchoRelic) Transaction

func (e *EchoRelic) Transaction(next echo.HandlerFunc) echo.HandlerFunc

Transaction is an echo middleware function which creates a new transaction for each request

Jump to

Keyboard shortcuts

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