(dw, w int64, labels string, numLabel map[string][]int64, numUnit map[string][]string, format func(int64, string) string, flat bool)
| 655 | } |
| 656 | |
| 657 | func (n *Node) addSample(dw, w int64, labels string, numLabel map[string][]int64, numUnit map[string][]string, format func(int64, string) string, flat bool) { |
| 658 | // Update sample value |
| 659 | if flat { |
| 660 | n.FlatDiv += dw |
| 661 | n.Flat += w |
| 662 | } else { |
| 663 | n.CumDiv += dw |
| 664 | n.Cum += w |
| 665 | } |
| 666 | |
| 667 | // Add string tags |
| 668 | if labels != "" { |
| 669 | t := n.LabelTags.findOrAddTag(labels, "", 0) |
| 670 | if flat { |
| 671 | t.FlatDiv += dw |
| 672 | t.Flat += w |
| 673 | } else { |
| 674 | t.CumDiv += dw |
| 675 | t.Cum += w |
| 676 | } |
| 677 | } |
| 678 | |
| 679 | numericTags := n.NumericTags[labels] |
| 680 | if numericTags == nil { |
| 681 | numericTags = TagMap{} |
| 682 | n.NumericTags[labels] = numericTags |
| 683 | } |
| 684 | // Add numeric tags |
| 685 | if format == nil { |
| 686 | format = defaultLabelFormat |
| 687 | } |
| 688 | for k, nvals := range numLabel { |
| 689 | units := numUnit[k] |
| 690 | for i, v := range nvals { |
| 691 | var t *Tag |
| 692 | if len(units) > 0 { |
| 693 | t = numericTags.findOrAddTag(format(v, units[i]), units[i], v) |
| 694 | } else { |
| 695 | t = numericTags.findOrAddTag(format(v, k), k, v) |
| 696 | } |
| 697 | if flat { |
| 698 | t.FlatDiv += dw |
| 699 | t.Flat += w |
| 700 | } else { |
| 701 | t.CumDiv += dw |
| 702 | t.Cum += w |
| 703 | } |
| 704 | } |
| 705 | } |
| 706 | } |
| 707 | |
| 708 | func defaultLabelFormat(v int64, key string) string { |
| 709 | return strconv.FormatInt(v, 10) |
no test coverage detected