Skip to content

jessie-codes/echo-relic

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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")
}