15
15
package sumologicexporter
16
16
17
17
import (
18
- "fmt"
19
18
"regexp"
20
- "sort"
21
- "strings"
22
19
23
20
"go.opentelemetry.io/collector/consumer/pdata"
24
21
tracetranslator "go.opentelemetry.io/collector/translator/trace"
@@ -28,9 +25,6 @@ type filter struct {
28
25
regexes []* regexp.Regexp
29
26
}
30
27
31
- // fields represents concatenated metadata
32
- type fields string
33
-
34
28
func newFilter (flds []string ) (filter , error ) {
35
29
metadataRegexes := make ([]* regexp.Regexp , len (flds ))
36
30
@@ -48,9 +42,9 @@ func newFilter(flds []string) (filter, error) {
48
42
}, nil
49
43
}
50
44
51
- // filterIn returns map of strings which matches at least one of the filter regexes
52
- func (f * filter ) filterIn (attributes pdata.AttributeMap ) map [ string ] string {
53
- returnValue := make (map [ string ] string )
45
+ // filterIn returns fields which match at least one of the filter regexes
46
+ func (f * filter ) filterIn (attributes pdata.AttributeMap ) fields {
47
+ returnValue := make (fields )
54
48
55
49
attributes .ForEach (func (k string , v pdata.AttributeValue ) {
56
50
for _ , regex := range f .regexes {
@@ -63,9 +57,9 @@ func (f *filter) filterIn(attributes pdata.AttributeMap) map[string]string {
63
57
return returnValue
64
58
}
65
59
66
- // filterOut returns map of strings which doesn 't match any of the filter regexes
67
- func (f * filter ) filterOut (attributes pdata.AttributeMap ) map [ string ] string {
68
- returnValue := make (map [ string ] string )
60
+ // filterOut returns fields which don 't match any of the filter regexes
61
+ func (f * filter ) filterOut (attributes pdata.AttributeMap ) fields {
62
+ returnValue := make (fields )
69
63
70
64
attributes .ForEach (func (k string , v pdata.AttributeValue ) {
71
65
for _ , regex := range f .regexes {
@@ -77,16 +71,3 @@ func (f *filter) filterOut(attributes pdata.AttributeMap) map[string]string {
77
71
})
78
72
return returnValue
79
73
}
80
-
81
- // getMetadata builds string which represents metadata in alphabetical order
82
- func (f * filter ) getMetadata (attributes pdata.AttributeMap ) fields {
83
- attrs := f .filterIn (attributes )
84
- metadata := make ([]string , 0 , len (attrs ))
85
-
86
- for k , v := range attrs {
87
- metadata = append (metadata , fmt .Sprintf ("%s=%s" , k , v ))
88
- }
89
- sort .Strings (metadata )
90
-
91
- return fields (strings .Join (metadata , ", " ))
92
- }
0 commit comments