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,19 +131,19 @@ 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_PARAM" , " 33" );
151
- setEnv (" JAEGER_SAMPLER_TYPE" , " const" );
142
+ testutils::EnvVariable:: setEnv (" JAEGER_SAMPLER_PARAM" , " 33" );
143
+ testutils::EnvVariable:: setEnv (" JAEGER_SAMPLER_TYPE" , " const" );
152
144
153
- setEnv (" JAEGER_SERVICE_NAME" , " AService" );
154
- setEnv (" JAEGER_TAGS" , " hostname=foobar,my.app.version=4.5.6" );
145
+ testutils::EnvVariable:: setEnv (" JAEGER_SERVICE_NAME" , " AService" );
146
+ testutils::EnvVariable:: setEnv (" JAEGER_TAGS" , " hostname=foobar,my.app.version=4.5.6" );
155
147
156
148
config.fromEnv ();
157
149
@@ -177,8 +169,8 @@ TEST(Config, testFromEnv)
177
169
178
170
ASSERT_EQ (false , config.disabled ());
179
171
180
- setEnv (" JAEGER_DISABLED" , " TRue" ); // case-insensitive
181
- setEnv (" JAEGER_AGENT_PORT" , " 445" );
172
+ testutils::EnvVariable:: setEnv (" JAEGER_DISABLED" , " TRue" ); // case-insensitive
173
+ testutils::EnvVariable:: setEnv (" JAEGER_AGENT_PORT" , " 445" );
182
174
183
175
config.fromEnv ();
184
176
ASSERT_EQ (true , config.disabled ());
0 commit comments