我正在阅读https://github.com/aws/aws-xray-sdk-go的官方文档,但不太确定如何将在lambda函数上创建的Cognito客户端添加到服务Map和x射线跟踪中。
import (
"context"
cognito "github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider"
"github.com/aws/aws-xray-sdk-go/xray"
)
func GetClient() {
...
cfg, errCfg := config.LoadDefaultConfig(context.TODO())
client := cognito.NewFromConfig(cfg)
// the next line is not valid, because the function receives a *client.Client as a parameter
// and my current client is of type *cognito.Client
// the error is: cannot use client (variable of type *cognitoidentityprovider.Client) as *"github.com/aws/aws-sdk-go/aws/client".Client value in argument to xray.AWS
xray.AWS(client)
...
}
我很感激你的建议。
1条答案
按热度按时间vfhzx4xs1#
请参阅以下文档,了解如何使用X-Ray SDK对AWS SDK for Go客户端进行检测:https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-go-awssdkclients.html