diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b5f1df8d..a01b689f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,28 @@ +## 3.24.0 + +### Added +* Turned Code Level Metrics on by default +* Added new test case to check if the nrsecurityagent is enabled in the gRPC integration +* Added new test case for InfoInterceptorStatusHandler function in the gRPC integration +* Added Name() method for Transaction values to get the current transaction name. + + +### Fixed +* Bumped gin from 1.9.0 to 1.9.1 +* Bumped gosnowflake from 1.6.16 to 1.6.19 +* Bumped nrsecurityagent to 1.1.0 with improved reporting of gRPC protocol versions. +* Fixed a bug where expected errors weren't being properly marked as expected on new relic dashboards + +### 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 (i.e., Go versions 1.19 and later are supported). + +We recommend updating to the latest agent version as soon as it's available. If you can't upgrade to the latest version, update your agents to a version no more than 90 days old. Read more about keeping agents up to date. (https://docs.newrelic.com/docs/new-relic-solutions/new-relic-one/install-configure/update-new-relic-agent/) + +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.23.1 ## Added diff --git a/README.md b/README.md index 6288d3471..c5d5347d8 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Go is a compiled language, and doesn’t use a virtual machine. This means that ### Compatibility and Requirements -For the latest version of the agent, Go 1.17+ is required. +For the latest version of the agent, Go 1.18+ is required. Linux, OS X, and Windows (Vista, Server 2008 and later) are supported. diff --git a/v3/go.mod b/v3/go.mod index 01b5abf73..4e184838d 100644 --- a/v3/go.mod +++ b/v3/go.mod @@ -1,7 +1,11 @@ module github.com/newrelic/go-agent/v3 + go 1.18 + require ( github.com/golang/protobuf v1.5.3 google.golang.org/grpc v1.54.0 ) + + retract v3.22.0 // release process error corrected in v3.22.1 diff --git a/v3/integrations/logcontext-v2/logWriter/go.mod b/v3/integrations/logcontext-v2/logWriter/go.mod index 2194dfac3..709202b5a 100644 --- a/v3/integrations/logcontext-v2/logWriter/go.mod +++ b/v3/integrations/logcontext-v2/logWriter/go.mod @@ -1,6 +1,9 @@ module github.com/newrelic/go-agent/v3/integrations/logcontext-v2/logWriter + go 1.17 + require ( github.com/newrelic/go-agent/v3 v3.19.1 github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrwriter v1.0.0 ) + diff --git a/v3/integrations/logcontext-v2/nrlogrus/go.mod b/v3/integrations/logcontext-v2/nrlogrus/go.mod index 419fe8c19..b2096a6d4 100644 --- a/v3/integrations/logcontext-v2/nrlogrus/go.mod +++ b/v3/integrations/logcontext-v2/nrlogrus/go.mod @@ -1,6 +1,9 @@ module github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrlogrus + go 1.17 + require ( github.com/newrelic/go-agent/v3 v3.18.0 github.com/sirupsen/logrus v1.8.1 ) + diff --git a/v3/integrations/logcontext-v2/nrwriter/go.mod b/v3/integrations/logcontext-v2/nrwriter/go.mod index c0bfa5b8e..2b86ff2ed 100644 --- a/v3/integrations/logcontext-v2/nrwriter/go.mod +++ b/v3/integrations/logcontext-v2/nrwriter/go.mod @@ -1,3 +1,6 @@ module github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrwriter + go 1.17 + require github.com/newrelic/go-agent/v3 v3.19.1 + diff --git a/v3/integrations/logcontext-v2/nrzap/go.mod b/v3/integrations/logcontext-v2/nrzap/go.mod index ae747fb70..11e14551c 100644 --- a/v3/integrations/logcontext-v2/nrzap/go.mod +++ b/v3/integrations/logcontext-v2/nrzap/go.mod @@ -1,6 +1,9 @@ module github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrzap + go 1.18 + require ( github.com/newrelic/go-agent/v3 v3.21.1 go.uber.org/zap v1.24.0 ) + diff --git a/v3/integrations/logcontext-v2/nrzerolog/go.mod b/v3/integrations/logcontext-v2/nrzerolog/go.mod index 1c63e378a..27630a598 100644 --- a/v3/integrations/logcontext-v2/nrzerolog/go.mod +++ b/v3/integrations/logcontext-v2/nrzerolog/go.mod @@ -1,6 +1,9 @@ module github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrzerolog + go 1.17 + require ( github.com/newrelic/go-agent/v3 v3.18.0 github.com/rs/zerolog v1.26.1 ) + diff --git a/v3/integrations/logcontext-v2/zerologWriter/go.mod b/v3/integrations/logcontext-v2/zerologWriter/go.mod index 38dfb0071..6117eca38 100644 --- a/v3/integrations/logcontext-v2/zerologWriter/go.mod +++ b/v3/integrations/logcontext-v2/zerologWriter/go.mod @@ -1,7 +1,10 @@ module github.com/newrelic/go-agent/v3/integrations/logcontext-v2/zerologWriter + go 1.17 + require ( github.com/newrelic/go-agent/v3 v3.19.1 github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrwriter v1.0.0 github.com/rs/zerolog v1.27.0 ) + diff --git a/v3/integrations/logcontext/nrlogrusplugin/go.mod b/v3/integrations/logcontext/nrlogrusplugin/go.mod index 756b6596a..88b24f5a1 100644 --- a/v3/integrations/logcontext/nrlogrusplugin/go.mod +++ b/v3/integrations/logcontext/nrlogrusplugin/go.mod @@ -1,7 +1,9 @@ module github.com/newrelic/go-agent/v3/integrations/logcontext/nrlogrusplugin + // As of Dec 2019, the logrus go.mod file uses 1.13: // https://github.com/sirupsen/logrus/blob/master/go.mod go 1.13 + require ( github.com/newrelic/go-agent/v3 v3.17.0 // v1.4.0 is required for for the log.WithContext. diff --git a/v3/integrations/nrawssdk-v1/go.mod b/v3/integrations/nrawssdk-v1/go.mod index c824264f2..f8a7c2f13 100644 --- a/v3/integrations/nrawssdk-v1/go.mod +++ b/v3/integrations/nrawssdk-v1/go.mod @@ -1,10 +1,12 @@ module github.com/newrelic/go-agent/v3/integrations/nrawssdk-v1 + // As of Dec 2019, aws-sdk-go's go.mod does not specify a Go version. 1.6 is // the earliest version of Go tested by aws-sdk-go's CI: // https://github.com/aws/aws-sdk-go/blob/master/.travis.yml go 1.7 + 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.16.0 + github.com/newrelic/go-agent/v3 v3.24.0 ) diff --git a/v3/integrations/nrawssdk-v2/go.mod b/v3/integrations/nrawssdk-v2/go.mod index bc3642769..a402d9fbf 100644 --- a/v3/integrations/nrawssdk-v2/go.mod +++ b/v3/integrations/nrawssdk-v2/go.mod @@ -1,7 +1,9 @@ module github.com/newrelic/go-agent/v3/integrations/nrawssdk-v2 + // As of May 2021, the aws-sdk-go-v2 go.mod file uses 1.15: // https://github.com/aws/aws-sdk-go-v2/blob/master/go.mod go 1.17 + require ( github.com/aws/aws-sdk-go-v2 v1.16.15 github.com/aws/aws-sdk-go-v2/config v1.17.6 @@ -9,5 +11,6 @@ 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.18.2 + github.com/newrelic/go-agent/v3 v3.24.0 ) + diff --git a/v3/integrations/nrb3/go.mod b/v3/integrations/nrb3/go.mod index b7ffdcbc9..73c540d4e 100644 --- a/v3/integrations/nrb3/go.mod +++ b/v3/integrations/nrb3/go.mod @@ -1,3 +1,6 @@ module github.com/newrelic/go-agent/v3/integrations/nrb3 + go 1.19 -require github.com/newrelic/go-agent/v3 v3.21.1 + +require github.com/newrelic/go-agent/v3 v3.24.0 + diff --git a/v3/integrations/nrecho-v3/go.mod b/v3/integrations/nrecho-v3/go.mod index 2e557e54f..5b0d18f5d 100644 --- a/v3/integrations/nrecho-v3/go.mod +++ b/v3/integrations/nrecho-v3/go.mod @@ -1,10 +1,12 @@ module github.com/newrelic/go-agent/v3/integrations/nrecho-v3 + // 1.7 is the earliest version of Go tested by v3.1.0: // https://github.com/labstack/echo/blob/v3.1.0/.travis.yml go 1.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.17.0 + github.com/newrelic/go-agent/v3 v3.24.0 ) diff --git a/v3/integrations/nrecho-v4/go.mod b/v3/integrations/nrecho-v4/go.mod index e436ce6ea..c109c0738 100644 --- a/v3/integrations/nrecho-v4/go.mod +++ b/v3/integrations/nrecho-v4/go.mod @@ -1,8 +1,11 @@ module github.com/newrelic/go-agent/v3/integrations/nrecho-v4 + // As of Jun 2022, the echo go.mod file uses 1.17: // https://github.com/labstack/echo/blob/master/go.mod go 1.17 + require ( github.com/labstack/echo/v4 v4.9.0 - github.com/newrelic/go-agent/v3 v3.18.2 + github.com/newrelic/go-agent/v3 v3.24.0 ) + diff --git a/v3/integrations/nrelasticsearch-v7/go.mod b/v3/integrations/nrelasticsearch-v7/go.mod index b5d3ca5a6..08ed46193 100644 --- a/v3/integrations/nrelasticsearch-v7/go.mod +++ b/v3/integrations/nrelasticsearch-v7/go.mod @@ -1,8 +1,10 @@ module github.com/newrelic/go-agent/v3/integrations/nrelasticsearch-v7 + // As of Jan 2020, the v7 elasticsearch go.mod uses 1.11: // https://github.com/elastic/go-elasticsearch/blob/7.x/go.mod go 1.11 + require ( github.com/elastic/go-elasticsearch/v7 v7.17.0 - github.com/newrelic/go-agent/v3 v3.17.0 + github.com/newrelic/go-agent/v3 v3.24.0 ) diff --git a/v3/integrations/nrgin/go.mod b/v3/integrations/nrgin/go.mod index 1255cd651..ceb2fdb46 100644 --- a/v3/integrations/nrgin/go.mod +++ b/v3/integrations/nrgin/go.mod @@ -1,9 +1,13 @@ module github.com/newrelic/go-agent/v3/integrations/nrgin + // As of Dec 2019, the gin go.mod file uses 1.12: // https://github.com/gin-gonic/gin/blob/master/go.mod go 1.19 + require ( - github.com/gin-gonic/gin v1.9.0 - github.com/newrelic/go-agent/v3 v3.23.0 + github.com/gin-gonic/gin v1.9.1 + github.com/newrelic/go-agent/v3 v3.24.0 ) + + replace github.com/newrelic/go-agent/v3 => ../.. diff --git a/v3/integrations/nrgin/nrgin_test.go b/v3/integrations/nrgin/nrgin_test.go index 26cca960d..8249f592a 100644 --- a/v3/integrations/nrgin/nrgin_test.go +++ b/v3/integrations/nrgin/nrgin_test.go @@ -284,6 +284,10 @@ func TestStatusCodes(t *testing.T) { "request.method": "GET", "request.uri": "/err", "response.headers.contentType": "text/plain; charset=utf-8", + "code.function": internal.MatchAnything, + "code.namespace": internal.MatchAnything, + "code.filepath": internal.MatchAnything, + "code.lineno": internal.MatchAnything, }, }}) } @@ -338,6 +342,10 @@ func TestNoResponseBody(t *testing.T) { "http.statusCode": expectCode, "request.method": "GET", "request.uri": "/nobody", + "code.function": internal.MatchAnything, + "code.namespace": internal.MatchAnything, + "code.filepath": internal.MatchAnything, + "code.lineno": internal.MatchAnything, }, }}) } diff --git a/v3/integrations/nrgorilla/go.mod b/v3/integrations/nrgorilla/go.mod index c76531f7b..9ecc2efd2 100644 --- a/v3/integrations/nrgorilla/go.mod +++ b/v3/integrations/nrgorilla/go.mod @@ -1,9 +1,11 @@ module github.com/newrelic/go-agent/v3/integrations/nrgorilla + // As of Dec 2019, the gorilla/mux go.mod file uses 1.12: // https://github.com/gorilla/mux/blob/master/go.mod go 1.12 + require ( // v1.7.0 is the earliest version of Gorilla using modules. github.com/gorilla/mux v1.7.0 - github.com/newrelic/go-agent/v3 v3.17.0 + github.com/newrelic/go-agent/v3 v3.24.0 ) diff --git a/v3/integrations/nrgraphgophers/go.mod b/v3/integrations/nrgraphgophers/go.mod index c6aea2014..b9e6ede4e 100644 --- a/v3/integrations/nrgraphgophers/go.mod +++ b/v3/integrations/nrgraphgophers/go.mod @@ -7,5 +7,5 @@ go 1.13 require ( // graphql-go has no tagged releases as of Jan 2020. github.com/graph-gophers/graphql-go v1.3.0 - github.com/newrelic/go-agent/v3 v3.17.0 + github.com/newrelic/go-agent/v3 v3.24.0 ) diff --git a/v3/integrations/nrgraphqlgo/go.mod b/v3/integrations/nrgraphqlgo/go.mod index 07696032e..a6fa0aff4 100644 --- a/v3/integrations/nrgraphqlgo/go.mod +++ b/v3/integrations/nrgraphqlgo/go.mod @@ -1,6 +1,8 @@ module github.com/newrelic/go-agent/v3/integrations/nrgraphqlgo + go 1.13 + require ( github.com/graphql-go/graphql v0.7.9 - github.com/newrelic/go-agent/v3 v3.17.0 + github.com/newrelic/go-agent/v3 v3.24.0 ) diff --git a/v3/integrations/nrgrpc/go.mod b/v3/integrations/nrgrpc/go.mod index 3edfa9155..a6f19bf5b 100644 --- a/v3/integrations/nrgrpc/go.mod +++ b/v3/integrations/nrgrpc/go.mod @@ -1,11 +1,17 @@ module github.com/newrelic/go-agent/v3/integrations/nrgrpc + go 1.19 + require ( // protobuf v1.3.0 is the earliest version using modules, we use v1.3.1 // because all dependencies were removed in this version. github.com/golang/protobuf v1.5.3 - github.com/newrelic/go-agent/v3 v3.23.0 + github.com/newrelic/go-agent/v3 v3.24.0 + github.com/newrelic/go-agent/v3/integrations/nrsecurityagent v1.1.0 // v1.15.0 is the earliest version of grpc using modules. google.golang.org/grpc v1.54.0 + google.golang.org/protobuf v1.28.1 ) + + replace github.com/newrelic/go-agent/v3 => ../.. diff --git a/v3/integrations/nrgrpc/nrgrpc_client_test.go b/v3/integrations/nrgrpc/nrgrpc_client_test.go index e81356dd5..e237296c9 100644 --- a/v3/integrations/nrgrpc/nrgrpc_client_test.go +++ b/v3/integrations/nrgrpc/nrgrpc_client_test.go @@ -11,6 +11,7 @@ import ( "testing" "github.com/newrelic/go-agent/v3/integrations/nrgrpc/testapp" + "github.com/newrelic/go-agent/v3/integrations/nrsecurityagent" "github.com/newrelic/go-agent/v3/internal" "github.com/newrelic/go-agent/v3/internal/integrationsupport" newrelic "github.com/newrelic/go-agent/v3/newrelic" @@ -75,7 +76,7 @@ func TestGetURL(t *testing.T) { } func testApp() integrationsupport.ExpectApp { - return integrationsupport.NewTestApp(replyFn, integrationsupport.ConfigFullTraces) + return integrationsupport.NewTestApp(replyFn, integrationsupport.ConfigFullTraces, newrelic.ConfigCodeLevelMetricsEnabled(false)) } var replyFn = func(reply *internal.ConnectReply) { @@ -609,3 +610,15 @@ func TestClientStreamingError(t *testing.T) { }, }}) } + +func TestClientSecurityAgentEnabled(t *testing.T) { + app := testApp() + err := nrsecurityagent.InitSecurityAgent(app.Application, + nrsecurityagent.ConfigSecurityMode("IAST"), + nrsecurityagent.ConfigSecurityValidatorServiceEndPointUrl("wss://csec.nr-data.net"), + nrsecurityagent.ConfigSecurityEnable(true), + ) + if err != nil { + t.Fatal("Could not setup the nrsecurityagent", err) + } +} diff --git a/v3/integrations/nrgrpc/nrgrpc_server.go b/v3/integrations/nrgrpc/nrgrpc_server.go index bdf25be0f..a0fab1866 100644 --- a/v3/integrations/nrgrpc/nrgrpc_server.go +++ b/v3/integrations/nrgrpc/nrgrpc_server.go @@ -38,11 +38,13 @@ import ( "net/http" "strings" + protoV1 "github.com/golang/protobuf/proto" "github.com/newrelic/go-agent/v3/newrelic" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" + protoV2 "google.golang.org/protobuf/proto" ) func startTransaction(ctx context.Context, app *newrelic.Application, fullMethod string) *newrelic.Transaction { @@ -309,7 +311,11 @@ func UnaryServerInterceptor(app *newrelic.Application, options ...HandlerOption) return func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) { txn := startTransaction(ctx, app, info.FullMethod) - newrelic.GetSecurityAgentInterface().SendEvent("GRPC", req) + + if newrelic.IsSecurityAgentPresent() { + messageType, version := getMessageType(req) + newrelic.GetSecurityAgentInterface().SendEvent("GRPC", req, messageType, version) + } defer txn.End() ctx = newrelic.NewContext(ctx, txn) @@ -330,7 +336,10 @@ func (s wrappedServerStream) Context() context.Context { } func (s wrappedServerStream) RecvMsg(msg any) error { - newrelic.GetSecurityAgentInterface().SendEvent("GRPC", msg) + if newrelic.IsSecurityAgentPresent() { + messageType, version := getMessageType(msg) + newrelic.GetSecurityAgentInterface().SendEvent("GRPC", msg, messageType, version) + } return s.ServerStream.RecvMsg(msg) } @@ -350,7 +359,6 @@ func newWrappedServerStream(stream grpc.ServerStream, txn *newrelic.Transaction) // streaming calls. // // See the notes and examples for the UnaryServerInterceptor function. -// func StreamServerInterceptor(app *newrelic.Application, options ...HandlerOption) grpc.StreamServerInterceptor { if app == nil { return func(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { @@ -369,9 +377,27 @@ func StreamServerInterceptor(app *newrelic.Application, options ...HandlerOption return func(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { txn := startTransaction(ss.Context(), app, info.FullMethod) defer txn.End() - + if newrelic.IsSecurityAgentPresent() { + newrelic.GetSecurityAgentInterface().SendEvent("GRPC_INFO", info.IsClientStream, info.IsServerStream) + } err := handler(srv, newWrappedServerStream(ss, txn)) reportInterceptorStatus(ss.Context(), txn, localHandlerMap, err) return err } } + +func getMessageType(req any) (string, string) { + messageType := "" + version := "v2" + messagev2, ok := req.(protoV2.Message) + if ok { + messageType = string(messagev2.ProtoReflect().Descriptor().FullName()) + } else { + messagev1, ok := req.(protoV1.Message) + if ok { + messageType = string(protoV1.MessageReflect(messagev1).Descriptor().FullName()) + version = "v1" + } + } + return messageType, version +} diff --git a/v3/integrations/nrgrpc/nrgrpc_server_test.go b/v3/integrations/nrgrpc/nrgrpc_server_test.go index 470fb5f57..ea14f1343 100644 --- a/v3/integrations/nrgrpc/nrgrpc_server_test.go +++ b/v3/integrations/nrgrpc/nrgrpc_server_test.go @@ -155,6 +155,106 @@ func TestWithCustomStatusHandler(t *testing.T) { Configure(WithStatusHandler(codes.OK, OKInterceptorStatusHandler)) } +func TestWithInfoStatusHandler(t *testing.T) { + app := testApp() + Configure(WithStatusHandler(codes.OK, InfoInterceptorStatusHandler)) + + s, conn := newTestServerAndConn(t, app.Application) + defer s.Stop() + defer conn.Close() + + client := testapp.NewTestApplicationClient(conn) + txn := app.StartTransaction("client") + ctx := newrelic.NewContext(context.Background(), txn) + _, err := client.DoUnaryUnary(ctx, &testapp.Message{}) + if err != nil { + t.Fatal("unable to call client DoUnaryUnary", err) + } + + app.ExpectMetrics(t, []internal.WantMetric{ + {Name: "Apdex", Scope: "", Forced: true, Data: nil}, + {Name: "Apdex/Go/TestApplication/DoUnaryUnary", Scope: "", Forced: false, Data: nil}, + {Name: "Custom/DoUnaryUnary", Scope: "", Forced: false, Data: nil}, + {Name: "Custom/DoUnaryUnary", Scope: "WebTransaction/Go/TestApplication/DoUnaryUnary", Forced: false, Data: nil}, + {Name: "DurationByCaller/App/123/456/HTTP/all", Scope: "", Forced: false, Data: nil}, + {Name: "DurationByCaller/App/123/456/HTTP/allWeb", Scope: "", Forced: false, Data: nil}, + {Name: "HttpDispatcher", Scope: "", Forced: true, Data: nil}, + {Name: "Supportability/TraceContext/Accept/Success", Scope: "", Forced: true, Data: nil}, + {Name: "TransportDuration/App/123/456/HTTP/all", Scope: "", Forced: false, Data: nil}, + {Name: "TransportDuration/App/123/456/HTTP/allWeb", Scope: "", Forced: false, Data: nil}, + {Name: "WebTransaction", Scope: "", Forced: true, Data: nil}, + {Name: "WebTransaction/Go/TestApplication/DoUnaryUnary", Scope: "", Forced: true, Data: nil}, + {Name: "WebTransactionTotalTime", Scope: "", Forced: true, Data: nil}, + {Name: "WebTransactionTotalTime/Go/TestApplication/DoUnaryUnary", Scope: "", Forced: false, Data: nil}, + }) + app.ExpectTxnEvents(t, []internal.WantEvent{{ + Intrinsics: map[string]interface{}{ + "guid": internal.MatchAnything, + "name": "WebTransaction/Go/TestApplication/DoUnaryUnary", + "nr.apdexPerfZone": internal.MatchAnything, + "parent.account": 123, + "parent.app": 456, + "parent.transportDuration": internal.MatchAnything, + "parent.transportType": "HTTP", + "parent.type": "App", + "parentId": internal.MatchAnything, + "parentSpanId": internal.MatchAnything, + "priority": internal.MatchAnything, + "sampled": internal.MatchAnything, + "traceId": internal.MatchAnything, + }, + UserAttributes: map[string]interface{}{ + "grpcStatusLevel": "info", + "grpcStatusCode": "OK", + "grpcStatusMessage": internal.MatchAnything, + }, + AgentAttributes: map[string]interface{}{ + "httpResponseCode": 0, + "http.statusCode": 0, + "request.headers.contentType": "application/grpc", + "request.method": "TestApplication/DoUnaryUnary", + "request.uri": "grpc://bufnet/TestApplication/DoUnaryUnary", + }, + }}) + app.ExpectSpanEvents(t, []internal.WantEvent{ + { + Intrinsics: map[string]interface{}{ + "category": "generic", + "name": "Custom/DoUnaryUnary", + "parentId": internal.MatchAnything, + }, + UserAttributes: map[string]interface{}{}, + AgentAttributes: map[string]interface{}{}, + }, + { + Intrinsics: map[string]interface{}{ + "category": "generic", + "name": "WebTransaction/Go/TestApplication/DoUnaryUnary", + "transaction.name": "WebTransaction/Go/TestApplication/DoUnaryUnary", + "nr.entryPoint": true, + "parentId": internal.MatchAnything, + "trustedParentId": internal.MatchAnything, + }, + UserAttributes: map[string]interface{}{ + "grpcStatusLevel": "info", + "grpcStatusCode": "OK", + }, + AgentAttributes: map[string]interface{}{ + "httpResponseCode": 0, + "http.statusCode": 0, + "parent.account": "123", + "parent.app": "456", + "parent.transportDuration": internal.MatchAnything, + "parent.transportType": "HTTP", + "parent.type": "App", + "request.headers.contentType": "application/grpc", + "request.method": "TestApplication/DoUnaryUnary", + "request.uri": "grpc://bufnet/TestApplication/DoUnaryUnary", + }, + }, + }) + Configure(WithStatusHandler(codes.OK, OKInterceptorStatusHandler)) +} func TestUnaryServerInterceptor(t *testing.T) { app := testApp() diff --git a/v3/integrations/nrhttprouter/go.mod b/v3/integrations/nrhttprouter/go.mod index bf68f8136..0824ceea2 100644 --- a/v3/integrations/nrhttprouter/go.mod +++ b/v3/integrations/nrhttprouter/go.mod @@ -1,9 +1,11 @@ module github.com/newrelic/go-agent/v3/integrations/nrhttprouter + // As of Dec 2019, the httprouter go.mod file uses 1.7: // https://github.com/julienschmidt/httprouter/blob/master/go.mod go 1.7 + require ( // v1.3.0 is the earliest version of httprouter using modules. github.com/julienschmidt/httprouter v1.3.0 - github.com/newrelic/go-agent/v3 v3.17.0 + github.com/newrelic/go-agent/v3 v3.24.0 ) diff --git a/v3/integrations/nrlambda/go.mod b/v3/integrations/nrlambda/go.mod index 762529d33..e16beae91 100644 --- a/v3/integrations/nrlambda/go.mod +++ b/v3/integrations/nrlambda/go.mod @@ -1,6 +1,9 @@ module github.com/newrelic/go-agent/v3/integrations/nrlambda + go 1.18 + require ( github.com/aws/aws-lambda-go v1.41.0 - github.com/newrelic/go-agent/v3 v3.21.1 + github.com/newrelic/go-agent/v3 v3.24.0 ) + diff --git a/v3/integrations/nrlogrus/go.mod b/v3/integrations/nrlogrus/go.mod index 226414374..b7af83629 100644 --- a/v3/integrations/nrlogrus/go.mod +++ b/v3/integrations/nrlogrus/go.mod @@ -1,10 +1,13 @@ module github.com/newrelic/go-agent/v3/integrations/nrlogrus + // As of Dec 2019, the logrus go.mod file uses 1.13: // https://github.com/sirupsen/logrus/blob/master/go.mod go 1.18 + require ( - github.com/newrelic/go-agent/v3 v3.21.0 + github.com/newrelic/go-agent/v3 v3.24.0 // v1.1.0 is required for the Logger.GetLevel method, and is the earliest // version of logrus using modules. github.com/sirupsen/logrus v1.1.0 ) + diff --git a/v3/integrations/nrlogxi/go.mod b/v3/integrations/nrlogxi/go.mod index f70105fb5..ded8f5d5f 100644 --- a/v3/integrations/nrlogxi/go.mod +++ b/v3/integrations/nrlogxi/go.mod @@ -1,9 +1,12 @@ module github.com/newrelic/go-agent/v3/integrations/nrlogxi + // As of Dec 2019, logxi requires 1.3+: // https://github.com/mgutz/logxi#requirements go 1.18 + require ( // 'v1', at commit aebf8a7d67ab, is the only logxi release. github.com/mgutz/logxi v0.0.0-20161027140823-aebf8a7d67ab - github.com/newrelic/go-agent/v3 v3.21.1 + github.com/newrelic/go-agent/v3 v3.24.0 ) + diff --git a/v3/integrations/nrmicro/go.mod b/v3/integrations/nrmicro/go.mod index 804e5d845..ca64a4b25 100644 --- a/v3/integrations/nrmicro/go.mod +++ b/v3/integrations/nrmicro/go.mod @@ -1,10 +1,14 @@ module github.com/newrelic/go-agent/v3/integrations/nrmicro + // As of Dec 2019, the go-micro go.mod file uses 1.13: // https://github.com/micro/go-micro/blob/master/go.mod go 1.19 + require ( github.com/golang/protobuf v1.5.3 github.com/micro/go-micro v1.8.0 - github.com/newrelic/go-agent/v3 v3.23.0 + github.com/newrelic/go-agent/v3 v3.24.0 ) + + replace github.com/newrelic/go-agent/v3 => ../.. diff --git a/v3/integrations/nrmicro/nrmicro_test.go b/v3/integrations/nrmicro/nrmicro_test.go index af4485c3a..6e5b08234 100644 --- a/v3/integrations/nrmicro/nrmicro_test.go +++ b/v3/integrations/nrmicro/nrmicro_test.go @@ -87,7 +87,7 @@ func getDTRequestHeaderVal(ctx context.Context) string { } func createTestApp() integrationsupport.ExpectApp { - return integrationsupport.NewTestApp(replyFn, cfgFn, integrationsupport.ConfigFullTraces) + return integrationsupport.NewTestApp(replyFn, cfgFn, integrationsupport.ConfigFullTraces, newrelic.ConfigCodeLevelMetricsEnabled(false)) } var replyFn = func(reply *internal.ConnectReply) { diff --git a/v3/integrations/nrmongo/go.mod b/v3/integrations/nrmongo/go.mod index 29bb7f9b0..a4418c430 100644 --- a/v3/integrations/nrmongo/go.mod +++ b/v3/integrations/nrmongo/go.mod @@ -1,10 +1,14 @@ module github.com/newrelic/go-agent/v3/integrations/nrmongo + // As of Dec 2019, 1.10 is the mongo-driver requirement: // https://github.com/mongodb/mongo-go-driver#requirements go 1.19 + require ( - github.com/newrelic/go-agent/v3 v3.23.0 + github.com/newrelic/go-agent/v3 v3.24.0 // mongo-driver does not support modules as of Nov 2019. go.mongodb.org/mongo-driver v1.10.2 ) + + replace github.com/newrelic/go-agent/v3 => ../.. diff --git a/v3/integrations/nrmongo/nrmongo_test.go b/v3/integrations/nrmongo/nrmongo_test.go index 6bc758c52..b6297fb8e 100644 --- a/v3/integrations/nrmongo/nrmongo_test.go +++ b/v3/integrations/nrmongo/nrmongo_test.go @@ -235,7 +235,7 @@ func TestCollName(t *testing.T) { } func createTestApp() integrationsupport.ExpectApp { - return integrationsupport.NewTestApp(replyFn, integrationsupport.ConfigFullTraces) + return integrationsupport.NewTestApp(replyFn, integrationsupport.ConfigFullTraces, newrelic.ConfigCodeLevelMetricsEnabled(false)) } var replyFn = func(reply *internal.ConnectReply) { diff --git a/v3/integrations/nrmssql/go.mod b/v3/integrations/nrmssql/go.mod index 28a861c8a..0430a7b7f 100644 --- a/v3/integrations/nrmssql/go.mod +++ b/v3/integrations/nrmssql/go.mod @@ -1,6 +1,9 @@ module github.com/newrelic/go-agent/v3/integrations/nrmssql + go 1.17 + require ( github.com/microsoft/go-mssqldb v0.19.0 - github.com/newrelic/go-agent/v3 v3.16.1 + github.com/newrelic/go-agent/v3 v3.24.0 ) + diff --git a/v3/integrations/nrmysql/go.mod b/v3/integrations/nrmysql/go.mod index 8b4f9105e..703f5fa74 100644 --- a/v3/integrations/nrmysql/go.mod +++ b/v3/integrations/nrmysql/go.mod @@ -1,9 +1,12 @@ module github.com/newrelic/go-agent/v3/integrations/nrmysql + // 1.10 is the Go version in mysql's go.mod go 1.17 + require ( // v1.5.0 is the first mysql version to support gomod github.com/go-sql-driver/mysql v1.6.0 // v3.3.0 includes the new location of ParseQuery - github.com/newrelic/go-agent/v3 v3.18.2 + github.com/newrelic/go-agent/v3 v3.24.0 ) + diff --git a/v3/integrations/nrnats/go.mod b/v3/integrations/nrnats/go.mod index 4589ff280..79d3f9d4e 100644 --- a/v3/integrations/nrnats/go.mod +++ b/v3/integrations/nrnats/go.mod @@ -7,21 +7,6 @@ go 1.19 require ( github.com/nats-io/nats-server v1.4.1 github.com/nats-io/nats.go v1.25.0 - github.com/newrelic/go-agent/v3 v3.23.0 + github.com/newrelic/go-agent/v3 v3.24.0 ) -require ( - github.com/golang/protobuf v1.5.3 // indirect - github.com/nats-io/gnatsd v1.4.1 // indirect - github.com/nats-io/go-nats v1.7.2 // indirect - github.com/nats-io/nats-server/v2 v2.9.17 // indirect - github.com/nats-io/nkeys v0.4.4 // indirect - github.com/nats-io/nuid v1.0.1 // indirect - golang.org/x/crypto v0.8.0 // indirect - golang.org/x/net v0.9.0 // indirect - golang.org/x/sys v0.7.0 // indirect - golang.org/x/text v0.9.0 // indirect - google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect - google.golang.org/grpc v1.54.0 // indirect - google.golang.org/protobuf v1.28.1 // indirect -) diff --git a/v3/integrations/nrpgx/go.mod b/v3/integrations/nrpgx/go.mod index 0cea1f3d0..8cd35d84f 100644 --- a/v3/integrations/nrpgx/go.mod +++ b/v3/integrations/nrpgx/go.mod @@ -1,9 +1,12 @@ module github.com/newrelic/go-agent/v3/integrations/nrpgx + // As of Dec 2019, go 1.11 is the earliest version of Go tested by lib/pq: // https://github.com/lib/pq/blob/master/.travis.yml go 1.18 + require ( github.com/jackc/pgx v3.6.2+incompatible github.com/jackc/pgx/v4 v4.13.0 github.com/newrelic/go-agent/v3 v3.3.0 ) + diff --git a/v3/integrations/nrpgx5/go.mod b/v3/integrations/nrpgx5/go.mod index d3bd5f334..cd31aa936 100644 --- a/v3/integrations/nrpgx5/go.mod +++ b/v3/integrations/nrpgx5/go.mod @@ -1,8 +1,11 @@ module github.com/newrelic/go-agent/v3/integrations/nrpgx5 + go 1.18 + require ( github.com/egon12/pgsnap v0.0.0-20221022154027-2847f0124ed8 github.com/jackc/pgx/v5 v5.0.3 - github.com/newrelic/go-agent/v3 v3.20.0 + github.com/newrelic/go-agent/v3 v3.24.0 github.com/stretchr/testify v1.8.0 ) + diff --git a/v3/integrations/nrpkgerrors/go.mod b/v3/integrations/nrpkgerrors/go.mod index 49a8efbb9..f4fde7818 100644 --- a/v3/integrations/nrpkgerrors/go.mod +++ b/v3/integrations/nrpkgerrors/go.mod @@ -1,9 +1,11 @@ module github.com/newrelic/go-agent/v3/integrations/nrpkgerrors + // As of Dec 2019, 1.11 is the earliest version of Go tested by pkg/errors: // https://github.com/pkg/errors/blob/master/.travis.yml go 1.11 + require ( - github.com/newrelic/go-agent/v3 v3.0.0 + github.com/newrelic/go-agent/v3 v3.24.0 // v0.8.0 was the last release in 2016, and when // major development on pkg/errors stopped. github.com/pkg/errors v0.8.0 diff --git a/v3/integrations/nrpq/go.mod b/v3/integrations/nrpq/go.mod index 8cfa11e1b..6df247b83 100644 --- a/v3/integrations/nrpq/go.mod +++ b/v3/integrations/nrpq/go.mod @@ -1,10 +1,14 @@ module github.com/newrelic/go-agent/v3/integrations/nrpq + // As of Dec 2019, go 1.11 is the earliest version of Go tested by lib/pq: // https://github.com/lib/pq/blob/master/.travis.yml go 1.11 + require ( // NewConnector dsn parsing tests expect v1.1.0 error return behavior. github.com/lib/pq v1.1.0 // v3.3.0 includes the new location of ParseQuery github.com/newrelic/go-agent/v3 v3.3.0 ) + +replace github.com/newrelic/go-agent/v3 => ../.. diff --git a/v3/integrations/nrredis-v7/go.mod b/v3/integrations/nrredis-v7/go.mod index 898f069dc..92cc140ff 100644 --- a/v3/integrations/nrredis-v7/go.mod +++ b/v3/integrations/nrredis-v7/go.mod @@ -1,8 +1,10 @@ module github.com/newrelic/go-agent/v3/integrations/nrredis-v7 + // As of Jan 2020, go 1.11 is in the go-redis go.mod file: // https://github.com/go-redis/redis/blob/master/go.mod go 1.11 + require ( github.com/go-redis/redis/v7 v7.0.0-beta.5 - github.com/newrelic/go-agent/v3 v3.17.0 + github.com/newrelic/go-agent/v3 v3.24.0 ) diff --git a/v3/integrations/nrredis-v8/go.mod b/v3/integrations/nrredis-v8/go.mod index e97685f7a..c3f45b3b4 100644 --- a/v3/integrations/nrredis-v8/go.mod +++ b/v3/integrations/nrredis-v8/go.mod @@ -1,8 +1,10 @@ module github.com/newrelic/go-agent/v3/integrations/nrredis-v8 + // As of Jan 2020, go 1.11 is in the go-redis go.mod file: // https://github.com/go-redis/redis/blob/master/go.mod go 1.11 + require ( github.com/go-redis/redis/v8 v8.4.0 - github.com/newrelic/go-agent/v3 v3.0.0 + github.com/newrelic/go-agent/v3 v3.24.0 ) diff --git a/v3/integrations/nrredis-v9/go.mod b/v3/integrations/nrredis-v9/go.mod index 884074439..3f3e87800 100644 --- a/v3/integrations/nrredis-v9/go.mod +++ b/v3/integrations/nrredis-v9/go.mod @@ -1,8 +1,11 @@ module github.com/newrelic/go-agent/v3/integrations/nrredis-v9 + // As of Mar 2023, go 1.17 is in the go-redis go.mod file: // https://github.com/redis/go-redis/blob/a38f75b640398bd709ee46c778a23e80e09d48b5/go.mod#L3 go 1.17 + require ( - github.com/newrelic/go-agent/v3 v3.20.4 + github.com/newrelic/go-agent/v3 v3.24.0 github.com/redis/go-redis/v9 v9.0.2 ) + diff --git a/v3/integrations/nrsarama/go.mod b/v3/integrations/nrsarama/go.mod index 37e3394f4..be15a07de 100644 --- a/v3/integrations/nrsarama/go.mod +++ b/v3/integrations/nrsarama/go.mod @@ -1,7 +1,10 @@ module github.com/newrelic/go-agent/v3/integrations/nrsarama + go 1.19 + require ( github.com/Shopify/sarama v1.38.1 - github.com/newrelic/go-agent/v3 v3.21.1 + github.com/newrelic/go-agent/v3 v3.24.0 github.com/stretchr/testify v1.8.1 ) + diff --git a/v3/integrations/nrsecurityagent/go.mod b/v3/integrations/nrsecurityagent/go.mod index e0cba1451..5f6d461ea 100644 --- a/v3/integrations/nrsecurityagent/go.mod +++ b/v3/integrations/nrsecurityagent/go.mod @@ -3,10 +3,11 @@ module github.com/newrelic/go-agent/v3/integrations/nrsecurityagent go 1.19 require ( - github.com/newrelic/csec-go-agent v0.2.1 - github.com/newrelic/go-agent/v3 v3.23.0 + github.com/newrelic/csec-go-agent v0.3.0 + github.com/newrelic/go-agent/v3 v3.24.0 github.com/newrelic/go-agent/v3/integrations/nrsqlite3 v1.2.0 gopkg.in/yaml.v2 v2.4.0 ) + replace github.com/newrelic/go-agent/v3 => ../.. diff --git a/v3/integrations/nrsnowflake/go.mod b/v3/integrations/nrsnowflake/go.mod index d910bb73f..29524853c 100644 --- a/v3/integrations/nrsnowflake/go.mod +++ b/v3/integrations/nrsnowflake/go.mod @@ -1,6 +1,9 @@ module github.com/newrelic/go-agent/v3/integrations/nrsnowflake -go 1.17 + +go 1.18 + require ( - github.com/newrelic/go-agent/v3 v3.20.2 - github.com/snowflakedb/gosnowflake v1.6.16 + github.com/newrelic/go-agent/v3 v3.24.0 + github.com/snowflakedb/gosnowflake v1.6.19 ) + diff --git a/v3/integrations/nrsqlite3/go.mod b/v3/integrations/nrsqlite3/go.mod index e391a40ab..d8ca907c1 100644 --- a/v3/integrations/nrsqlite3/go.mod +++ b/v3/integrations/nrsqlite3/go.mod @@ -1,9 +1,11 @@ module github.com/newrelic/go-agent/v3/integrations/nrsqlite3 + // As of Dec 2019, 1.9 is the oldest version of Go tested by go-sqlite3: // https://github.com/mattn/go-sqlite3/blob/master/.travis.yml go 1.9 + require ( github.com/mattn/go-sqlite3 v1.0.0 // v3.3.0 includes the new location of ParseQuery - github.com/newrelic/go-agent/v3 v3.3.0 + github.com/newrelic/go-agent/v3 v3.24.0 ) diff --git a/v3/integrations/nrstan/go.mod b/v3/integrations/nrstan/go.mod index 2dcf89041..2f8c61ca5 100644 --- a/v3/integrations/nrstan/go.mod +++ b/v3/integrations/nrstan/go.mod @@ -1,8 +1,11 @@ module github.com/newrelic/go-agent/v3/integrations/nrstan + // As of Dec 2019, 1.11 is the earliest Go version tested by Stan: // https://github.com/nats-io/stan.go/blob/master/.travis.yml go 1.18 + require ( github.com/nats-io/stan.go v0.10.4 - github.com/newrelic/go-agent/v3 v3.21.1 + github.com/newrelic/go-agent/v3 v3.24.0 ) + diff --git a/v3/integrations/nrzap/go.mod b/v3/integrations/nrzap/go.mod index df4415978..a3a74eb4f 100644 --- a/v3/integrations/nrzap/go.mod +++ b/v3/integrations/nrzap/go.mod @@ -1,9 +1,11 @@ module github.com/newrelic/go-agent/v3/integrations/nrzap + // As of Dec 2019, zap has 1.13 in their go.mod file: // https://github.com/uber-go/zap/blob/master/go.mod go 1.13 + require ( - github.com/newrelic/go-agent/v3 v3.0.0 + github.com/newrelic/go-agent/v3 v3.24.0 // v1.12.0 is the earliest version of zap using modules. go.uber.org/zap v1.12.0 ) diff --git a/v3/internal/integrationsupport/integrationsupport_test.go b/v3/internal/integrationsupport/integrationsupport_test.go index 7e6912cee..1b2561c5f 100644 --- a/v3/internal/integrationsupport/integrationsupport_test.go +++ b/v3/internal/integrationsupport/integrationsupport_test.go @@ -31,6 +31,7 @@ func testApp(t *testing.T) *newrelic.Application { newrelic.ConfigLicense("0123456789012345678901234567890123456789"), newrelic.ConfigEnabled(false), newrelic.ConfigDistributedTracerEnabled(true), + newrelic.ConfigCodeLevelMetricsEnabled(false), ) if nil != err { t.Fatal(err) diff --git a/v3/newrelic/config.go b/v3/newrelic/config.go index bb9fbaab7..69f324a4e 100644 --- a/v3/newrelic/config.go +++ b/v3/newrelic/config.go @@ -669,7 +669,7 @@ func defaultConfig() Config { c.InfiniteTracing.SpanEvents.QueueSize = 10000 // Code Level Metrics - c.CodeLevelMetrics.Enabled = false + c.CodeLevelMetrics.Enabled = true c.CodeLevelMetrics.RedactPathPrefixes = true c.CodeLevelMetrics.RedactIgnoredPrefixes = true c.CodeLevelMetrics.Scope = AllCLM diff --git a/v3/newrelic/config_test.go b/v3/newrelic/config_test.go index 3051ad19f..37eb88159 100644 --- a/v3/newrelic/config_test.go +++ b/v3/newrelic/config_test.go @@ -149,7 +149,7 @@ func TestCopyConfigReferenceFieldsPresent(t *testing.T) { "Attributes":{"Enabled":false,"Exclude":["10"],"Include":["9"]}, "Enabled":true }, - "CodeLevelMetrics":{"Enabled":false,"IgnoredPrefix":"","IgnoredPrefixes":null,"PathPrefix":"","PathPrefixes":null,"RedactIgnoredPrefixes":true,"RedactPathPrefixes":true,"Scope":"all"}, + "CodeLevelMetrics":{"Enabled":true,"IgnoredPrefix":"","IgnoredPrefixes":null,"PathPrefix":"","PathPrefixes":null,"RedactIgnoredPrefixes":true,"RedactPathPrefixes":true,"Scope":"all"}, "CrossApplicationTracer":{"Enabled":false}, "CustomInsightsEvents":{ "Enabled":true, @@ -349,7 +349,7 @@ func TestCopyConfigReferenceFieldsAbsent(t *testing.T) { }, "Enabled":true }, - "CodeLevelMetrics":{"Enabled":false,"IgnoredPrefix":"","IgnoredPrefixes":null,"PathPrefix":"","PathPrefixes":null,"RedactIgnoredPrefixes":true,"RedactPathPrefixes":true,"Scope":"all"}, + "CodeLevelMetrics":{"Enabled":true,"IgnoredPrefix":"","IgnoredPrefixes":null,"PathPrefix":"","PathPrefixes":null,"RedactIgnoredPrefixes":true,"RedactPathPrefixes":true,"Scope":"all"}, "CrossApplicationTracer":{"Enabled":false}, "CustomInsightsEvents":{ "Enabled":true, diff --git a/v3/newrelic/error_events.go b/v3/newrelic/error_events.go index 46e95b609..07aca4f35 100644 --- a/v3/newrelic/error_events.go +++ b/v3/newrelic/error_events.go @@ -31,6 +31,9 @@ func (e *errorEvent) WriteJSON(buf *bytes.Buffer) { if e.SpanID != "" { w.stringField("spanId", e.SpanID) } + if e.Expect { + w.stringField("error.expected", "true") + } sharedTransactionIntrinsics(&e.txnEvent, &w) sharedBetterCATIntrinsics(&e.txnEvent, &w) diff --git a/v3/newrelic/examples_test.go b/v3/newrelic/examples_test.go index 1fc800e56..f553eeea6 100644 --- a/v3/newrelic/examples_test.go +++ b/v3/newrelic/examples_test.go @@ -22,6 +22,7 @@ func Example() { app, err := newrelic.NewApplication( newrelic.ConfigAppName("Example Application"), newrelic.ConfigLicense("__YOUR_NEW_RELIC_LICENSE_KEY__"), + newrelic.ConfigCodeLevelMetricsEnabled(false), newrelic.ConfigDebugLogger(os.Stdout), ) if nil != err { diff --git a/v3/newrelic/internal_app_test.go b/v3/newrelic/internal_app_test.go index 5e1b342a3..9857596c3 100644 --- a/v3/newrelic/internal_app_test.go +++ b/v3/newrelic/internal_app_test.go @@ -95,6 +95,7 @@ func newTestApp(replyfn func(*internal.ConnectReply), cfgFn ...ConfigOption) exp }, ConfigAppName(sampleAppName), ConfigLicense(testLicenseKey), + ConfigCodeLevelMetricsEnabled(false), ) app, err := NewApplication(cfgFn...) diff --git a/v3/newrelic/internal_benchmark_test.go b/v3/newrelic/internal_benchmark_test.go index 22a5371cd..0d3019ea5 100644 --- a/v3/newrelic/internal_benchmark_test.go +++ b/v3/newrelic/internal_benchmark_test.go @@ -55,6 +55,7 @@ func BenchmarkTraceSegmentWithDefer(b *testing.B) { ConfigAppName("my app"), ConfigLicense(sampleLicense), ConfigEnabled(false), + ConfigCodeLevelMetricsEnabled(false), ) if nil != err { b.Fatal(err) @@ -75,6 +76,7 @@ func BenchmarkTraceSegmentNoDefer(b *testing.B) { ConfigAppName("my app"), ConfigLicense(sampleLicense), ConfigEnabled(false), + ConfigCodeLevelMetricsEnabled(false), ) if nil != err { b.Fatal(err) @@ -96,6 +98,7 @@ func BenchmarkTraceSegmentZeroSegmentThreshold(b *testing.B) { ConfigAppName("my app"), ConfigLicense(sampleLicense), ConfigEnabled(false), + ConfigCodeLevelMetricsEnabled(false), func(cfg *Config) { cfg.TransactionTracer.Segments.Threshold = 0 }, @@ -120,6 +123,7 @@ func BenchmarkDatastoreSegment(b *testing.B) { ConfigAppName("my app"), ConfigLicense(sampleLicense), ConfigEnabled(false), + ConfigCodeLevelMetricsEnabled(false), ) if nil != err { b.Fatal(err) @@ -146,6 +150,7 @@ func BenchmarkExternalSegment(b *testing.B) { ConfigAppName("my app"), ConfigLicense(sampleLicense), ConfigEnabled(false), + ConfigCodeLevelMetricsEnabled(false), ) if nil != err { b.Fatal(err) diff --git a/v3/newrelic/internal_test.go b/v3/newrelic/internal_test.go index 10561273e..994ce2c2b 100644 --- a/v3/newrelic/internal_test.go +++ b/v3/newrelic/internal_test.go @@ -207,6 +207,7 @@ func TestNewApplicationNil(t *testing.T) { ConfigAppName("appname"), ConfigLicense("wrong length"), ConfigEnabled(false), + ConfigCodeLevelMetricsEnabled(false), ) if nil == err { t.Error("error expected when license key is short") @@ -266,6 +267,7 @@ func testApp(replyfn func(*internal.ConnectReply), cfgfn func(*Config), t testin app, err := NewApplication( ConfigAppName("my app"), ConfigLicense(testLicenseKey), + ConfigCodeLevelMetricsEnabled(false), cfgfn, func(cfg *Config) { cfg.Logger = lg diff --git a/v3/newrelic/internal_txn.go b/v3/newrelic/internal_txn.go index 37e1f7709..a11afa271 100644 --- a/v3/newrelic/internal_txn.go +++ b/v3/newrelic/internal_txn.go @@ -771,6 +771,12 @@ func (txn *txn) SetName(name string) error { return nil } +func (txn *txn) GetName() string { + txn.Lock() + defer txn.Unlock() + return txn.Name +} + func (txn *txn) Ignore() error { txn.Lock() defer txn.Unlock() @@ -1363,3 +1369,17 @@ func (txn *txn) IsSampled() bool { return txn.lazilyCalculateSampled() } + +func (txn *txn) getCsecData() any { + txn.Lock() + defer txn.Unlock() + return txn.csecData +} + +func (txn *txn) setCsecData() { + txn.Lock() + defer txn.Unlock() + if txn.csecData == nil { + txn.csecData = secureAgent.SendEvent("NEW_GOROUTINE", "") + } +} diff --git a/v3/newrelic/internal_txn_test.go b/v3/newrelic/internal_txn_test.go index 09cf7770c..c9ef3a298 100644 --- a/v3/newrelic/internal_txn_test.go +++ b/v3/newrelic/internal_txn_test.go @@ -567,6 +567,26 @@ func TestNilTransaction(t *testing.T) { } } +func TestGetName(t *testing.T) { + replyfn := func(reply *internal.ConnectReply) { + reply.SetSampleEverything() + reply.EntityGUID = "entities-are-guid" + reply.TraceIDGenerator = internal.NewTraceIDGenerator(12345) + } + cfgfn := func(cfg *Config) { + cfg.AppName = "app-name" + cfg.DistributedTracer.Enabled = true + } + app := testApp(replyfn, cfgfn, t) + txn := app.StartTransaction("hello") + defer txn.End() + txn.Ignore() + txn.SetName("hello世界") + if theName := txn.Name(); theName != "hello世界" { + t.Error(theName) + } +} + func TestEmptyTransaction(t *testing.T) { txn := &Transaction{} diff --git a/v3/newrelic/secure_agent.go b/v3/newrelic/secure_agent.go index 0b6225185..5011a3e7d 100644 --- a/v3/newrelic/secure_agent.go +++ b/v3/newrelic/secure_agent.go @@ -43,6 +43,9 @@ type securityAgent interface { func (app *Application) RegisterSecurityAgent(s securityAgent) { if app != nil && app.app != nil && s != nil { secureAgent = s + if app.app.run != nil { + secureAgent.RefreshState(getLinkedMetaData(app.app)) + } } } diff --git a/v3/newrelic/transaction.go b/v3/newrelic/transaction.go index c2b5d995e..9e620c6f4 100644 --- a/v3/newrelic/transaction.go +++ b/v3/newrelic/transaction.go @@ -75,6 +75,19 @@ func (txn *Transaction) SetName(name string) { txn.thread.logAPIError(txn.thread.SetName(name), "set transaction name", nil) } +// Name returns the name currently set for the transaction, as, e.g. by a call to SetName. +// If unable to do so (such as due to a nil transaction pointer), the empty string is returned. +func (txn *Transaction) Name() string { + // This is called Name rather than GetName to be consistent with the prevailing naming + // conventions for the Go language, even though the underlying internal call must be called + // something else (like GetName) because there's already a Name struct member. + + if txn == nil || txn.thread == nil { + return "" + } + return txn.thread.GetName() +} + // NoticeError records an error. The Transaction saves the first five // errors. For more control over the recorded error fields, see the // newrelic.Error type. @@ -312,9 +325,9 @@ func (txn *Transaction) startSegmentAt(at time.Time) SegmentStartTime { // // ... code you want to time here ... // segment.End() func (txn *Transaction) StartSegment(name string) *Segment { - if txn != nil && txn.thread != nil && txn.thread.thread != nil && txn.thread.thread.threadID > 0 { + if IsSecurityAgentPresent() && txn != nil && txn.thread != nil && txn.thread.thread != nil && txn.thread.thread.threadID > 0 { // async segment start - secureAgent.SendEvent("NEW_GOROUTINE_LINKER", txn.thread.csecData) + secureAgent.SendEvent("NEW_GOROUTINE_LINKER", txn.thread.getCsecData()) } return &Segment{ StartTime: txn.StartSegmentNow(), @@ -498,8 +511,8 @@ func (txn *Transaction) NewGoroutine() *Transaction { return nil } newTxn := txn.thread.NewGoroutine() - if newTxn.thread != nil && newTxn.thread.csecData == nil { - newTxn.thread.csecData = secureAgent.SendEvent("NEW_GOROUTINE", "") + if IsSecurityAgentPresent() && newTxn.thread != nil { + newTxn.thread.setCsecData() } return newTxn } diff --git a/v3/newrelic/version.go b/v3/newrelic/version.go index be6fbfed7..6959820c0 100644 --- a/v3/newrelic/version.go +++ b/v3/newrelic/version.go @@ -11,7 +11,7 @@ import ( const ( // Version is the full string version of this Go Agent. - Version = "3.23.1" + Version = "3.24.0" ) var (