support versions less than 3.2.0

docsExamined is renamed from nscannedObjects in 3.2.0.
This commit is contained in:
MATSUU Takuto
2017-09-13 18:36:07 +09:00
parent aec4ac03cb
commit 8ce461a7c1
2 changed files with 8 additions and 1 deletions

View File

@@ -2,11 +2,13 @@ package proto
import "time" import "time"
// docsExamined is renamed from nscannedObjects in 3.2.0
type SystemProfile struct { type SystemProfile struct {
AllUsers []interface{} `bson:"allUsers"` AllUsers []interface{} `bson:"allUsers"`
Client string `bson:"client"` Client string `bson:"client"`
CursorExhausted bool `bson:"cursorExhausted"` CursorExhausted bool `bson:"cursorExhausted"`
DocsExamined int `bson:"docsExamined"` DocsExamined int `bson:"docsExamined"`
NscannedObjects int `bson:"nscannedObjects"`
ExecStats struct { ExecStats struct {
Advanced int `bson:"advanced"` Advanced int `bson:"advanced"`
ExecutionTimeMillisEstimate int `bson:"executionTimeMillisEstimate"` ExecutionTimeMillisEstimate int `bson:"executionTimeMillisEstimate"`

View File

@@ -91,7 +91,12 @@ func (s *Stats) Add(doc proto.SystemProfile) error {
s.setQueryInfoAndCounters(key, qiac) s.setQueryInfoAndCounters(key, qiac)
} }
qiac.Count++ qiac.Count++
qiac.NScanned = append(qiac.NScanned, float64(doc.DocsExamined)) // docsExamined is renamed from nscannedObjects in 3.2.0.
if doc.NscannedObjects > 0 {
qiac.NScanned = append(qiac.NScanned, float64(doc.NscannedObjects))
} else {
qiac.NScanned = append(qiac.NScanned, float64(doc.DocsExamined))
}
qiac.NReturned = append(qiac.NReturned, float64(doc.Nreturned)) qiac.NReturned = append(qiac.NReturned, float64(doc.Nreturned))
qiac.QueryTime = append(qiac.QueryTime, float64(doc.Millis)) qiac.QueryTime = append(qiac.QueryTime, float64(doc.Millis))
qiac.ResponseLength = append(qiac.ResponseLength, float64(doc.ResponseLength)) qiac.ResponseLength = append(qiac.ResponseLength, float64(doc.ResponseLength))