Skip to content

panic when using timestream QueryWithContext with X-Ray #411

@sportlane

Description

@sportlane

Describe the bug

When using timestreamquery QueryWithContext function with X-Ray, the program panic with the error:
"panic: failed to begin subsegment named 'Timestream Query': segment cannot be found."

The DescribeEndpoints call queued before QueryWithContext is not getting context set up.

Current Behavior

panic: failed to begin subsegment named 'Timestream Query': segment cannot be found.

goroutine 1 [running]:
github.com/aws/aws-xray-sdk-go/strategy/ctxmissing.(*DefaultRuntimeErrorStrategy).ContextMissing(0xc0000302d0?, {0x17376e0?, 0xc00062cd70?})
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/strategy/ctxmissing/default_context_missing.go:60 +0x29
github.com/aws/aws-xray-sdk-go/xray.BeginSubsegment({0x1ae9510, 0xc000028068}, {0x18433c3, 0x10})
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/xray/segment.go:272 +0x6a8
github.com/aws/aws-xray-sdk-go/xray.glob..func1(0xc000368500)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/xray/aws.go:67 +0x75
github.com/aws/aws-sdk-go/aws/request.(*HandlerList).Run(0xc0003686a8, 0xc000368500)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/aws/request/handlers.go:267 +0x9a
github.com/aws/aws-sdk-go/aws/request.(*Request).Build(0xc000368500)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/aws/request/request.go:416 +0x39
github.com/aws/aws-sdk-go/aws/request.(*Request).Sign(0xc000368500)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/aws/request/request.go:437 +0x25
github.com/aws/aws-sdk-go/aws/request.(*Request).Send(0xc000368500)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/aws/request/request.go:550 +0x13b
github.com/aws/aws-sdk-go/service/timestreamquery.(*TimestreamQuery).DescribeEndpoints(0x18394a4?, 0x4?)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/service/timestreamquery/api.go:465 +0x25
github.com/aws/aws-sdk-go/service/timestreamquery.(*discovererDescribeEndpoints).Discover(0xc000638340)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/service/timestreamquery/api.go:496 +0x5e
github.com/aws/aws-sdk-go/aws/crr.(*EndpointCache).discover(0xc000513908?, {0x1ae3ac0?, 0xc000638340?}, {0x1839e2f, 0x5})
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/aws/crr/cache.go:113 +0x66
github.com/aws/aws-sdk-go/aws/crr.(*EndpointCache).Get(0xc000638000, {0x1ae3ac0?, 0xc000638340}, {0x1839e2f, 0x5}, 0x1)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/aws/crr/cache.go:64 +0x11b
github.com/aws/aws-sdk-go/service/timestreamquery.(*discovererDescribeEndpoints).Handler(0xc000638340, 0xc000368000)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/service/timestreamquery/api.go:545 +0x86
github.com/aws/aws-sdk-go/aws/request.(*HandlerList).Run(0xc0003681c8, 0xc000368000)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/aws/request/handlers.go:267 +0x9a
github.com/aws/aws-sdk-go/aws/request.(*Request).Build(0xc000368000)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/aws/request/request.go:421 +0x67
github.com/aws/aws-sdk-go/aws/request.(*Request).Sign(0xc000368000)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/aws/request/request.go:437 +0x25
github.com/aws/aws-sdk-go/aws/request.(*Request).Send(0xc000368000)
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/aws/request/request.go:550 +0x13b
github.com/aws/aws-sdk-go/service/timestreamquery.(*TimestreamQuery).QueryWithContext(0x1ae9510?, {0x1ae9580, 0xc0006139e0}, 0x4?, {0x0, 0x0, 0xc00034b0e0?})
        /Users/user/go/pkg/mod/github.com/aws/[email protected]/service/timestreamquery/api.go:1396 +0x186
main.main()
        /Users/user/Documents/Source/test/ts-test.go:25 +0x185
exit status 2

Reproduction Steps

package main

import (
	"context"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/timestreamquery"
	"github.com/aws/aws-xray-sdk-go/xray"
)

func main() {

	sess := session.Must(session.NewSessionWithOptions(session.Options{
		SharedConfigState: session.SharedConfigEnable,
		Config: aws.Config{
			Region: aws.String("us-east-1"),
		},
	}))

	tsclient := timestreamquery.New(sess)
	xray.AWS(tsclient.Client)

	ctx, _ := xray.BeginSegment(context.Background(), "test")
	tsclient.QueryWithContext(ctx, &timestreamquery.QueryInput{
		QueryString: aws.String("SELECT * FROM FOO"),
	})
}

SDK version used

v1.7.0

Environment details (Version of Go (go version)? OS name and version, etc.)

go version go1.19.3 darwin/amd64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions