Documentation
¶
Overview ¶
Package aws provides functions to trace aws/aws-sdk-go (https://github.com/aws/aws-sdk-go).
Example ¶
To start tracing requests, wrap the AWS session.Session by invoking awstrace.WrapSession.
package main
import (
awstrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
)
func main() {
cfg := aws.NewConfig().WithRegion("us-west-2")
sess := session.Must(session.NewSession(cfg))
sess = awstrace.WrapSession(sess)
s3api := s3.New(sess)
s3api.CreateBucket(&s3.CreateBucketInput{
Bucket: aws.String("some-bucket-name"),
})
}
Output:
Example (Context) ¶
An example of the aws span inheriting a parent span from context.
package main
import (
"context"
"log"
"os"
awstrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/aws/aws-sdk-go/aws"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
)
func main() {
cfg := aws.NewConfig().WithRegion("us-west-2")
sess := session.Must(session.NewSession(cfg))
sess = awstrace.WrapSession(sess)
uploader := s3manager.NewUploader(sess)
// 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 := &s3manager.UploadInput{
Bucket: aws.String("my_bucket"),
Key: aws.String(filename),
Body: file,
ContentType: aws.String("image/png"),
}
// Inherit parent span from context.
_, err = uploader.UploadWithContext(ctx, uploadParams)
if err != nil {
log.Fatalf("error: %v", err)
}
}
Output:
Index ¶
Examples ¶
Constants ¶
const ( // SendHandlerName is the name of the Datadog NamedHandler for the Send phase of an awsv1 request SendHandlerName = v2.SendHandlerName // CompleteHandlerName is the name of the Datadog NamedHandler for the Complete phase of an awsv1 request CompleteHandlerName = v2.CompleteHandlerName )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
Option represents an option that can be passed to Dial.
func WithAnalytics ¶ added in v1.11.0
WithAnalytics enables Trace Analytics for all started spans.
func WithAnalyticsRate ¶ added in v1.11.0
WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.
func WithErrorCheck ¶ added in v1.51.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.