@@ -1702,6 +1702,75 @@ static void test_account_id_from_cross_process_id(void) {
1702
1702
nr_header_account_id_from_cross_process_id ("10#10" ));
1703
1703
}
1704
1704
1705
+ static void test_nr_header_create_distributed_trace_map (void ) {
1706
+ nr_hashmap_t * header_map = NULL ;
1707
+ char * tracestate = "tracestate" ;
1708
+ char * traceparent = "traceparent" ;
1709
+ char * dt_payload = "newrelic" ;
1710
+
1711
+ header_map = nr_header_create_distributed_trace_map (NULL , NULL , NULL );
1712
+ tlib_pass_if_null (
1713
+ "NULL payload and NULL traceparent should return NULL header map" ,
1714
+ header_map );
1715
+
1716
+ header_map = nr_header_create_distributed_trace_map (NULL , NULL , tracestate );
1717
+ tlib_pass_if_null (
1718
+ "NULL payload and NULL traceparent should return NULL header map" ,
1719
+ header_map );
1720
+
1721
+ header_map = nr_header_create_distributed_trace_map (dt_payload , NULL , NULL );
1722
+ tlib_pass_if_not_null ("if valid dt_payload should return a header map" ,
1723
+ header_map );
1724
+ tlib_pass_if_size_t_equal (
1725
+ "1 header passed in so should expect headers hashmap size of 1" , 1 ,
1726
+ nr_hashmap_count (header_map ));
1727
+ nr_hashmap_destroy (& header_map );
1728
+
1729
+ header_map
1730
+ = nr_header_create_distributed_trace_map (dt_payload , traceparent , NULL );
1731
+ tlib_pass_if_not_null ("if valid dt_payload should return a header map" ,
1732
+ header_map );
1733
+ tlib_pass_if_size_t_equal (
1734
+ "2 headers passed in so should expect headers hashmap size of 2" , 2 ,
1735
+ nr_hashmap_count (header_map ));
1736
+ nr_hashmap_destroy (& header_map );
1737
+
1738
+ header_map
1739
+ = nr_header_create_distributed_trace_map (dt_payload , NULL , tracestate );
1740
+ tlib_pass_if_not_null ("if valid dt_payload should return a header map" ,
1741
+ header_map );
1742
+ tlib_pass_if_size_t_equal (
1743
+ "2 headers passed in so should expect headers hashmap size of 2" , 2 ,
1744
+ nr_hashmap_count (header_map ));
1745
+ nr_hashmap_destroy (& header_map );
1746
+
1747
+ header_map = nr_header_create_distributed_trace_map (dt_payload , traceparent ,
1748
+ tracestate );
1749
+ tlib_pass_if_not_null ("if valid dt_payload should return a header map" ,
1750
+ header_map );
1751
+ tlib_pass_if_size_t_equal (
1752
+ "3 headers passed in so should expect headers hashmap size of 3" , 3 ,
1753
+ nr_hashmap_count (header_map ));
1754
+ nr_hashmap_destroy (& header_map );
1755
+
1756
+ header_map
1757
+ = nr_header_create_distributed_trace_map (NULL , traceparent , tracestate );
1758
+ tlib_pass_if_not_null ("if valid traceparent should return a header map" ,
1759
+ header_map );
1760
+ tlib_pass_if_size_t_equal (
1761
+ "Two headers passed in so should expect headers hashmap size of 2" , 2 ,
1762
+ nr_hashmap_count (header_map ));
1763
+ nr_hashmap_destroy (& header_map );
1764
+
1765
+ header_map = nr_header_create_distributed_trace_map (NULL , traceparent , NULL );
1766
+ tlib_pass_if_not_null ("if valid traceparent should return a header map" ,
1767
+ header_map );
1768
+ tlib_pass_if_size_t_equal (
1769
+ "1 header passed in so should expect headers hashmap size of 1" , 1 ,
1770
+ nr_hashmap_count (header_map ));
1771
+ nr_hashmap_destroy (& header_map );
1772
+ }
1773
+
1705
1774
tlib_parallel_info_t parallel_info = {.suggested_nthreads = 2 , .state_size = 0 };
1706
1775
1707
1776
void test_main (void * p NRUNUSED ) {
@@ -1721,4 +1790,5 @@ void test_main(void* p NRUNUSED) {
1721
1790
test_set_cat_txn ();
1722
1791
test_set_synthetics_txn ();
1723
1792
test_account_id_from_cross_process_id ();
1793
+ test_nr_header_create_distributed_trace_map ();
1724
1794
}
0 commit comments