muhammednagy / echo-relic

Echo middleware for new relic

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

echo-relic

Echo middleware for New Relic

GoDoc Build Status Coverage Status

install

go get github.com/muhammednagy/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/muhammednagy/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")
}

About

Echo middleware for new relic

License:MIT License


Languages

Language:Go 100.0%