Skip to content

Commit

Permalink
日志添加-res len > 0
Browse files Browse the repository at this point in the history
  • Loading branch information
wushuai.lc committed Nov 10, 2020
1 parent 5b264ef commit c403202
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions pkg/agent/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,21 +252,23 @@ func GetFields(c client.Client, sdb string, meas string, rp string) map[string]*

res := response.Results
log.Debugf("get fields from meas[%s], response:[%s]", meas, response.Results)
if len(res) > 0 {
if len(res[0].Series) == 0 {
log.Warnf("The response for Query is null, get Fields from DB %s Measurement %s error!\n", sdb, meas)
} else {

values := res[0].Series[0].Values
//show progress of getting measurements
for _, row := range values {
fieldname := row[0].(string)
fieldtype := row[1].(string)
fields[fieldname] = &FieldSch{Name: fieldname, Type: fieldtype}
log.Debugf("Detected Field [%s] type [%s] on measurement [%s]", fieldname, fieldtype, meas)
}

if len(res[0].Series) == 0 {
log.Warnf("The response for Query is null, get Fields from DB %s Measurement %s error!\n", sdb, meas)
} else {

values := res[0].Series[0].Values
//show progress of getting measurements
for _, row := range values {
fieldname := row[0].(string)
fieldtype := row[1].(string)
fields[fieldname] = &FieldSch{Name: fieldname, Type: fieldtype}
log.Debugf("Detected Field [%s] type [%s] on measurement [%s]", fieldname, fieldtype, meas)
}

}

return fields
}

Expand Down

1 comment on commit c403202

@fcddk
Copy link
Owner

@fcddk fcddk commented on c403202 Nov 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix panic index out of range when execute the function agent.GetFields
toni-moreno#48

Please sign in to comment.