From b6709ab89285c12475913efc6b781c668517a3ab Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 05:40:20 +0000 Subject: [PATCH] Bump github.com/newrelic/go-agent/v3 from 3.30.0 to 3.31.0 Bumps [github.com/newrelic/go-agent/v3](https://github.com/newrelic/go-agent) from 3.30.0 to 3.31.0. - [Release notes](https://github.com/newrelic/go-agent/releases) - [Changelog](https://github.com/newrelic/go-agent/blob/master/CHANGELOG.md) - [Commits](https://github.com/newrelic/go-agent/compare/v3.30.0...v3.31.0) --- updated-dependencies: - dependency-name: github.com/newrelic/go-agent/v3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 19 ++++- .../v3/internal/utilization/addresses.go | 4 +- .../go-agent/v3/newrelic/application.go | 84 ++++++++++++++++++- .../go-agent/v3/newrelic/attributes.go | 2 + .../v3/newrelic/attributes_from_internal.go | 31 +++++++ .../newrelic/go-agent/v3/newrelic/config.go | 14 ++++ .../go-agent/v3/newrelic/config_options.go | 28 +++++++ .../go-agent/v3/newrelic/custom_event.go | 26 ++++++ .../go-agent/v3/newrelic/internal_app.go | 13 ++- .../newrelic/go-agent/v3/newrelic/version.go | 2 +- vendor/modules.txt | 2 +- 12 files changed, 218 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index afcbe023..8cdd8685 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/golang-jwt/jwt/v4 v4.5.0 github.com/golang/mock v1.6.0 github.com/lib/pq v1.10.9 - github.com/newrelic/go-agent/v3 v3.30.0 + github.com/newrelic/go-agent/v3 v3.31.0 github.com/stretchr/testify v1.9.0 github.com/twinj/uuid v1.0.0 golang.org/x/crypto v0.21.0 diff --git a/go.sum b/go.sum index ad8b39c8..ebe9b801 100644 --- a/go.sum +++ b/go.sum @@ -845,8 +845,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/myesui/uuid v1.0.0 h1:xCBmH4l5KuvLYc5L7AS7SZg9/jKdIFubM7OVoLqaQUI= github.com/myesui/uuid v1.0.0/go.mod h1:2CDfNgU0LR8mIdO8vdWd8i9gWWxLlcoIGGpSNgafq84= -github.com/newrelic/go-agent/v3 v3.30.0 h1:ZXHCT/Cot4iIPwcegCZURuRQOsfmGA6wilW+S3bfBjY= -github.com/newrelic/go-agent/v3 v3.30.0/go.mod h1:9utrgxlSryNqRrTvII2XBL+0lpofXbqXApvVWPpbzUg= +github.com/newrelic/go-agent/v3 v3.31.0 h1:MVZA93FO6IEybg5EZUcOHUoDg5oBFuy8nrUIa2hfd8M= +github.com/newrelic/go-agent/v3 v3.31.0/go.mod h1:MnbPbcIAmtKH80ZRXovE9kQLDs0Nc32IQa7bWydDKsk= github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= @@ -933,6 +933,7 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= +golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= @@ -952,6 +953,7 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20220827204233-334a2380cb91/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= +golang.org/x/exp v0.0.0-20240318143956-a85f2c67cd81/go.mod h1:CQ1k9gNrJ50XIzaKCRR2hssIjF07kZFEiieALBM/ARQ= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -994,6 +996,9 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91 golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1052,9 +1057,12 @@ golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1100,6 +1108,8 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1179,10 +1189,12 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= @@ -1192,6 +1204,7 @@ golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= @@ -1281,6 +1294,8 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= +golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/vendor/github.com/newrelic/go-agent/v3/internal/utilization/addresses.go b/vendor/github.com/newrelic/go-agent/v3/internal/utilization/addresses.go index 791b5272..aa2e7268 100644 --- a/vendor/github.com/newrelic/go-agent/v3/internal/utilization/addresses.go +++ b/vendor/github.com/newrelic/go-agent/v3/internal/utilization/addresses.go @@ -47,8 +47,8 @@ func nonlocalIPAddressesByInterface() (map[string][]string, error) { // * The UDP connection interface is more likely to contain unique external IPs. func utilizationIPs() ([]string, error) { // Port choice designed to match - // https://source.datanerd.us/java-agent/java_agent/blob/master/newrelic-agent/src/main/java/com/newrelic/agent/config/Hostname.java#L110 - conn, err := net.Dial("udp", "newrelic.com:10002") + // https://github.com/newrelic/newrelic-java-agent/blob/main/newrelic-agent/src/main/java/com/newrelic/agent/config/Hostname.java#L120 + conn, err := net.Dial("udp", "collector.newrelic.com:10002") if err != nil { return nil, err } diff --git a/vendor/github.com/newrelic/go-agent/v3/newrelic/application.go b/vendor/github.com/newrelic/go-agent/v3/newrelic/application.go index 0249c738..d1ec4994 100644 --- a/vendor/github.com/newrelic/go-agent/v3/newrelic/application.go +++ b/vendor/github.com/newrelic/go-agent/v3/newrelic/application.go @@ -15,6 +15,26 @@ type Application struct { app *app } +/* +// IsAIMonitoringEnabled returns true if monitoring for the specified mode of the named integration is enabled. +func (app *Application) IsAIMonitoringEnabled(integration string, streaming bool) bool { + if app == nil || app.app == nil || app.app.run == nil { + return false + } + aiconf := app.app.run.Config.AIMonitoring + if !aiconf.Enabled { + return false + } + if aiconf.IncludeOnly != nil && integration != "" && !slices.Contains(aiconf.IncludeOnly, integration) { + return false + } + if streaming && !aiconf.Streaming { + return false + } + return true +} +*/ + // StartTransaction begins a Transaction with the given name. func (app *Application) StartTransaction(name string, opts ...TraceOption) *Transaction { if app == nil { @@ -48,6 +68,69 @@ func (app *Application) RecordCustomEvent(eventType string, params map[string]in } } +// RecordLLMFeedbackEvent adds a LLM Feedback event. +// An error is logged if eventType or params is invalid. +func (app *Application) RecordLLMFeedbackEvent(trace_id string, rating any, category string, message string, metadata map[string]interface{}) { + if app == nil || app.app == nil { + return + } + CustomEventData := map[string]interface{}{ + "trace_id": trace_id, + "rating": rating, + "category": category, + "message": message, + "ingest_source": "Go", + } + for k, v := range metadata { + CustomEventData[k] = v + } + // if rating is an int or string, record the event + err := app.app.RecordCustomEvent("LlmFeedbackMessage", CustomEventData) + if err != nil { + app.app.Error("unable to record custom event", map[string]interface{}{ + "event-type": "LlmFeedbackMessage", + "reason": err.Error(), + }) + } +} + +// InvokeLLMTokenCountCallback invokes the function registered previously as the callback +// function to compute token counts to report for LLM transactions, if any. If there is +// no current callback funtion, this simply returns a zero count and a false boolean value. +// Otherwise, it returns the value returned by the callback and a true value. +// +// Although there's no harm in calling this method to invoke your callback function, +// there is no need (or particular benefit) of doing so. This is called as needed internally +// by the AI Monitoring integrations. +func (app *Application) InvokeLLMTokenCountCallback(model, content string) (int, bool) { + if app == nil || app.app == nil || app.app.llmTokenCountCallback == nil { + return 0, false + } + return app.app.llmTokenCountCallback(model, content), true +} + +// HasLLMTokenCountCallback returns true if there is currently a registered callback function +// or false otherwise. +func (app *Application) HasLLMTokenCountCallback() bool { + return app != nil && app.app != nil && app.app.llmTokenCountCallback != nil +} + +// SetLLMTokenCountCallback registers a callback function which will be used by the AI Montoring +// integration packages in cases where they are unable to determine the token counts directly. +// You may call SetLLMTokenCountCallback multiple times. If you do, each call registers a new +// callback function which replaces the previous one. Calling SetLLMTokenCountCallback(nil) removes +// the callback function entirely. +// +// Your callback function will be passed two string parameters: model name and content. It must +// return a single integer value which is the number of tokens to report. If it returns a value less +// than or equal to zero, no token count report will be made (which includes the case where your +// callback function was unable to determine the token count). +func (app *Application) SetLLMTokenCountCallback(callbackFunction func(string, string) int) { + if app != nil && app.app != nil { + app.app.llmTokenCountCallback = callbackFunction + } +} + // RecordCustomMetric records a custom metric. The metric name you // provide will be prefixed by "Custom/". Custom metrics are not // currently supported in serverless mode. @@ -136,7 +219,6 @@ func (app *Application) Shutdown(timeout time.Duration) { // a boolean true value is returned as the second return value. If it is // false, then the Config data returned is the standard default configuration. // This usually occurs if the Application is not yet fully initialized. -// func (app *Application) Config() (Config, bool) { if app == nil || app.app == nil { return defaultConfig(), false diff --git a/vendor/github.com/newrelic/go-agent/v3/newrelic/attributes.go b/vendor/github.com/newrelic/go-agent/v3/newrelic/attributes.go index 0221b579..2fd2f8d0 100644 --- a/vendor/github.com/newrelic/go-agent/v3/newrelic/attributes.go +++ b/vendor/github.com/newrelic/go-agent/v3/newrelic/attributes.go @@ -56,6 +56,8 @@ const ( AttributeErrorGroupName = "error.group.name" // AttributeUserID tracks the user a transaction and its child events are impacting AttributeUserID = "enduser.id" + // AttributeLLM tracks LLM transactions + AttributeLLM = "llm" ) // Attributes destined for Errors and Transaction Traces: diff --git a/vendor/github.com/newrelic/go-agent/v3/newrelic/attributes_from_internal.go b/vendor/github.com/newrelic/go-agent/v3/newrelic/attributes_from_internal.go index 64012b93..fca46d9c 100644 --- a/vendor/github.com/newrelic/go-agent/v3/newrelic/attributes_from_internal.go +++ b/vendor/github.com/newrelic/go-agent/v3/newrelic/attributes_from_internal.go @@ -58,6 +58,7 @@ var ( AttributeCodeFilepath: usualDests, AttributeCodeLineno: usualDests, AttributeUserID: usualDests, + AttributeLLM: usualDests, // Span specific attributes SpanAttributeDBStatement: usualDests, @@ -382,6 +383,36 @@ func validateUserAttribute(key string, val interface{}) (interface{}, error) { return val, nil } +// validateUserAttributeUnlimitedSize validates a user attribute without truncating string values. +func validateUserAttributeUnlimitedSize(key string, val interface{}) (interface{}, error) { + switch v := val.(type) { + case string, bool, + uint8, uint16, uint32, uint64, int8, int16, int32, int64, + uint, int, uintptr: + case float32: + if err := validateFloat(float64(v), key); err != nil { + return nil, err + } + case float64: + if err := validateFloat(v, key); err != nil { + return nil, err + } + default: + return nil, errInvalidAttributeType{ + key: key, + val: val, + } + } + + // Attributes whose keys are excessively long are dropped rather than + // truncated to avoid worrying about the application of configuration to + // truncated values or performing the truncation after configuration. + if len(key) > attributeKeyLengthLimit { + return nil, invalidAttributeKeyErr{key: key} + } + return val, nil +} + func validateFloat(v float64, key string) error { if math.IsInf(v, 0) || math.IsNaN(v) { return invalidFloatAttrValue{ diff --git a/vendor/github.com/newrelic/go-agent/v3/newrelic/config.go b/vendor/github.com/newrelic/go-agent/v3/newrelic/config.go index 5d79bf8f..d0461ca1 100644 --- a/vendor/github.com/newrelic/go-agent/v3/newrelic/config.go +++ b/vendor/github.com/newrelic/go-agent/v3/newrelic/config.go @@ -235,6 +235,17 @@ type Config struct { DynoNamePrefixesToShorten []string } + // AIMonitoring controls the behavior of AI monitoring features. + AIMonitoring struct { + Enabled bool + // Indicates whether streams will be instrumented + Streaming struct { + Enabled bool + } + RecordContent struct { + Enabled bool + } + } // CrossApplicationTracer controls behavior relating to cross application // tracing (CAT). In the case where CrossApplicationTracer and // DistributedTracer are both enabled, DistributedTracer takes precedence. @@ -667,6 +678,9 @@ func defaultConfig() Config { c.Heroku.UseDynoNames = true c.Heroku.DynoNamePrefixesToShorten = []string{"scheduler", "run"} + c.AIMonitoring.Enabled = false + c.AIMonitoring.Streaming.Enabled = true + c.AIMonitoring.RecordContent.Enabled = true c.InfiniteTracing.TraceObserver.Port = 443 c.InfiniteTracing.SpanEvents.QueueSize = 10000 diff --git a/vendor/github.com/newrelic/go-agent/v3/newrelic/config_options.go b/vendor/github.com/newrelic/go-agent/v3/newrelic/config_options.go index 5b9261e1..082b46d8 100644 --- a/vendor/github.com/newrelic/go-agent/v3/newrelic/config_options.go +++ b/vendor/github.com/newrelic/go-agent/v3/newrelic/config_options.go @@ -60,6 +60,13 @@ func ConfigDistributedTracerReservoirLimit(limit int) ConfigOption { return func(cfg *Config) { cfg.DistributedTracer.ReservoirLimit = limit } } +// ConfigAIMonitoringStreamingEnabled turns on or off the collection of AI Monitoring streaming mode metrics. +func ConfigAIMonitoringStreamingEnabled(enabled bool) ConfigOption { + return func(cfg *Config) { + cfg.AIMonitoring.Streaming.Enabled = enabled + } +} + // ConfigCodeLevelMetricsEnabled turns on or off the collection of code // level metrics entirely. func ConfigCodeLevelMetricsEnabled(enabled bool) ConfigOption { @@ -236,6 +243,21 @@ func ConfigAppLogDecoratingEnabled(enabled bool) ConfigOption { } } +// ConfigAIMonitoringEnabled enables or disables the collection of AI Monitoring event data. +func ConfigAIMonitoringEnabled(enabled bool) ConfigOption { + return func(cfg *Config) { + cfg.AIMonitoring.Enabled = enabled + } +} + +// ConfigAIMonitoringRecordContentEnabled enables or disables the collection of the prompt and +// response data along with other AI event metadata. +func ConfigAIMonitoringRecordContentEnabled(enabled bool) ConfigOption { + return func(cfg *Config) { + cfg.AIMonitoring.RecordContent.Enabled = enabled + } +} + // ConfigAppLogMetricsEnabled enables or disables the collection of metrics // data for logs seen by an instrumented logging framework // default: true @@ -363,6 +385,9 @@ func ConfigDebugLogger(w io.Writer) ConfigOption { // NEW_RELIC_APPLICATION_LOGGING_METRICS_ENABLED sets ApplicationLogging.Metrics.Enabled. Set to false to disable the collection of application log metrics. // NEW_RELIC_APPLICATION_LOGGING_LOCAL_DECORATING_ENABLED sets ApplicationLogging.LocalDecoration.Enabled. Set to true to enable local log decoration. // NEW_RELIC_APPLICATION_LOGGING_FORWARDING_MAX_SAMPLES_STORED sets ApplicationLogging.LogForwarding.Limit. Set to 0 to prevent captured logs from being forwarded. +// NEW_RELIC_AI_MONITORING_ENABLED sets AIMonitoring.Enabled +// NEW_RELIC_AI_MONITORING_STREAMING_ENABLED sets AIMonitoring.Streaming.Enabled +// NEW_RELIC_AI_MONITORING_RECORD_CONTENT_ENABLED sets AIMonitoring.RecordContent.Enabled // // This function is strict and will assign Config.Error if any of the // environment variables cannot be parsed. @@ -426,6 +451,9 @@ func configFromEnvironment(getenv func(string) string) ConfigOption { assignInt(&cfg.ApplicationLogging.Forwarding.MaxSamplesStored, "NEW_RELIC_APPLICATION_LOGGING_FORWARDING_MAX_SAMPLES_STORED") assignBool(&cfg.ApplicationLogging.Metrics.Enabled, "NEW_RELIC_APPLICATION_LOGGING_METRICS_ENABLED") assignBool(&cfg.ApplicationLogging.LocalDecorating.Enabled, "NEW_RELIC_APPLICATION_LOGGING_LOCAL_DECORATING_ENABLED") + assignBool(&cfg.AIMonitoring.Enabled, "NEW_RELIC_AI_MONITORING_ENABLED") + assignBool(&cfg.AIMonitoring.Streaming.Enabled, "NEW_RELIC_AI_MONITORING_STREAMING_ENABLED") + assignBool(&cfg.AIMonitoring.RecordContent.Enabled, "NEW_RELIC_AI_MONITORING_RECORD_CONTENT_ENABLED") if env := getenv("NEW_RELIC_LABELS"); env != "" { if labels := getLabels(getenv("NEW_RELIC_LABELS")); len(labels) > 0 { diff --git a/vendor/github.com/newrelic/go-agent/v3/newrelic/custom_event.go b/vendor/github.com/newrelic/go-agent/v3/newrelic/custom_event.go index a1aacb8f..80aa0881 100644 --- a/vendor/github.com/newrelic/go-agent/v3/newrelic/custom_event.go +++ b/vendor/github.com/newrelic/go-agent/v3/newrelic/custom_event.go @@ -100,6 +100,32 @@ func createCustomEvent(eventType string, params map[string]interface{}, now time }, nil } +// CreateCustomEventUnlimitedSize creates a custom event without restricting string value length. +func createCustomEventUnlimitedSize(eventType string, params map[string]interface{}, now time.Time) (*customEvent, error) { + if err := eventTypeValidate(eventType); err != nil { + return nil, err + } + + if len(params) > customEventAttributeLimit { + return nil, errNumAttributes + } + + truncatedParams := make(map[string]interface{}) + for key, val := range params { + val, err := validateUserAttributeUnlimitedSize(key, val) + if err != nil { + return nil, err + } + truncatedParams[key] = val + } + + return &customEvent{ + eventType: eventType, + timestamp: now, + truncatedParams: truncatedParams, + }, nil +} + // MergeIntoHarvest implements Harvestable. func (e *customEvent) MergeIntoHarvest(h *harvest) { h.CustomEvents.Add(e) diff --git a/vendor/github.com/newrelic/go-agent/v3/newrelic/internal_app.go b/vendor/github.com/newrelic/go-agent/v3/newrelic/internal_app.go index 3b0d55f3..b85365a8 100644 --- a/vendor/github.com/newrelic/go-agent/v3/newrelic/internal_app.go +++ b/vendor/github.com/newrelic/go-agent/v3/newrelic/internal_app.go @@ -63,6 +63,9 @@ type app struct { // (disconnect, license exception, shutdown). err error + // registered callback functions + llmTokenCountCallback func(string, string) int + serverless *serverlessHarvest } @@ -542,9 +545,13 @@ var ( // RecordCustomEvent implements newrelic.Application's RecordCustomEvent. func (app *app) RecordCustomEvent(eventType string, params map[string]interface{}) error { + var event *customEvent + var e error + if nil == app { return nil } + if app.config.Config.HighSecurity { return errHighSecurityEnabled } @@ -553,7 +560,11 @@ func (app *app) RecordCustomEvent(eventType string, params map[string]interface{ return errCustomEventsDisabled } - event, e := createCustomEvent(eventType, params, time.Now()) + if eventType == "LlmEmbedding" || eventType == "LlmChatCompletionSummary" || eventType == "LlmChatCompletionMessage" { + event, e = createCustomEventUnlimitedSize(eventType, params, time.Now()) + } else { + event, e = createCustomEvent(eventType, params, time.Now()) + } if nil != e { return e } diff --git a/vendor/github.com/newrelic/go-agent/v3/newrelic/version.go b/vendor/github.com/newrelic/go-agent/v3/newrelic/version.go index 5e1658b1..4a34de8e 100644 --- a/vendor/github.com/newrelic/go-agent/v3/newrelic/version.go +++ b/vendor/github.com/newrelic/go-agent/v3/newrelic/version.go @@ -11,7 +11,7 @@ import ( const ( // Version is the full string version of this Go Agent. - Version = "3.30.0" + Version = "3.31.0" ) var ( diff --git a/vendor/modules.txt b/vendor/modules.txt index 5ce7034d..d45e857b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -104,7 +104,7 @@ github.com/modern-go/concurrent github.com/modern-go/reflect2 # github.com/myesui/uuid v1.0.0 ## explicit -# github.com/newrelic/go-agent/v3 v3.30.0 +# github.com/newrelic/go-agent/v3 v3.31.0 ## explicit; go 1.19 github.com/newrelic/go-agent/v3/internal github.com/newrelic/go-agent/v3/internal/cat