@@ -293,7 +293,10 @@ mod tests {
293293 }
294294
295295 impl crate :: types:: SpanProperties for TestSpan {
296- type Attribute = TestAttr ;
296+ type Attribute < ' a >
297+ = & ' a TestAttr
298+ where
299+ Self : ' a ;
297300
298301 fn operation_name ( & self ) -> Cow < ' _ , str > {
299302 Cow :: Borrowed ( self . name )
@@ -310,10 +313,7 @@ mod tests {
310313 fn status_code ( & self ) -> Option < u32 > {
311314 self . status_code
312315 }
313- fn attributes < ' a > ( & ' a self ) -> impl Iterator < Item = & ' a TestAttr >
314- where
315- Self : ' a ,
316- {
316+ fn attributes ( & self ) -> impl Iterator < Item = & TestAttr > + ' _ {
317317 self . attrs . iter ( )
318318 }
319319 fn get_alternate_key < ' b > ( & self , key : & ' b str ) -> Option < Cow < ' b , str > > {
@@ -362,9 +362,21 @@ mod tests {
362362 #[ test]
363363 fn test_from_configs_preserves_provenance ( ) {
364364 let configs = vec ! [
365- SamplingRuleConfig { sample_rate: 1.0 , provenance: "customer" . into( ) , ..Default :: default ( ) } ,
366- SamplingRuleConfig { sample_rate: 0.5 , provenance: "dynamic" . into( ) , ..Default :: default ( ) } ,
367- SamplingRuleConfig { sample_rate: 0.1 , provenance: "default" . into( ) , ..Default :: default ( ) } ,
365+ SamplingRuleConfig {
366+ sample_rate: 1.0 ,
367+ provenance: "customer" . into( ) ,
368+ ..Default :: default ( )
369+ } ,
370+ SamplingRuleConfig {
371+ sample_rate: 0.5 ,
372+ provenance: "dynamic" . into( ) ,
373+ ..Default :: default ( )
374+ } ,
375+ SamplingRuleConfig {
376+ sample_rate: 0.1 ,
377+ provenance: "default" . into( ) ,
378+ ..Default :: default ( )
379+ } ,
368380 ] ;
369381 let rules = SamplingRule :: from_configs ( configs) ;
370382 assert_eq ! ( rules[ 0 ] . provenance, "customer" ) ;
@@ -377,7 +389,10 @@ mod tests {
377389 #[ test]
378390 fn test_matches_http_status_code_rule_matching ( ) {
379391 let rule = SamplingRule :: new (
380- 1.0 , None , None , None ,
392+ 1.0 ,
393+ None ,
394+ None ,
395+ None ,
381396 Some ( HashMap :: from ( [ ( "http.status_code" . into ( ) , "200" . into ( ) ) ] ) ) ,
382397 None ,
383398 ) ;
@@ -389,7 +404,10 @@ mod tests {
389404 #[ test]
390405 fn test_matches_http_status_code_rule_not_matching ( ) {
391406 let rule = SamplingRule :: new (
392- 1.0 , None , None , None ,
407+ 1.0 ,
408+ None ,
409+ None ,
410+ None ,
393411 Some ( HashMap :: from ( [ ( "http.status_code" . into ( ) , "200" . into ( ) ) ] ) ) ,
394412 None ,
395413 ) ;
@@ -401,7 +419,10 @@ mod tests {
401419 #[ test]
402420 fn test_matches_http_status_code_absent_returns_false ( ) {
403421 let rule = SamplingRule :: new (
404- 1.0 , None , None , None ,
422+ 1.0 ,
423+ None ,
424+ None ,
425+ None ,
405426 Some ( HashMap :: from ( [ ( "http.status_code" . into ( ) , "200" . into ( ) ) ] ) ) ,
406427 None ,
407428 ) ;
@@ -412,8 +433,14 @@ mod tests {
412433 #[ test]
413434 fn test_matches_http_response_status_code_key ( ) {
414435 let rule = SamplingRule :: new (
415- 1.0 , None , None , None ,
416- Some ( HashMap :: from ( [ ( "http.response.status_code" . into ( ) , "404" . into ( ) ) ] ) ) ,
436+ 1.0 ,
437+ None ,
438+ None ,
439+ None ,
440+ Some ( HashMap :: from ( [ (
441+ "http.response.status_code" . into ( ) ,
442+ "404" . into ( ) ,
443+ ) ] ) ) ,
417444 None ,
418445 ) ;
419446 let mut span = make_span ( "op" , "svc" , "res" ) ;
@@ -424,7 +451,10 @@ mod tests {
424451 #[ test]
425452 fn test_matches_http_status_code_wildcard ( ) {
426453 let rule = SamplingRule :: new (
427- 1.0 , None , None , None ,
454+ 1.0 ,
455+ None ,
456+ None ,
457+ None ,
428458 Some ( HashMap :: from ( [ ( "http.status_code" . into ( ) , "2*" . into ( ) ) ] ) ) ,
429459 None ,
430460 ) ;
@@ -440,25 +470,43 @@ mod tests {
440470 // Rule uses DD key "http.method"; span stores OTel key "http.request.method"
441471 // with alternate mapping back to "http.method"
442472 let rule = SamplingRule :: new (
443- 1.0 , None , None , None ,
473+ 1.0 ,
474+ None ,
475+ None ,
476+ None ,
444477 Some ( HashMap :: from ( [ ( "http.method" . into ( ) , "POST" . into ( ) ) ] ) ) ,
445478 None ,
446479 ) ;
447480 let mut span = make_span ( "op" , "svc" , "res" ) ;
448- span. attrs = vec ! [ TestAttr { key: "http.request.method" , value: TestValue { value: "POST" , is_metric: false } } ] ;
481+ span. attrs = vec ! [ TestAttr {
482+ key: "http.request.method" ,
483+ value: TestValue {
484+ value: "POST" ,
485+ is_metric: false ,
486+ } ,
487+ } ] ;
449488 span. alternates = vec ! [ ( "http.request.method" , "http.method" ) ] ;
450489 assert ! ( rule. matches( & span) ) ;
451490 }
452491
453492 #[ test]
454493 fn test_matches_alternate_key_value_mismatch ( ) {
455494 let rule = SamplingRule :: new (
456- 1.0 , None , None , None ,
495+ 1.0 ,
496+ None ,
497+ None ,
498+ None ,
457499 Some ( HashMap :: from ( [ ( "http.method" . into ( ) , "POST" . into ( ) ) ] ) ) ,
458500 None ,
459501 ) ;
460502 let mut span = make_span ( "op" , "svc" , "res" ) ;
461- span. attrs = vec ! [ TestAttr { key: "http.request.method" , value: TestValue { value: "GET" , is_metric: false } } ] ;
503+ span. attrs = vec ! [ TestAttr {
504+ key: "http.request.method" ,
505+ value: TestValue {
506+ value: "GET" ,
507+ is_metric: false ,
508+ } ,
509+ } ] ;
462510 span. alternates = vec ! [ ( "http.request.method" , "http.method" ) ] ;
463511 assert ! ( !rule. matches( & span) ) ;
464512 }
@@ -467,12 +515,21 @@ mod tests {
467515 fn test_matches_non_http_tag_no_alternate_fallback ( ) {
468516 // Non-http. keys do NOT fall through to alternate-key scan
469517 let rule = SamplingRule :: new (
470- 1.0 , None , None , None ,
518+ 1.0 ,
519+ None ,
520+ None ,
521+ None ,
471522 Some ( HashMap :: from ( [ ( "custom.tag" . into ( ) , "value" . into ( ) ) ] ) ) ,
472523 None ,
473524 ) ;
474525 let mut span = make_span ( "op" , "svc" , "res" ) ;
475- span. attrs = vec ! [ TestAttr { key: "some.other.key" , value: TestValue { value: "value" , is_metric: false } } ] ;
526+ span. attrs = vec ! [ TestAttr {
527+ key: "some.other.key" ,
528+ value: TestValue {
529+ value: "value" ,
530+ is_metric: false ,
531+ } ,
532+ } ] ;
476533 span. alternates = vec ! [ ( "some.other.key" , "custom.tag" ) ] ;
477534 assert ! ( !rule. matches( & span) ) ;
478535 }
@@ -482,24 +539,42 @@ mod tests {
482539 #[ test]
483540 fn test_match_attribute_value_non_integer_float_wildcard_matches ( ) {
484541 let rule = SamplingRule :: new (
485- 1.0 , None , None , None ,
542+ 1.0 ,
543+ None ,
544+ None ,
545+ None ,
486546 Some ( HashMap :: from ( [ ( "score" . into ( ) , "*" . into ( ) ) ] ) ) ,
487547 None ,
488548 ) ;
489549 let mut span = make_span ( "op" , "svc" , "res" ) ;
490- span. attrs = vec ! [ TestAttr { key: "score" , value: TestValue { value: "3.14" , is_metric: true } } ] ;
550+ span. attrs = vec ! [ TestAttr {
551+ key: "score" ,
552+ value: TestValue {
553+ value: "3.14" ,
554+ is_metric: true ,
555+ } ,
556+ } ] ;
491557 assert ! ( rule. matches( & span) ) ;
492558 }
493559
494560 #[ test]
495561 fn test_match_attribute_value_non_integer_float_non_wildcard_no_match ( ) {
496562 let rule = SamplingRule :: new (
497- 1.0 , None , None , None ,
563+ 1.0 ,
564+ None ,
565+ None ,
566+ None ,
498567 Some ( HashMap :: from ( [ ( "score" . into ( ) , "3.14" . into ( ) ) ] ) ) ,
499568 None ,
500569 ) ;
501570 let mut span = make_span ( "op" , "svc" , "res" ) ;
502- span. attrs = vec ! [ TestAttr { key: "score" , value: TestValue { value: "3.14" , is_metric: true } } ] ;
571+ span. attrs = vec ! [ TestAttr {
572+ key: "score" ,
573+ value: TestValue {
574+ value: "3.14" ,
575+ is_metric: true ,
576+ } ,
577+ } ] ;
503578 assert ! ( !rule. matches( & span) ) ;
504579 }
505580
0 commit comments