Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Starts a span and adds it to the request context. StartHandler = request.NamedHandler{ Name: "opentracing.Start", Fn: func(r *request.Request) { _, ctx := opentracing.StartSpanFromContext(r.Context(), "client.request") r.SetContext(ctx) }, } // Adds information about the request to the span. RequestInfoHandler = request.NamedHandler{ Name: "opentracing.RequestInfo", Fn: func(r *request.Request) { span := opentracing.SpanFromContext(r.Context()) span.SetTag("service.name", fmt.Sprintf("aws.%s", r.ClientInfo.ServiceName)) span.SetTag("resource.name", r.Operation.Name) span.SetTag("http.method", r.Operation.HTTPMethod) span.SetTag("http.url", r.ClientInfo.Endpoint+r.Operation.HTTPPath) span.SetTag("out.host", r.ClientInfo.Endpoint) span.SetTag("aws.operation", r.Operation.Name) }, } // Finishes the span. FinishHandler = request.NamedHandler{ Name: "opentracing.Finish", Fn: func(r *request.Request) { span := opentracing.SpanFromContext(r.Context()) span.SetTag("aws.retry_count", fmt.Sprintf("%d", r.RetryCount)) if r.HTTPResponse != nil { span.SetTag("http.status_code", fmt.Sprintf("%d", r.HTTPResponse.StatusCode)) } if r.Error != nil { span.SetTag(dd_ext.Error, r.Error) if _, ok := r.Error.(fmt.Formatter); ok { span.SetTag(dd_ext.ErrorStack, fmt.Sprintf("%+v", r.Error)) } if err, ok := r.Error.(awserr.Error); ok { span.SetTag("aws.err.code", fmt.Sprintf("%s", err.Code())) } } span.Finish() }, } // DynamoDBInfoHandler adds extra information to the span for requests // to DynamoDB. DynamoDBInfoHandler = request.NamedHandler{ Name: "opentracing.DynamoDB", Fn: func(r *request.Request) { if r.ClientInfo.ServiceName != dynamodb.ServiceName { return } tableName := dynamoDBTableName(r) if tableName == nil { return } span := opentracing.SpanFromContext(r.Context()) span.SetOperationName(r.Operation.Name) span.SetTag("span.type", "db") span.SetTag("resource.name", *tableName) span.SetTag("aws.dynamodb.table", *tableName) }, } )
Functions ¶
func WithTracing ¶
WithTracing adds the necessary request handlers to an AWS session.Session object to enable tracing with opentracing.
Types ¶
type Option ¶
type Option func(opentracing.Span, *request.Request, error)
Option is a hook for adding span tags.
Click to show internal directories.
Click to hide internal directories.