2.6.0
New Features
Added support for async: the ability to instrument multiple concurrent goroutines, or goroutines that access or manipulate the same Transaction.
The new
Transaction.NewGoroutine() Transactionmethod allows transactions to create segments in multiple goroutines!NewGoroutinereturns a new reference to theTransaction. This must be called any time you are passing theTransactionto another goroutine which makes segments. Each segment-creating goroutine must have its ownTransactionreference. It does not matter if you call this before or after the other goroutine has started.All
Transactionmethods can be used in anyTransactionreference. TheTransactionwill end whenEnd()is called in any goroutine.Example passing a new
Transactionreference directly to another goroutine:go func(txn newrelic.Transaction) {defer newrelic.StartSegment(txn, "async").End()time.Sleep(100 * time.Millisecond)}(txn.NewGoroutine())Example passing a new
Transactionreference on a channel to another goroutine:ch := make(chan newrelic.Transaction)go func() {txn := <-chdefer newrelic.StartSegment(txn, "async").End()time.Sleep(100 * time.Millisecond)}()ch <- txn.NewGoroutine()Added integration support for
aws-sdk-goandaws-sdk-go-v2.When using these SDKs, a segment will be created for each out going request. For DynamoDB calls, these will be Datastore segments and for all others they will be External segments.
- v1 Documentation
- v2 Documentation
- Added span event and transaction trace segment attribute configuration. You may control which attributes are captured in span events and transaction trace segments using the
Config.SpanEvents.AttributesandConfig.TransactionTracer.Segments.Attributessettings. For example, if you want to disable the collection of"db.statement"in your span events, modify your config like this:
cfg.SpanEvents.Attributes.Exclude = append(cfg.SpanEvents.Attributes.Exclude,newrelic.SpanAttributeDBStatement)To disable the collection of all attributes from your transaction trace segments, modify your config like this:
cfg.TransactionTracer.Segments.Attributes.Enabled = false
Bug Fixes
- Fixed a bug that would prevent External Segments from being created under certain error conditions related to Cross Application Tracing.
Miscellaneous
Improved linking between Cross Application Transaction Traces in the APM UI. When
Config.CrossApplicationTracer.Enabled = true, External segments in the Transaction Traces details will now link to the downstream Transaction Trace if there is one. Additionally, the segment name will now include the name of the downstream application and the name of the downstream transaction.Update attribute names of Datastore and External segments on Transaction Traces to be in line with attribute names on Spans. Specifically:
"uri"=>"http.url""query"=>"db.statement""database_name"=>"db.instance""host"=>"peer.hostname""port_path_or_id"+"host"=>"peer.address"
2.5.0
- Added support for New Relic Browser using the new
BrowserTimingHeadermethod on theTransactionwhich returns a BrowserTimingHeader. The New Relic Browser JavaScript code measures page load timing, also known as real user monitoring. The Pro version of this feature measures AJAX requests, single-page applications, JavaScript errors, and much more! Example use:
func browser(w http.ResponseWriter, r *http.Request) { hdr, err := w.(newrelic.Transaction).BrowserTimingHeader() if nil != err { log.Printf("unable to create browser timing header: %v", err) } // BrowserTimingHeader() will always return a header whose methods can // be safely called. if js := hdr.WithTags(); js != nil { w.Write(js) } io.WriteString(w, "browser header page")}- The Go agent now collects an attribute named
request.urion Transaction Traces, Transaction Events, Error Traces, and Error Events.request.uriwill never contain user, password, query parameters, or fragment. To prevent the request's URL from being collected in any data, modify yourConfiglike this:
cfg.Attributes.Exclude = append(cfg.Attributes.Exclude, newrelic.AttributeRequestURI)2.4.0 Notes
- Introduced
Transaction.Applicationmethod which returns theApplicationthat started theTransaction. This method is useful since it may prevent having to pass theApplicationto code that already has access to theTransaction. Example use:
txn.Application().RecordCustomEvent("customerOrder", map[string]interface{}{ "numItems": 2, "totalPrice": 13.75,})- The
Transaction.AddAttributemethod no longer acceptsnilvalues since our backend ignores them.
2.3.0 Notes
Added support for Echo in the new
nrechopackage.Introduced
Transaction.SetWebResponse(http.ResponseWriter)method which sets the transaction's response writer. After calling this method, theTransactionmay be used in place of thehttp.ResponseWriterto intercept the response code. This method is useful when thehttp.ResponseWriteris not available at the beginning of the transaction (if so, it can be given as a parameter toApplication.StartTransaction). This method will return a reference to the transaction which implements the combination ofhttp.CloseNotifier,http.Flusher,http.Hijacker, andio.ReaderFromimplemented by the ResponseWriter. Example:
func setResponseDemo(txn newrelic.Transaction) { recorder := httptest.NewRecorder() txn = txn.SetWebResponse(recorder) txn.WriteHeader(200) fmt.Println("response code recorded:", recorder.Code)}- The
Transaction'shttp.ResponseWritermethods may now be called safely if ahttp.ResponseWriterhas not been set. This allows you to add a response code to the transaction without using ahttp.ResponseWriter. Example:
func transactionWithResponseCode(app newrelic.Application) { txn := app.StartTransaction("hasResponseCode", nil, nil) defer txn.End() txn.WriteHeader(200) // Safe!}- The agent will now collect environment variables prefixed by
NEW_RELIC_METADATA_andKUBERNETES_SERVICE_HOST. These will be added to Transaction events to provide context between your Kubernetes cluster and your services. For details on the benefits (currently in beta) see this blog post - The agent now collects the fully qualified domain name of the host and local IP addresses for improved linking with our Infrastructure product.
2.2 Notes
- The
Transactionparameter to NewRoundTripper and StartExternalSegment is now optional: If it isnil, then aTransactionwill be looked for in the request's context (using FromContext). Passing aniltransaction is STRONGLY recommended when using NewRoundTripper since it allows onehttp.Client.Transportto be used for multiple transactions. Example use:
client := &http.Client{}client.Transport = newrelic.NewRoundTripper(nil, client.Transport)request, _ := http.NewRequest("GET", "http://example.com", nil)request = newrelic.RequestWithTransactionContext(request, txn)resp, err := client.Do(request)- Introduced
Transaction.SetWebRequest(WebRequest)method which marks the transaction as a web transaction. If theWebRequestparameter is non-nil,SetWebRequestwill collect details on request attributes, url, and method. This method is useful if you don't have access to the request at the beginning of the transaction, or if your request is not an*http.Request(just add methods to your request that satisfy WebRequest). To use an*http.Requestas the parameter, use the NewWebRequest transformation function. Example:
var request *http.Request = getInboundRequest()txn.SetWebRequest(newrelic.NewWebRequest(request))- Fixed
Debuginnrlogruspackage. Previous versions of the New Relic Go Agent incorrectly logged to Info level instead of Debug. This has now been fixed. Thanks to @paddycarey for catching this. - nrgin.Transaction may now be called with either a
context.Contextor a*gin.Context. If you were passing a*gin.Contextaround your functions as acontext.Context, you may access the Transaction by calling either nrgin.Transaction or FromContext. These functions now work nicely together. For example, FromContext will return theTransactionadded by nrgin.Middleware. Thanks to @rodriguezgustavo for the suggestion.
2.1.0 New
Go Agent now supports distributed tracing
Distributed tracing lets you see the path that a request takes as it travels through your distributed system. By showing the distributed activity through a unified view, you can troubleshoot and understand a complex system better than ever before.
Distributed tracing is available with an APM Pro or equivalent subscription. To see a complete distributed trace, you need to enable the feature on a set of neighboring services. Enabling distributed tracing changes the behavior of some New Relic features, so carefully consult the transition guide before you enable this feature.
To enable distributed tracing, set the following fields in your config. Note that distributed tracing and cross application tracing cannot be used simultaneously.
config := newrelic.NewConfig("Your Application Name", "__YOUR_NEW_RELIC_LICENSE_KEY__") config.CrossApplicationTracer.Enabled = false config.DistributedTracer.Enabled = truePlease refer to the distributed tracing section of the guide for more detail on how to ensure you get the most out of the Go agent's distributed tracing support.
New distributed trace calls/functions
Added functions NewContext and FromContext for adding and retrieving the Transaction from a Context. Handlers instrumented by WrapHandle, WrapHandleFunc, and nrgorilla.InstrumentRoutes may use FromContext on the request's context to access the Transaction. Thanks to @caarlos0 for the contribution! Though NewContext and FromContext require Go 1.7+ (when context was added), RequestWithTransactionContext is always exported so that it can be used in all framework and library instrumentation.
2.0.0 New
The
End()functions defined on theSegment,DatastoreSegment, andExternalSegmenttypes now receive the segment as a pointer, rather than as a value. This prevents unexpected behaviour when a call toEnd()is deferred before one or more fields are changed on the segment.In practice, this is likely to only affect this pattern:
defer newrelic.DatastoreSegment{// ...}.End()Instead, you will now need to separate the literal from the deferred call:
ds := newrelic.DatastoreSegment{// ...}defer ds.End()When creating custom and external segments, we recommend using
newrelic.StartSegment()andnewrelic.StartExternalSegment(), respectively.Added GoDoc badge to README. Thanks to @mrhwick for the contribution!
Config.UseTLSconfiguration setting has been removed to increase security. TLS will now always be used in communication with New Relic Servers.
New Features
- Added support for Cross Application Tracing (CAT). Please refer to the upgrading section of the guide for more detail on how to ensure you get the most out of the Go agent's new CAT support.
- The agent now collects additional metadata when running within Amazon Web Services, Google Cloud Platform, Microsoft Azure, and Pivotal Cloud Foundry. This information is used to provide an enhanced experience when the agent is deployed on those platforms.
New
- Added new RecordCustomMetric method to Application. This functionality can be used to track averages or counters without using custom events. See Custom Metric Documentation
- Fixed import needed for
logrus. The importSirupsen/logrushad been renamed tosirupsen/logrus. Thanks to @alfred-landrum for spotting this. - Added ErrorAttributer, an optional interface that can be implemented by errors provided to
Transaction.NoticeErrorto attach additional attributes. These attributes are subject to attribute configuration. - Added Error, a type that allows direct control of error fields.
- Updated license to address scope of usage.
New
- Added support for github.com/gin-gonic/gin in the new
nrginpackage.