项目作者: jessie-codes

项目描述 :
Echo middleware for new relic
高级语言: Go
项目地址: git://github.com/jessie-codes/echo-relic.git
创建时间: 2017-08-11T18:16:16Z
项目社区:https://github.com/jessie-codes/echo-relic

开源协议:MIT License

下载


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.

  1. package main
  2. import (
  3. "github.com/labstack/echo"
  4. "github.com/newrelic/go-agent"
  5. "github.com/jessie-codes/echo-relic/v3"
  6. )
  7. func main() {
  8. e := echo.New()
  9. relic = echorelic.New("__APP_NAME__", "__NEW_RELIC_LICENSE_KEY__")
  10. e.Use(relic.Transaction)
  11. e.GET("/", func(c echo.Context) error {
  12. txn := c.Get("newRelicTransaction")
  13. //route handle code
  14. return c.JSON(http.StatusOK, result)
  15. })
  16. e.Start(":8080")
  17. }