Skip to content

Commit

Permalink
Merge pull request #929 from newrelic/develop
Browse files Browse the repository at this point in the history
Release 3.33.1
  • Loading branch information
nr-swilloughby authored Jul 2, 2024
2 parents 424d175 + 4076dc0 commit cab3b31
Show file tree
Hide file tree
Showing 72 changed files with 309 additions and 152 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## 3.33.1
### Added
- Increased max span events default limit to 2,000 to align with agent specifications
- Added support for gRPC API endpoints and HTTP status codes in the nrsecurity integration
- Added feature to detect route of an incoming request for all supported frameworks in the nrsecurity integration.
- Updated support for latest New Relic Security Agent release.
### Fixed
- Fixed an issue with nrzap attributes not properly being forwarded
- Improved comments on nropenai
- Fixed a minor bug relating to ExpectStatusCodes in `app_run.go`
### Support statement
We use the latest version of the Go language. At minimum, you should be using no version of Go older than what is supported by the Go team themselves.
See the [Go agent EOL Policy](/docs/apm/agents/go-agent/get-started/go-agent-eol-policy) for details about supported versions of the Go agent and third-party components.


## 3.33.0
### Added
- Support for Zap Field Attributes
Expand Down
2 changes: 1 addition & 1 deletion v3/integrations/logcontext-v2/logWriter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/newrelic/go-agent/v3/integrations/logcontext-v2/logWriter
go 1.20

require (
github.com/newrelic/go-agent/v3 v3.32.0
github.com/newrelic/go-agent/v3 v3.33.1
github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrwriter v1.0.0
)

Expand Down
2 changes: 1 addition & 1 deletion v3/integrations/logcontext-v2/nrlogrus/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrlogrus
go 1.20

require (
github.com/newrelic/go-agent/v3 v3.32.0
github.com/newrelic/go-agent/v3 v3.33.1
github.com/sirupsen/logrus v1.8.1
)

Expand Down
2 changes: 1 addition & 1 deletion v3/integrations/logcontext-v2/nrslog/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrslog

go 1.20

require github.com/newrelic/go-agent/v3 v3.32.0
require github.com/newrelic/go-agent/v3 v3.33.1


replace github.com/newrelic/go-agent/v3 => ../../..
2 changes: 1 addition & 1 deletion v3/integrations/logcontext-v2/nrwriter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrwriter

go 1.20

require github.com/newrelic/go-agent/v3 v3.32.0
require github.com/newrelic/go-agent/v3 v3.33.1


replace github.com/newrelic/go-agent/v3 => ../../..
2 changes: 1 addition & 1 deletion v3/integrations/logcontext-v2/nrzap/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrzap
go 1.20

require (
github.com/newrelic/go-agent/v3 v3.32.0
github.com/newrelic/go-agent/v3 v3.33.1
go.uber.org/zap v1.24.0
)

Expand Down
25 changes: 14 additions & 11 deletions v3/integrations/logcontext-v2/nrzap/nrzap.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ func init() { internal.TrackUsage("integration", "logcontext-v2", "zap") }

// NewRelicZapCore implements zap.Core
type NewRelicZapCore struct {
core zapcore.Core
nr newrelicApplicationState
fields []zap.Field
core zapcore.Core
nr newrelicApplicationState
}

