nrawssdk

package
v3.10.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstrumentHandlers

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 = "us-west-2"
// 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)

Types

This section is empty.

Jump to

Keyboard shortcuts

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