Documentation
¶
Overview ¶
Package nrawssdk instruments requests made by the https://github.com/aws/aws-sdk-go-v2 library.
For most operations, external segments and spans are automatically created for display in the New Relic UI on the External services section. For DynamoDB operations, datastore segements and spans are created and will be displayed on the Databases page. All operations will also be displayed on transaction traces and distributed traces.
To use this integration, simply apply the AppendMiddlewares fuction to the apiOptions in your AWS Config object before performing any AWS operations. See example/main.go for a working sample.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendMiddlewares
deprecated
func AppendMiddlewares(apiOptions *[]func(*smithymiddle.Stack) error, txn *newrelic.Transaction)
Deprecated: Use InitializeMiddleware instead. Please note the different parameters used.
func InitializeMiddleware ¶ added in v1.2.6
func InitializeMiddleware(apiOptions *[]func(*smithymiddle.Stack) error, ctx context.Context, credentials aws.CredentialsProvider)
InitializeMiddleware registers New Relic middleware in the AWS SDK V2 for Go service stack. It must be called only once per AWS configuration.
The New Relic transaction, `txn`, is fetched from the ctx. Make sure to add the txn to the ctx before passing it in in as a parameter. This can be done with: ctx := newrelic.NewContext(context.Background(), txn)
Additional attributes will be added to transaction trace segments and span events: aws.accountId, aws.region, aws.requestId, and aws.operation. In addition, http.statusCode will be added to span events.
To see segments and spans for all AWS invocations, call InitializeMiddleware with the aws.Config and provide ctx. For example:
awsConfig, err := config.LoadDefaultConfig(ctx)
if err != nil {
log.Fatal(err)
}
nrawssdk.InitializeMiddleware(awsConfig, ctx, awsConfig.Credentials)
The middleware can also be added later, per AWS service call using the `optFns` parameter. For example:
awsConfig, err := config.LoadDefaultConfig(ctx)
if err != nil {
log.Fatal(err)
}
...
s3Client := s3.NewFromConfig(awsConfig)
...
txn := loadNewRelicTransaction()
output, err := s3Client.ListBuckets(ctx, nil, func(o *s3.Options) error {
nrawssdk.InitializeMiddlewares(&o.APIOptions, ctx, wsConfig.Credential)
return nil
})
if err != nil {
log.Fatal(err)
}
Types ¶
This section is empty.