19
19
#include " jaegertracing/propagation/HeadersConfig.h"
20
20
#include " jaegertracing/samplers/Config.h"
21
21
#include " jaegertracing/utils/YAML.h"
22
+ #include " jaegertracing/testutils/EnvVariable.h"
22
23
#include < gtest/gtest.h>
23
24
24
25
#include < cstdlib>
@@ -95,15 +96,6 @@ TEST(Config, testZeroSamplingParam)
95
96
96
97
#endif // JAEGERTRACING_WITH_YAML_CPP
97
98
98
-
99
- void setEnv (const char *variable, const char *value) {
100
- #ifdef WIN32
101
- _putenv_s (variable, value);
102
- #else
103
- setenv (variable, value, true );
104
- #endif
105
- }
106
-
107
99
TEST (Config, testFromEnv)
108
100
{
109
101
std::vector<Tag> tags;
@@ -139,20 +131,20 @@ TEST(Config, testFromEnv)
139
131
ASSERT_EQ (.7 , config.sampler ().param ());
140
132
ASSERT_EQ (std::string (" probabilistic" ), config.sampler ().type ());
141
133
142
- setEnv (" JAEGER_AGENT_HOST" , " host33" );
143
- setEnv (" JAEGER_AGENT_PORT" , " 45" );
144
- setEnv (" JAEGER_ENDPOINT" , " http://host34:56567" );
134
+ testutils::EnvVariable:: setEnv (" JAEGER_AGENT_HOST" , " host33" );
135
+ testutils::EnvVariable:: setEnv (" JAEGER_AGENT_PORT" , " 45" );
136
+ testutils::EnvVariable:: setEnv (" JAEGER_ENDPOINT" , " http://host34:56567" );
145
137
146
- setEnv (" JAEGER_REPORTER_MAX_QUEUE_SIZE" , " 33" );
147
- setEnv (" JAEGER_REPORTER_FLUSH_INTERVAL" , " 45" );
148
- setEnv (" JAEGER_REPORTER_LOG_SPANS" , " true" );
138
+ testutils::EnvVariable:: setEnv (" JAEGER_REPORTER_MAX_QUEUE_SIZE" , " 33" );
139
+ testutils::EnvVariable:: setEnv (" JAEGER_REPORTER_FLUSH_INTERVAL" , " 45" );
140
+ testutils::EnvVariable:: setEnv (" JAEGER_REPORTER_LOG_SPANS" , " true" );
149
141
150
- setEnv (" JAEGER_SAMPLER_TYPE" , " remote" );
151
- setEnv (" JAEGER_SAMPLER_PARAM" , " 0.33" );
152
- setEnv (" JAEGER_SAMPLING_ENDPOINT" , " http://myagent:1234" );
142
+ testutils::EnvVariable:: setEnv (" JAEGER_SAMPLER_TYPE" , " remote" );
143
+ testutils::EnvVariable:: setEnv (" JAEGER_SAMPLER_PARAM" , " 0.33" );
144
+ testutils::EnvVariable:: setEnv (" JAEGER_SAMPLING_ENDPOINT" , " http://myagent:1234" );
153
145
154
- setEnv (" JAEGER_SERVICE_NAME" , " AService" );
155
- setEnv (" JAEGER_TAGS" , " hostname=foobar,my.app.version=4.5.6" );
146
+ testutils::EnvVariable:: setEnv (" JAEGER_SERVICE_NAME" , " AService" );
147
+ testutils::EnvVariable:: setEnv (" JAEGER_TAGS" , " hostname=foobar,my.app.version=4.5.6" );
156
148
157
149
config.fromEnv ();
158
150
@@ -179,13 +171,25 @@ TEST(Config, testFromEnv)
179
171
180
172
ASSERT_EQ (false , config.disabled ());
181
173
182
- setEnv (" JAEGER_DISABLED" , " TRue" ); // case-insensitive
183
- setEnv (" JAEGER_AGENT_PORT" , " 445" );
174
+ testutils::EnvVariable:: setEnv (" JAEGER_DISABLED" , " TRue" ); // case-insensitive
175
+ testutils::EnvVariable:: setEnv (" JAEGER_AGENT_PORT" , " 445" );
184
176
185
177
config.fromEnv ();
186
178
ASSERT_EQ (true , config.disabled ());
187
179
ASSERT_EQ (std::string (" host33:445" ),
188
180
config.reporter ().localAgentHostPort ());
181
+
182
+ testutils::EnvVariable::setEnv (" JAEGER_AGENT_HOST" , " " );
183
+ testutils::EnvVariable::setEnv (" JAEGER_AGENT_PORT" , " " );
184
+ testutils::EnvVariable::setEnv (" JAEGER_ENDPOINT" , " " );
185
+ testutils::EnvVariable::setEnv (" JAEGER_REPORTER_MAX_QUEUE_SIZE" , " " );
186
+ testutils::EnvVariable::setEnv (" JAEGER_REPORTER_FLUSH_INTERVAL" , " " );
187
+ testutils::EnvVariable::setEnv (" JAEGER_REPORTER_LOG_SPANS" , " " );
188
+ testutils::EnvVariable::setEnv (" JAEGER_SAMPLER_PARAM" , " " );
189
+ testutils::EnvVariable::setEnv (" JAEGER_SAMPLER_TYPE" , " " );
190
+ testutils::EnvVariable::setEnv (" JAEGER_SERVICE_NAME" , " " );
191
+ testutils::EnvVariable::setEnv (" JAEGER_TAGS" , " " );
192
+ testutils::EnvVariable::setEnv (" JAEGER_DISABLED" , " " );
189
193
}
190
194
191
195
} // namespace jaegertracing
0 commit comments