Skip to content

Commit

Permalink
Merge pull request #341 from newrelic/develop
Browse files Browse the repository at this point in the history
Release v3.14.0
  • Loading branch information
nr-swilloughby committed Jul 12, 2021
2 parents d083918 + f751b4c commit d628ce8
Show file tree
Hide file tree
Showing 14 changed files with 1,094 additions and 343 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
# ChangeLog

## Unreleased
## 3.14.0

## Fixed
* Integration tags and `go.mod` files for integrations were updated so that [pkg.go.dev]() displays the documentation for each integration correctly.
* The `nrgrpc` server integration was reporting all non-`OK` grpc statuses as errors. This has now been changed so that only selected grpc status codes will be reported as errors. Others are shown (via transaction attributes) as "warnings" or "informational" messages. There is a built-in set of defaults as to which status codes are reported at which severity levels, but this may be overridden by the caller as desired. Also supports custom grpc error handling functions supplied by the user.
* This is implemented by adding `WithStatusHandler()` options to the end of the `UnaryServerInterceptor()` and `StreamServerInterceptor()` calls, thus extending the capability of those functions while retaining the existing functionality and usage syntax for backward compatibility.
* Added advice on the recommended usage of the `app.WaitForConnection()` method. Fixes [https://github.com/newrelic/go-agent/issues/296](Issue #296)

## Added
* Added a convenience function to build distributed trace header set from a JSON string for use with the `AcceptDistributedTraceHeaders()` method. Normally, you must create a valid set of HTTP headers representing the trace identification information from the other trace so the new trace will be associated with it. This needs to be in a Go `http.Header` type value.
* If working only in Go, this may be just fine as it is. However, if the other trace information came from another source, possibly in a different language or environment, it is often the case that the trace data is already presented to you in the form of a JSON string.
* This new function, `DistributedTraceHeadersFromJSON()`, creates the required `http.Header` value from the JSON string without requiring manual effort on your part.
* We also provide a new all-in-one method `AcceptDistributedTraceHeadersFromJSON()` to be used in place of `AcceptDistributedTraceHeaders()`. It accepts a JSON string rather than an `http.Header`, adding its trace info to the new transaction in one step.
* Fixes [https://github.com/newrelic/go-agent/issues/331](Issue #331)

### Changed
* Improved the NR AWS SDK V2 integration to use the current transaction rather than the one passed in during middleware creation, if `nil` is passed into nrawssdk-v2.AppendMiddlewares. Thanks to @HenriBeck for noticing and suggesting improvement, and thanks to @nc-wittj for the fantastic PR! [#328](https://github.com/newrelic/go-agent/pull/328)

## Support Statement
New Relic recommends that you upgrade the agent regularly to ensure that you're getting the latest features and performance benefits. Additionally, older releases will no longer be supported when they reach end-of-life.

## 3.13.0

Expand Down
2 changes: 1 addition & 1 deletion v3/integrations/nrawssdk-v2/example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func main() {
}

// Instrument all new AWS clients with New Relic
nraws.AppendMiddlewares(&awsConfig.APIOptions, txn)
nraws.AppendMiddlewares(&awsConfig.APIOptions, nil)

s3Client := s3.NewFromConfig(awsConfig)
output, err := s3Client.ListBuckets(ctx, nil)
Expand Down
48 changes: 34 additions & 14 deletions v3/integrations/nrawssdk-v2/nrawssdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ func (m nrMiddleware) deserializeMiddleware(stack *smithymiddle.Stack) error {
ctx context.Context, in smithymiddle.DeserializeInput, next smithymiddle.DeserializeHandler) (
out smithymiddle.DeserializeOutput, metadata smithymiddle.Metadata, err error) {

txn := m.txn
if txn == nil {
txn = newrelic.FromContext(ctx)
}

smithyRequest := in.Request.(*smithyhttp.Request)

// The actual http.Request is inside the smithyhttp.Request
Expand All @@ -70,10 +75,10 @@ func (m nrMiddleware) deserializeMiddleware(stack *smithymiddle.Stack) error {
Host: httpRequest.URL.Host,
PortPathOrID: httpRequest.URL.Port(),
DatabaseName: "",
StartTime: m.txn.StartSegmentNow(),
StartTime: txn.StartSegmentNow(),
}
} else {
segment = newrelic.StartExternalSegment(m.txn, httpRequest)
segment = newrelic.StartExternalSegment(txn, httpRequest)
}

// Hand off execution to other middlewares and then perform the request
Expand All @@ -84,15 +89,15 @@ func (m nrMiddleware) deserializeMiddleware(stack *smithymiddle.Stack) error {

if ok {
// Set additional span attributes
integrationsupport.AddAgentSpanAttribute(m.txn,
integrationsupport.AddAgentSpanAttribute(txn,
newrelic.AttributeResponseCode, strconv.Itoa(response.StatusCode))
integrationsupport.AddAgentSpanAttribute(m.txn,
integrationsupport.AddAgentSpanAttribute(txn,
newrelic.SpanAttributeAWSOperation, operation)
integrationsupport.AddAgentSpanAttribute(m.txn,
integrationsupport.AddAgentSpanAttribute(txn,
newrelic.SpanAttributeAWSRegion, region)
requestID, ok := awsmiddle.GetRequestIDMetadata(metadata)
if ok {
integrationsupport.AddAgentSpanAttribute(m.txn,
integrationsupport.AddAgentSpanAttribute(txn,
newrelic.AttributeAWSRequestID, requestID)
}
}
Expand All @@ -105,19 +110,34 @@ func (m nrMiddleware) deserializeMiddleware(stack *smithymiddle.Stack) error {
// AppendMiddlewares inserts New Relic middleware in the given `apiOptions` for
// the AWS SDK V2 for Go. It must be called only once per AWS configuration.
//
// If `txn` is provided as nil, the New Relic transaction will be retrieved
// using `newrelic.FromContext`.
//
// Additional attributes will be added to transaction trace segments and span
// events: aws.region, aws.requestId, and aws.operation. In addition,
// http.statusCode will be added to span events.
//
// To see segments and spans for each AWS invocation, call AppendMiddlewares
// with the AWS Config `apiOptions` and pass in your current New Relic
// transaction. For example:
// To see segments and spans for all AWS invocations, call AppendMiddlewares
// with the AWS Config `apiOptions` and provide nil for `txn`. For example:
//
// awsConfig, err := config.LoadDefaultConfig(ctx)
// if err != nil {
// log.Fatal(err)
// }
// nraws.AppendMiddlewares(&awsConfig.APIOptions, nil)
//
// If do not want the transaction to be retrived from the context, you can
// explicitly set `txn`. For example:
//
// awsConfig, err := config.LoadDefaultConfig(ctx)
// if err != nil {
// log.Fatal(err)
// }
//
// ...
//
// awsConfig, err := config.LoadDefaultConfig(ctx)
// if err != nil {
// log.Fatal(err)
// }
// nraws.AppendMiddlewares(ctx, &awsConfig.APIOptions, txn)
// txn := loadNewRelicTransaction()
// nraws.AppendMiddlewares(&awsConfig.APIOptions, txn)
func AppendMiddlewares(apiOptions *[]func(*smithymiddle.Stack) error, txn *newrelic.Transaction) {
m := nrMiddleware{txn: txn}
*apiOptions = append(*apiOptions, m.deserializeMiddleware)
Expand Down
Loading

0 comments on commit d628ce8

Please sign in to comment.