LCOV - code coverage report
Current view: top level - source/common/stats - custom_stat_namespaces_impl.cc (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 4 18 22.2 %
Date: 2024-01-05 06:35:25 Functions: 1 3 33.3 %

          Line data    Source code
       1             : #include "source/common/stats/custom_stat_namespaces_impl.h"
       2             : 
       3             : #include "source/common/common/assert.h"
       4             : #include "source/common/common/thread.h"
       5             : 
       6             : namespace Envoy {
       7             : namespace Stats {
       8             : 
       9           0 : bool CustomStatNamespacesImpl::registered(const absl::string_view name) const {
      10           0 :   ASSERT_IS_MAIN_OR_TEST_THREAD();
      11           0 :   return namespaces_.find(name) != namespaces_.end();
      12           0 : }
      13             : 
      14           4 : void CustomStatNamespacesImpl::registerStatNamespace(const absl::string_view name) {
      15           4 :   ASSERT_IS_MAIN_OR_TEST_THREAD();
      16           4 :   namespaces_.insert(std::string(name));
      17           4 : };
      18             : 
      19             : absl::optional<absl::string_view>
      20           0 : CustomStatNamespacesImpl::stripRegisteredPrefix(const absl::string_view stat_name) const {
      21           0 :   ASSERT_IS_MAIN_OR_TEST_THREAD();
      22           0 :   if (!namespaces_.empty()) {
      23           0 :     const auto pos = stat_name.find_first_of('.');
      24           0 :     if (pos != std::string::npos && registered(stat_name.substr(0, pos))) {
      25             :       // Trim the custom namespace.
      26           0 :       return stat_name.substr(pos + 1);
      27           0 :     }
      28           0 :   }
      29           0 :   return absl::nullopt;
      30           0 : };
      31             : 
      32             : } // namespace Stats
      33             : } // namespace Envoy

Generated by: LCOV version 1.15