replace zxq.co/ripple/hanayo
This commit is contained in:
29
vendor/github.com/johnniedoe/contrib/newrelic/newrelic.go
generated
vendored
Normal file
29
vendor/github.com/johnniedoe/contrib/newrelic/newrelic.go
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
package newrelic
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
metrics "github.com/yvasiyarov/go-metrics"
|
||||
"github.com/yvasiyarov/gorelic"
|
||||
)
|
||||
|
||||
var agent *gorelic.Agent
|
||||
|
||||
func NewRelic(license string, appname string, verbose bool) gin.HandlerFunc {
|
||||
agent = gorelic.NewAgent()
|
||||
agent.NewrelicLicense = license
|
||||
|
||||
agent.HTTPTimer = metrics.NewTimer()
|
||||
agent.CollectHTTPStat = true
|
||||
agent.Verbose = verbose
|
||||
|
||||
agent.NewrelicName = appname
|
||||
agent.Run()
|
||||
|
||||
return func(c *gin.Context) {
|
||||
startTime := time.Now()
|
||||
c.Next()
|
||||
agent.HTTPTimer.UpdateSince(startTime)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user