(bpsm, nsIndexStat map[string]interface{})
| 625 | } |
| 626 | |
| 627 | func extractStats(bpsm, nsIndexStat map[string]interface{}) error { |
| 628 | // common stats across different index types |
| 629 | v := jsonpointer.Get(bpsm, "/DocCount") |
| 630 | if vuint64, ok := v.(uint64); ok { |
| 631 | updateStat("doc_count", float64(vuint64), nsIndexStat) |
| 632 | } |
| 633 | v = jsonpointer.Get(bpsm, "/bleveIndexStats/index/term_searchers_started") |
| 634 | if vuint64, ok := v.(uint64); ok { |
| 635 | updateStat("total_term_searchers", float64(vuint64), nsIndexStat) |
| 636 | } |
| 637 | v = jsonpointer.Get(bpsm, "/bleveIndexStats/index/term_searchers_finished") |
| 638 | if vuint64, ok := v.(uint64); ok { |
| 639 | updateStat("total_term_searchers_finished", float64(vuint64), nsIndexStat) |
| 640 | } |
| 641 | v = jsonpointer.Get(bpsm, "/bleveIndexStats/index/num_plain_text_bytes_indexed") |
| 642 | if vuint64, ok := v.(uint64); ok { |
| 643 | updateStat("total_bytes_indexed", float64(vuint64), nsIndexStat) |
| 644 | } |
| 645 | |
| 646 | v = jsonpointer.Get(bpsm, "/bleveIndexStats/index/kv") |
| 647 | if _, ok := v.(map[string]interface{}); ok { |
| 648 | // see if metrics are enabled, they would always be at the top-level |
| 649 | v = jsonpointer.Get(bpsm, "/bleveIndexStats/index/kv/metrics") |
| 650 | if metrics, ok := v.(map[string]interface{}); ok { |
| 651 | extractMetricsStats(metrics, nsIndexStat) |
| 652 | // if we found metrics, look for moss one level deeper |
| 653 | v = jsonpointer.Get(bpsm, "/bleveIndexStats/index/kv/kv/moss") |
| 654 | if mossStats, ok := v.(*moss.CollectionStats); ok { |
| 655 | extractMossStats(mossStats, nsIndexStat) |
| 656 | // if we found moss, look for kv one level deeper |
| 657 | v = jsonpointer.Get(bpsm, "/bleveIndexStats/index/kv/kv/kv") |
| 658 | if kvStats, ok := v.(map[string]interface{}); ok { |
| 659 | extractKVStats(kvStats, nsIndexStat) |
| 660 | } |
| 661 | } else { |
| 662 | // no moss at this level, but still look for kv stats |
| 663 | v = jsonpointer.Get(bpsm, "/bleveIndexStats/index/kv/kv") |
| 664 | if kvStats, ok := v.(map[string]interface{}); ok { |
| 665 | extractKVStats(kvStats, nsIndexStat) |
| 666 | } |
| 667 | } |
| 668 | } else { |
| 669 | // maybe no metrics, look for moss at this level |
| 670 | v = jsonpointer.Get(bpsm, "/bleveIndexStats/index/kv/moss") |
| 671 | if mossStats, ok := v.(*moss.CollectionStats); ok { |
| 672 | extractMossStats(mossStats, nsIndexStat) |
| 673 | // if we found moss, look for kv one level deeper |
| 674 | v = jsonpointer.Get(bpsm, "/bleveIndexStats/index/kv/kv") |
| 675 | if kvStats, ok := v.(map[string]interface{}); ok { |
| 676 | extractKVStats(kvStats, nsIndexStat) |
| 677 | } |
| 678 | } else { |
| 679 | // maybe no metrics or moss, look for kv here |
| 680 | v = jsonpointer.Get(bpsm, "/bleveIndexStats/index/kv") |
| 681 | if kvStats, ok := v.(map[string]interface{}); ok { |
| 682 | extractKVStats(kvStats, nsIndexStat) |
| 683 | } |
| 684 | } |
no test coverage detected