Skip to content

Commit

Permalink
Merge pull request cockroachdb#18 from crowdflux/himanshu-github
Browse files Browse the repository at this point in the history
getting api handler name
  • Loading branch information
himanshu144141 authored Aug 18, 2016
2 parents 72d6c7c + 22941bb commit 505064c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/api/newrelic.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ package api
import (
"github.com/gin-gonic/gin"
"github.com/newrelic/go-agent"
"strings"
)

func NewRelicMiddleware(app newrelic.Application) gin.HandlerFunc {
return func(c *gin.Context) {

txn := app.StartTransaction(c.HandlerName(), c.Writer, c.Request)
handlerStrings := strings.Split(c.HandlerName(), "/")
handlerName := handlerStrings[len(handlerStrings)-1]

txn := app.StartTransaction(handlerName, c.Writer, c.Request)
defer txn.End()

c.Next()
Expand Down

0 comments on commit 505064c

Please sign in to comment.