@@ -407,10 +407,18 @@ type ReplStats struct {
407407
408408// Export exposes the replication stats.
409409func (replStats * ReplStats ) Export (ch chan <- prometheus.Metric ) {
410- replStats .Apply .Export (ch )
411- replStats .Buffer .Export (ch )
412- replStats .Network .Export (ch )
413- replStats .PreloadStats .Export (ch )
410+ if replStats .Apply != nil {
411+ replStats .Apply .Export (ch )
412+ }
413+ if replStats .Buffer != nil {
414+ replStats .Buffer .Export (ch )
415+ }
416+ if replStats .Network != nil {
417+ replStats .Network .Export (ch )
418+ }
419+ if replStats .PreloadStats != nil {
420+ replStats .PreloadStats .Export (ch )
421+ }
414422 // 3.0+ only
415423 if replStats .Executor != nil {
416424 replStats .Executor .Export (ch )
@@ -425,11 +433,15 @@ type PreloadStats struct {
425433
426434// Export exposes the preload stats.
427435func (preloadStats * PreloadStats ) Export (ch chan <- prometheus.Metric ) {
428- metricsReplPreloadDocsNumTotal .Set (preloadStats .Docs .Num )
429- metricsReplPreloadDocsTotalMilliseconds .Set (preloadStats .Docs .TotalMillis )
436+ if preloadStats .Docs != nil {
437+ metricsReplPreloadDocsNumTotal .Set (preloadStats .Docs .Num )
438+ metricsReplPreloadDocsTotalMilliseconds .Set (preloadStats .Docs .TotalMillis )
439+ }
430440
431- metricsReplPreloadIndexesNumTotal .Set (preloadStats .Indexes .Num )
432- metricsReplPreloadIndexesTotalMilliseconds .Set (preloadStats .Indexes .TotalMillis )
441+ if preloadStats .Indexes != nil {
442+ metricsReplPreloadIndexesNumTotal .Set (preloadStats .Indexes .Num )
443+ metricsReplPreloadIndexesTotalMilliseconds .Set (preloadStats .Indexes .TotalMillis )
444+ }
433445}
434446
435447// StorageStats are the stats associated with the storage.
0 commit comments