@@ -32,6 +32,7 @@ class TJaegerTracingConfigurator : public TActorBootstrapped<TJaegerTracingConfi
32
32
33
33
void ApplyConfigs(const NKikimrConfig::TTracingConfig& cfg);
34
34
static TMaybe<ERequestType> GetRequestType (const NKikimrConfig::TTracingConfig::TSelectors& selectors);
35
+ static TMaybe<TString> GetDatabase (const NKikimrConfig::TTracingConfig::TSelectors& selectors);
35
36
static TSettings<double , TThrottlingSettings> GetSettings (const NKikimrConfig::TTracingConfig& cfg);
36
37
37
38
TSamplingThrottlingConfigurator TracingConfigurator;
@@ -85,18 +86,28 @@ TMaybe<ERequestType> TJaegerTracingConfigurator::GetRequestType(const NKikimrCon
85
86
return {};
86
87
}
87
88
89
+ TMaybe<TString> TJaegerTracingConfigurator::GetDatabase (const NKikimrConfig::TTracingConfig::TSelectors& selectors) {
90
+ if (selectors.HasDatabase ()) {
91
+ return selectors.GetDatabase ();
92
+ }
93
+ return NothingObject;
94
+ }
95
+
88
96
TSettings<double , TThrottlingSettings> TJaegerTracingConfigurator::GetSettings (const NKikimrConfig::TTracingConfig& cfg) {
89
97
TSettings<double , TThrottlingSettings> settings;
90
98
91
99
for (const auto & samplingRule : cfg.GetSampling ()) {
100
+ const auto & scope = samplingRule.GetScope ();
101
+
92
102
ERequestType requestType;
93
- if (auto parsedRequestType = GetRequestType (samplingRule. GetScope () )) {
103
+ if (auto parsedRequestType = GetRequestType (scope )) {
94
104
requestType = *parsedRequestType;
95
105
} else {
96
106
ALOG_ERROR (NKikimrServices::CMS_CONFIGS, " failed to parse request type in the rule "
97
107
<< samplingRule.ShortDebugString () << " . Skipping the rule" );
98
108
continue ;
99
109
}
110
+
100
111
if (!samplingRule.HasLevel () || !samplingRule.HasFraction () || !samplingRule.HasMaxTracesPerMinute ()) {
101
112
ALOG_ERROR (NKikimrServices::CMS_CONFIGS, " missing required fields in rule " << samplingRule.ShortDebugString ()
102
113
<< " (required fields are: level, fraction, max_traces_per_minute). Skipping the rule" );
@@ -129,10 +140,19 @@ TSettings<double, TThrottlingSettings> TJaegerTracingConfigurator::GetSettings(c
129
140
.MaxTracesBurst = samplingRule.GetMaxTracesBurst (),
130
141
},
131
142
};
132
- settings.SamplingRules [static_cast <size_t >(requestType)].push_back (rule);
143
+
144
+ auto & requestTypeRules = settings.SamplingRules [static_cast <size_t >(requestType)];
145
+ auto database = GetDatabase (scope);
146
+ if (database) {
147
+ requestTypeRules.DatabaseRules [*database].push_back (rule);
148
+ } else {
149
+ requestTypeRules.Global .push_back (rule);
150
+ }
133
151
}
134
152
135
153
for (const auto & throttlingRule : cfg.GetExternalThrottling ()) {
154
+ const auto & scope = throttlingRule.GetScope ();
155
+
136
156
ERequestType requestType;
137
157
if (auto parsedRequestType = GetRequestType (throttlingRule.GetScope ())) {
138
158
requestType = *parsedRequestType;
@@ -161,14 +181,13 @@ TSettings<double, TThrottlingSettings> TJaegerTracingConfigurator::GetSettings(c
161
181
.MaxTracesBurst = maxBurst,
162
182
},
163
183
};
164
- auto & currentRule = settings.ExternalThrottlingRules [static_cast <size_t >(requestType)];
165
- if (currentRule) {
166
- ALOG_WARN (NKikimrServices::CMS_CONFIGS, " duplicate external throttling rule for scope "
167
- << throttlingRule.GetScope () << " . Adding the limits" );
168
- currentRule->Throttler .MaxTracesBurst += rule.Throttler .MaxTracesBurst ;
169
- currentRule->Throttler .MaxTracesPerMinute += rule.Throttler .MaxTracesPerMinute ;
184
+
185
+ auto & requestTypeRules = settings.ExternalThrottlingRules [static_cast <size_t >(requestType)];
186
+ auto database = GetDatabase (scope);
187
+ if (database) {
188
+ requestTypeRules.DatabaseRules [*database].push_back (rule);
170
189
} else {
171
- currentRule = rule;
190
+ requestTypeRules. Global . push_back ( rule) ;
172
191
}
173
192
}
174
193
@@ -181,7 +200,7 @@ TSettings<double, TThrottlingSettings> TJaegerTracingConfigurator::GetSettings(c
181
200
},
182
201
};
183
202
184
- settings.ExternalThrottlingRules [static_cast <size_t >(ERequestType::UNSPECIFIED)] = rule;
203
+ settings.ExternalThrottlingRules [static_cast <size_t >(ERequestType::UNSPECIFIED)]. Global . push_back ( rule) ;
185
204
}
186
205
187
206
return settings;
0 commit comments