Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contrib/aws/aws-sdk-go-v2: add NewTraceMiddleware function #2830

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions contrib/aws/aws-sdk-go-v2/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,26 @@ type spanTimestampKey struct{}
// 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.
func AppendMiddleware(awsCfg *aws.Config, opts ...Option) {
cfg := &config{}
tm := NewTraceMiddleware(opts...)
awsCfg.APIOptions = append(awsCfg.APIOptions, tm...)
}

// NewTraceMiddleware returns a new slice containing the tracing middleware.
// See https://aws.github.io/aws-sdk-go-v2/docs/middleware for more information.
func NewTraceMiddleware(opts ...Option) []func(*middleware.Stack) error {
cfg := &config{}
defaults(cfg)
for _, opt := range opts {
opt(cfg)
}

tm := traceMiddleware{cfg: cfg}
awsCfg.APIOptions = append(awsCfg.APIOptions, tm.initTraceMiddleware, tm.startTraceMiddleware, tm.deserializeTraceMiddleware)

return []func(*middleware.Stack) error{
tm.initTraceMiddleware,
tm.startTraceMiddleware,
tm.deserializeTraceMiddleware,
}
}

type traceMiddleware struct {
Expand Down
Loading