@@ -160,7 +160,6 @@ struct TStatCollector {
160
160
using TMetricRegistry = ::NMonitoring::TMetricRegistry;
161
161
162
162
public:
163
-
164
163
struct TEndpointElectorStatCollector {
165
164
166
165
TEndpointElectorStatCollector (::NMonitoring::TIntGauge* endpointCount = nullptr
@@ -197,29 +196,34 @@ struct TStatCollector {
197
196
198
197
TClientRetryOperationStatCollector () : MetricRegistry_(), Database_() {}
199
198
200
- TClientRetryOperationStatCollector (::NMonitoring::TMetricRegistry* registry, const std::string& database)
201
- : MetricRegistry_(registry), Database_(database)
199
+ TClientRetryOperationStatCollector (::NMonitoring::TMetricRegistry* registry,
200
+ const std::string& database,
201
+ const std::string& clientType)
202
+ : MetricRegistry_(registry)
203
+ , Database_(database)
204
+ , ClientType_(clientType)
202
205
{ }
203
206
204
207
void IncSyncRetryOperation (const EStatus& status) {
205
208
if (auto registry = MetricRegistry_.Get ()) {
206
209
std::string statusName = TStringBuilder () << status;
207
210
std::string sensor = TStringBuilder () << " RetryOperation/" << UnderscoreToUpperCamel (statusName);
208
- registry->Rate ({ {" database" , Database_}, {" sensor" , sensor} })->Inc ();
211
+ registry->Rate ({ {" database" , Database_}, {" ydb_client " , ClientType_}, { " sensor" , sensor} })->Inc ();
209
212
}
210
213
}
211
214
212
215
void IncAsyncRetryOperation (const EStatus& status) {
213
216
if (auto registry = MetricRegistry_.Get ()) {
214
217
std::string statusName = TStringBuilder () << status;
215
218
std::string sensor = TStringBuilder () << " RetryOperation/" << UnderscoreToUpperCamel (statusName);
216
- registry->Rate ({ {" database" , Database_}, {" sensor" , sensor} })->Inc ();
219
+ registry->Rate ({ {" database" , Database_}, {" ydb_client " , ClientType_}, { " sensor" , sensor} })->Inc ();
217
220
}
218
221
}
219
222
220
223
private:
221
224
TAtomicPointer<::NMonitoring::TMetricRegistry> MetricRegistry_;
222
225
std::string Database_;
226
+ std::string ClientType_;
223
227
};
224
228
225
229
struct TClientStatCollector {
@@ -264,22 +268,11 @@ struct TStatCollector {
264
268
RequestFailDueQueueOverflow_.Set (sensorsRegistry->Rate ({ DatabaseLabel_, {" sensor" , " Request/FailedDiscoveryQueueOverflow" } }));
265
269
RequestFailDueNoEndpoint_.Set (sensorsRegistry->Rate ({ DatabaseLabel_, {" sensor" , " Request/FailedNoEndpoint" } }));
266
270
RequestFailDueTransportError_.Set (sensorsRegistry->Rate ({ DatabaseLabel_, {" sensor" , " Request/FailedTransportError" } }));
267
- CacheMiss_.Set (sensorsRegistry->Rate ({ DatabaseLabel_, {" sensor" , " Request/ClientQueryCacheMiss" } }));
268
- ActiveSessions_.Set (sensorsRegistry->IntGauge ({ DatabaseLabel_, {" sensor" , " Sessions/InUse" } }));
269
- InPoolSessions_.Set (sensorsRegistry->IntGauge ({ DatabaseLabel_, {" sensor" , " Sessions/InPool" } }));
270
- Waiters_.Set (sensorsRegistry->IntGauge ({ DatabaseLabel_, {" sensor" , " Sessions/WaitForReturn" } }));
271
271
SessionCV_.Set (sensorsRegistry->IntGauge ({ DatabaseLabel_, {" sensor" , " SessionBalancer/Variation" } }));
272
- SessionRemovedDueBalancing_.Set (sensorsRegistry->Rate ({ DatabaseLabel_, {" sensor" , " SessionBalancer/SessionsRemoved" } }));
273
- RequestMigrated_.Set (sensorsRegistry->Rate ({ DatabaseLabel_, {" sensor" , " SessionBalancer/RequestsMigrated" } }));
274
- FakeSessions_.Set (sensorsRegistry->Rate ({ DatabaseLabel_, {" sensor" , " Sessions/SessionsLimitExceeded" } }));
275
272
GRpcInFlight_.Set (sensorsRegistry->IntGauge ({ DatabaseLabel_, {" sensor" , " Grpc/InFlight" } }));
276
273
277
274
RequestLatency_.Set (sensorsRegistry->HistogramRate ({ DatabaseLabel_, {" sensor" , " Request/Latency" } },
278
275
::NMonitoring::ExponentialHistogram (20 , 2 , 1 )));
279
- QuerySize_.Set (sensorsRegistry->HistogramRate ({ DatabaseLabel_, {" sensor" , " Request/QuerySize" } },
280
- ::NMonitoring::ExponentialHistogram (20 , 2 , 32 )));
281
- ParamsSize_.Set (sensorsRegistry->HistogramRate ({ DatabaseLabel_, {" sensor" , " Request/ParamsSize" } },
282
- ::NMonitoring::ExponentialHistogram (10 , 2 , 32 )));
283
276
ResultSize_.Set (sensorsRegistry->HistogramRate ({ DatabaseLabel_, {" sensor" , " Request/ResultSize" } },
284
277
::NMonitoring::ExponentialHistogram (20 , 2 , 32 )));
285
278
}
@@ -336,31 +329,57 @@ struct TStatCollector {
336
329
337
330
TEndpointElectorStatCollector GetEndpointElectorStatCollector () {
338
331
if (auto registry = MetricRegistryPtr_.Get ()) {
339
- auto endpointCoint = registry->IntGauge ({ { " database " , Database_} , {" sensor" , " Endpoints/Total" } });
340
- auto pessimizationRatio = registry->IntGauge ({ { " database " , Database_} , {" sensor" , " Endpoints/BadRatio" } });
341
- auto activeEndpoints = registry->IntGauge ({ { " database " , Database_} , {" sensor" , " Endpoints/Good" } });
332
+ auto endpointCoint = registry->IntGauge ({ DatabaseLabel_ , {" sensor" , " Endpoints/Total" } });
333
+ auto pessimizationRatio = registry->IntGauge ({ DatabaseLabel_ , {" sensor" , " Endpoints/BadRatio" } });
334
+ auto activeEndpoints = registry->IntGauge ({ DatabaseLabel_ , {" sensor" , " Endpoints/Good" } });
342
335
return TEndpointElectorStatCollector (endpointCoint, pessimizationRatio, activeEndpoints);
343
- } else {
344
- return TEndpointElectorStatCollector ();
345
336
}
337
+
338
+ return TEndpointElectorStatCollector ();
346
339
}
347
340
348
- TSessionPoolStatCollector GetSessionPoolStatCollector () {
349
- if (!IsCollecting ()) {
350
- return TSessionPoolStatCollector ();
341
+ TSessionPoolStatCollector GetSessionPoolStatCollector (const std::string& clientType) {
342
+ if (auto registry = MetricRegistryPtr_.Get ()) {
343
+ auto activeSessions = registry->IntGauge ({ DatabaseLabel_, {" ydb_client" , clientType},
344
+ {" sensor" , " Sessions/InUse" } });
345
+ auto inPoolSessions = registry->IntGauge ({ DatabaseLabel_, {" ydb_client" , clientType},
346
+ {" sensor" , " Sessions/InPool" } });
347
+ auto fakeSessions = registry->Rate ({ DatabaseLabel_, {" ydb_client" , clientType},
348
+ {" sensor" , " Sessions/SessionsLimitExceeded" } });
349
+ auto waiters = registry->IntGauge ({ DatabaseLabel_, {" ydb_client" , clientType},
350
+ {" sensor" , " Sessions/WaitForReturn" } });
351
+
352
+ return TSessionPoolStatCollector (activeSessions, inPoolSessions, fakeSessions, waiters);
351
353
}
352
354
353
- return TSessionPoolStatCollector (ActiveSessions_. Get (), InPoolSessions_. Get (), FakeSessions_. Get (), Waiters_. Get () );
355
+ return TSessionPoolStatCollector ();
354
356
}
355
357
356
- TClientStatCollector GetClientStatCollector () {
357
- if (IsCollecting ()) {
358
- return TClientStatCollector (CacheMiss_.Get (), QuerySize_.Get (), ParamsSize_.Get (),
359
- SessionRemovedDueBalancing_.Get (), RequestMigrated_.Get (),
360
- TClientRetryOperationStatCollector (MetricRegistryPtr_.Get (), Database_));
361
- } else {
362
- return TClientStatCollector ();
358
+ TClientStatCollector GetClientStatCollector (const std::string& clientType) {
359
+ if (auto registry = MetricRegistryPtr_.Get ()) {
360
+ ::NMonitoring::TRate* cacheMiss = nullptr ;
361
+ ::NMonitoring::TRate* sessionRemovedDueBalancing = nullptr ;
362
+ ::NMonitoring::TRate* requestMigrated = nullptr ;
363
+
364
+ if (clientType == " Table" ) {
365
+ cacheMiss = registry->Rate ({ DatabaseLabel_, {" ydb_client" , clientType},
366
+ {" sensor" , " Request/ClientQueryCacheMiss" } });
367
+ sessionRemovedDueBalancing = registry->Rate ({ DatabaseLabel_, {" ydb_client" , clientType},
368
+ {" sensor" , " SessionBalancer/SessionsRemoved" } });
369
+ requestMigrated = registry->Rate ({ DatabaseLabel_, {" ydb_client" , clientType},
370
+ {" sensor" , " SessionBalancer/RequestsMigrated" } });
371
+ }
372
+
373
+ auto querySize = registry->HistogramRate ({ DatabaseLabel_, {" ydb_client" , clientType},
374
+ {" sensor" , " Request/QuerySize" } }, ::NMonitoring::ExponentialHistogram (20 , 2 , 32 ));
375
+ auto paramsSize = registry->HistogramRate ({ DatabaseLabel_, {" ydb_client" , clientType},
376
+ {" sensor" , " Request/ParamsSize" } }, ::NMonitoring::ExponentialHistogram (10 , 2 , 32 ));
377
+
378
+ return TClientStatCollector (cacheMiss, querySize, paramsSize, sessionRemovedDueBalancing, requestMigrated,
379
+ TClientRetryOperationStatCollector (MetricRegistryPtr_.Get (), Database_, clientType));
363
380
}
381
+
382
+ return TClientStatCollector ();
364
383
}
365
384
366
385
bool IsCollecting () {
@@ -374,6 +393,7 @@ struct TStatCollector {
374
393
375
394
void IncGRpcInFlightByHost (const std::string& host);
376
395
void DecGRpcInFlightByHost (const std::string& host);
396
+
377
397
private:
378
398
const std::string Database_;
379
399
const ::NMonitoring::TLabel DatabaseLabel_;
@@ -384,18 +404,9 @@ struct TStatCollector {
384
404
TAtomicCounter<::NMonitoring::TRate> RequestFailDueNoEndpoint_;
385
405
TAtomicCounter<::NMonitoring::TRate> RequestFailDueTransportError_;
386
406
TAtomicCounter<::NMonitoring::TRate> DiscoveryFailDueTransportError_;
387
- TAtomicPointer<::NMonitoring::TIntGauge> ActiveSessions_;
388
- TAtomicPointer<::NMonitoring::TIntGauge> InPoolSessions_;
389
- TAtomicPointer<::NMonitoring::TIntGauge> Waiters_;
390
407
TAtomicCounter<::NMonitoring::TIntGauge> SessionCV_;
391
- TAtomicCounter<::NMonitoring::TRate> SessionRemovedDueBalancing_;
392
- TAtomicCounter<::NMonitoring::TRate> RequestMigrated_;
393
- TAtomicCounter<::NMonitoring::TRate> FakeSessions_;
394
- TAtomicCounter<::NMonitoring::TRate> CacheMiss_;
395
408
TAtomicCounter<::NMonitoring::TIntGauge> GRpcInFlight_;
396
409
TAtomicHistogram<::NMonitoring::THistogram> RequestLatency_;
397
- TAtomicHistogram<::NMonitoring::THistogram> QuerySize_;
398
- TAtomicHistogram<::NMonitoring::THistogram> ParamsSize_;
399
410
TAtomicHistogram<::NMonitoring::THistogram> ResultSize_;
400
411
};
401
412
0 commit comments