// newrelicApplicationState is a private struct that stores newrelic application data
Expand Down Expand Up @@ -147,7 +148,7 @@ func WrapBackgroundCore(core zapcore.Core, app *newrelic.Application) (*NewRelic
// Errors will be returned if the zapcore object is nil, or if the application is nil. It is up to the user to decide
// how to handle the case where the newrelic.Transaction is nil.
// In the case that the newrelic.Application is nil, a valid NewRelicZapCore object will still be returned.
func WrapTransactionCore(core zapcore.Core, txn *newrelic.Transaction) (*NewRelicZapCore, error) {
func WrapTransactionCore(core zapcore.Core, txn *newrelic.Transaction) (zapcore.Core, error) {
if core == nil {
return nil, ErrNilZapcore
}
Expand All @@ -167,9 +168,10 @@ func WrapTransactionCore(core zapcore.Core, txn *newrelic.Transaction) (*NewReli
// With makes a copy of a NewRelicZapCore with new zap.Fields. It calls zapcore.With() on the zap core object
// then makes a deepcopy of the NewRelicApplicationState object so the original
// object can be deallocated when it's no longer in scope.
func (c NewRelicZapCore) With(fields []zap.Field) zapcore.Core {
return NewRelicZapCore{
core: c.core.With(fields),
func (c *NewRelicZapCore) With(fields []zap.Field) zapcore.Core {
return &NewRelicZapCore{
core: c.core.With(fields),
fields: append(fields, c.fields...),
nr: newrelicApplicationState{
c.nr.app,
c.nr.txn,
Expand All @@ -178,24 +180,25 @@ func (c NewRelicZapCore) With(fields []zap.Field) zapcore.Core {
}

// Check simply calls zapcore.Check on the Core object.
func (c NewRelicZapCore) Check(entry zapcore.Entry, checkedEntry *zapcore.CheckedEntry) *zapcore.CheckedEntry {
func (c *NewRelicZapCore) Check(entry zapcore.Entry, checkedEntry *zapcore.CheckedEntry) *zapcore.CheckedEntry {
ce := c.core.Check(entry, checkedEntry)
ce.AddCore(entry, c)
return ce
}

// Write wraps zapcore.Write and captures the log entry and sends that data to New Relic.
func (c NewRelicZapCore) Write(entry zapcore.Entry, fields []zap.Field) error {
c.nr.recordLog(entry, fields)
func (c *NewRelicZapCore) Write(entry zapcore.Entry, fields []zap.Field) error {
allFields := append(fields, c.fields...)
c.nr.recordLog(entry, allFields)
return nil
}

// Sync simply calls zapcore.Sync on the Core object.
func (c NewRelicZapCore) Sync() error {
func (c *NewRelicZapCore) Sync() error {
return c.core.Sync()
}

// Enabled simply calls zapcore.Enabled on the zapcore.Level passed to it.
func (c NewRelicZapCore) Enabled(level zapcore.Level) bool {
func (c *NewRelicZapCore) Enabled(level zapcore.Level) bool {
return c.core.Enabled(level)
}
5 changes: 5 additions & 0 deletions v3/integrations/logcontext-v2/nrzap/nrzap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ func TestTransactionLoggerWithFields(t *testing.T) {
t.Error(err)
}

wrappedCore = wrappedCore.With([]zapcore.Field{
zap.String("foo", "bar"),
})

logger := zap.New(wrappedCore)

msg := "this is a test info message"
Expand All @@ -186,6 +190,7 @@ func TestTransactionLoggerWithFields(t *testing.T) {
"duration": 1 * time.Second,
"int": 123,
"bool": true,
"foo": "bar",
},
Severity: zap.InfoLevel.String(),
Message: msg,
Expand Down
2 changes: 1 addition & 1 deletion v3/integrations/logcontext-v2/nrzerolog/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrzerolog
go 1.20

require (
github.com/newrelic/go-agent/v3 v3.32.0
github.com/newrelic/go-agent/v3 v3.33.1
github.com/rs/zerolog v1.26.1
)

Expand Down
2 changes: 1 addition & 1 deletion v3/integrations/logcontext-v2/zerologWriter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/newrelic/go-agent/v3/integrations/logcontext-v2/zerologWriter
go 1.20

require (
github.com/newrelic/go-agent/v3 v3.32.0
github.com/newrelic/go-agent/v3 v3.33.1
github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrwriter v1.0.0
github.com/rs/zerolog v1.27.0
)
Expand Down
2 changes: 1 addition & 1 deletion v3/integrations/logcontext/nrlogrusplugin/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module github.com/newrelic/go-agent/v3/integrations/logcontext/nrlogrusplugin
go 1.20

require (
github.com/newrelic/go-agent/v3 v3.32.0
github.com/newrelic/go-agent/v3 v3.33.1
// v1.4.0 is required for for the log.WithContext.
github.com/sirupsen/logrus v1.4.0
)
Expand Down
2 changes: 1 addition & 1 deletion v3/integrations/nramqp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/newrelic/go-agent/v3/integrations/nramqp
go 1.20

require (
github.com/newrelic/go-agent/v3 v3.32.0
github.com/newrelic/go-agent/v3 v3.33.1
github.com/rabbitmq/amqp091-go v1.9.0
)
replace github.com/newrelic/go-agent/v3 => ../..
2 changes: 1 addition & 1 deletion v3/integrations/nrawsbedrock/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/bedrock v1.7.3
github.com/aws/aws-sdk-go-v2/service/bedrockruntime v1.7.1
github.com/google/uuid v1.3.0
github.com/newrelic/go-agent/v3 v3.32.0
github.com/newrelic/go-agent/v3 v3.33.1
)


Expand Down
2 changes: 1 addition & 1 deletion v3/integrations/nrawssdk-v1/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ go 1.20
require (
// v1.15.0 is the first aws-sdk-go version with module support.
github.com/aws/aws-sdk-go v1.34.0
github.com/newrelic/go-agent/v3 v3.32.0
github.com/newrelic/go-agent/v3 v3.33.1
)


Expand Down
2 changes: 1 addition & 1 deletion v3/integrations/nrawssdk-v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/lambda v1.24.5
github.com/aws/aws-sdk-go-v2/service/s3 v1.27.10
github.com/aws/smithy-go v1.13.3
github.com/newrelic/go-agent/v3 v3.32.0
github.com/newrelic/go-agent/v3 v3.33.1
)


Expand Down
2 changes: 1 addition & 1 deletion v3/integrations/nrb3/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/newrelic/go-agent/v3/integrations/nrb3

go 1.20

require github.com/newrelic/go-agent/v3 v3.32.0
require github.com/newrelic/go-agent/v3 v3.33.1


replace github.com/newrelic/go-agent/v3 => ../..
2 changes: 1 addition & 1 deletion v3/integrations/nrecho-v3/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
// v3.1.0 is the earliest v3 version of Echo that works with modules due
// to the github.com/rsc/letsencrypt import of v3.0.0.
github.com/labstack/echo v3.1.0+incompatible
github.com/newrelic/go-agent/v3 v3.32.0
github.com/newrelic/go-agent/v3 v3.33.1
)


Expand Down
26 changes: 14 additions & 12 deletions v3/integrations/nrecho-v3/nrecho.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ func handlerName(router interface{}) string {
}
}

func transactionName(c echo.Context) string {
func transactionName(c echo.Context) (string, string) {
ptr := handlerPointer(c.Handler())
if ptr == handlerPointer(echo.NotFoundHandler) {
return "NotFoundHandler"
return "NotFoundHandler", ""
}
if ptr == handlerPointer(echo.MethodNotAllowedHandler) {
return "MethodNotAllowedHandler"
return "MethodNotAllowedHandler", ""
}
return c.Request().Method + " " + c.Path()
return c.Request().Method + " " + c.Path(), c.Path()
}

// Middleware creates Echo middleware that instruments requests.
Expand All @@ -77,9 +77,12 @@ func Middleware(app *newrelic.Application) func(echo.HandlerFunc) echo.HandlerFu
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) (err error) {
rw := c.Response().Writer
txn := app.StartTransaction(transactionName(c))
tName, route := transactionName(c)
txn := app.StartTransaction(tName)
defer txn.End()

if newrelic.IsSecurityAgentPresent() {
txn.SetCsecAttributes(newrelic.AttributeCsecRoute, route)
}
txn.SetWebRequestHTTP(c.Request())

c.Response().Writer = txn.SetWebResponse(rw)
Expand Down Expand Up @@ -112,14 +115,13 @@ func Middleware(app *newrelic.Application) func(echo.HandlerFunc) echo.HandlerFu
// which is used to detect application URL mapping(api-endpoints) for provable security.
// In this version of the integration, this wrapper is only necessary if you are using the New Relic security agent integration [https://github.com/newrelic/go-agent/tree/master/v3/integrations/nrsecurityagent],
// but it may be enhanced to provide additional functionality in future releases.
// e := echo.New()
// ....
// ....
// ....
//
// nrecho.WrapRouter(e)
// e := echo.New()
// ....
// ....
// ....
//

// nrecho.WrapRouter(e)
func WrapRouter(engine *echo.Echo) {
if engine != nil && newrelic.IsSecurityAgentPresent() {
router := engine.Routes()
Expand Down
2 changes: 1 addition & 1 deletion v3/integrations/nrecho-v4/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ go 1.20

require (
github.com/labstack/echo/v4 v4.9.0
github.com/newrelic/go-agent/v3 v3.32.0
github.com/newrelic/go-agent/v3 v3.33.1
)


Expand Down
26 changes: 14 additions & 12 deletions v3/integrations/nrecho-v4/nrecho.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ func handlerPointer(handler echo.HandlerFunc) uintptr {
return reflect.ValueOf(handler).Pointer()
}

func transactionName(c echo.Context) string {
func transactionName(c echo.Context) (string, string) {
ptr := handlerPointer(c.Handler())
if ptr == handlerPointer(echo.NotFoundHandler) {
return "NotFoundHandler"
return "NotFoundHandler", ""
}
if ptr == handlerPointer(echo.MethodNotAllowedHandler) {
return "MethodNotAllowedHandler"
return "MethodNotAllowedHandler", ""
}
return c.Request().Method + " " + c.Path()
return c.Request().Method + " " + c.Path(), c.Path()
}

// Skipper defines a function to skip middleware. Returning true skips processing
Expand Down Expand Up @@ -100,9 +100,12 @@ func Middleware(app *newrelic.Application, opts ...ConfigOption) func(echo.Handl
}

rw := c.Response().Writer
txn := config.App.StartTransaction(transactionName(c))
tname, path := transactionName(c)
txn := config.App.StartTransaction(tname)
defer txn.End()

if newrelic.IsSecurityAgentPresent() {
txn.SetCsecAttributes(newrelic.AttributeCsecRoute, path)
}
txn.SetWebRequestHTTP(c.Request())

c.Response().Writer = txn.SetWebResponse(rw)
Expand Down Expand Up @@ -135,14 +138,13 @@ func Middleware(app *newrelic.Application, opts ...ConfigOption) func(echo.Handl
// which is used to detect application URL mapping(api-endpoints) for provable security.
// In this version of the integration, this wrapper is only necessary if you are using the New Relic security agent integration [https://github.com/newrelic/go-agent/tree/master/v3/integrations/nrsecurityagent],
// but it may be enhanced to provide additional functionality in future releases.
// e := echo.New()
// ....
// ....
// ....
//
// nrecho.WrapRouter(e)
// e := echo.New()
// ....
// ....
// ....
//

// nrecho.WrapRouter(e)
func WrapRouter(engine *echo.Echo) {
if engine != nil && newrelic.IsSecurityAgentPresent() {
router := engine.Routes()
Expand Down
2 changes: 1 addition & 1 deletion v3/integrations/nrelasticsearch-v7/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ go 1.20

require (
github.com/elastic/go-elasticsearch/v7 v7.17.0
github.com/newrelic/go-agent/v3 v3.32.0
github.com/newrelic/go-agent/v3 v3.33.1
)


Expand Down
2 changes: 1 addition & 1 deletion v3/integrations/nrfasthttp/examples/client-fasthttp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module client-example
go 1.20

require (
github.com/newrelic/go-agent/v3 v3.32.0
github.com/newrelic/go-agent/v3 v3.33.1
github.com/newrelic/go-agent/v3/integrations/nrfasthttp v1.0.0
github.com/valyala/fasthttp v1.49.0
)
Expand Down
2 changes: 1 addition & 1 deletion v3/integrations/nrfasthttp/examples/server-fasthttp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module server-example
go 1.20

require (
github.com/newrelic/go-agent/v3 v3.32.0
github.com/newrelic/go-agent/v3 v3.33.1
github.com/newrelic/go-agent/v3/integrations/nrfasthttp v1.0.0
github.com/valyala/fasthttp v1.49.0
)
Expand Down
2 changes: 1 addition & 1 deletion v3/integrations/nrfasthttp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/newrelic/go-agent/v3/integrations/nrfasthttp
go 1.20

require (
github.com/newrelic/go-agent/v3 v3.32.0
github.com/newrelic/go-agent/v3 v3.33.1
github.com/valyala/fasthttp v1.49.0
)

Expand Down
Loading

0 comments on commit cab3b31

Please sign in to comment.