@@ -10,7 +10,6 @@ import (
10
10
"testing"
11
11
12
12
"github.com/stretchr/testify/assert"
13
- "github.com/stretchr/testify/require"
14
13
"go.opentelemetry.io/collector/pdata/pcommon"
15
14
"go.opentelemetry.io/collector/pdata/plog"
16
15
"go.opentelemetry.io/collector/pdata/pmetric"
@@ -117,9 +116,17 @@ func TestSerializeLog(t *testing.T) {
117
116
{
118
117
name : "geo attributes" ,
119
118
logCustomizer : func (_ pcommon.Resource , _ pcommon.InstrumentationScope , record plog.LogRecord ) {
120
- record .Attributes ().PutDouble ("foo.geo.location.lon" , 1 )
121
- record .Attributes ().PutDouble ("foo.geo.location.lat" , 2 )
122
- record .Attributes ().PutDouble ("bar.geo.location.lat" , 3 )
119
+ record .Attributes ().PutDouble ("geo.location.lon" , 1.1 )
120
+ record .Attributes ().PutDouble ("geo.location.lat" , 2.2 )
121
+ record .Attributes ().PutDouble ("foo.bar.geo.location.lon" , 3.3 )
122
+ record .Attributes ().PutDouble ("foo.bar.geo.location.lat" , 4.4 )
123
+ record .Attributes ().PutDouble ("a.geo.location.lon" , 5.5 )
124
+ record .Attributes ().PutDouble ("b.geo.location.lat" , 6.6 )
125
+ record .Attributes ().PutDouble ("unrelatedgeo.location.lon" , 7.7 )
126
+ record .Attributes ().PutDouble ("unrelatedgeo.location.lat" , 8.8 )
127
+ record .Attributes ().PutDouble ("d" , 9.9 )
128
+ record .Attributes ().PutStr ("e.geo.location.lon" , "foo" )
129
+ record .Attributes ().PutStr ("e.geo.location.lat" , "bar" )
123
130
},
124
131
wantErr : false ,
125
132
expected : map [string ]any {
@@ -129,8 +136,15 @@ func TestSerializeLog(t *testing.T) {
129
136
"resource" : map [string ]any {},
130
137
"scope" : map [string ]any {},
131
138
"attributes" : map [string ]any {
132
- "foo.geo.location" : []any {json .Number ("1.0" ), json .Number ("2.0" )},
133
- "bar.geo.location.lat" : json .Number ("3.0" ),
139
+ "geo.location" : []any {json .Number ("1.1" ), json .Number ("2.2" )},
140
+ "foo.bar.geo.location" : []any {json .Number ("3.3" ), json .Number ("4.4" )},
141
+ "a.geo.location.lon" : json .Number ("5.5" ),
142
+ "b.geo.location.lat" : json .Number ("6.6" ),
143
+ "unrelatedgeo.location.lon" : json .Number ("7.7" ),
144
+ "unrelatedgeo.location.lat" : json .Number ("8.8" ),
145
+ "d" : json .Number ("9.9" ),
146
+ "e.geo.location.lon" : "foo" ,
147
+ "e.geo.location.lat" : "bar" ,
134
148
},
135
149
},
136
150
},
@@ -202,31 +216,3 @@ func TestSerializeMetricsConflict(t *testing.T) {
202
216
},
203
217
}, result , eventAsJSON )
204
218
}
205
-
206
- func TestMergeGeolocation (t * testing.T ) {
207
- attributes := map [string ]any {
208
- "geo.location.lon" : 1.1 ,
209
- "geo.location.lat" : 2.2 ,
210
- "foo.bar.geo.location.lon" : 3.3 ,
211
- "foo.bar.geo.location.lat" : 4.4 ,
212
- "a.geo.location.lon" : 5.5 ,
213
- "b.geo.location.lat" : 6.6 ,
214
- "unrelatedgeo.location.lon" : 7.7 ,
215
- "unrelatedgeo.location.lat" : 8.8 ,
216
- "d" : 9.9 ,
217
- "e.geo.location.lon" : "foo" ,
218
- "e.geo.location.lat" : "bar" ,
219
- }
220
- wantAttributes := map [string ]any {
221
- "a.geo.location.lon" : 5.5 ,
222
- "b.geo.location.lat" : 6.6 ,
223
- "geo.location" : []any {1.1 , 2.2 },
224
- "foo.bar.geo.location" : []any {3.3 , 4.4 },
225
- }
226
- input := pcommon .NewMap ()
227
- err := input .FromRaw (attributes )
228
- require .NoError (t , err )
229
- output := mergeGeolocation (input )
230
- after := output .AsRaw ()
231
- assert .Equal (t , wantAttributes , after )
232
- }
0 commit comments