Skip to content

Commit

Permalink
fix nil pointer to support mongo 4.4 (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
hzhao-wish authored Dec 13, 2022
1 parent 65d9e0b commit d5aa8f6
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions collector/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,13 @@ type PreloadStats struct {

// Export exposes the preload stats.
func (preloadStats *PreloadStats) Export(ch chan<- prometheus.Metric) {
metricsReplPreloadDocsNumTotal.Set(preloadStats.Docs.Num)
metricsReplPreloadDocsTotalMilliseconds.Set(preloadStats.Docs.TotalMillis)
if preloadStats != nil {
metricsReplPreloadDocsNumTotal.Set(preloadStats.Docs.Num)
metricsReplPreloadDocsTotalMilliseconds.Set(preloadStats.Docs.TotalMillis)

metricsReplPreloadIndexesNumTotal.Set(preloadStats.Indexes.Num)
metricsReplPreloadIndexesTotalMilliseconds.Set(preloadStats.Indexes.TotalMillis)
metricsReplPreloadIndexesNumTotal.Set(preloadStats.Indexes.Num)
metricsReplPreloadIndexesTotalMilliseconds.Set(preloadStats.Indexes.TotalMillis)
}
}

// StorageStats are the stats associated with the storage.
Expand Down Expand Up @@ -420,8 +422,8 @@ func (cursorStats *CursorStats) Export(ch chan<- prometheus.Metric) {

// TTLStats are the stats with a ttl index
type TTLStats struct {
DeletedDocuments float64 `bson:"deletedDocuments"`
Passes float64 `bson:"passes"`
DeletedDocuments float64 `bson:"deletedDocuments"`
Passes float64 `bson:"passes"`
}

// Export exports the ttl stats.
Expand All @@ -432,8 +434,8 @@ func (ttlStats *TTLStats) Export(ch chan<- prometheus.Metric) {

// QueryStats are the stats with a ttl index
type QueryStats struct {
PlanCacheSize float64 `bson:"planCacheTotalSizeEstimateBytes"`
UpdateCount float64 `bson:"updateOneOpStyleBroadcastWithExactIDCount"`
PlanCacheSize float64 `bson:"planCacheTotalSizeEstimateBytes"`
UpdateCount float64 `bson:"updateOneOpStyleBroadcastWithExactIDCount"`
}

// Export exports the query stats.
Expand Down

0 comments on commit d5aa8f6

Please sign in to comment.