go-agent: v3/integrations/nrawssdk-v2: Does not work with the v1.0.0+ releases of AWS SDK v2

Description

It seems the v1.0.0+ Go AWS v2 SDK had a few breaking changes since the beta releases, which the v3/integrations/nrawssdk-v2 package seems to be based on. Thus, we cannot use the NewRelic integration with our application using the latest AWS v2 SDK.

Steps to Reproduce

Use v3/integrations/nrawssdk-v2 with the latest AWS SDK v2 release. Notice errors when using go get:

$ go get github.com/newrelic/go-agent/v3/integrations/nrawssdk-v2
go: downloading github.com/newrelic/go-agent/v3 v3.11.0
go: downloading github.com/newrelic/go-agent v3.11.0+incompatible
go: downloading github.com/newrelic/go-agent/v3/integrations/nrawssdk-v2 v1.0.0
# github.com/newrelic/go-agent/v3/integrations/nrawssdk-v2
../../../../../go/pkg/mod/github.com/newrelic/go-agent/v3/integrations/nrawssdk-v2@v1.0.0/nrawssdk.go:12:24: undefined: aws.Request
../../../../../go/pkg/mod/github.com/newrelic/go-agent/v3/integrations/nrawssdk-v2@v1.0.0/nrawssdk.go:23:22: undefined: aws.Request
../../../../../go/pkg/mod/github.com/newrelic/go-agent/v3/integrations/nrawssdk-v2@v1.0.0/nrawssdk.go:76:35: undefined: aws.Handlers
../../../../../go/pkg/mod/github.com/newrelic/go-agent/v3/integrations/nrawssdk-v2@v1.0.0/nrawssdk.go:77:30: undefined: aws.NamedHandler
../../../../../go/pkg/mod/github.com/newrelic/go-agent/v3/integrations/nrawssdk-v2@v1.0.0/nrawssdk.go:81:29: undefined: aws.NamedHandler

Expected Behavior

It works and does not have compile time errors.

NR Diag results

Your Environment

Reproduction case

Additional context

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 19 (15 by maintainers)

Most upvoted comments

@RichVanderwal I implemented @HenriBeck’s suggestion in this PR: https://github.com/newrelic/go-agent/pull/328

It seems to be working well, and is much easier to leverage in our serverless app. Let me know what you think.

@RichVanderwal from my testing today it seems to work for me to extract the transaction from the context with a minimal middleware like this:

func NewRelicMiddleware(stack *smithymiddle.Stack) error {
	return stack.Deserialize.Add(
		smithymiddle.DeserializeMiddlewareFunc(
			"NRDeserializeMiddleware",
			func(
				ctx context.Context,
				in smithymiddle.DeserializeInput,
				next smithymiddle.DeserializeHandler,
			) (out smithymiddle.DeserializeOutput, metadata smithymiddle.Metadata, err error) {
				smithyRequest := in.Request.(*smithyhttp.Request)
				txn := newrelic.FromContext(ctx)

				// The actual http.Request is inside the smithyhttp.Request
				httpRequest := smithyRequest.Request
				segment := newrelic.StartExternalSegment(txn, httpRequest)

				// Hand off execution to other middlewares and then perform the request
				out, metadata, err = next.HandleDeserialize(ctx, in)

				segment.End()
				return out, metadata, err
			},
		),
		smithymiddle.Before,
	)
}

I guess it also would be easy enough to just read from the context in case the txn on the middleware itself is nil just to keep this manual option also available

Fixed in the May Go Agent Release. We’d love to hear feedback from @nc-wittj , @betabandido, @R-NK, @zsrinivas, and @HenriBeck !

Any news on this? This is blocking us from using NR to monitor AWS requests.

Also, I should mention that this is scheduled to be fixed in our April 2021 maintenance release. https://github.com/newrelic/go-agent/issues/250

Thanks, @nc-wittj ! We’ll hand this to our Product Manager to help us prioritize this bug in our NR AWS SDK V2 integration.