AWS X-ray on a Golang lambda function for Cognito

xfb7svmp  于 2023-04-09  发布在  Go
关注(0)|答案(1)|浏览(128)

我正在阅读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)
    ...
    }

我很感激你的建议。

相关问题