@@ -7,18 +7,6 @@ pub mod grpc_agent;
77pub mod processor;
88pub mod transform;
99
10- /// Check if any OTLP agent (HTTP or gRPC) should be enabled.
11- #[ must_use]
12- pub fn should_enable_otlp_agent ( config : & Arc < Config > ) -> bool {
13- config. otlp_config_traces_enabled
14- && ( config
15- . otlp_config_receiver_protocols_http_endpoint
16- . is_some ( )
17- || config
18- . otlp_config_receiver_protocols_grpc_endpoint
19- . is_some ( ) )
20- }
21-
2210/// Check if the HTTP OTLP agent should be enabled.
2311#[ must_use]
2412pub fn should_enable_http ( config : & Arc < Config > ) -> bool {
@@ -46,7 +34,7 @@ mod tests {
4634 use crate :: config:: get_config;
4735
4836 #[ test]
49- fn test_should_enable_otlp_agent_from_yaml ( ) {
37+ fn test_should_enable_http_from_yaml ( ) {
5038 figment:: Jail :: expect_with ( |jail| {
5139 jail. clear_env ( ) ;
5240 jail. create_file (
@@ -60,35 +48,35 @@ mod tests {
6048 " ,
6149 ) ?;
6250
63- let config = get_config ( Path :: new ( "" ) ) ;
51+ let config = Arc :: new ( get_config ( Path :: new ( "" ) ) ) ;
6452
65- // Since the default for traces is `true`, we don't need to set it.
66- assert ! ( should_enable_otlp_agent ( & Arc :: new ( config) ) ) ;
53+ assert ! ( should_enable_http ( & config ) ) ;
54+ assert ! ( !should_enable_grpc ( & config) ) ;
6755
6856 Ok ( ( ) )
6957 } ) ;
7058 }
7159
7260 #[ test]
73- fn test_should_enable_otlp_agent_from_env_vars ( ) {
61+ fn test_should_enable_http_from_env_vars ( ) {
7462 figment:: Jail :: expect_with ( |jail| {
7563 jail. clear_env ( ) ;
7664 jail. set_env (
7765 "DD_OTLP_CONFIG_RECEIVER_PROTOCOLS_HTTP_ENDPOINT" ,
7866 "0.0.0.0:4318" ,
7967 ) ;
8068
81- let config = get_config ( Path :: new ( "" ) ) ;
69+ let config = Arc :: new ( get_config ( Path :: new ( "" ) ) ) ;
8270
83- // Since the default for traces is `true`, we don't need to set it.
84- assert ! ( should_enable_otlp_agent ( & Arc :: new ( config) ) ) ;
71+ assert ! ( should_enable_http ( & config ) ) ;
72+ assert ! ( !should_enable_grpc ( & config) ) ;
8573
8674 Ok ( ( ) )
8775 } ) ;
8876 }
8977
9078 #[ test]
91- fn test_should_not_enable_otlp_agent_if_traces_are_disabled ( ) {
79+ fn test_should_not_enable_http_if_traces_disabled ( ) {
9280 figment:: Jail :: expect_with ( |jail| {
9381 jail. clear_env ( ) ;
9482 jail. set_env ( "DD_OTLP_CONFIG_TRACES_ENABLED" , "false" ) ;
@@ -97,16 +85,16 @@ mod tests {
9785 "0.0.0.0:4318" ,
9886 ) ;
9987
100- let config = get_config ( Path :: new ( "" ) ) ;
88+ let config = Arc :: new ( get_config ( Path :: new ( "" ) ) ) ;
10189
102- assert ! ( !should_enable_otlp_agent ( & Arc :: new ( config) ) ) ;
90+ assert ! ( !should_enable_http ( & config) ) ;
10391
10492 Ok ( ( ) )
10593 } ) ;
10694 }
10795
10896 #[ test]
109- fn test_should_enable_otlp_agent_with_grpc_endpoint ( ) {
97+ fn test_should_enable_grpc_from_env_vars ( ) {
11098 figment:: Jail :: expect_with ( |jail| {
11199 jail. clear_env ( ) ;
112100 jail. set_env (
@@ -116,7 +104,6 @@ mod tests {
116104
117105 let config = Arc :: new ( get_config ( Path :: new ( "" ) ) ) ;
118106
119- assert ! ( should_enable_otlp_agent( & config) ) ;
120107 assert ! ( should_enable_grpc( & config) ) ;
121108 assert ! ( !should_enable_http( & config) ) ;
122109
@@ -139,7 +126,6 @@ mod tests {
139126
140127 let config = Arc :: new ( get_config ( Path :: new ( "" ) ) ) ;
141128
142- assert ! ( should_enable_otlp_agent( & config) ) ;
143129 assert ! ( should_enable_http( & config) ) ;
144130 assert ! ( should_enable_grpc( & config) ) ;
145131
@@ -159,7 +145,6 @@ mod tests {
159145
160146 let config = Arc :: new ( get_config ( Path :: new ( "" ) ) ) ;
161147
162- assert ! ( !should_enable_otlp_agent( & config) ) ;
163148 assert ! ( !should_enable_grpc( & config) ) ;
164149
165150 Ok ( ( ) )
0 commit comments