fixed NaN response from Druid during span aggregates results

This commit is contained in:
Ankit Nayan 2021-04-26 23:19:34 +05:30
parent 44304229cb
commit 584215b186

View File

@ -254,19 +254,18 @@ func SearchSpansAggregate(client *godruid.Client, queryParams *model.SpanSearchA
return nil, clientErr return nil, clientErr
} }
// fmt.Println("response", client.LastResponse) fmt.Println("response", client.LastResponse)
reveivedResponse := new([]SpanSearchAggregatesDuratonReceivedItem) receivedResponse := new([]SpanSearchAggregatesDuratonReceivedItem)
err = json.Unmarshal([]byte(client.LastResponse), receivedResponse)
err = json.Unmarshal([]byte(client.LastResponse), reveivedResponse) if err != nil && len(*receivedResponse) == 0 {
if err != nil {
zap.S().Error(err) zap.S().Error(err)
return nil, fmt.Errorf("Error in unmarshalling response from druid") return nil, fmt.Errorf("Error in unmarshalling response from druid")
} }
var response []SpanSearchAggregatesResponseItem var response []SpanSearchAggregatesResponseItem
for _, elem := range *reveivedResponse { for _, elem := range *receivedResponse {
value := elem.Result.Value value := elem.Result.Value
timeObj, _ := time.Parse(time.RFC3339Nano, elem.Timestamp) timeObj, _ := time.Parse(time.RFC3339Nano, elem.Timestamp)