@@ -92,10 +92,10 @@ Optional<StringView> lookup_propagation_env(environment::Variable variable) {
9292}
9393
9494// Return a `std::vector<PropagationStyle>` parsed from the specified `env_var`.
95- // If `env_var` is not in the environment, return `nullopt`.
96- // If parsing fails, log and ignore the environment variable .
95+ // If `env_var` is not in the environment, return `nullopt`. If an error occurs,
96+ // throw an `Error` .
9797Optional<std::vector<PropagationStyle>> styles_from_env (
98- environment::Variable env_var, Logger &logger ) {
98+ environment::Variable env_var) {
9999 const auto styles_env = lookup_propagation_env (env_var);
100100 if (!styles_env) {
101101 return {};
@@ -107,8 +107,7 @@ Optional<std::vector<PropagationStyle>> styles_from_env(
107107 prefix += " Unable to parse " ;
108108 append (prefix, name (env_var));
109109 prefix += " environment variable: " ;
110- logger.log_error (error->with_prefix (prefix));
111- return {};
110+ throw error->with_prefix (prefix);
112111 }
113112 return *styles;
114113}
@@ -134,10 +133,9 @@ Expected<TracerConfig> load_tracer_env_config(Logger &logger) {
134133 prefix += " Unable to parse " ;
135134 append (prefix, name (env::DD_TAGS ));
136135 prefix += " environment variable: " ;
137- logger.log_error (error->with_prefix (prefix));
138- } else {
139- env_cfg.tags = std::move (*tags);
136+ return error->with_prefix (prefix);
140137 }
138+ env_cfg.tags = std::move (*tags);
141139 }
142140
143141 if (auto startup_env = env::lookup<env::DD_TRACE_STARTUP_LOGS >()) {
@@ -168,16 +166,14 @@ Expected<TracerConfig> load_tracer_env_config(Logger &logger) {
168166 // Baggage
169167 const auto baggage_items_env = env::lookup<env::DD_TRACE_BAGGAGE_MAX_ITEMS >();
170168 if (auto *error = baggage_items_env.if_error ()) {
171- logger.log_error (error->with_prefix (
172- " Unable to parse DD_TRACE_BAGGAGE_MAX_ITEMS environment variable: " ));
169+ return *error;
173170 } else if (*baggage_items_env) {
174171 env_cfg.baggage_max_items = std::move (**baggage_items_env);
175172 }
176173
177174 const auto baggage_bytes_env = env::lookup<env::DD_TRACE_BAGGAGE_MAX_BYTES >();
178175 if (auto *error = baggage_bytes_env.if_error ()) {
179- logger.log_error (error->with_prefix (
180- " Unable to parse DD_TRACE_BAGGAGE_MAX_BYTES environment variable: " ));
176+ return *error;
181177 } else if (*baggage_bytes_env) {
182178 env_cfg.baggage_max_bytes = std::move (**baggage_bytes_env);
183179 }
@@ -252,27 +248,31 @@ Expected<TracerConfig> load_tracer_env_config(Logger &logger) {
252248 warn_message (var_name, *value, var_name_override, *value_override)});
253249 }
254250
255- const auto global_styles =
256- styles_from_env (environment::DD_TRACE_PROPAGATION_STYLE , logger);
251+ try {
252+ const auto global_styles =
253+ styles_from_env (environment::DD_TRACE_PROPAGATION_STYLE );
257254
258- if (auto trace_extraction_styles = styles_from_env (
259- environment::DD_TRACE_PROPAGATION_STYLE_EXTRACT , logger )) {
260- env_cfg.extraction_styles = std::move (*trace_extraction_styles);
261- } else if (auto extraction_styles = styles_from_env (
262- environment::DD_PROPAGATION_STYLE_EXTRACT , logger )) {
263- env_cfg.extraction_styles = std::move (*extraction_styles);
264- } else {
265- env_cfg.extraction_styles = global_styles;
266- }
255+ if (auto trace_extraction_styles =
256+ styles_from_env ( environment::DD_TRACE_PROPAGATION_STYLE_EXTRACT )) {
257+ env_cfg.extraction_styles = std::move (*trace_extraction_styles);
258+ } else if (auto extraction_styles =
259+ styles_from_env ( environment::DD_PROPAGATION_STYLE_EXTRACT )) {
260+ env_cfg.extraction_styles = std::move (*extraction_styles);
261+ } else {
262+ env_cfg.extraction_styles = global_styles;
263+ }
267264
268- if (auto trace_injection_styles = styles_from_env (
269- environment::DD_TRACE_PROPAGATION_STYLE_INJECT , logger)) {
270- env_cfg.injection_styles = std::move (*trace_injection_styles);
271- } else if (auto injection_styles = styles_from_env (
272- environment::DD_PROPAGATION_STYLE_INJECT , logger)) {
273- env_cfg.injection_styles = std::move (*injection_styles);
274- } else {
275- env_cfg.injection_styles = global_styles;
265+ if (auto trace_injection_styles =
266+ styles_from_env (environment::DD_TRACE_PROPAGATION_STYLE_INJECT )) {
267+ env_cfg.injection_styles = std::move (*trace_injection_styles);
268+ } else if (auto injection_styles =
269+ styles_from_env (environment::DD_PROPAGATION_STYLE_INJECT )) {
270+ env_cfg.injection_styles = std::move (*injection_styles);
271+ } else {
272+ env_cfg.injection_styles = global_styles;
273+ }
274+ } catch (Error &error) {
275+ return std::move (error);
276276 }
277277
278278 return env_cfg;
@@ -429,8 +429,7 @@ Expected<FinalizedTracerConfig> finalize_config(const TracerConfig &user_config,
429429 return std::move (*error);
430430 }
431431
432- if (auto trace_sampler_config =
433- finalize_config (user_config.trace_sampler , *logger)) {
432+ if (auto trace_sampler_config = finalize_config (user_config.trace_sampler )) {
434433 // Merge metadata vectors
435434 for (auto &[key, values] : trace_sampler_config->metadata ) {
436435 auto &dest = final_config.metadata [key];
0 commit comments