diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index efaae3ba6..eb2f2684e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -30,6 +30,7 @@ jobs: - dirs: v3/integrations/logcontext-v2/nrlogrus - dirs: v3/integrations/logcontext-v2/nrzerolog - dirs: v3/integrations/logcontext-v2/nrzap + - dirs: v3/integrations/logcontext-v2/nrslog - dirs: v3/integrations/logcontext-v2/nrwriter - dirs: v3/integrations/logcontext-v2/zerologWriter - dirs: v3/integrations/logcontext-v2/logWriter @@ -138,4 +139,4 @@ jobs: else echo "Directory /app/$dir does not exist." fi - done \ No newline at end of file + done diff --git a/CHANGELOG.md b/CHANGELOG.md index 90083c249..8a5dc4621 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,20 @@ +## 3.32.0 +### Added + * Updates to support for the New Relic security agent to report API endpoints. + * Adds new wrapper function for the `nrecho`, `nrgin`, and `nrgorilla` integrations. + * Handler to take New Relic transaction data from context automatically when using `nrslog` integration (thanks, @adomaskizogian!) + +### Fixed + * Adds missing license file to the `nropenai` integration. + * Changes `*bedrockruntime.Client` parameters in `nrawsbedrock` integration to use a more general interface type, allowing the use of custom types which extend the bedrock client type. + * Fixes `pgx5` pool example + * Updated unit tests to check `Transaction.Ignore` + * Updated `nrzap` unit tests to add background logger sugared test case. + +### 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](https://docs.newrelic.com/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.31.0 ### Added * Integration packages to instrument AI model invocations (see below). diff --git a/README.md b/README.md index c5d5347d8..063f837e1 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,14 @@ package primitives can be found [here](GUIDE.md#datastore-segments). | [snowflakedb/gosnowflake](https://github.com/snowflakedb/gosnowflake) | [v3/integrations/nrsnowflake](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrsnowflake) | Instrument Snowflake driver | | [mongodb/mongo-go-driver](https://github.com/mongodb/mongo-go-driver) | [v3/integrations/nrmongo](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrmongo) | Instrument MongoDB calls | +#### AI + +| Project | Integration Package | | +| ------------- | ------------- | - | +| [sashabaranov/go-openai](https://github.com/sashabaranov/go-openai) | [v3/integrations/nropenai](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nropenai) | Send AI Monitoring Events with OpenAI | +| [aws/aws-sdk-go-v2/tree/main/service/bedrockruntime](https://github.com/aws/aws-sdk-go-v2/tree/main/service/bedrockruntime) | [v3/integrations/nrawsbedrock](https://godoc.org/github.com/newrelic/go-agent/v3/integrations/nrawsbedrock) | Send AI Monitoring Events with AWS Bedrock | + + #### Agent Logging | Project | Integration Package | | diff --git a/v3/go.mod b/v3/go.mod index c2d68c2a3..afbca8df0 100644 --- a/v3/go.mod +++ b/v3/go.mod @@ -1,10 +1,9 @@ module github.com/newrelic/go-agent/v3 -go 1.19 +go 1.20 require ( github.com/golang/protobuf v1.5.3 - golang.org/x/exp v0.0.0-20240318143956-a85f2c67cd81 google.golang.org/grpc v1.56.3 ) diff --git a/v3/integrations/logcontext-v2/logWriter/go.mod b/v3/integrations/logcontext-v2/logWriter/go.mod index f61edf225..6f5b7e47c 100644 --- a/v3/integrations/logcontext-v2/logWriter/go.mod +++ b/v3/integrations/logcontext-v2/logWriter/go.mod @@ -1,9 +1,9 @@ module github.com/newrelic/go-agent/v3/integrations/logcontext-v2/logWriter -go 1.19 +go 1.20 require ( - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 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 fb1f34055..16e4e2805 100644 --- a/v3/integrations/logcontext-v2/nrlogrus/go.mod +++ b/v3/integrations/logcontext-v2/nrlogrus/go.mod @@ -1,9 +1,9 @@ module github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrlogrus -go 1.19 +go 1.20 require ( - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 github.com/sirupsen/logrus v1.8.1 ) diff --git a/v3/integrations/logcontext-v2/nrslog/go.mod b/v3/integrations/logcontext-v2/nrslog/go.mod index 4cdd8758c..cb9c8a719 100644 --- a/v3/integrations/logcontext-v2/nrslog/go.mod +++ b/v3/integrations/logcontext-v2/nrslog/go.mod @@ -1,8 +1,8 @@ module github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrslog -go 1.19 +go 1.20 -require github.com/newrelic/go-agent/v3 v3.31.0 +require github.com/newrelic/go-agent/v3 v3.32.0 replace github.com/newrelic/go-agent/v3 => ../../.. diff --git a/v3/integrations/logcontext-v2/nrslog/handler.go b/v3/integrations/logcontext-v2/nrslog/handler.go index 551e32b0c..4e0d3c90f 100644 --- a/v3/integrations/logcontext-v2/nrslog/handler.go +++ b/v3/integrations/logcontext-v2/nrslog/handler.go @@ -39,6 +39,7 @@ func JSONHandler(app *newrelic.Application, w io.Writer, opts *slog.HandlerOptio } // WithTransaction creates a new Slog Logger object to be used for logging within a given transaction. +// Calling this function with a logger having underlying TransactionFromContextHandler handler is a no-op. func WithTransaction(txn *newrelic.Transaction, logger *slog.Logger) *slog.Logger { if txn == nil || logger == nil { return logger @@ -56,6 +57,7 @@ func WithTransaction(txn *newrelic.Transaction, logger *slog.Logger) *slog.Logge // WithTransaction creates a new Slog Logger object to be used for logging within a given transaction it its found // in a context. +// Calling this function with a logger having underlying TransactionFromContextHandler handler is a no-op. func WithContext(ctx context.Context, logger *slog.Logger) *slog.Logger { if ctx == nil { return logger @@ -181,3 +183,41 @@ func (h NRHandler) WithGroup(name string) slog.Handler { txn: h.txn, } } + +// NRHandler is an Slog handler that includes logic to implement New Relic Logs in Context. +// New Relic transaction value is taken from context. It cannot be set directly. +// This serves as a quality of life improvement for cases where slog.Default global instance is +// referenced, allowing to use slog methods directly and maintaining New Relic instrumentation. +type TransactionFromContextHandler struct { + NRHandler +} + +// WithTransactionFromContext creates a wrapped NRHandler, enabling it to automatically reference New Relic +// transaction from context. +func WithTransactionFromContext(handler NRHandler) TransactionFromContextHandler { + return TransactionFromContextHandler{handler} +} + +// Handle handles the Record. +// It will only be called when Enabled returns true. +// The Context argument is as for Enabled and NewRelic transaction. +// Canceling the context should not affect record processing. +// (Among other things, log messages may be necessary to debug a +// cancellation-related problem.) +// +// Handle methods that produce output should observe the following rules: +// - If r.Time is the zero time, ignore the time. +// - If r.PC is zero, ignore it. +// - Attr's values should be resolved. +// - If an Attr's key and value are both the zero value, ignore the Attr. +// This can be tested with attr.Equal(Attr{}). +// - If a group's key is empty, inline the group's Attrs. +// - If a group has no Attrs (even if it has a non-empty key), +// ignore it. +func (h TransactionFromContextHandler) Handle(ctx context.Context, record slog.Record) error { + if txn := newrelic.FromContext(ctx); txn != nil { + return h.NRHandler.WithTransaction(txn).Handle(ctx, record) + } + + return h.NRHandler.Handle(ctx, record) +} diff --git a/v3/integrations/logcontext-v2/nrslog/handler_test.go b/v3/integrations/logcontext-v2/nrslog/handler_test.go index 503fec909..550650dd3 100644 --- a/v3/integrations/logcontext-v2/nrslog/handler_test.go +++ b/v3/integrations/logcontext-v2/nrslog/handler_test.go @@ -258,3 +258,40 @@ func TestWithGroup(t *testing.T) { } } + +func TestTransactionFromContextHandler(t *testing.T) { + app := integrationsupport.NewTestApp(integrationsupport.SampleEverythingReplyFn, + newrelic.ConfigAppLogDecoratingEnabled(true), + newrelic.ConfigAppLogForwardingEnabled(true), + ) + + out := bytes.NewBuffer([]byte{}) + message := "Hello World!" + + handler := TextHandler(app.Application, out, &slog.HandlerOptions{}) + log := slog.New(WithTransactionFromContext(handler)) + + txn := app.Application.StartTransaction("my txn") + ctx := newrelic.NewContext(context.Background(), txn) + txninfo := txn.GetLinkingMetadata() + + log.InfoContext(ctx, message) + + txn.End() + + logcontext.ValidateDecoratedOutput(t, out, &logcontext.DecorationExpect{ + EntityGUID: integrationsupport.TestEntityGUID, + Hostname: host, + EntityName: integrationsupport.SampleAppName, + }) + + app.ExpectLogEvents(t, []internal.WantLog{ + { + Severity: slog.LevelInfo.String(), + Message: message, + Timestamp: internal.MatchAnyUnixMilli, + SpanID: txninfo.SpanID, + TraceID: txninfo.TraceID, + }, + }) +} diff --git a/v3/integrations/logcontext-v2/nrwriter/go.mod b/v3/integrations/logcontext-v2/nrwriter/go.mod index b0e8dfa37..10f545e23 100644 --- a/v3/integrations/logcontext-v2/nrwriter/go.mod +++ b/v3/integrations/logcontext-v2/nrwriter/go.mod @@ -1,8 +1,8 @@ module github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrwriter -go 1.19 +go 1.20 -require github.com/newrelic/go-agent/v3 v3.31.0 +require github.com/newrelic/go-agent/v3 v3.32.0 replace github.com/newrelic/go-agent/v3 => ../../.. diff --git a/v3/integrations/logcontext-v2/nrzap/go.mod b/v3/integrations/logcontext-v2/nrzap/go.mod index 8eb005634..d7a336e3a 100644 --- a/v3/integrations/logcontext-v2/nrzap/go.mod +++ b/v3/integrations/logcontext-v2/nrzap/go.mod @@ -1,9 +1,9 @@ module github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrzap -go 1.19 +go 1.20 require ( - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 go.uber.org/zap v1.24.0 ) diff --git a/v3/integrations/logcontext-v2/nrzap/nrzap_test.go b/v3/integrations/logcontext-v2/nrzap/nrzap_test.go index 923de536a..33adfcd26 100644 --- a/v3/integrations/logcontext-v2/nrzap/nrzap_test.go +++ b/v3/integrations/logcontext-v2/nrzap/nrzap_test.go @@ -43,6 +43,37 @@ func TestBackgroundLogger(t *testing.T) { }) } +func TestBackgroundLoggerSugared(t *testing.T) { + app := integrationsupport.NewTestApp(integrationsupport.SampleEverythingReplyFn, + newrelic.ConfigAppLogDecoratingEnabled(true), + newrelic.ConfigAppLogForwardingEnabled(true), + ) + + core := zapcore.NewCore(zapcore.NewJSONEncoder(zap.NewProductionEncoderConfig()), zapcore.AddSync(os.Stdout), zap.InfoLevel) + + backgroundCore, err := WrapBackgroundCore(core, app.Application) + if err != nil && err != ErrNilApp { + t.Fatal(err) + } + + logger := zap.New(backgroundCore).Sugar() + + err = errors.New("this is a test error") + msg := "this is a test error message" + + // for background logging: + logger.Error(msg, zap.Error(err), zap.String("test-key", "test-val")) + logger.Sync() + + app.ExpectLogEvents(t, []internal.WantLog{ + { + Severity: zap.ErrorLevel.String(), + Message: `this is a test error message{error 26 0 this is a test error} {test-key 15 0 test-val }`, + Timestamp: internal.MatchAnyUnixMilli, + }, + }) +} + func TestBackgroundLoggerNilApp(t *testing.T) { app := integrationsupport.NewTestApp(integrationsupport.SampleEverythingReplyFn, newrelic.ConfigAppLogDecoratingEnabled(true), diff --git a/v3/integrations/logcontext-v2/nrzerolog/go.mod b/v3/integrations/logcontext-v2/nrzerolog/go.mod index b54d7233a..d8b2781d0 100644 --- a/v3/integrations/logcontext-v2/nrzerolog/go.mod +++ b/v3/integrations/logcontext-v2/nrzerolog/go.mod @@ -1,9 +1,9 @@ module github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrzerolog -go 1.19 +go 1.20 require ( - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.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 c7c423c18..dfdd583e6 100644 --- a/v3/integrations/logcontext-v2/zerologWriter/go.mod +++ b/v3/integrations/logcontext-v2/zerologWriter/go.mod @@ -1,9 +1,9 @@ module github.com/newrelic/go-agent/v3/integrations/logcontext-v2/zerologWriter -go 1.19 +go 1.20 require ( - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 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 358ca628b..2e6ec317e 100644 --- a/v3/integrations/logcontext/nrlogrusplugin/go.mod +++ b/v3/integrations/logcontext/nrlogrusplugin/go.mod @@ -2,10 +2,10 @@ 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.19 +go 1.20 require ( - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 // v1.4.0 is required for for the log.WithContext. github.com/sirupsen/logrus v1.4.0 ) diff --git a/v3/integrations/nramqp/go.mod b/v3/integrations/nramqp/go.mod index b41a912b2..72015f620 100644 --- a/v3/integrations/nramqp/go.mod +++ b/v3/integrations/nramqp/go.mod @@ -1,9 +1,9 @@ module github.com/newrelic/go-agent/v3/integrations/nramqp -go 1.19 +go 1.20 require ( - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 github.com/rabbitmq/amqp091-go v1.9.0 ) replace github.com/newrelic/go-agent/v3 => ../.. diff --git a/v3/integrations/nrawsbedrock/go.mod b/v3/integrations/nrawsbedrock/go.mod index cab2c2de9..2b7a3917d 100644 --- a/v3/integrations/nrawsbedrock/go.mod +++ b/v3/integrations/nrawsbedrock/go.mod @@ -1,6 +1,6 @@ module github.com/newrelic/go-agent/v3/integrations/nrawsbedrock -go 1.19 +go 1.20 require ( github.com/aws/aws-sdk-go-v2 v1.26.0 @@ -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.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 ) diff --git a/v3/integrations/nrawsbedrock/nrawsbedrock.go b/v3/integrations/nrawsbedrock/nrawsbedrock.go index 99114a5f1..640bf37d7 100644 --- a/v3/integrations/nrawsbedrock/nrawsbedrock.go +++ b/v3/integrations/nrawsbedrock/nrawsbedrock.go @@ -28,11 +28,16 @@ // ConfigAIMonitoringStreamingEnabled(true), // enable instrumentation of streaming invocations // ConfigAIMonitoringRecordContentEnabled(true), // include input/output data in instrumentation // +// Currently, the following must also be set for AIM reporting to function correctly: +// ConfigCustomInsightsEventsEnabled(true) // (the default) +// ConfigHighSecurityEnabled(false) // (the default) +// // Or, if ConfigFromEnvironment() is included in your configuration options, the above configuration // options may be specified using these environment variables, respectively: // NEW_RELIC_AI_MONITORING_ENABLED=true // NEW_RELIC_AI_MONITORING_STREAMING_ENABLED=true // NEW_RELIC_AI_MONITORING_RECORD_CONTENT_ENABLED=true +// NEW_RELIC_HIGH_SECURITY=false // The values for these variables may be any form accepted by strconv.ParseBool (e.g., 1, t, T, true, TRUE, True, // 0, f, F, false, FALSE, or False). // @@ -110,13 +115,18 @@ func isEnabled(app *newrelic.Application, streaming bool) (bool, bool) { return config.AIMonitoring.Enabled, config.AIMonitoring.RecordContent.Enabled } +// Modeler is any type that can invoke Bedrock models (e.g., bedrockruntime.Client). +type Modeler interface { + InvokeModel(context.Context, *bedrockruntime.InvokeModelInput, ...func(*bedrockruntime.Options)) (*bedrockruntime.InvokeModelOutput, error) + InvokeModelWithResponseStream(context.Context, *bedrockruntime.InvokeModelWithResponseStreamInput, ...func(*bedrockruntime.Options)) (*bedrockruntime.InvokeModelWithResponseStreamOutput, error) +} + // ResponseStream tracks the model invocation throughout its lifetime until all stream events // are processed. type ResponseStream struct { // The request parameters that started the invocation ctx context.Context app *newrelic.Application - client *bedrockruntime.Client params *bedrockruntime.InvokeModelWithResponseStreamInput attrs map[string]any meta map[string]any @@ -173,7 +183,7 @@ type modelInputList struct { // Either start a transaction on your own and add it to the context c passed into this function, or // a transaction will be started for you that lasts only for the duration of the model invocation. // -func InvokeModelWithResponseStream(app *newrelic.Application, brc *bedrockruntime.Client, ctx context.Context, params *bedrockruntime.InvokeModelWithResponseStreamInput, optFns ...func(*bedrockruntime.Options)) (ResponseStream, error) { +func InvokeModelWithResponseStream(app *newrelic.Application, brc Modeler, ctx context.Context, params *bedrockruntime.InvokeModelWithResponseStreamInput, optFns ...func(*bedrockruntime.Options)) (ResponseStream, error) { return InvokeModelWithResponseStreamAttributes(app, brc, ctx, params, nil, optFns...) } @@ -188,7 +198,7 @@ func InvokeModelWithResponseStream(app *newrelic.Application, brc *bedrockruntim // // We recommend including at least "llm.conversation_id" in your attributes. // -func InvokeModelWithResponseStreamAttributes(app *newrelic.Application, brc *bedrockruntime.Client, ctx context.Context, params *bedrockruntime.InvokeModelWithResponseStreamInput, attrs map[string]any, optFns ...func(*bedrockruntime.Options)) (ResponseStream, error) { +func InvokeModelWithResponseStreamAttributes(app *newrelic.Application, brc Modeler, ctx context.Context, params *bedrockruntime.InvokeModelWithResponseStreamInput, attrs map[string]any, optFns ...func(*bedrockruntime.Options)) (ResponseStream, error) { var aiEnabled bool var err error @@ -196,7 +206,6 @@ func InvokeModelWithResponseStreamAttributes(app *newrelic.Application, brc *bed ctx: ctx, app: app, meta: map[string]any{}, - client: brc, params: params, attrs: attrs, } @@ -375,7 +384,7 @@ func (s *ResponseStream) Close() error { // If your callback function returns an error, the processing of the response stream will // terminate at that point. // -func ProcessModelWithResponseStream(app *newrelic.Application, brc *bedrockruntime.Client, ctx context.Context, callback func([]byte) error, params *bedrockruntime.InvokeModelWithResponseStreamInput, optFns ...func(*bedrockruntime.Options)) error { +func ProcessModelWithResponseStream(app *newrelic.Application, brc Modeler, ctx context.Context, callback func([]byte) error, params *bedrockruntime.InvokeModelWithResponseStreamInput, optFns ...func(*bedrockruntime.Options)) error { return ProcessModelWithResponseStreamAttributes(app, brc, ctx, callback, params, nil, optFns...) } @@ -390,7 +399,7 @@ func ProcessModelWithResponseStream(app *newrelic.Application, brc *bedrockrunti // // We recommend including at least "llm.conversation_id" in your attributes. // -func ProcessModelWithResponseStreamAttributes(app *newrelic.Application, brc *bedrockruntime.Client, ctx context.Context, callback func([]byte) error, params *bedrockruntime.InvokeModelWithResponseStreamInput, attrs map[string]any, optFns ...func(*bedrockruntime.Options)) error { +func ProcessModelWithResponseStreamAttributes(app *newrelic.Application, brc Modeler, ctx context.Context, callback func([]byte) error, params *bedrockruntime.InvokeModelWithResponseStreamInput, attrs map[string]any, optFns ...func(*bedrockruntime.Options)) error { var err error var userErr error @@ -437,7 +446,7 @@ func ProcessModelWithResponseStreamAttributes(app *newrelic.Application, brc *be // // If the transaction is unable to be created or used, the Bedrock call will be made anyway, without instrumentation. // -func InvokeModel(app *newrelic.Application, brc *bedrockruntime.Client, ctx context.Context, params *bedrockruntime.InvokeModelInput, optFns ...func(*bedrockruntime.Options)) (*bedrockruntime.InvokeModelOutput, error) { +func InvokeModel(app *newrelic.Application, brc Modeler, ctx context.Context, params *bedrockruntime.InvokeModelInput, optFns ...func(*bedrockruntime.Options)) (*bedrockruntime.InvokeModelOutput, error) { return InvokeModelWithAttributes(app, brc, ctx, params, nil, optFns...) } @@ -451,7 +460,7 @@ func InvokeModel(app *newrelic.Application, brc *bedrockruntime.Client, ctx cont // // We recommend including at least "llm.conversation_id" in your attributes. // -func InvokeModelWithAttributes(app *newrelic.Application, brc *bedrockruntime.Client, ctx context.Context, params *bedrockruntime.InvokeModelInput, attrs map[string]any, optFns ...func(*bedrockruntime.Options)) (*bedrockruntime.InvokeModelOutput, error) { +func InvokeModelWithAttributes(app *newrelic.Application, brc Modeler, ctx context.Context, params *bedrockruntime.InvokeModelInput, attrs map[string]any, optFns ...func(*bedrockruntime.Options)) (*bedrockruntime.InvokeModelOutput, error) { var txn *newrelic.Transaction // the transaction to record in, or nil if we aren't instrumenting this time var err error diff --git a/v3/integrations/nrawssdk-v1/go.mod b/v3/integrations/nrawssdk-v1/go.mod index 8f224f3d9..10a481a16 100644 --- a/v3/integrations/nrawssdk-v1/go.mod +++ b/v3/integrations/nrawssdk-v1/go.mod @@ -3,12 +3,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.19 +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.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 ) diff --git a/v3/integrations/nrawssdk-v2/go.mod b/v3/integrations/nrawssdk-v2/go.mod index b04fac799..d503c908d 100644 --- a/v3/integrations/nrawssdk-v2/go.mod +++ b/v3/integrations/nrawssdk-v2/go.mod @@ -2,7 +2,7 @@ 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.19 +go 1.20 require ( github.com/aws/aws-sdk-go-v2 v1.16.15 @@ -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.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 ) diff --git a/v3/integrations/nrb3/go.mod b/v3/integrations/nrb3/go.mod index ba44d1ea6..14dd3694d 100644 --- a/v3/integrations/nrb3/go.mod +++ b/v3/integrations/nrb3/go.mod @@ -1,8 +1,8 @@ module github.com/newrelic/go-agent/v3/integrations/nrb3 -go 1.19 +go 1.20 -require github.com/newrelic/go-agent/v3 v3.31.0 +require github.com/newrelic/go-agent/v3 v3.32.0 replace github.com/newrelic/go-agent/v3 => ../.. diff --git a/v3/integrations/nrecho-v3/go.mod b/v3/integrations/nrecho-v3/go.mod index 76d71b4d9..53f9ea7ee 100644 --- a/v3/integrations/nrecho-v3/go.mod +++ b/v3/integrations/nrecho-v3/go.mod @@ -2,13 +2,13 @@ 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.19 +go 1.20 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.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 ) diff --git a/v3/integrations/nrecho-v3/nrecho.go b/v3/integrations/nrecho-v3/nrecho.go index ad5f862b8..9fe29f54b 100644 --- a/v3/integrations/nrecho-v3/nrecho.go +++ b/v3/integrations/nrecho-v3/nrecho.go @@ -51,9 +51,7 @@ func transactionName(c echo.Context) string { // e := echo.New() // // Add the nrecho middleware before other middlewares or routes: // e.Use(nrecho.Middleware(app)) -// func Middleware(app *newrelic.Application) func(echo.HandlerFunc) echo.HandlerFunc { - if nil == app { return func(next echo.HandlerFunc) echo.HandlerFunc { return next @@ -93,3 +91,24 @@ func Middleware(app *newrelic.Application) func(echo.HandlerFunc) echo.HandlerFu } } } + +// WrapRouter extracts API endpoints from the echo instance passed to it +// 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) +// + +func WrapRouter(engine *echo.Echo) { + if engine != nil && newrelic.IsSecurityAgentPresent() { + router := engine.Routes() + for _, r := range router { + newrelic.GetSecurityAgentInterface().SendEvent("API_END_POINTS", r.Path, r.Method, r.Handler) + } + } +} diff --git a/v3/integrations/nrecho-v4/go.mod b/v3/integrations/nrecho-v4/go.mod index fde8e8d4c..709dae0cd 100644 --- a/v3/integrations/nrecho-v4/go.mod +++ b/v3/integrations/nrecho-v4/go.mod @@ -2,11 +2,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.19 +go 1.20 require ( github.com/labstack/echo/v4 v4.9.0 - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 ) diff --git a/v3/integrations/nrecho-v4/nrecho.go b/v3/integrations/nrecho-v4/nrecho.go index 4c3b8cd18..d768c7a76 100644 --- a/v3/integrations/nrecho-v4/nrecho.go +++ b/v3/integrations/nrecho-v4/nrecho.go @@ -71,7 +71,6 @@ func WithSkipper(skipper Skipper) ConfigOption { // e := echo.New() // // Add the nrecho middleware before other middlewares or routes: // e.Use(nrecho.MiddlewareWithConfig(nrecho.Config{App: app})) -// func Middleware(app *newrelic.Application, opts ...ConfigOption) func(echo.HandlerFunc) echo.HandlerFunc { if app == nil { return func(next echo.HandlerFunc) echo.HandlerFunc { @@ -131,3 +130,24 @@ func Middleware(app *newrelic.Application, opts ...ConfigOption) func(echo.Handl } } } + +// WrapRouter extracts API endpoints from the echo instance passed to it +// 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) +// + +func WrapRouter(engine *echo.Echo) { + if engine != nil && newrelic.IsSecurityAgentPresent() { + router := engine.Routes() + for _, r := range router { + newrelic.GetSecurityAgentInterface().SendEvent("API_END_POINTS", r.Path, r.Method, r.Name) + } + } +} diff --git a/v3/integrations/nrelasticsearch-v7/go.mod b/v3/integrations/nrelasticsearch-v7/go.mod index 109f83fcc..c1a838d43 100644 --- a/v3/integrations/nrelasticsearch-v7/go.mod +++ b/v3/integrations/nrelasticsearch-v7/go.mod @@ -2,11 +2,11 @@ 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.19 +go 1.20 require ( github.com/elastic/go-elasticsearch/v7 v7.17.0 - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 ) diff --git a/v3/integrations/nrfasthttp/examples/client-fasthttp/go.mod b/v3/integrations/nrfasthttp/examples/client-fasthttp/go.mod index f83576a4a..9a1d14830 100644 --- a/v3/integrations/nrfasthttp/examples/client-fasthttp/go.mod +++ b/v3/integrations/nrfasthttp/examples/client-fasthttp/go.mod @@ -1,9 +1,9 @@ module client-example -go 1.19 +go 1.20 require ( - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 github.com/newrelic/go-agent/v3/integrations/nrfasthttp v1.0.0 github.com/valyala/fasthttp v1.49.0 ) diff --git a/v3/integrations/nrfasthttp/examples/server-fasthttp/go.mod b/v3/integrations/nrfasthttp/examples/server-fasthttp/go.mod index ffe9afaee..a1f5053a1 100644 --- a/v3/integrations/nrfasthttp/examples/server-fasthttp/go.mod +++ b/v3/integrations/nrfasthttp/examples/server-fasthttp/go.mod @@ -1,9 +1,9 @@ module server-example -go 1.19 +go 1.20 require ( - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 github.com/newrelic/go-agent/v3/integrations/nrfasthttp v1.0.0 github.com/valyala/fasthttp v1.49.0 ) diff --git a/v3/integrations/nrfasthttp/go.mod b/v3/integrations/nrfasthttp/go.mod index 084624aa6..deaf31122 100644 --- a/v3/integrations/nrfasthttp/go.mod +++ b/v3/integrations/nrfasthttp/go.mod @@ -1,9 +1,9 @@ module github.com/newrelic/go-agent/v3/integrations/nrfasthttp -go 1.19 +go 1.20 require ( - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 github.com/valyala/fasthttp v1.49.0 ) diff --git a/v3/integrations/nrfasthttp/instrumentation.go b/v3/integrations/nrfasthttp/instrumentation.go index abefb8460..f05a8b770 100644 --- a/v3/integrations/nrfasthttp/instrumentation.go +++ b/v3/integrations/nrfasthttp/instrumentation.go @@ -50,7 +50,9 @@ func WrapHandle(app *newrelic.Application, pattern string, handler fasthttp.Requ if app == nil { return pattern, handler } - + if newrelic.IsSecurityAgentPresent() { + newrelic.GetSecurityAgentInterface().SendEvent("API_END_POINTS", pattern, "*", internal.HandlerName(handler)) + } // add the wrapped function to the trace options as the source code reference point // (but only if we know we're collecting CLM for this transaction and the user didn't already // specify a different code location explicitly). diff --git a/v3/integrations/nrgin/go.mod b/v3/integrations/nrgin/go.mod index 151d5d70a..5b440be98 100644 --- a/v3/integrations/nrgin/go.mod +++ b/v3/integrations/nrgin/go.mod @@ -2,11 +2,11 @@ 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 +go 1.20 require ( github.com/gin-gonic/gin v1.9.1 - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 ) diff --git a/v3/integrations/nrgin/nrgin.go b/v3/integrations/nrgin/nrgin.go index 88ef11b24..e2943466b 100644 --- a/v3/integrations/nrgin/nrgin.go +++ b/v3/integrations/nrgin/nrgin.go @@ -144,6 +144,26 @@ func MiddlewareHandlerTxnNames(app *newrelic.Application) gin.HandlerFunc { return middleware(app, false) } +// WrapRouter extracts API endpoints from the router instance passed to it +// 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. +// router := gin.Default() +// .... +// .... +// .... +// +// nrgin.WrapRouter(router) +// + +func WrapRouter(engine *gin.Engine) { + if engine != nil && newrelic.IsSecurityAgentPresent() { + router := engine.Routes() + for _, r := range router { + newrelic.GetSecurityAgentInterface().SendEvent("API_END_POINTS", r.Path, r.Method, internal.HandlerName(r.HandlerFunc)) + } + } +} func middleware(app *newrelic.Application, useNewNames bool) gin.HandlerFunc { return func(c *gin.Context) { if app != nil { diff --git a/v3/integrations/nrgorilla/go.mod b/v3/integrations/nrgorilla/go.mod index 3f90d6488..d515a54d0 100644 --- a/v3/integrations/nrgorilla/go.mod +++ b/v3/integrations/nrgorilla/go.mod @@ -2,12 +2,12 @@ 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.19 +go 1.20 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.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 ) diff --git a/v3/integrations/nrgorilla/nrgorilla.go b/v3/integrations/nrgorilla/nrgorilla.go index dd2088a25..a8425d0a3 100644 --- a/v3/integrations/nrgorilla/nrgorilla.go +++ b/v3/integrations/nrgorilla/nrgorilla.go @@ -111,3 +111,35 @@ func Middleware(app *newrelic.Application) mux.MiddlewareFunc { }) } } + +// WrapRouter extracts API endpoints from the router object passed to it +// 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. +// r := mux.NewRouter() +// .... +// .... +// .... +// +// nrgorilla.WrapRouter(router) +// + +func WrapRouter(router *mux.Router) { + if router != nil && newrelic.IsSecurityAgentPresent() { + router.Walk(func(route *mux.Route, router *mux.Router, ancestors []*mux.Route) error { + path, err1 := route.GetPathTemplate() + if err1 != nil { + return nil + } + methods, _ := route.GetMethods() + if len(methods) == 0 { + newrelic.GetSecurityAgentInterface().SendEvent("API_END_POINTS", path, "*", internal.HandlerName(route.GetHandler())) + } else { + for _, method := range methods { + newrelic.GetSecurityAgentInterface().SendEvent("API_END_POINTS", path, method, internal.HandlerName(route.GetHandler())) + } + } + return nil + }) + } +} diff --git a/v3/integrations/nrgraphgophers/go.mod b/v3/integrations/nrgraphgophers/go.mod index d31aa17fe..ca56c234e 100644 --- a/v3/integrations/nrgraphgophers/go.mod +++ b/v3/integrations/nrgraphgophers/go.mod @@ -2,12 +2,12 @@ module github.com/newrelic/go-agent/v3/integrations/nrgraphgophers // As of Jan 2020, the graphql-go go.mod file uses 1.13: // https://github.com/graph-gophers/graphql-go/blob/master/go.mod -go 1.19 +go 1.20 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.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 ) diff --git a/v3/integrations/nrgraphqlgo/example/go.mod b/v3/integrations/nrgraphqlgo/example/go.mod index 6658d1500..2018d0d9d 100644 --- a/v3/integrations/nrgraphqlgo/example/go.mod +++ b/v3/integrations/nrgraphqlgo/example/go.mod @@ -1,11 +1,11 @@ module github.com/newrelic/go-agent/v3/integrations/nrgraphqlgo/example -go 1.19 +go 1.20 require ( github.com/graphql-go/graphql v0.8.1 github.com/graphql-go/graphql-go-handler v0.2.3 - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 github.com/newrelic/go-agent/v3/integrations/nrgraphqlgo v1.0.0 ) diff --git a/v3/integrations/nrgraphqlgo/go.mod b/v3/integrations/nrgraphqlgo/go.mod index f812ba0de..c99dff089 100644 --- a/v3/integrations/nrgraphqlgo/go.mod +++ b/v3/integrations/nrgraphqlgo/go.mod @@ -1,10 +1,10 @@ module github.com/newrelic/go-agent/v3/integrations/nrgraphqlgo -go 1.19 +go 1.20 require ( github.com/graphql-go/graphql v0.8.1 - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 ) diff --git a/v3/integrations/nrgrpc/go.mod b/v3/integrations/nrgrpc/go.mod index bd71b2b31..aaa6c82a2 100644 --- a/v3/integrations/nrgrpc/go.mod +++ b/v3/integrations/nrgrpc/go.mod @@ -1,12 +1,12 @@ module github.com/newrelic/go-agent/v3/integrations/nrgrpc -go 1.19 +go 1.20 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.31.0 + github.com/newrelic/go-agent/v3 v3.32.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.56.3 diff --git a/v3/integrations/nrhttprouter/go.mod b/v3/integrations/nrhttprouter/go.mod index 231bd7667..a1cc04662 100644 --- a/v3/integrations/nrhttprouter/go.mod +++ b/v3/integrations/nrhttprouter/go.mod @@ -2,12 +2,12 @@ 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.19 +go 1.20 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.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 ) diff --git a/v3/integrations/nrhttprouter/nrhttprouter.go b/v3/integrations/nrhttprouter/nrhttprouter.go index 75cb73ff4..d1df356eb 100644 --- a/v3/integrations/nrhttprouter/nrhttprouter.go +++ b/v3/integrations/nrhttprouter/nrhttprouter.go @@ -8,33 +8,33 @@ // httprouter.Router. Use an *nrhttprouter.Router in place of your // *httprouter.Router. Example: // -// package main +// package main // -// import ( -// "fmt" -// "net/http" -// "os" +// import ( +// "fmt" +// "net/http" +// "os" // -// "github.com/julienschmidt/httprouter" -// newrelic "github.com/newrelic/go-agent/v3/newrelic" -// "github.com/newrelic/go-agent/v3/integrations/nrhttprouter" -// ) +// "github.com/julienschmidt/httprouter" +// newrelic "github.com/newrelic/go-agent/v3/newrelic" +// "github.com/newrelic/go-agent/v3/integrations/nrhttprouter" +// ) // -// func main() { -// cfg := newrelic.NewConfig("httprouter App", os.Getenv("NEW_RELIC_LICENSE_KEY")) -// app, _ := newrelic.NewApplication(cfg) +// func main() { +// cfg := newrelic.NewConfig("httprouter App", os.Getenv("NEW_RELIC_LICENSE_KEY")) +// app, _ := newrelic.NewApplication(cfg) // -// // Create the Router replacement: -// router := nrhttprouter.New(app) +// // Create the Router replacement: +// router := nrhttprouter.New(app) // -// router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { -// w.Write([]byte("welcome\n")) -// }) -// router.GET("/hello/:name", (w http.ResponseWriter, r *http.Request, ps httprouter.Params) { -// w.Write([]byte(fmt.Sprintf("hello %s\n", ps.ByName("name")))) -// }) -// http.ListenAndServe(":8000", router) -// } +// router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { +// w.Write([]byte("welcome\n")) +// }) +// router.GET("/hello/:name", (w http.ResponseWriter, r *http.Request, ps httprouter.Params) { +// w.Write([]byte(fmt.Sprintf("hello %s\n", ps.ByName("name")))) +// }) +// http.ListenAndServe(":8000", router) +// } // // Runnable example: https://github.com/newrelic/go-agent/tree/master/v3/integrations/nrhttprouter/example/main.go package nrhttprouter @@ -84,6 +84,9 @@ func (r *Router) handle(method string, path string, original httprouter.Handle) } } r.Router.Handle(method, path, handle) + if newrelic.IsSecurityAgentPresent() { + newrelic.GetSecurityAgentInterface().SendEvent("API_END_POINTS", path, method, internal.HandlerName(original)) + } } // DELETE replaces httprouter.Router.DELETE. diff --git a/v3/integrations/nrlambda/go.mod b/v3/integrations/nrlambda/go.mod index e4ffb607b..534debcf6 100644 --- a/v3/integrations/nrlambda/go.mod +++ b/v3/integrations/nrlambda/go.mod @@ -1,10 +1,10 @@ module github.com/newrelic/go-agent/v3/integrations/nrlambda -go 1.19 +go 1.20 require ( github.com/aws/aws-lambda-go v1.41.0 - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 ) diff --git a/v3/integrations/nrlogrus/go.mod b/v3/integrations/nrlogrus/go.mod index dddba8e82..241faf5c1 100644 --- a/v3/integrations/nrlogrus/go.mod +++ b/v3/integrations/nrlogrus/go.mod @@ -2,10 +2,10 @@ 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.19 +go 1.20 require ( - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 github.com/newrelic/go-agent/v3/integrations/logcontext-v2/nrlogrus v1.0.0 // v1.1.0 is required for the Logger.GetLevel method, and is the earliest // version of logrus using modules. diff --git a/v3/integrations/nrlogxi/go.mod b/v3/integrations/nrlogxi/go.mod index 118d30cb4..c2632d57b 100644 --- a/v3/integrations/nrlogxi/go.mod +++ b/v3/integrations/nrlogxi/go.mod @@ -2,12 +2,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.19 +go 1.20 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.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 ) diff --git a/v3/integrations/nrmicro/go.mod b/v3/integrations/nrmicro/go.mod index d345b6d57..ee19c0d00 100644 --- a/v3/integrations/nrmicro/go.mod +++ b/v3/integrations/nrmicro/go.mod @@ -2,12 +2,12 @@ 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 +go 1.20 require ( github.com/golang/protobuf v1.5.4 github.com/micro/go-micro v1.8.0 - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 google.golang.org/protobuf v1.33.0 ) diff --git a/v3/integrations/nrmongo/go.mod b/v3/integrations/nrmongo/go.mod index 23103f360..078f8f0de 100644 --- a/v3/integrations/nrmongo/go.mod +++ b/v3/integrations/nrmongo/go.mod @@ -2,10 +2,10 @@ 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 +go 1.20 require ( - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 // mongo-driver does not support modules as of Nov 2019. go.mongodb.org/mongo-driver v1.10.2 ) diff --git a/v3/integrations/nrmssql/go.mod b/v3/integrations/nrmssql/go.mod index 77fb20cb9..dfd549cbc 100644 --- a/v3/integrations/nrmssql/go.mod +++ b/v3/integrations/nrmssql/go.mod @@ -1,10 +1,10 @@ module github.com/newrelic/go-agent/v3/integrations/nrmssql -go 1.19 +go 1.20 require ( github.com/microsoft/go-mssqldb v0.19.0 - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 ) diff --git a/v3/integrations/nrmysql/go.mod b/v3/integrations/nrmysql/go.mod index 674a4ec68..44514daa6 100644 --- a/v3/integrations/nrmysql/go.mod +++ b/v3/integrations/nrmysql/go.mod @@ -1,13 +1,13 @@ module github.com/newrelic/go-agent/v3/integrations/nrmysql // 1.10 is the Go version in mysql's go.mod -go 1.19 +go 1.20 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.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 ) diff --git a/v3/integrations/nrnats/go.mod b/v3/integrations/nrnats/go.mod index 380cdba69..56ea68997 100644 --- a/v3/integrations/nrnats/go.mod +++ b/v3/integrations/nrnats/go.mod @@ -2,12 +2,12 @@ module github.com/newrelic/go-agent/v3/integrations/nrnats // As of Jun 2023, 1.19 is the earliest version of Go tested by nats: // https://github.com/nats-io/nats.go/blob/master/.travis.yml -go 1.19 +go 1.20 require ( github.com/nats-io/nats-server v1.4.1 github.com/nats-io/nats.go v1.28.0 - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 ) diff --git a/v3/integrations/nrnats/test/go.mod b/v3/integrations/nrnats/test/go.mod index d390cbb67..7ae18f9c5 100644 --- a/v3/integrations/nrnats/test/go.mod +++ b/v3/integrations/nrnats/test/go.mod @@ -1,14 +1,14 @@ module github.com/newrelic/go-agent/v3/integrations/test // This module exists to avoid having extra nrnats module dependencies. -go 1.19 +go 1.20 replace github.com/newrelic/go-agent/v3/integrations/nrnats v1.0.0 => ../ require ( github.com/nats-io/nats-server v1.4.1 github.com/nats-io/nats.go v1.17.0 - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 github.com/newrelic/go-agent/v3/integrations/nrnats v1.0.0 ) diff --git a/v3/integrations/nropenai/LICENSE.txt b/v3/integrations/nropenai/LICENSE.txt new file mode 100644 index 000000000..cee548c2d --- /dev/null +++ b/v3/integrations/nropenai/LICENSE.txt @@ -0,0 +1,206 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +Versions 3.8.0 and above for this project are licensed under Apache 2.0. For +prior versions of this project, please see the LICENCE.txt file in the root +directory of that version for more information. diff --git a/v3/integrations/nropenai/go.mod b/v3/integrations/nropenai/go.mod index a434d09a9..ccb8a89cc 100644 --- a/v3/integrations/nropenai/go.mod +++ b/v3/integrations/nropenai/go.mod @@ -1,10 +1,10 @@ module github.com/newrelic/go-agent/v3/integrations/nropenai -go 1.19 +go 1.20 require ( github.com/google/uuid v1.6.0 - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 github.com/pkoukk/tiktoken-go v0.1.6 github.com/sashabaranov/go-openai v1.20.2 ) diff --git a/v3/integrations/nrpgx/example/sqlx/go.mod b/v3/integrations/nrpgx/example/sqlx/go.mod index 797b84d3e..777934c00 100644 --- a/v3/integrations/nrpgx/example/sqlx/go.mod +++ b/v3/integrations/nrpgx/example/sqlx/go.mod @@ -1,10 +1,10 @@ // This sqlx example is a separate module to avoid adding sqlx dependency to the // nrpgx go.mod file. module github.com/newrelic/go-agent/v3/integrations/nrpgx/example/sqlx -go 1.19 +go 1.20 require ( github.com/jmoiron/sqlx v1.2.0 - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 github.com/newrelic/go-agent/v3/integrations/nrpgx v0.0.0 ) replace github.com/newrelic/go-agent/v3/integrations/nrpgx => ../../ diff --git a/v3/integrations/nrpgx/go.mod b/v3/integrations/nrpgx/go.mod index 821dd13c5..0b1539aef 100644 --- a/v3/integrations/nrpgx/go.mod +++ b/v3/integrations/nrpgx/go.mod @@ -1,11 +1,11 @@ module github.com/newrelic/go-agent/v3/integrations/nrpgx -go 1.19 +go 1.20 require ( github.com/jackc/pgx v3.6.2+incompatible github.com/jackc/pgx/v4 v4.18.2 - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 ) diff --git a/v3/integrations/nrpgx5/example/pgxpool/main.go b/v3/integrations/nrpgx5/example/pgxpool/main.go index 8457a478d..f7eb38329 100644 --- a/v3/integrations/nrpgx5/example/pgxpool/main.go +++ b/v3/integrations/nrpgx5/example/pgxpool/main.go @@ -7,19 +7,28 @@ import ( "os" "time" + "github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5/pgxpool" "github.com/newrelic/go-agent/v3/integrations/nrpgx5" "github.com/newrelic/go-agent/v3/newrelic" ) -func main() { - cfg, err := pgxpool.ParseConfig("postgres://postgres:postgres@localhost:5432") +func NewPgxPool(ctx context.Context, dbURL string) (*pgxpool.Pool, error) { + cfg, err := pgxpool.ParseConfig(dbURL) if err != nil { - panic(err) + return nil, err + } + + cfg.BeforeConnect = func(_ context.Context, config *pgx.ConnConfig) error { + config.Tracer = nrpgx5.NewTracer() + return nil } - cfg.ConnConfig.Tracer = nrpgx5.NewTracer() - db, err := pgxpool.NewWithConfig(context.Background(), cfg) + return pgxpool.NewWithConfig(ctx, cfg) +} + +func main() { + db, err := NewPgxPool(context.Background(), "postgres://postgres:postgres@localhost:5432") if err != nil { panic(err) } diff --git a/v3/integrations/nrpgx5/go.mod b/v3/integrations/nrpgx5/go.mod index 9914ca701..3f7cb5026 100644 --- a/v3/integrations/nrpgx5/go.mod +++ b/v3/integrations/nrpgx5/go.mod @@ -1,11 +1,11 @@ module github.com/newrelic/go-agent/v3/integrations/nrpgx5 -go 1.19 +go 1.20 require ( github.com/egon12/pgsnap v0.0.0-20221022154027-2847f0124ed8 github.com/jackc/pgx/v5 v5.5.4 - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 github.com/stretchr/testify v1.8.1 ) diff --git a/v3/integrations/nrpkgerrors/go.mod b/v3/integrations/nrpkgerrors/go.mod index 7830f0065..b5d3022a3 100644 --- a/v3/integrations/nrpkgerrors/go.mod +++ b/v3/integrations/nrpkgerrors/go.mod @@ -2,10 +2,10 @@ 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.19 +go 1.20 require ( - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.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/example/sqlx/go.mod b/v3/integrations/nrpq/example/sqlx/go.mod index 43604e893..e41cddc77 100644 --- a/v3/integrations/nrpq/example/sqlx/go.mod +++ b/v3/integrations/nrpq/example/sqlx/go.mod @@ -1,11 +1,11 @@ // This sqlx example is a separate module to avoid adding sqlx dependency to the // nrpq go.mod file. module github.com/newrelic/go-agent/v3/integrations/nrpq/example/sqlx -go 1.19 +go 1.20 require ( github.com/jmoiron/sqlx v1.2.0 github.com/lib/pq v1.1.0 - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 github.com/newrelic/go-agent/v3/integrations/nrpq v0.0.0 ) replace github.com/newrelic/go-agent/v3/integrations/nrpq => ../../ diff --git a/v3/integrations/nrpq/go.mod b/v3/integrations/nrpq/go.mod index f2c639f4d..cf01efa1f 100644 --- a/v3/integrations/nrpq/go.mod +++ b/v3/integrations/nrpq/go.mod @@ -1,12 +1,12 @@ module github.com/newrelic/go-agent/v3/integrations/nrpq -go 1.19 +go 1.20 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.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 ) diff --git a/v3/integrations/nrredis-v7/go.mod b/v3/integrations/nrredis-v7/go.mod index 9879a1878..4483f63b0 100644 --- a/v3/integrations/nrredis-v7/go.mod +++ b/v3/integrations/nrredis-v7/go.mod @@ -1,11 +1,11 @@ module github.com/newrelic/go-agent/v3/integrations/nrredis-v7 // https://github.com/go-redis/redis/blob/master/go.mod -go 1.19 +go 1.20 require ( github.com/go-redis/redis/v7 v7.0.0-beta.5 - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 ) diff --git a/v3/integrations/nrredis-v8/go.mod b/v3/integrations/nrredis-v8/go.mod index 30b446fdb..bcc60d118 100644 --- a/v3/integrations/nrredis-v8/go.mod +++ b/v3/integrations/nrredis-v8/go.mod @@ -1,11 +1,11 @@ module github.com/newrelic/go-agent/v3/integrations/nrredis-v8 // https://github.com/go-redis/redis/blob/master/go.mod -go 1.19 +go 1.20 require ( github.com/go-redis/redis/v8 v8.4.0 - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 ) diff --git a/v3/integrations/nrredis-v9/go.mod b/v3/integrations/nrredis-v9/go.mod index bd52c7fb3..7e58a6341 100644 --- a/v3/integrations/nrredis-v9/go.mod +++ b/v3/integrations/nrredis-v9/go.mod @@ -1,10 +1,10 @@ module github.com/newrelic/go-agent/v3/integrations/nrredis-v9 // https://github.com/redis/go-redis/blob/a38f75b640398bd709ee46c778a23e80e09d48b5/go.mod#L3 -go 1.19 +go 1.20 require ( - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.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 b3fe4825e..627c0e17d 100644 --- a/v3/integrations/nrsarama/go.mod +++ b/v3/integrations/nrsarama/go.mod @@ -1,10 +1,10 @@ module github.com/newrelic/go-agent/v3/integrations/nrsarama -go 1.19 +go 1.20 require ( github.com/Shopify/sarama v1.38.1 - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 github.com/stretchr/testify v1.8.1 ) diff --git a/v3/integrations/nrsecurityagent/go.mod b/v3/integrations/nrsecurityagent/go.mod index 8e419fe8d..321e774b6 100644 --- a/v3/integrations/nrsecurityagent/go.mod +++ b/v3/integrations/nrsecurityagent/go.mod @@ -1,10 +1,10 @@ module github.com/newrelic/go-agent/v3/integrations/nrsecurityagent -go 1.19 +go 1.20 require ( - github.com/newrelic/csec-go-agent v1.0.0 - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/csec-go-agent v1.1.0 + github.com/newrelic/go-agent/v3 v3.32.0 github.com/newrelic/go-agent/v3/integrations/nrsqlite3 v1.2.0 gopkg.in/yaml.v2 v2.4.0 ) diff --git a/v3/integrations/nrsnowflake/go.mod b/v3/integrations/nrsnowflake/go.mod index 3b58181da..b2e7f4b5c 100644 --- a/v3/integrations/nrsnowflake/go.mod +++ b/v3/integrations/nrsnowflake/go.mod @@ -1,9 +1,9 @@ module github.com/newrelic/go-agent/v3/integrations/nrsnowflake -go 1.19 +go 1.20 require ( - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 github.com/snowflakedb/gosnowflake v1.6.19 ) diff --git a/v3/integrations/nrsqlite3/go.mod b/v3/integrations/nrsqlite3/go.mod index c930c0569..3a6eddb79 100644 --- a/v3/integrations/nrsqlite3/go.mod +++ b/v3/integrations/nrsqlite3/go.mod @@ -2,12 +2,12 @@ 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.19 +go 1.20 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.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 ) diff --git a/v3/integrations/nrstan/examples/go.mod b/v3/integrations/nrstan/examples/go.mod index a698c1873..f57e435b4 100644 --- a/v3/integrations/nrstan/examples/go.mod +++ b/v3/integrations/nrstan/examples/go.mod @@ -1,9 +1,9 @@ module github.com/newrelic/go-agent/v3/integrations/nrstan/examples // This module exists to avoid a dependency on nrnrats. -go 1.19 +go 1.20 require ( github.com/nats-io/stan.go v0.5.0 - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 github.com/newrelic/go-agent/v3/integrations/nrnats v0.0.0 github.com/newrelic/go-agent/v3/integrations/nrstan v0.0.0 ) diff --git a/v3/integrations/nrstan/go.mod b/v3/integrations/nrstan/go.mod index af124b900..aa283ea2e 100644 --- a/v3/integrations/nrstan/go.mod +++ b/v3/integrations/nrstan/go.mod @@ -2,11 +2,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.19 +go 1.20 require ( github.com/nats-io/stan.go v0.10.4 - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 ) diff --git a/v3/integrations/nrstan/test/go.mod b/v3/integrations/nrstan/test/go.mod index 2c6f47a70..4708789e9 100644 --- a/v3/integrations/nrstan/test/go.mod +++ b/v3/integrations/nrstan/test/go.mod @@ -2,12 +2,12 @@ module github.com/newrelic/go-agent/v3/integrations/nrstan/test // This module exists to avoid a dependency on // github.com/nats-io/nats-streaming-server in nrstan. -go 1.19 +go 1.20 require ( github.com/nats-io/nats-streaming-server v0.25.6 github.com/nats-io/stan.go v0.10.4 - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 github.com/newrelic/go-agent/v3/integrations/nrstan v0.0.0 ) diff --git a/v3/integrations/nrzap/go.mod b/v3/integrations/nrzap/go.mod index e4bf61761..f3f0b26d9 100644 --- a/v3/integrations/nrzap/go.mod +++ b/v3/integrations/nrzap/go.mod @@ -2,10 +2,10 @@ 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.19 +go 1.20 require ( - github.com/newrelic/go-agent/v3 v3.31.0 + github.com/newrelic/go-agent/v3 v3.32.0 // v1.12.0 is the earliest version of zap using modules. go.uber.org/zap v1.12.0 ) diff --git a/v3/internal/utilities.go b/v3/internal/utilities.go index e6c78e5ca..d57538b9a 100644 --- a/v3/internal/utilities.go +++ b/v3/internal/utilities.go @@ -7,6 +7,8 @@ import ( "bytes" "encoding/json" "fmt" + "reflect" + "runtime" "time" ) @@ -26,3 +28,17 @@ func CompactJSONString(js string) string { } return buf.String() } + +// HandlerName return name of a function. +func HandlerName(h interface{}) string { + if h == nil { + return "" + } + t := reflect.ValueOf(h).Type() + if t.Kind() == reflect.Func { + if pointer := runtime.FuncForPC(reflect.ValueOf(h).Pointer()); pointer != nil { + return pointer.Name() + } + } + return "" +} diff --git a/v3/newrelic/instrumentation.go b/v3/newrelic/instrumentation.go index d0ffd7379..b58db6ccc 100644 --- a/v3/newrelic/instrumentation.go +++ b/v3/newrelic/instrumentation.go @@ -5,6 +5,8 @@ package newrelic import ( "net/http" + + "github.com/newrelic/go-agent/v3/internal" ) // instrumentation.go contains helpers built on the lower level api. @@ -42,6 +44,10 @@ func WrapHandle(app *Application, pattern string, handler http.Handler, options // specify a different code location explicitly). cache := NewCachedCodeLocation() + if IsSecurityAgentPresent() { + secureAgent.SendEvent("API_END_POINTS", pattern, "*", internal.HandlerName(handler)) + } + return pattern, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { var tOptions *traceOptSet var txnOptionList []TraceOption diff --git a/v3/newrelic/internal_txn_test.go b/v3/newrelic/internal_txn_test.go index c9ef3a298..bbe42c9d0 100644 --- a/v3/newrelic/internal_txn_test.go +++ b/v3/newrelic/internal_txn_test.go @@ -587,6 +587,26 @@ func TestGetName(t *testing.T) { } } +func TestIgnoreTransaction(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") + txn.Ignore() + txn.SetName("hello世界") + txn.NoticeError(errors.New("hi")) + txn.End() + + app.ExpectTxnTraces(t, []internal.WantTxnTrace{}) +} + func TestEmptyTransaction(t *testing.T) { txn := &Transaction{} diff --git a/v3/newrelic/secure_agent.go b/v3/newrelic/secure_agent.go index 6c0057c10..ae0ce723f 100644 --- a/v3/newrelic/secure_agent.go +++ b/v3/newrelic/secure_agent.go @@ -10,7 +10,7 @@ import ( // calls in this case, effectively removing the hooks from the running agent. // // If the nrsecureagent integration was initialized, it will register a real securityAgent -// value in the securityAgent varialble instead, thus "activating" the hooks. +// value in the securityAgent variable instead, thus "activating" the hooks. var secureAgent securityAgent = noOpSecurityAgent{} // GetSecurityAgentInterface returns the securityAgent value @@ -20,7 +20,7 @@ var secureAgent securityAgent = noOpSecurityAgent{} // // Packages which need to make calls to secureAgent's methods // may obtain the secureAgent value by calling this function. -// This avoids exposing the variable itself so it's not +// This avoids exposing the variable itself, so it's not // writable externally and also sets up for the future if this // ends up not being a global variable later. func GetSecurityAgentInterface() securityAgent { diff --git a/v3/newrelic/version.go b/v3/newrelic/version.go index 4a34de8eb..53df4c5bd 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.31.0" + Version = "3.32.0" ) var (