nrawssdk

package module
v1.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

README

v3/integrations/nrawssdk-v2 GoDoc

Package nrawssdk instruments https://github.com/aws/aws-sdk-go-v2 requests.

import "github.com/newrelic/go-agent/v3/integrations/nrawssdk-v2"

For more information, see godocs.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL