Reputation: 3337
I'm trying to use awx xray on my go app that makes an http call to service. I simply followed this and am not sure if I missed something, https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-go-httpclients.html
I make the http call like this:
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 {
}
and in my main.go
file, I have this in 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,
})
}
and my xray.json
config looks like this:
{
"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
}
}
now when I start my app...my api calls are making it through but I don't see anything in AWS xray and on my xray daemon locally, I only see this in the logs:
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
what am I missing here? everything seems to be working except the Xray part, why am I not getting any data or errors?
Upvotes: 0
Views: 1108
Reputation: 19
In Lambda scenario, Lambda is responsible for creating Segments and AWS X-Ray Golang SDK only creates Subsegments and then emits them. Based on your code snippet, you didn't find the code that you instrument your application with X-Ray Go SDK APIs to generate subsegments inside Lambda functions. Here I attached a link where you can find how to instrument your application: lambdadocs
Upvotes: 1