Documentation ¶
Overview ¶
Package awstrace contains aws session wrapper for tracing through SNS and SQS supporting Datadog native and B3 tracing contexts. For this to work for SNS subscriptions, you need to enable raw message delivery.
Examples ¶
An example of tracing between two services through SQS ¶
Using WrapSession, service 1
func sendMessage(msg string) error { // Pass trace headers by wrapping the session with WrapSession sess := session.Must(session.NewSession()) sess = awstrace.WrapSession(sess) // Context need to containing Datadog or B3 trace for this to work ctx, span := oc_trace.StartSpan(ctx, "example") defer span.End() // Sending message and injecting tracing headers client := sqs.New(sess) _, err := client.SendMessageWithContext(ctx, &sqs.SendMessageInput{ MessageBody: aws.String(msg), }) return err }
Using StartDatadogSpanFromMessage, service 2
func handleRecord(ctx context.Context, record *sqs.SQSMessage) { // Creating a new datadog span and extracing the trace headers span, ctx = awstrace.StartDatadogSpanFromMessage(ctx, serviceName, record) defer span.Finish() ... }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartDatadogSpanFromMessage ¶
func StartDatadogSpanFromMessage(ctx context.Context, serviceName string, msg events.SQSMessage) (dd_tracer.Span, context.Context)
StartDatadogSpanFromMessage will start a Datadog span based on message attributes found in sqs message. It will extract trace and span id either depending on the extraction style. Configure the extraction style by using the environment variable: DD_PROPAGATION_STYLE_EXTRACT=Datadog,B3 Default extraction style is set to Datadog For this to work for SNS subscriptions, you need to enable raw message delivery.
func WrapSession ¶
WrapSession will wrap the AWS session and injecting tracing headers into the outgoing requests for these functions: - sns.PublishWithContext(...) - sqs.SendMessageWithContext(...) - sqs.SendMessageBatchWithContext(...) the wrapper support B3 and Datadog
Types ¶
This section is empty.