diff --git a/go.mod b/go.mod index 881e3cfc..a9cbc3a0 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,7 @@ require ( github.com/mattn/go-isatty v0.0.13 // indirect github.com/micromdm/scep/v2 v2.1.0 github.com/miekg/pkcs11 v1.1.1 // indirect - github.com/newrelic/go-agent v3.18.0+incompatible + github.com/newrelic/go-agent/v3 v3.18.0 github.com/pkg/errors v0.9.1 github.com/rs/xid v1.2.1 github.com/sirupsen/logrus v1.8.1 diff --git a/go.sum b/go.sum index 2038dcf3..b7fecfa4 100644 --- a/go.sum +++ b/go.sum @@ -633,8 +633,8 @@ github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxzi github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/nbrownus/go-metrics-prometheus v0.0.0-20210712211119-974a6260965f/go.mod h1:nwPd6pDNId/Xi16qtKrFHrauSwMNuvk+zcjk89wrnlA= -github.com/newrelic/go-agent v3.18.0+incompatible h1:0MUUHr33A9yIhTZh98JaqWV26iFezRABqicL8MQAYTM= -github.com/newrelic/go-agent v3.18.0+incompatible/go.mod h1:a8Fv1b/fYhFSReoTU6HDkTYIMZeSVNffmoS726Y0LzQ= +github.com/newrelic/go-agent/v3 v3.18.0 h1:AOR3hhF2ZVE0yfvNPuOaEhEvNMYyIfEBY8EizQpnt7g= +github.com/newrelic/go-agent/v3 v3.18.0/go.mod h1:BFJOlbZWRlPTXKYIC1TTTtQKTnYntEJaU0VU507hDc0= github.com/nishanths/predeclared v0.0.0-20200524104333-86fad755b4d3/go.mod h1:nt3d53pc1VYcphSCIaYAJtnPYnr3Zyn8fMq2wvPGPso= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= diff --git a/monitoring/monitoring.go b/monitoring/monitoring.go index 2dda4840..a0d0886b 100644 --- a/monitoring/monitoring.go +++ b/monitoring/monitoring.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - newrelic "github.com/newrelic/go-agent" + "github.com/newrelic/go-agent/v3/newrelic" "github.com/pkg/errors" "github.com/smallstep/certificates/logging" ) @@ -41,7 +41,10 @@ func New(raw json.RawMessage) (*Monitoring, error) { m := new(Monitoring) switch strings.ToLower(config.Type) { case "", "newrelic": - app, err := newrelic.NewApplication(newrelic.NewConfig(config.Name, config.Key)) + app, err := newrelic.NewApplication( + newrelic.ConfigAppName(config.Name), + newrelic.ConfigLicense(config.Key), + ) if err != nil { return nil, errors.Wrap(err, "error loading New Relic application") } @@ -58,13 +61,16 @@ func (m *Monitoring) Middleware(next http.Handler) http.Handler { return m.middleware(next) } -func newRelicMiddleware(app newrelic.Application) Middleware { +func newRelicMiddleware(app *newrelic.Application) Middleware { return func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // Start transaction - txn := app.StartTransaction(transactionName(r), w, r) + txn := app.StartTransaction(transactionName(r)) defer txn.End() + w = txn.SetWebResponse(w) + txn.SetWebRequestHTTP(r) + // Wrap request writer if necessary rw := logging.NewResponseLogger(w)