Documentation ¶
Overview ¶
Package aws provides functions to trace aws/aws-sdk-go-v2 (https://github.com/aws/aws-sdk-go-v2).
Usage Example:
import ( "context" "log" "os" "github.com/aws/aws-sdk-go-v2/aws" awscfg "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/feature/s3/manager" "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/sqs" awstrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/aws/aws-sdk-go-v2/aws" "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext" "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" ) func Example() { awsCfg, err := awscfg.LoadDefaultConfig(context.Background()) if err != nil { log.Fatalf(err.Error()) } awstrace.AppendMiddleware(&awsCfg) sqsClient := sqs.NewFromConfig(awsCfg) sqsClient.ListQueues(context.Background(), &sqs.ListQueuesInput{}) } // An example of the aws span inheriting a parent span from context. func Example_context() { cfg, err := awscfg.LoadDefaultConfig(context.TODO(), awscfg.WithRegion("us-west-2")) if err != nil { log.Fatalf("error: %v", err) } awstrace.AppendMiddleware(&cfg) client := s3.NewFromConfig(cfg) uploader := manager.NewUploader(client) // Create a root span. span, ctx := tracer.StartSpanFromContext(context.Background(), "parent.request", tracer.SpanType(ext.SpanTypeWeb), tracer.ServiceName("web"), tracer.ResourceName("/upload"), ) defer span.Finish() // Open image file. filename := "my_image.png" file, err := os.Open(filename) if err != nil { log.Fatalf("error: %v", err) } defer file.Close() uploadParams := &s3.PutObjectInput{ Bucket: aws.String("my_bucket"), Key: aws.String(filename), Body: file, ContentType: aws.String("image/png"), } // Inherit parent span from context. _, err = uploader.Upload(ctx, uploadParams) if err != nil { log.Fatalf("error: %v", err) } }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendMiddleware ¶
AppendMiddleware takes the aws.Config and adds the Datadog tracing middleware into the APIOptions middleware stack. See https://aws.github.io/aws-sdk-go-v2/docs/middleware for more information.
Types ¶
type Option ¶
type Option func(*config)
Option represents an option that can be passed to Dial.
func WithAnalytics ¶
WithAnalytics enables Trace Analytics for all started spans.
func WithAnalyticsRate ¶
WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.
func WithErrorCheck ¶ added in v1.53.0
WithErrorCheck specifies a function fn which determines whether the passed error should be marked as an error. The fn is called whenever an aws operation finishes with an error.
func WithServiceName ¶
WithServiceName sets the given service name for the dialled connection. When the service name is not explicitly set it will be inferred based on the request to AWS.