(ss []*Spanset)
| 12 | var errSpansetOperationMultiple = errors.New("spanset operators are not supported for multiple spansets per trace. consider using coalesce()") |
| 13 | |
| 14 | func (g GroupOperation) evaluate(ss []*Spanset) ([]*Spanset, error) { |
| 15 | result := make([]*Spanset, 0, len(ss)) |
| 16 | groups := g.groupBuffer |
| 17 | |
| 18 | // Iterate over each spanset in the input slice |
| 19 | for _, spanset := range ss { |
| 20 | // clear out the groups |
| 21 | for k := range groups { |
| 22 | delete(groups, k) |
| 23 | } |
| 24 | |
| 25 | // Iterate over each span in the spanset |
| 26 | for _, span := range spanset.Spans { |
| 27 | // Execute the FieldExpression for the span |
| 28 | result, err := g.Expression.execute(span) |
| 29 | if err != nil { |
| 30 | return nil, err |
| 31 | } |
| 32 | |
| 33 | // Check if the result already has a group in the map |
| 34 | group, ok := groups[result.MapKey()] |
| 35 | if !ok { |
| 36 | // If not, create a new group and add it to the map |
| 37 | group = &Spanset{} |
| 38 | // copy all existing attributes forward |
| 39 | group.Attributes = append(group.Attributes, spanset.Attributes...) |
| 40 | group.AddAttribute(g.String(), result) |
| 41 | groups[result.MapKey()] = group |
| 42 | } |
| 43 | |
| 44 | // Add the current spanset to the group |
| 45 | group.Spans = append(group.Spans, span) |
| 46 | } |
| 47 | |
| 48 | // add all groups created by this spanset to the result |
| 49 | for _, group := range groups { |
| 50 | result = append(result, group) |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | return result, nil |
| 55 | } |
| 56 | |
| 57 | // CoalesceOperation undoes grouping. It takes spansets and recombines them into |
| 58 | // one by trace id. Since all spansets are guaranteed to be from the same traceid |
nothing calls this directly
no test coverage detected