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.