@@ -23,7 +23,7 @@ Expected<TraceSamplerConfig> load_trace_sampler_env_config() {
2323 nlohmann::json json_rules;
2424 try {
2525 json_rules = nlohmann::json::parse (*rules_env);
26- } catch (const nlohmann::json::parse_error& error) {
26+ } catch (const nlohmann::json::parse_error & error) {
2727 std::string message;
2828 message += " Unable to parse JSON from " ;
2929 append (message, name (environment::DD_TRACE_SAMPLING_RULES));
@@ -50,9 +50,9 @@ Expected<TraceSamplerConfig> load_trace_sampler_env_config() {
5050 const std::unordered_set<std::string> allowed_properties{
5151 " service" , " name" , " resource" , " tags" , " sample_rate" };
5252
53- for (const auto & json_rule : json_rules) {
53+ for (const auto & json_rule : json_rules) {
5454 auto matcher = from_json (json_rule);
55- if (auto * error = matcher.if_error ()) {
55+ if (auto * error = matcher.if_error ()) {
5656 std::string prefix;
5757 prefix += " Unable to create a rule from " ;
5858 append (prefix, name (environment::DD_TRACE_SAMPLING_RULES));
@@ -85,7 +85,7 @@ Expected<TraceSamplerConfig> load_trace_sampler_env_config() {
8585 }
8686
8787 // Look for unexpected properties.
88- for (const auto & [key, value] : json_rule.items ()) {
88+ for (const auto & [key, value] : json_rule.items ()) {
8989 if (allowed_properties.count (key)) {
9090 continue ;
9191 }
@@ -110,7 +110,7 @@ Expected<TraceSamplerConfig> load_trace_sampler_env_config() {
110110
111111 if (auto sample_rate_env = lookup (environment::DD_TRACE_SAMPLE_RATE)) {
112112 auto maybe_sample_rate = parse_double (*sample_rate_env);
113- if (auto * error = maybe_sample_rate.if_error ()) {
113+ if (auto * error = maybe_sample_rate.if_error ()) {
114114 std::string prefix;
115115 prefix += " While parsing " ;
116116 append (prefix, name (environment::DD_TRACE_SAMPLE_RATE));
@@ -122,7 +122,7 @@ Expected<TraceSamplerConfig> load_trace_sampler_env_config() {
122122
123123 if (auto limit_env = lookup (environment::DD_TRACE_RATE_LIMIT)) {
124124 auto maybe_max_per_second = parse_double (*limit_env);
125- if (auto * error = maybe_max_per_second.if_error ()) {
125+ if (auto * error = maybe_max_per_second.if_error ()) {
126126 std::string prefix;
127127 prefix += " While parsing " ;
128128 append (prefix, name (environment::DD_TRACE_RATE_LIMIT));
@@ -135,9 +135,9 @@ Expected<TraceSamplerConfig> load_trace_sampler_env_config() {
135135 return env_config;
136136}
137137
138- std::string to_string (const std::vector<TraceSamplerConfig::Rule>& rules) {
138+ std::string to_string (const std::vector<TraceSamplerConfig::Rule> & rules) {
139139 nlohmann::json res;
140- for (const auto & r : rules) {
140+ for (const auto & r : rules) {
141141 auto j = nlohmann::json (static_cast <SpanMatcher>(r));
142142 j[" sample_rate" ] = r.sample_rate ;
143143 res.emplace_back (std::move (j));
@@ -147,8 +147,8 @@ std::string to_string(const std::vector<TraceSamplerConfig::Rule>& rules) {
147147}
148148
149149// Convert a stable config string value to Optional<double>.
150- Optional<double > stable_config_double (const StableConfig& cfg,
151- const std::string& key) {
150+ Optional<double > stable_config_double (const StableConfig & cfg,
151+ const std::string & key) {
152152 auto val = cfg.lookup (key);
153153 if (!val || val->empty ()) return nullopt ;
154154 auto result = parse_double (StringView (*val));
@@ -159,17 +159,17 @@ Optional<double> stable_config_double(const StableConfig& cfg,
159159// Try to parse a stable config string value as trace sampling rules JSON.
160160// Returns empty vector on any parse error (stable config errors are non-fatal).
161161Optional<std::vector<TraceSamplerConfig::Rule>> stable_config_sampling_rules (
162- const StableConfig& cfg, const std::string& key) {
162+ const StableConfig & cfg, const std::string & key) {
163163 return parse_stable_config_rules<TraceSamplerConfig::Rule, nlohmann::json>(
164- cfg, key, [](TraceSamplerConfig::Rule&, const nlohmann::json&) {});
164+ cfg, key, [](TraceSamplerConfig::Rule &, const nlohmann::json &) {});
165165}
166166
167167} // namespace
168168
169- TraceSamplerConfig::Rule::Rule (const SpanMatcher& base) : SpanMatcher(base) {}
169+ TraceSamplerConfig::Rule::Rule (const SpanMatcher & base) : SpanMatcher(base) {}
170170
171171Expected<FinalizedTraceSamplerConfig> finalize_config (
172- const TraceSamplerConfig& config, const StableConfigs* stable_configs) {
172+ const TraceSamplerConfig & config, const StableConfigs * stable_configs) {
173173 Expected<TraceSamplerConfig> env_config = load_trace_sampler_env_config ();
174174 if (auto error = env_config.if_error ()) {
175175 return *error;
@@ -211,9 +211,9 @@ Expected<FinalizedTraceSamplerConfig> finalize_config(
211211 ConfigMetadata::Origin::LOCAL_STABLE_CONFIG)};
212212 }
213213
214- for (const auto & rule : rules) {
214+ for (const auto & rule : rules) {
215215 auto maybe_rate = Rate::from (rule.sample_rate );
216- if (auto * error = maybe_rate.if_error ()) {
216+ if (auto * error = maybe_rate.if_error ()) {
217217 std::string prefix;
218218 prefix +=
219219 " Unable to parse sample_rate in trace sampling rule with root span "
@@ -242,7 +242,7 @@ Expected<FinalizedTraceSamplerConfig> finalize_config(
242242 Optional<double > sample_rate = resolve_and_record_config (
243243 fleet_sample_rate, env_config->sample_rate , config.sample_rate ,
244244 local_sample_rate, &result.metadata , ConfigName::TRACE_SAMPLING_RATE, 1.0 ,
245- [](const double & d) { return to_string (d, 1 ); });
245+ [](const double & d) { return to_string (d, 1 ); });
246246
247247 bool is_sample_rate_provided = fleet_sample_rate || env_config->sample_rate ||
248248 config.sample_rate || local_sample_rate;
@@ -251,7 +251,7 @@ Expected<FinalizedTraceSamplerConfig> finalize_config(
251251 // sample rate is valid.
252252 if (sample_rate && is_sample_rate_provided) {
253253 auto maybe_rate = Rate::from (*sample_rate);
254- if (auto * error = maybe_rate.if_error ()) {
254+ if (auto * error = maybe_rate.if_error ()) {
255255 return error->with_prefix (
256256 " Unable to parse overall sample_rate for trace sampling: " );
257257 }
@@ -275,7 +275,7 @@ Expected<FinalizedTraceSamplerConfig> finalize_config(
275275 double max_per_second = resolve_and_record_config (
276276 fleet_rate_limit, env_config->max_per_second , config.max_per_second ,
277277 local_rate_limit, &result.metadata , ConfigName::TRACE_SAMPLING_LIMIT,
278- 100.0 , [](const double & d) { return std::to_string (d); });
278+ 100.0 , [](const double & d) { return std::to_string (d); });
279279
280280 const auto allowed_types = {FP_NORMAL, FP_SUBNORMAL};
281281 if (!(max_per_second > 0 ) ||
0 commit comments