Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix nil pointer to support mongo 4.4 #32

Merged
merged 1 commit into from
Dec 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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