@@ -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,85 @@ 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 ( 500 , r#"{"error":"Internal Server Error"}"# , Duration :: from_secs ( 0 ) ) ;
1756
+ }
1757
+
1758
+ #[ test]
1759
+ #[ cfg_attr( miri, ignore) ]
1760
+ fn test_agent_malfunction_info_timeout ( ) {
1761
+ test_agent_malfunction_info ( 408 , r#"{"error":"Internal Server Error"}"# , Duration :: from_secs ( 600 ) ) ;
1762
+ }
1763
+
1764
+ #[ test]
1765
+ #[ cfg_attr( miri, ignore) ]
1766
+ fn test_agent_malfunction_info_wrong_answer ( ) {
1767
+ test_agent_malfunction_info ( 200 , "WRONG_ANSWER" , Duration :: from_secs ( 0 ) ) ;
1768
+ }
1769
+
1770
+ fn test_agent_malfunction_info ( status : u16 , response : & str , delay : Duration ) {
1771
+ let server = MockServer :: start ( ) ;
1772
+
1773
+ let mock_traces = server. mock ( |when, then| {
1774
+ when. method ( POST )
1775
+ . header ( "Content-type" , "application/msgpack" )
1776
+ . path ( "/v0.4/traces" ) ;
1777
+ then. status ( 200 ) . body (
1778
+ r#"{
1779
+ "rate_by_service": {
1780
+ "service:test,env:staging": 1.0,
1781
+ }
1782
+ }"# ,
1783
+ ) ;
1784
+ } ) ;
1785
+
1786
+ let mock_info = server. mock ( |when, then| {
1787
+ when. method ( GET ) . path ( "/info" ) ;
1788
+ then. delay ( delay) . status ( status) . body ( response) ;
1789
+ } ) ;
1790
+
1791
+ let builder = TraceExporterBuilder :: default ( ) ;
1792
+ let exporter = builder
1793
+ . set_url ( & server. url ( "/" ) )
1794
+ . set_service ( "test" )
1795
+ . set_env ( "staging" )
1796
+ . set_tracer_version ( "v0.1" )
1797
+ . set_language ( "nodejs" )
1798
+ . set_language_version ( "1.0" )
1799
+ . set_language_interpreter ( "v8" )
1800
+ . set_input_format ( TraceExporterInputFormat :: V04 )
1801
+ . set_output_format ( TraceExporterOutputFormat :: V04 )
1802
+ . enable_stats ( Duration :: from_secs ( 10 ) )
1803
+ . build ( )
1804
+ . unwrap ( ) ;
1805
+
1806
+ let trace_chunk = vec ! [ Span {
1807
+ duration: 10 ,
1808
+ ..Default :: default ( )
1809
+ } ] ;
1810
+
1811
+ let data = tinybytes:: Bytes :: from ( rmp_serde:: to_vec_named ( & vec ! [ trace_chunk] ) . unwrap ( ) ) ;
1812
+
1813
+ // Wait for the info fetcher to get the config
1814
+ while mock_info. hits ( ) == 0 {
1815
+ exporter. runtime . block_on ( async {
1816
+ sleep ( Duration :: from_millis ( 100 ) ) . await ;
1817
+ } )
1818
+ }
1819
+
1820
+ let _ = exporter. send ( data, 1 ) . unwrap ( ) ;
1821
+
1822
+ exporter. shutdown ( None ) . unwrap ( ) ;
1823
+
1824
+ mock_traces. assert ( ) ;
1825
+ }
1745
1826
}
0 commit comments