Echo middleware for New Relic
go get github.com/jessie-codes/echo-relic
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")
}