我正在尝试在我的go应用程序上使用awx,该应用程序对服务进行http调用。我只是简单地看了一下,不确定是不是漏掉了什么,https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-go-httpclients.html
我像这样调用http:
payloadStr, _ := json.Marshal(dxPayload)
fmt.Println("size: ", int(unsafe.Sizeof(bytes.NewBuffer(payloadStr))))
clambda = &http.Client{}
//-------ADDED XRAY HERE-------//
xray.Client(clambda)
reqLambda, errReq := http.NewRequest("POST", lambdaurl, bytes.NewBuffer(payloadStr))
if errReq != nil {
log.Fatal("Request Error: ", errReq)
return
}
reqLambda.Header.Add("accept", "application/json;v=1")
reqLambda.Header.Add("cach-control", "no-cache")
reqLambda.Header.Add("content-type", "application/json")
reqLambda.Header.Add("authorization", "Bearer " + devexToken.AccessToken)
respLambda, errResp := clambda.Do(reqLambda)
if errResp != nil {
log.Fatal("Status Response Error ", errResp)
return
} else {
}在我的main.go文件中,我在func init()中有以下内容
func init() {
pConfig = createpConfig()
//aws xray config
ss, err := sampling.NewLocalizedStrategyFromFilePath("xray.json")
if err != nil {
panic(err)
}
xray.Configure(xray.Config{
SamplingStrategy: ss,
})
}我的xray.json配置如下所示:
{
"version": 1,
"rules": [
{
"description": "ehb",
"service_name": "ehb-kafka-push",
"http_method": "*",
"url_path": "/private/api/calllambda/*",
"fixed_target": 0,
"rate": 0.85
}
],
"default": {
"fixed_target": 1,
"rate": 0.1
}
}现在,当我开始我的AWS应用程序接口调用时,我在AWS xray和我本地的xray守护进程中没有看到任何东西,我只在日志中看到了以下内容:
2018-08-26T18:45:04-07:00 [Info] Initializing AWS X-Ray daemon 2.1.3
2018-08-26T18:45:04-07:00 [Debug] Listening on UDP 127.0.0.1:2000
2018-08-26T18:45:04-07:00 [Info] Using buffer memory limit of 163 MB
2018-08-26T18:45:04-07:00 [Info] 2608 segment buffers allocated
2018-08-26T18:45:04-07:00 [Debug] Fetch region us-east-1 from commandline argument
2018-08-26T18:45:04-07:00 [Info] Using region: us-east-1
2018-08-26T18:45:04-07:00 [Debug] ARN of the AWS resource running the daemon:
2018-08-26T18:45:04-07:00 [Debug] No Metadata set for telemetry records
2018-08-26T18:45:04-07:00 [Debug] Using Endpoint: https://xray.us-east-1.amazonaws.com
2018-08-26T18:45:04-07:00 [Debug] Telemetry initiated
2018-08-26T18:45:04-07:00 [Debug] Using Endpoint: https://xray.us-east-1.amazonaws.com
2018-08-26T18:45:04-07:00 [Debug] Batch size: 50
2018-08-26T18:46:04-07:00 [Debug] Skipped telemetry data as no segments found
2018-08-26T18:47:04-07:00 [Debug] Skipped telemetry data as no segments found
2018-08-26T18:48:04-07:00 [Debug] Skipped telemetry data as no segments found这里我漏掉了什么?除了Xray部分,一切似乎都正常,为什么我得不到任何数据或错误?
发布于 2018-08-29 04:32:52
在Lambda方案中,Lambda负责创建细分市场,而AWS X-Ray Golang SDK仅创建子细分市场,然后发射它们。根据您的代码片段,您没有找到使用X-Ray Go SDK API检测应用程序以在Lambda函数中生成子段的代码。在这里,我附加了一个链接,您可以在该链接中了解如何检测应用程序:lambdadocs
https://stackoverflow.com/questions/52031957
复制相似问题