Skip to content

Commit b6b9a5d

Browse files
author
Carlos Castro
authored
fix resultSet bug in custom queries (#96)
1 parent 24a0841 commit b6b9a5d

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/metrics/metrics.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,13 @@ func populateCustomMetrics(instanceEntity *integration.Entity, connection *conne
153153
return
154154
}
155155

156-
if !rows.NextResultSet() {
157-
log.Warn("No result set found for custom query: %+v", query)
158-
}
159-
160156
defer func() {
161157
_ = rows.Close()
162158
}()
163159

160+
var rowCount = 0
164161
for rows.Next() {
162+
rowCount++
165163
row := make(map[string]interface{})
166164
err := rows.MapScan(row)
167165
if err != nil {
@@ -263,6 +261,11 @@ func populateCustomMetrics(instanceEntity *integration.Entity, connection *conne
263261
}
264262
}
265263
}
264+
if rowCount == 0 {
265+
log.Warn("No result set found for custom query: %+v", query)
266+
} else {
267+
log.Debug("%v Rows returned for custom query: %+v", rowCount, query)
268+
}
266269

267270
if err := rows.Err(); err != nil {
268271
log.Error("Error iterating rows: %s", err)

0 commit comments

Comments
 (0)