2.2 Notes
- The
Transaction
parameter to NewRoundTripper and StartExternalSegment is now optional: If it isnil
, then aTransaction
will be looked for in the request's context (using FromContext). Passing anil
transaction is STRONGLY recommended when using NewRoundTripper since it allows onehttp.Client.Transport
to 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 theWebRequest
parameter is non-nil,SetWebRequest
will 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.Request
as the parameter, use the NewWebRequest transformation function. Example:
var request *http.Request = getInboundRequest()txn.SetWebRequest(newrelic.NewWebRequest(request))
- Fixed
Debug
innrlogrus
package. 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.Context
or a*gin.Context
. If you were passing a*gin.Context
around 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 theTransaction
added by nrgin.Middleware. Thanks to @rodriguezgustavo for the suggestion.