【发布时间】:2021-09-20 01:33:40
【问题描述】:
每https://aws.amazon.com/xray/faqs/:
Q: My application components run in their own AWS accounts. Can I use X-Ray to collect data across AWS accounts?
Yes, the X-Ray agent can assume a role to publish data into an account different from the one in which it is running. This enables you publish data from various components of your application into a central account.
我知道我可以担任这样的角色:
st := sts.NewFromConfig(awsConf)
creds := stscreds.NewAssumeRoleProvider(st, "myRoleArn")
awsConf.Credentials = aws.NewCredentialsCache(creds)
我知道我可以使用这些凭据创建 xray 服务:
import xrayv2 "github.com/aws/aws-sdk-go-v2/service/xray"
xrayService := xrayv2.NewFromConfig(awsConf)
问题在于 xray 服务是为直接与 xray API 交互而设计的,它没有 xray 客户端提供的任何奇妙的魔力。 我知道的xray客户端是这样配置的:
import "github.com/aws/aws-xray-sdk-go/xray"
xray.Configure(xray.Config{
DaemonAddr: "",
ServiceVersion: "",
Emitter: nil,
SamplingStrategy: nil,
StreamingStrategy: nil,
ExceptionFormattingStrategy: nil,
ContextMissingStrategy: nil,
LogLevel: "",
LogFormat: "",
})
无论我使用的是 aws 还是 aws-v2 库,我都看不到可以为 xray 客户端提供任何类型的 aws conf/凭证提供程序的地方。我可以创建一个自定义发射器,但我希望避免这种情况。
关于如何向github.com/aws/aws-xray-sdk-go/xray 提供凭据缓存的任何想法?
【问题讨论】:
标签: amazon-web-services go aws-xray aws-sdk-go