nrawssdk

package
v3.26.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstrumentHandlers

func InstrumentHandlers(handlers *request.Handlers)

InstrumentHandlers will add instrumentation to the given *request.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 the Session and see segments created for each invocation that uses the Session, call InstrumentHandlers with the session's Handlers and add the current Transaction to the `http.Request`'s Context:

ses := session.New()
// Add instrumentation to handlers
nrawssdk.InstrumentHandlers(&ses.Handlers)
lambdaClient   = lambda.New(ses, aws.NewConfig())

req, out := lambdaClient.InvokeRequest(&lambda.InvokeInput{
    ClientContext:  aws.String("MyApp"),
    FunctionName:   aws.String("Function"),
    InvocationType: aws.String("Event"),
    LogType:        aws.String("Tail"),
    Payload:        []byte("{}"),
}
// Add txn to http.Request's context
req.HTTPRequest = newrelic.RequestWithTransactionContext(req.HTTPRequest, txn)
err := req.Send()

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

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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