4#include <unordered_map>
6#include <userver/engine/shared_mutex.hpp>
7#include <userver/utils/statistics/entry.hpp>
9#include <userver/ugrpc/impl/statistics.hpp>
11USERVER_NAMESPACE_BEGIN
13namespace ugrpc::impl {
17class StatisticsStorage
final {
19 explicit StatisticsStorage(utils::statistics::Storage& statistics_storage,
20 std::string_view domain);
22 StatisticsStorage(
const StatisticsStorage&) =
delete;
23 StatisticsStorage& operator=(
const StatisticsStorage&) =
delete;
27 ugrpc::impl::ServiceStatistics& GetServiceStatistics(
28 const ugrpc::impl::StaticServiceMetadata& metadata);
33 std::uint64_t GetStartedRequests()
const;
37 using ServiceId =
const char*;
39 void ExtendStatistics(utils::statistics::Writer& writer);
44 struct ServiceIdComparer
final {
45 bool operator()(ServiceId lhs, ServiceId rhs)
const {
return lhs == rhs; }
48 std::unordered_map<ServiceId, ugrpc::impl::ServiceStatistics,
49 std::hash<ServiceId>, ServiceIdComparer>
51 engine::SharedMutex mutex_;
53 utils::statistics::Entry statistics_holder_;