@@ -79,7 +79,8 @@ func TestClientSpanWithSchemeHostTargetAttributesStable(t *testing.T) {
79
79
attributes [string (conventions .HTTPRequestMethodKey )] = "GET"
80
80
attributes [string (conventions .URLSchemeKey )] = "https"
81
81
attributes [string (conventionsv112 .HTTPHostKey )] = "api.example.com"
82
- attributes [string (conventions .URLQueryKey )] = "/users/junit"
82
+ attributes [string (conventions .URLPathKey )] = "/users/junit"
83
+ attributes [string (conventions .URLQueryKey )] = "v=1"
83
84
attributes [string (conventions .HTTPResponseStatusCodeKey )] = 200
84
85
attributes ["user.id" ] = "junit"
85
86
span := constructHTTPClientSpan (attributes )
@@ -92,7 +93,7 @@ func TestClientSpanWithSchemeHostTargetAttributesStable(t *testing.T) {
92
93
require .NoError (t , w .Encode (httpData ))
93
94
jsonStr := w .String ()
94
95
testWriters .release (w )
95
- assert .Contains (t , jsonStr , "https://api.example.com/users/junit" )
96
+ assert .Contains (t , jsonStr , "https://api.example.com/users/junit?v=1 " )
96
97
}
97
98
98
99
func TestClientSpanWithPeerAttributes (t * testing.T ) {
@@ -128,7 +129,7 @@ func TestClientSpanWithPeerAttributesStable(t *testing.T) {
128
129
attributes [string (conventionsv112 .NetPeerNameKey )] = "kb234.example.com"
129
130
attributes [string (conventionsv112 .NetPeerPortKey )] = 8080
130
131
attributes [string (conventionsv112 .NetPeerIPKey )] = "10.8.17.36"
131
- attributes [string (conventions .URLQueryKey )] = "/ users/ junit"
132
+ attributes [string (conventions .URLQueryKey )] = "users= junit"
132
133
attributes [string (conventions .HTTPResponseStatusCodeKey )] = 200
133
134
span := constructHTTPClientSpan (attributes )
134
135
@@ -143,7 +144,7 @@ func TestClientSpanWithPeerAttributesStable(t *testing.T) {
143
144
require .NoError (t , w .Encode (httpData ))
144
145
jsonStr := w .String ()
145
146
testWriters .release (w )
146
- assert .Contains (t , jsonStr , "http://kb234.example.com:8080/users/ junit" )
147
+ assert .Contains (t , jsonStr , "http://kb234.example.com:8080/? users= junit" )
147
148
}
148
149
149
150
func TestClientSpanWithHttpPeerAttributes (t * testing.T ) {
@@ -279,7 +280,7 @@ func TestServerSpanWithSchemeHostTargetAttributesStable(t *testing.T) {
279
280
attributes [string (conventions .HTTPRequestMethodKey )] = http .MethodGet
280
281
attributes [string (conventions .URLSchemeKey )] = "https"
281
282
attributes [string (conventions .ServerAddressKey )] = "api.example.com"
282
- attributes [string (conventions .URLQueryKey )] = "/users/junit"
283
+ attributes [string (conventions .URLPathKey )] = "/users/junit"
283
284
attributes [string (conventions .ClientAddressKey )] = "192.168.15.32"
284
285
attributes [string (conventions .HTTPResponseStatusCodeKey )] = 200
285
286
span := constructHTTPServerSpan (attributes )
@@ -295,6 +296,28 @@ func TestServerSpanWithSchemeHostTargetAttributesStable(t *testing.T) {
295
296
assert .Contains (t , jsonStr , "https://api.example.com/users/junit" )
296
297
}
297
298
299
+ func TestServerSpanWithNewConventionsWithURLPath (t * testing.T ) {
300
+ attributes := make (map [string ]any )
301
+ attributes [string (conventions .HTTPRequestMethodKey )] = http .MethodGet
302
+ attributes [string (conventions .ServerAddressKey )] = "localhost"
303
+ attributes [string (conventions .URLSchemeKey )] = "http"
304
+ attributes [string (conventions .URLQueryKey )] = "?version=test"
305
+ attributes [string (conventions .URLPathKey )] = "/api"
306
+ attributes [string (conventions .ClientAddressKey )] = "127.0.0.1"
307
+ attributes [string (conventions .HTTPResponseStatusCodeKey )] = 200
308
+ span := constructHTTPServerSpan (attributes )
309
+
310
+ filtered , httpData := makeHTTP (span )
311
+
312
+ assert .NotNil (t , httpData )
313
+ assert .NotNil (t , filtered )
314
+ w := testWriters .borrow ()
315
+ require .NoError (t , w .Encode (httpData ))
316
+ jsonStr := w .String ()
317
+ testWriters .release (w )
318
+ assert .Contains (t , jsonStr , "http://localhost/api?version=test" )
319
+ }
320
+
298
321
func TestServerSpanWithSchemeServernamePortTargetAttributes (t * testing.T ) {
299
322
attributes := make (map [string ]any )
300
323
attributes [string (conventionsv112 .HTTPMethodKey )] = http .MethodGet
@@ -323,7 +346,7 @@ func TestServerSpanWithSchemeServernamePortTargetAttributesStable(t *testing.T)
323
346
attributes [string (conventions .URLSchemeKey )] = "https"
324
347
attributes [string (conventions .ServerAddressKey )] = "api.example.com"
325
348
attributes [string (conventions .ServerPortKey )] = 443
326
- attributes [string (conventions .URLQueryKey )] = "/ users/ junit"
349
+ attributes [string (conventions .URLQueryKey )] = "users= junit"
327
350
attributes [string (conventions .ClientAddressKey )] = "192.168.15.32"
328
351
attributes [string (conventions .HTTPResponseStatusCodeKey )] = 200
329
352
span := constructHTTPServerSpan (attributes )
@@ -336,7 +359,7 @@ func TestServerSpanWithSchemeServernamePortTargetAttributesStable(t *testing.T)
336
359
require .NoError (t , w .Encode (httpData ))
337
360
jsonStr := w .String ()
338
361
testWriters .release (w )
339
- assert .Contains (t , jsonStr , "https://api.example.com/users/ junit" )
362
+ assert .Contains (t , jsonStr , "https://api.example.com/? users= junit" )
340
363
}
341
364
342
365
func TestServerSpanWithSchemeNamePortTargetAttributes (t * testing.T ) {
0 commit comments