userver: userver/ydb/impl/stats_scope.hpp Source File
Loading...
Searching...
No Matches
stats_scope.hpp
1#pragma once
2
3#include <chrono>
4#include <string>
5
6#include <userver/ydb/query.hpp>
7
8USERVER_NAMESPACE_BEGIN
9
10namespace ydb::impl {
11
12struct Stats;
13struct StatsCounters;
14
15class StatsScope final {
16 public:
17 struct TransactionTag {};
18
19 StatsScope(Stats& stats, const Query& query);
20 StatsScope(TransactionTag, Stats& stats, const std::string& tx_name);
21
22 StatsScope(StatsScope&&) noexcept;
23 ~StatsScope();
24
25 void OnError() noexcept;
26 void OnCancelled() noexcept;
27
28 private:
29 explicit StatsScope(StatsCounters&);
30
31 StatsCounters& stats_;
32 const std::chrono::steady_clock::time_point start_;
33 bool is_active_{true};
34 bool is_error_{false};
35 bool is_cancelled_{false};
36};
37
38} // namespace ydb::impl
39
40USERVER_NAMESPACE_END