From 135c4818934b305db96c8ded93fb429915942567 Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Thu, 28 Jul 2022 11:09:34 -0600 Subject: [PATCH 1/2] Update deps to bring in support for OpenBSD OpenBSD support was added to the following deps: - github.com/go-piv/piv-go in https://github.com/go-piv/piv-go/pull/101 - github.com/newrelic/go-agent in https://github.com/newrelic/go-agent/pull/455 - github.com/miekg/pkcs11 in https://github.com/miekg/pkcs11/pull/140 With these deps bumped, tests all pass on OpenBSD amd64. --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 546ec53d..881e3cfc 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect github.com/go-chi/chi v4.0.2+incompatible github.com/go-kit/kit v0.10.0 // indirect - github.com/go-piv/piv-go v1.7.0 + github.com/go-piv/piv-go v1.10.0 github.com/go-sql-driver/mysql v1.6.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.6.0 @@ -34,8 +34,8 @@ require ( github.com/mattn/go-colorable v0.1.8 // indirect github.com/mattn/go-isatty v0.0.13 // indirect github.com/micromdm/scep/v2 v2.1.0 - github.com/miekg/pkcs11 v1.0.3 // indirect - github.com/newrelic/go-agent v2.15.0+incompatible + github.com/miekg/pkcs11 v1.1.1 // indirect + github.com/newrelic/go-agent v3.18.0+incompatible 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 32a27e27..2038dcf3 100644 --- a/go.sum +++ b/go.sum @@ -268,8 +268,8 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9 github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0 h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih4= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-piv/piv-go v1.7.0 h1:rfjdFdASfGV5KLJhSjgpGJ5lzVZVtRWn8ovy/H9HQ/U= -github.com/go-piv/piv-go v1.7.0/go.mod h1:ON2WvQncm7dIkCQ7kYJs+nc3V4jHGfrrJnSF8HKy7Gk= +github.com/go-piv/piv-go v1.10.0 h1:P1Y1VjBI5DnXW0+YkKmTuh5opWnMIrKriUaIOblee9Q= +github.com/go-piv/piv-go v1.10.0/go.mod h1:NZ2zmjVkfFaL/CF8cVQ/pXdXtuj110zEKGdJM6fJZZM= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= @@ -596,8 +596,8 @@ github.com/micromdm/scep/v2 v2.1.0/go.mod h1:BkF7TkPPhmgJAMtHfP+sFTKXmgzNJgLQlvv github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4= github.com/miekg/pkcs11 v1.0.3-0.20190429190417-a667d056470f/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= -github.com/miekg/pkcs11 v1.0.3 h1:iMwmD7I5225wv84WxIG/bmxz9AXjWvTWIbM/TYHvWtw= -github.com/miekg/pkcs11 v1.0.3/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= +github.com/miekg/pkcs11 v1.1.1 h1:Ugu9pdy6vAYku5DEpVWVFPYnzV+bxB+iRdbuFSu7TvU= +github.com/miekg/pkcs11 v1.1.1/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= @@ -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 v2.15.0+incompatible h1:IB0Fy+dClpBq9aEoIrLyQXzU34JyI1xVTanPLB/+jvU= -github.com/newrelic/go-agent v2.15.0+incompatible/go.mod h1:a8Fv1b/fYhFSReoTU6HDkTYIMZeSVNffmoS726Y0LzQ= +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/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= From 821743f71e71888e936d3a96fd99f18c34a79412 Mon Sep 17 00:00:00 2001 From: Mariano Cano Date: Thu, 4 Aug 2022 11:16:11 -0700 Subject: [PATCH 2/2] Upgrade newrelic to v3 --- go.mod | 2 +- go.sum | 4 ++-- monitoring/monitoring.go | 14 ++++++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) 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)