mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-20 02:44:58 +00:00
PMM-9288 Changes.
This commit is contained in:
@@ -13,7 +13,6 @@ 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"`
|
|
||||||
NscannedObjects int `bson:"nscannedObjects"`
|
NscannedObjects int `bson:"nscannedObjects"`
|
||||||
ExecStats struct {
|
ExecStats struct {
|
||||||
Advanced int `bson:"advanced"`
|
Advanced int `bson:"advanced"`
|
||||||
@@ -67,7 +66,7 @@ type SystemProfile struct {
|
|||||||
RShared int `bson:"r"`
|
RShared int `bson:"r"`
|
||||||
} `bson:"acquireWaitCount"`
|
} `bson:"acquireWaitCount"`
|
||||||
TimeAcquiringMicros struct {
|
TimeAcquiringMicros struct {
|
||||||
RShared int `bson:"r"`
|
RShared int64 `bson:"r"`
|
||||||
} `bson:"timeAcquiringMicros"`
|
} `bson:"timeAcquiringMicros"`
|
||||||
} `bson:"Database"`
|
} `bson:"Database"`
|
||||||
Global struct {
|
Global struct {
|
||||||
@@ -90,7 +89,6 @@ type SystemProfile struct {
|
|||||||
PlanSummary string `bson:"planSummary"`
|
PlanSummary string `bson:"planSummary"`
|
||||||
Protocol string `bson:"protocol"`
|
Protocol string `bson:"protocol"`
|
||||||
Query bson.D `bson:"query"`
|
Query bson.D `bson:"query"`
|
||||||
QueryHash string `bson:"queryHash"`
|
|
||||||
UpdateObj bson.D `bson:"updateobj"`
|
UpdateObj bson.D `bson:"updateobj"`
|
||||||
Command bson.D `bson:"command"`
|
Command bson.D `bson:"command"`
|
||||||
OriginatingCommand bson.D `bson:"originatingCommand"`
|
OriginatingCommand bson.D `bson:"originatingCommand"`
|
||||||
@@ -98,13 +96,16 @@ type SystemProfile struct {
|
|||||||
Ts time.Time `bson:"ts"`
|
Ts time.Time `bson:"ts"`
|
||||||
User string `bson:"user"`
|
User string `bson:"user"`
|
||||||
WriteConflicts int `bson:"writeConflicts"`
|
WriteConflicts int `bson:"writeConflicts"`
|
||||||
|
DocsExamined int `bson:"docsExamined"`
|
||||||
|
QueryHash string `bson:"queryHash"`
|
||||||
Storage struct {
|
Storage struct {
|
||||||
Data struct {
|
Data struct {
|
||||||
BytesRead int `bson:"bytesRead"`
|
BytesRead int `bson:"bytesRead"`
|
||||||
TimeReadingMicros int `bson:"timeReadingMicros"`
|
TimeReadingMicros int64 `bson:"timeReadingMicros"`
|
||||||
} `bson:"data"`
|
} `bson:"data"`
|
||||||
} `bson:"storage"`
|
} `bson:"storage"`
|
||||||
AppName string `bson:"appName"`
|
AppName string `bson:"appName"`
|
||||||
|
Comments string `bson:"comments"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewExampleQuery(doc SystemProfile) ExampleQuery {
|
func NewExampleQuery(doc SystemProfile) ExampleQuery {
|
||||||
|
@@ -93,14 +93,18 @@ func (s *Stats) Add(doc proto.SystemProfile) error {
|
|||||||
TableScan: false,
|
TableScan: false,
|
||||||
Query: string(queryBson),
|
Query: string(queryBson),
|
||||||
PlanSummary: doc.PlanSummary,
|
PlanSummary: doc.PlanSummary,
|
||||||
|
QueryHash: doc.QueryHash,
|
||||||
|
AppName: doc.AppName,
|
||||||
|
Client: doc.Client,
|
||||||
|
User: doc.User,
|
||||||
|
Database: strings.Split(doc.Ns, ".")[0],
|
||||||
|
Comments: doc.Comments,
|
||||||
|
TimeStamp: doc.Ts,
|
||||||
}
|
}
|
||||||
s.setQueryInfoAndCounters(key, qiac)
|
s.setQueryInfoAndCounters(key, qiac)
|
||||||
}
|
}
|
||||||
qiac.Count++
|
qiac.Count++
|
||||||
// docsExamined is renamed from nscannedObjects in 3.2.0.
|
|
||||||
// https://docs.mongodb.com/manual/reference/database-profiler/#system.profile.docsExamined
|
|
||||||
s.Lock()
|
s.Lock()
|
||||||
qiac.PlanSummary = doc.PlanSummary
|
|
||||||
if qiac.PlanSummary == planSummaryCollScan {
|
if qiac.PlanSummary == planSummaryCollScan {
|
||||||
qiac.CollScanCount++
|
qiac.CollScanCount++
|
||||||
qiac.CollScanSum += int64(doc.Millis)
|
qiac.CollScanSum += int64(doc.Millis)
|
||||||
@@ -108,11 +112,8 @@ func (s *Stats) Add(doc proto.SystemProfile) error {
|
|||||||
if strings.HasPrefix(qiac.PlanSummary, planSummaryIXScan) {
|
if strings.HasPrefix(qiac.PlanSummary, planSummaryIXScan) {
|
||||||
qiac.PlanSummary = planSummaryIXScan
|
qiac.PlanSummary = planSummaryIXScan
|
||||||
}
|
}
|
||||||
if doc.NscannedObjects > 0 {
|
|
||||||
qiac.NScanned = append(qiac.NScanned, float64(doc.NscannedObjects))
|
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))
|
||||||
@@ -122,6 +123,19 @@ func (s *Stats) Add(doc proto.SystemProfile) error {
|
|||||||
if qiac.LastSeen.IsZero() || qiac.LastSeen.Before(doc.Ts) {
|
if qiac.LastSeen.IsZero() || qiac.LastSeen.Before(doc.Ts) {
|
||||||
qiac.LastSeen = doc.Ts
|
qiac.LastSeen = doc.Ts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qiac.StorageBytesRead += doc.Storage.Data.BytesRead
|
||||||
|
qiac.StorageTimeReadingMicros += doc.Storage.Data.TimeReadingMicros
|
||||||
|
|
||||||
|
qiac.LGlobalAcquireCountRShared += doc.Locks.Global.AcquireCount.RShared
|
||||||
|
qiac.LGlobalAcquireCountWShared += doc.Locks.Global.AcquireCount.WShared
|
||||||
|
qiac.LDatabaseAcquireCountRShared += doc.Locks.Database.AcquireCount.RShared
|
||||||
|
qiac.LDatabaseAcquireWaitCountRShared += doc.Locks.Database.AcquireWaitCount.RShared
|
||||||
|
qiac.LDatabaseTimeAcquiringMicrosRShared += doc.Locks.Database.TimeAcquiringMicros.RShared
|
||||||
|
qiac.LCollectionAcquireCountRShared += doc.Locks.Collection.AcquireCount.RShared
|
||||||
|
|
||||||
|
qiac.DocsExamined = append(qiac.DocsExamined, float64(doc.DocsExamined))
|
||||||
|
qiac.KeysExamined = append(qiac.KeysExamined, float64(doc.KeysExamined))
|
||||||
s.Unlock()
|
s.Unlock()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -207,6 +221,26 @@ type QueryInfoAndCounters struct {
|
|||||||
PlanSummary string
|
PlanSummary string
|
||||||
CollScanCount int
|
CollScanCount int
|
||||||
CollScanSum int64 // in milliseconds
|
CollScanSum int64 // in milliseconds
|
||||||
|
|
||||||
|
DocsExamined []float64
|
||||||
|
KeysExamined []float64
|
||||||
|
TimeStamp time.Time
|
||||||
|
QueryHash string
|
||||||
|
AppName string
|
||||||
|
Client string
|
||||||
|
User string
|
||||||
|
Database string
|
||||||
|
Comments string
|
||||||
|
|
||||||
|
LGlobalAcquireCountRShared int
|
||||||
|
LGlobalAcquireCountWShared int
|
||||||
|
LDatabaseAcquireCountRShared int
|
||||||
|
LDatabaseAcquireWaitCountRShared int
|
||||||
|
LDatabaseTimeAcquiringMicrosRShared int64 // in microseconds
|
||||||
|
LCollectionAcquireCountRShared int
|
||||||
|
|
||||||
|
StorageBytesRead int
|
||||||
|
StorageTimeReadingMicros int64 // in microseconds
|
||||||
}
|
}
|
||||||
|
|
||||||
// times is an array of time.Time that implements the Sorter interface
|
// times is an array of time.Time that implements the Sorter interface
|
||||||
@@ -238,6 +272,7 @@ type totalCounters struct {
|
|||||||
Returned float64
|
Returned float64
|
||||||
QueryTime float64
|
QueryTime float64
|
||||||
Bytes float64
|
Bytes float64
|
||||||
|
DocsExamined float64
|
||||||
}
|
}
|
||||||
|
|
||||||
type QueryStats struct {
|
type QueryStats struct {
|
||||||
@@ -258,9 +293,7 @@ type QueryStats struct {
|
|||||||
Returned Statistics
|
Returned Statistics
|
||||||
Scanned Statistics
|
Scanned Statistics
|
||||||
|
|
||||||
PlanSummary string
|
DocsExamined Statistics
|
||||||
CollScanCount int
|
|
||||||
CollScanSum int64 // in milliseconds
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Statistics struct {
|
type Statistics struct {
|
||||||
@@ -283,6 +316,7 @@ func countersToStats(query QueryInfoAndCounters, uptime int64, tc totalCounters)
|
|||||||
Query: query.Query,
|
Query: query.Query,
|
||||||
Fingerprint: query.Fingerprint,
|
Fingerprint: query.Fingerprint,
|
||||||
Scanned: calcStats(query.NScanned),
|
Scanned: calcStats(query.NScanned),
|
||||||
|
DocsExamined: calcStats(query.DocsExamined),
|
||||||
Returned: calcStats(query.NReturned),
|
Returned: calcStats(query.NReturned),
|
||||||
QueryTime: calcStats(query.QueryTime),
|
QueryTime: calcStats(query.QueryTime),
|
||||||
ResponseLength: calcStats(query.ResponseLength),
|
ResponseLength: calcStats(query.ResponseLength),
|
||||||
@@ -290,9 +324,6 @@ func countersToStats(query QueryInfoAndCounters, uptime int64, tc totalCounters)
|
|||||||
LastSeen: query.LastSeen,
|
LastSeen: query.LastSeen,
|
||||||
Namespace: query.Namespace,
|
Namespace: query.Namespace,
|
||||||
QPS: float64(query.Count) / float64(uptime),
|
QPS: float64(query.Count) / float64(uptime),
|
||||||
PlanSummary: query.PlanSummary,
|
|
||||||
CollScanCount: query.CollScanCount,
|
|
||||||
CollScanSum: query.CollScanSum,
|
|
||||||
}
|
}
|
||||||
if tc.Scanned > 0 {
|
if tc.Scanned > 0 {
|
||||||
queryStats.Scanned.Pct = queryStats.Scanned.Total * 100 / tc.Scanned
|
queryStats.Scanned.Pct = queryStats.Scanned.Total * 100 / tc.Scanned
|
||||||
@@ -309,6 +340,9 @@ func countersToStats(query QueryInfoAndCounters, uptime int64, tc totalCounters)
|
|||||||
if queryStats.Returned.Total > 0 {
|
if queryStats.Returned.Total > 0 {
|
||||||
queryStats.Ratio = queryStats.Scanned.Total / queryStats.Returned.Total
|
queryStats.Ratio = queryStats.Scanned.Total / queryStats.Returned.Total
|
||||||
}
|
}
|
||||||
|
if queryStats.DocsExamined.Total > 0 {
|
||||||
|
queryStats.DocsExamined.Pct = queryStats.DocsExamined.Total / queryStats.DocsExamined.Total
|
||||||
|
}
|
||||||
|
|
||||||
return queryStats
|
return queryStats
|
||||||
}
|
}
|
||||||
@@ -321,6 +355,7 @@ func aggregateCounters(queries []QueryInfoAndCounters) QueryInfoAndCounters {
|
|||||||
qt.NReturned = append(qt.NReturned, query.NReturned...)
|
qt.NReturned = append(qt.NReturned, query.NReturned...)
|
||||||
qt.QueryTime = append(qt.QueryTime, query.QueryTime...)
|
qt.QueryTime = append(qt.QueryTime, query.QueryTime...)
|
||||||
qt.ResponseLength = append(qt.ResponseLength, query.ResponseLength...)
|
qt.ResponseLength = append(qt.ResponseLength, query.ResponseLength...)
|
||||||
|
qt.DocsExamined = append(qt.DocsExamined, query.DocsExamined...)
|
||||||
}
|
}
|
||||||
return qt
|
return qt
|
||||||
}
|
}
|
||||||
@@ -342,6 +377,9 @@ func calcTotalCounters(queries []QueryInfoAndCounters) totalCounters {
|
|||||||
|
|
||||||
bytes, _ := stats.Sum(query.ResponseLength)
|
bytes, _ := stats.Sum(query.ResponseLength)
|
||||||
tc.Bytes += bytes
|
tc.Bytes += bytes
|
||||||
|
|
||||||
|
docsExamined, _ := stats.Sum(query.DocsExamined)
|
||||||
|
tc.DocsExamined += docsExamined
|
||||||
}
|
}
|
||||||
return tc
|
return tc
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user