@@ -1328,7 +1328,7 @@ mod tests {
1328
1328
r#"{
1329
1329
"rate_by_service": {
1330
1330
"service:foo,env:staging": 1.0,
1331
- "service:,env:": 0.8
1331
+ "service:,env:": 0.8
1332
1332
}
1333
1333
}"# ,
1334
1334
) ;
@@ -1548,7 +1548,7 @@ mod tests {
1548
1548
r#"{
1549
1549
"rate_by_service": {
1550
1550
"service:foo,env:staging": 1.0,
1551
- "service:,env:": 0.8
1551
+ "service:,env:": 0.8
1552
1552
}
1553
1553
}"# ,
1554
1554
) ;
@@ -1580,7 +1580,7 @@ mod tests {
1580
1580
r#"{
1581
1581
"rate_by_service": {
1582
1582
"service:foo,env:staging": 1.0,
1583
- "service:,env:": 0.8
1583
+ "service:,env:": 0.8
1584
1584
}
1585
1585
}"#
1586
1586
. to_string( )
@@ -1695,7 +1695,7 @@ mod tests {
1695
1695
let response_body = r#"{
1696
1696
"rate_by_service": {
1697
1697
"service:foo,env:staging": 1.0,
1698
- "service:,env:": 0.8
1698
+ "service:,env:": 0.8
1699
1699
}
1700
1700
}"# ;
1701
1701
let traces_endpoint = server. mock ( |when, then| {
@@ -1742,4 +1742,93 @@ mod tests {
1742
1742
}
1743
1743
metrics_endpoint. assert_hits ( 1 ) ;
1744
1744
}
1745
+
1746
+ #[ test]
1747
+ #[ cfg_attr( miri, ignore) ]
1748
+ fn test_agent_malfunction_info_4xx ( ) {
1749
+ test_agent_malfunction_info ( 404 , r#"{"error":"Not Found"}"# , Duration :: from_secs ( 0 ) ) ;
1750
+ }
1751
+
1752
+ #[ test]
1753
+ #[ cfg_attr( miri, ignore) ]
1754
+ fn test_agent_malfunction_info_5xx ( ) {
1755
+ test_agent_malfunction_info (
1756
+ 500 ,
1757
+ r#"{"error":"Internal Server Error"}"# ,
1758
+ Duration :: from_secs ( 0 ) ,
1759
+ ) ;
1760
+ }
1761
+
1762
+ #[ test]
1763
+ #[ cfg_attr( miri, ignore) ]
1764
+ fn test_agent_malfunction_info_timeout ( ) {
1765
+ test_agent_malfunction_info (
1766
+ 408 ,
1767
+ r#"{"error":"Internal Server Error"}"# ,
1768
+ Duration :: from_secs ( 600 ) ,
1769
+ ) ;
1770
+ }
1771
+
1772
+ #[ test]
1773
+ #[ cfg_attr( miri, ignore) ]
1774
+ fn test_agent_malfunction_info_wrong_answer ( ) {
1775
+ test_agent_malfunction_info ( 200 , "WRONG_ANSWER" , Duration :: from_secs ( 0 ) ) ;
1776
+ }
1777
+
1778
+ fn test_agent_malfunction_info ( status : u16 , response : & str , delay : Duration ) {
1779
+ let server = MockServer :: start ( ) ;
1780
+
1781
+ let mock_traces = server. mock ( |when, then| {
1782
+ when. method ( POST )
1783
+ . header ( "Content-type" , "application/msgpack" )
1784
+ . path ( "/v0.4/traces" ) ;
1785
+ then. status ( 200 ) . body (
1786
+ r#"{
1787
+ "rate_by_service": {
1788
+ "service:test,env:staging": 1.0,
1789
+ }
1790
+ }"# ,
1791
+ ) ;
1792
+ } ) ;
1793
+
1794
+ let mock_info = server. mock ( |when, then| {
1795
+ when. method ( GET ) . path ( "/info" ) ;
1796
+ then. delay ( delay) . status ( status) . body ( response) ;
1797
+ } ) ;
1798
+
1799
+ let builder = TraceExporterBuilder :: default ( ) ;
1800
+ let exporter = builder
1801
+ . set_url ( & server. url ( "/" ) )
1802
+ . set_service ( "test" )
1803
+ . set_env ( "staging" )
1804
+ . set_tracer_version ( "v0.1" )
1805
+ . set_language ( "nodejs" )
1806
+ . set_language_version ( "1.0" )
1807
+ . set_language_interpreter ( "v8" )
1808
+ . set_input_format ( TraceExporterInputFormat :: V04 )
1809
+ . set_output_format ( TraceExporterOutputFormat :: V04 )
1810
+ . enable_stats ( Duration :: from_secs ( 10 ) )
1811
+ . build ( )
1812
+ . unwrap ( ) ;
1813
+
1814
+ let trace_chunk = vec ! [ Span {
1815
+ duration: 10 ,
1816
+ ..Default :: default ( )
1817
+ } ] ;
1818
+
1819
+ let data = tinybytes:: Bytes :: from ( rmp_serde:: to_vec_named ( & vec ! [ trace_chunk] ) . unwrap ( ) ) ;
1820
+
1821
+ // Wait for the info fetcher to get the config
1822
+ while mock_info. hits ( ) == 0 {
1823
+ exporter. runtime . block_on ( async {
1824
+ sleep ( Duration :: from_millis ( 100 ) ) . await ;
1825
+ } )
1826
+ }
1827
+
1828
+ let _ = exporter. send ( data, 1 ) . unwrap ( ) ;
1829
+
1830
+ exporter. shutdown ( None ) . unwrap ( ) ;
1831
+
1832
+ mock_traces. assert ( ) ;
1833
+ }
1745
1834
}
0 commit comments