/nr-fasthttp

NewRelic instrumentation helpers for valyala/fasthttp

Primary LanguageGoApache License 2.0Apache-2.0

nr-fasthttp

NewRelic instrumentation helpers for valyala/fasthttp.

Usage

Instrumenting external segments:

txn := newrelicApp.StartTransaction("test", nil, nil)
defer txn.End()

req := fasthttp.AcquireRequest()
defer fasthttp.ReleaseRequest(req)

resp := fasthttp.AcquireResponse()
defer fasthttp.ReleaseResponse(resp)

proxyClient := &fasthttp.HostClient{
  Addr: "localhost:8080",
}

nrfasthttp.Do(proxyClient, txn, req, res)

Instrumenting web transactions

With buaazp/fasthttprouter:

router.Handle("GET", "/me", nrfasthttp.WrapHandler(newrelicApp, "/me", yourHandler)

router.NotFound = nrfasthttp.WrapHandler(newrelicApp, "404", yourHandler)

Using fastthttp only:

fasthttp.Serve(listener, nrfasthttp.WrapHandler(newrelicApp, "Request", yourHandler))

Getting newrelic.Transaction:

func handler (ctx *fasthttp.RequestCtx) {
    txn := ntfasthttp.GetTransaction(ctx)
}

For complete documentation, check here. The API is based on newrelic/go-agent API so usage is very similiar.

License

See here.