@@ -56,21 +56,26 @@ struct ConfigMetadata {
5656 : name(n), value(std::move(v)), origin(orig), error(std::move(err)) {}
5757};
5858
59- // Return a pair containing the configuration origin and value of a
60- // configuration value chosen from one of the specified `from_env`,
61- // `from_config`, and `fallback`. This function defines the relative precedence
62- // among configuration values originating from the environment , programmatic
63- // configuration, and default configuration .
59+ // Return a vector containing the configuration values chosen from one of the
60+ // specified `from_env`, `from_user`, and `fallback`. This function defines
61+ // the relative precedence among configuration values, from lower to higher,
62+ // originating from the default configuration , programmatic configuration,
63+ // and environment .
6464template <typename Value, typename DefaultValue>
65- std::pair<ConfigMetadata::Origin, Value> pick (const Optional<Value> &from_env,
66- const Optional<Value> &from_user,
67- DefaultValue fallback) {
65+ std::vector<std::pair<ConfigMetadata::Origin, Value>> pick (
66+ const Optional<Value>& from_env, const Optional<Value>& from_user,
67+ DefaultValue fallback) {
68+ std::vector<std::pair<ConfigMetadata::Origin, Value>> result;
69+ result.emplace_back (ConfigMetadata::Origin::DEFAULT, fallback);
70+
71+ if (from_user) {
72+ result.emplace_back (ConfigMetadata::Origin::CODE, *from_user);
73+ }
6874 if (from_env) {
69- return {ConfigMetadata::Origin::ENVIRONMENT_VARIABLE, *from_env};
70- } else if (from_user) {
71- return {ConfigMetadata::Origin::CODE, *from_user};
75+ result.emplace_back (ConfigMetadata::Origin::ENVIRONMENT_VARIABLE,
76+ *from_env);
7277 }
73- return {ConfigMetadata::Origin::DEFAULT, fallback} ;
78+ return result ;
7479}
7580
7681} // namespace tracing
0 commit comments