go-agent: github.com/newrelic/go-agent/_integrations/nrawssdk/v2 Index | Files

package nrawssdk

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

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

Index

Package Files

nrawssdk.go

func InstrumentHandlers Uses

func InstrumentHandlers(handlers *aws.Handlers)

InstrumentHandlers will add instrumentation to the given *aws.Handlers.

A Segment will be created for each out going request. The Transaction must be added to the `http.Request`'s Context in order for the segment to be recorded. For DynamoDB calls, these segments will be `newrelic.DatastoreSegment` type and for all others they will be `newrelic.ExternalSegment` type.

Additional attributes will be added to Transaction Trace Segments and Span Events: aws.region, aws.requestId, and aws.operation.

To add instrumentation to a Config and see segments created for each invocation that uses that Config, call InstrumentHandlers with the config's Handlers and add the current Transaction to the `http.Request`'s Context:

cfg, _ := external.LoadDefaultAWSConfig()
cfg.Region = endpoints.UsWest2RegionID
// Add instrumentation to handlers
nrawssdk.InstrumentHandlers(&cfg.Handlers)
lambdaClient   = lambda.New(cfg)

req := lambdaClient.InvokeRequest(&lambda.InvokeInput{
    ClientContext:  aws.String("MyApp"),
    FunctionName:   aws.String("Function"),
    InvocationType: lambda.InvocationTypeEvent,
    LogType:        lambda.LogTypeTail,
    Payload:        []byte("{}"),
}
// Add txn to http.Request's context
ctx := newrelic.NewContext(req.Context(), txn)
resp, err := req.Send(ctx)

To add instrumentation to a Request and see a segment created just for the individual request, call InstrumentHandlers with the `aws.Request`'s Handlers and add the current Transaction to the `http.Request`'s Context:

req := lambdaClient.InvokeRequest(&lambda.InvokeInput{
    ClientContext:  aws.String("MyApp"),
    FunctionName:   aws.String("Function"),
    InvocationType: lambda.InvocationTypeEvent,
    LogType:        lambda.LogTypeTail,
    Payload:        []byte("{}"),
}
// Add instrumentation to handlers
nrawssdk.InstrumentHandlers(&req.Handlers)
// Add txn to http.Request's context
ctx := newrelic.NewContext(req.Context(), txn)
resp, err := req.Send(ctx)

Package nrawssdk imports 3 packages (graph). Updated 2019-07-11. Refresh now. Tools for package owners.