Skip to content

Commit

Permalink
contrib/aws/aws-sdk-go-v2: add NewTraceMiddleware function
Browse files Browse the repository at this point in the history
  • Loading branch information
rarguelloF committed Aug 27, 2024
1 parent 6f8d5e9 commit 8c8481f
Showing 1 changed file with 13 additions and 2 deletions.
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

0 comments on commit 8c8481f

Please sign in to comment.