From 22229b2b9049467d02ea9ebbf37c9a279577fef6 Mon Sep 17 00:00:00 2001 From: Leif Hedstrom Date: Fri, 27 Oct 2023 12:16:29 -0600 Subject: [PATCH 1/6] Initial refactoring, cleanup --- example/cripts/example1.cc | 2 +- include/api/Metrics.h | 411 +++++++-------- include/iocore/net/quic/QUICStats.h | 5 +- include/proxy/http/HttpCacheSM.h | 8 +- include/proxy/http/HttpConfig.h | 484 ++++++++--------- include/proxy/http/PreWarmManager.h | 4 +- include/proxy/http2/HTTP2.h | 60 +-- include/proxy/http2/Http2ServerSession.h | 4 +- include/proxy/http3/Http3.h | 6 +- include/proxy/logging/LogConfig.h | 52 +- src/api/InkAPI.cc | 30 +- src/api/Metrics.cc | 236 ++++----- src/api/unit_tests/test_Metrics.cc | 14 +- src/iocore/aio/AIO.cc | 26 +- src/iocore/aio/P_AIO.h | 10 +- src/iocore/aio/test_AIO.cc | 8 +- src/iocore/cache/Cache.cc | 176 +++---- src/iocore/cache/CacheDir.cc | 52 +- src/iocore/cache/CacheDisk.cc | 8 +- src/iocore/cache/CacheHttp.cc | 6 +- src/iocore/cache/CacheRead.cc | 64 +-- src/iocore/cache/CacheVC.cc | 8 +- src/iocore/cache/CacheWrite.cc | 52 +- src/iocore/cache/P_CacheInternal.h | 14 +- src/iocore/cache/P_CacheStats.h | 72 +-- src/iocore/cache/RamCacheCLFUS.cc | 48 +- src/iocore/cache/RamCacheLRU.cc | 16 +- src/iocore/dns/DNS.cc | 58 +-- src/iocore/dns/P_DNSProcessor.h | 31 +- src/iocore/hostdb/HostDB.cc | 36 +- src/iocore/hostdb/P_HostDBProcessor.h | 16 +- src/iocore/hostdb/P_RefCountCache.h | 56 +- src/iocore/io_uring/io_uring.cc | 19 +- src/iocore/io_uring/unit_tests/test_diskIO.cc | 9 +- src/iocore/net/BIO_fastopen.cc | 4 +- src/iocore/net/Net.cc | 86 ++-- src/iocore/net/NetHandler.cc | 8 +- src/iocore/net/OCSPStapling.cc | 8 +- src/iocore/net/P_Net.h | 87 ++-- src/iocore/net/P_UnixNet.h | 2 +- src/iocore/net/QUICNetProcessor.cc | 2 +- src/iocore/net/QUICNetProcessor_quiche.cc | 2 +- src/iocore/net/QUICNetVConnection.cc | 2 +- src/iocore/net/SSLDiags.cc | 40 +- src/iocore/net/SSLNetVConnection.cc | 68 +-- src/iocore/net/SSLSessionCache.cc | 12 +- src/iocore/net/SSLStats.cc | 132 ++--- src/iocore/net/SSLStats.h | 120 ++--- src/iocore/net/SSLUtils.cc | 6 +- src/iocore/net/Socks.cc | 4 +- src/iocore/net/TLSBasicSupport.cc | 2 +- src/iocore/net/TLSSessionResumptionSupport.cc | 20 +- src/iocore/net/UnixNet.cc | 10 +- src/iocore/net/UnixNetAccept.cc | 24 +- src/iocore/net/UnixNetProcessor.cc | 2 +- src/iocore/net/UnixNetVConnection.cc | 38 +- src/iocore/net/quic/QUICGlobals.cc | 8 +- src/mgmt/rpc/handlers/config/Configuration.cc | 10 +- src/mgmt/rpc/handlers/server/Server.cc | 12 +- src/proxy/http/Http1ClientSession.cc | 18 +- src/proxy/http/Http1ClientTransaction.cc | 4 +- src/proxy/http/Http1ServerSession.cc | 12 +- src/proxy/http/Http1ServerTransaction.cc | 4 +- src/proxy/http/HttpCacheSM.cc | 4 +- src/proxy/http/HttpConfig.cc | 486 +++++++++--------- src/proxy/http/HttpSM.cc | 76 +-- src/proxy/http/HttpSessionAccept.cc | 4 +- src/proxy/http/HttpSessionManager.cc | 6 +- src/proxy/http/HttpTransact.cc | 390 +++++++------- src/proxy/http/HttpTunnel.cc | 10 +- src/proxy/http/HttpVCTable.cc | 2 +- src/proxy/http/PreWarmManager.cc | 35 +- src/proxy/http2/HTTP2.cc | 62 +-- src/proxy/http2/Http2ClientSession.cc | 10 +- src/proxy/http2/Http2CommonSession.cc | 16 +- src/proxy/http2/Http2ConnectionState.cc | 22 +- src/proxy/http2/Http2ServerSession.cc | 6 +- src/proxy/http2/Http2SessionAccept.cc | 4 +- src/proxy/http2/Http2Stream.cc | 14 +- src/proxy/http3/Http3.cc | 4 +- src/proxy/logging/Log.cc | 24 +- src/proxy/logging/LogAccess.cc | 8 +- src/proxy/logging/LogConfig.cc | 54 +- src/proxy/logging/LogFile.cc | 18 +- src/proxy/logging/LogObject.cc | 12 +- src/records/RecCore.cc | 15 +- src/traffic_server/traffic_server.cc | 54 +- 87 files changed, 2095 insertions(+), 2089 deletions(-) diff --git a/example/cripts/example1.cc b/example/cripts/example1.cc index 9e07276f571..202f14352c1 100644 --- a/example/cripts/example1.cc +++ b/example/cripts/example1.cc @@ -230,7 +230,7 @@ do_remap() // Testing some simple metrics static auto m1 = Metrics::Sum("cript.example1`.m1"); - static auto m2 = Metrics::Counter("cript.example1`.m2"); + static auto m2 = Counter::AtomicType("cript.example1`.m2"); m1.increment(100); m2.increment(); diff --git a/include/api/Metrics.h b/include/api/Metrics.h index 89845c2b65a..519c3951c08 100644 --- a/include/api/Metrics.h +++ b/include/api/Metrics.h @@ -40,259 +40,262 @@ namespace ts { -class Metrics +namespace Metrics { -private: - using self_type = Metrics; - -public: - using IntType = std::atomic; - using IdType = int32_t; // Could be a tuple, but one way or another, they have to be combined to an int32_t. - using SpanIntType = swoc::MemSpan; - - static constexpr uint16_t METRICS_MAX_BLOBS = 8192; - static constexpr uint16_t METRICS_MAX_SIZE = 2048; // For a total of 16M metrics - static constexpr IdType NOT_FOUND = std::numeric_limits::min(); // <16-bit,16-bit> = - static const auto MEMORY_ORDER = std::memory_order_relaxed; - -private: - using NameAndId = std::tuple; - using NameContainer = std::array; - using AtomicContainer = std::array; - using MetricStorage = std::tuple; - using MetricBlobs = std::array; - using LookupTable = std::unordered_map; - -public: - Metrics(const self_type &) = delete; - self_type &operator=(const self_type &) = delete; - Metrics &operator=(Metrics &&) = delete; - Metrics(Metrics &&) = delete; - - virtual ~Metrics() + class Counter { - for (size_t i = 0; i <= _cur_blob; ++i) { - delete _blobs[i]; - } - } + private: + using self_type = Counter; - Metrics() - { - _blobs[0] = new MetricStorage(); - ink_release_assert(_blobs[0]); - ink_release_assert(0 == newMetric("proxy.process.api.metrics.bad_id")); // Reserve slot 0 for errors, this should always be 0 - } - - // Singleton - static Metrics &getInstance(); - - // Yes, we don't return objects here, but rather ID's and atomic's directly. Treat - // the std::atomic as the underlying class for a single metric, and be happy. - IdType newMetric(const std::string_view name); - SpanIntType newMetricSpan(size_t size, IdType *id = nullptr); - IdType lookup(const std::string_view name) const; - IntType *lookup(IdType id, std::string_view *name = nullptr) const; - - std::optional - lookupPtr(const std::string_view name) const - { - IdType id = lookup(name); - if (id != NOT_FOUND) { - return lookup(id); - } - return std::nullopt; - } + public: + using AtomicType = std::atomic; + using IdType = int32_t; // Could be a tuple, but one way or another, they have to be combined to an int32_t. + using SpanType = swoc::MemSpan; - // A bit of a convenience, since we use the ptr to the atomic frequently in the core - IntType * - newMetricPtr(const std::string_view name) - { - return lookup(newMetric(name)); - } + static constexpr uint16_t MAX_BLOBS = 8192; + static constexpr uint16_t MAX_SIZE = 1024; // For a total of 8M metrics + static constexpr IdType NOT_FOUND = std::numeric_limits::min(); // <16-bit,16-bit> = + static const auto MEMORY_ORDER = std::memory_order_relaxed; - bool rename(IdType id, const std::string_view name); + private: + using NameAndId = std::tuple; + using LookupTable = std::unordered_map; + using NameStorage = std::array; + using AtomicStorage = std::array; + using NamesAndAtomics = std::tuple; + using BlobStorage = std::array; - IntType & - operator[](IdType id) - { - return *lookup(id); - } + public: + Counter(const self_type &) = delete; + self_type &operator=(const self_type &) = delete; + Counter &operator=(Counter &&) = delete; + Counter(Counter &&) = delete; - IdType - operator[](const std::string_view name) const - { - return lookup(name); - } + virtual ~Counter() + { + for (size_t i = 0; i <= _cur_blob; ++i) { + delete _blobs[i]; + } + } - int64_t - increment(IdType id, uint64_t val = 1) - { - auto metric = lookup(id); + Counter() + { + _blobs[0] = new NamesAndAtomics(); + ink_release_assert(_blobs[0]); + ink_release_assert(0 == create("proxy.process.api.metrics.bad_id")); // Reserve slot 0 for errors, this should always be 0 + } - return (metric ? metric->fetch_add(val, MEMORY_ORDER) : NOT_FOUND); - } + // Singleton + static Counter &getInstance(); - // ToDo: Do we even need these inc/dec functions? - int64_t - decrement(IdType id, uint64_t val = 1) - { - auto metric = lookup(id); + // Yes, we don't return objects here, but rather ID's and atomic's directly. Treat + // the std::atomic as the underlying class for a single metric, and be happy. + IdType create(const std::string_view name); + SpanType createSpan(size_t size, IdType *id = nullptr); + IdType lookup(const std::string_view name) const; + AtomicType *lookup(IdType id, std::string_view *name = nullptr) const; - return (metric ? metric->fetch_sub(val, MEMORY_ORDER) : NOT_FOUND); - } + std::optional + lookupPtr(const std::string_view name) const + { + IdType id = lookup(name); + if (id != NOT_FOUND) { + return lookup(id); + } + return std::nullopt; + } - std::string_view name(IdType id) const; + // A bit of a convenience, since we use the ptr to the atomic frequently in the core + AtomicType * + createPtr(const std::string_view name) + { + return lookup(create(name)); + } - bool - valid(IdType id) const - { - auto [blob, entry] = _splitID(id); + bool rename(IdType id, const std::string_view name); - return (id >= 0 && ((blob < _cur_blob && entry < METRICS_MAX_SIZE) || (blob == _cur_blob && entry <= _cur_off))); - } + AtomicType & + operator[](IdType id) + { + return *lookup(id); + } - // Static methods to encapsulate access to the atomic's - static void - increment(IntType *metric, uint64_t val = 1) - { - ink_assert(metric); - metric->fetch_add(val, MEMORY_ORDER); - } + IdType + operator[](const std::string_view name) const + { + return lookup(name); + } - static void - decrement(IntType *metric, uint64_t val = 1) - { - ink_assert(metric); - metric->fetch_sub(val, MEMORY_ORDER); - } + int64_t + increment(IdType id, uint64_t val = 1) + { + auto metric = lookup(id); - static int64_t - read(IntType *metric) - { - ink_assert(metric); - return metric->load(); - } + return (metric ? metric->fetch_add(val, MEMORY_ORDER) : NOT_FOUND); + } - static void - write(IntType *metric, int64_t val) - { - ink_assert(metric); - return metric->store(val); - } + int64_t + decrement(IdType id, uint64_t val = 1) + { + auto metric = lookup(id); - class iterator - { - public: - using iterator_category = std::input_iterator_tag; - using value_type = std::tuple; - using difference_type = ptrdiff_t; - using pointer = value_type *; - using reference = value_type &; + return (metric ? metric->fetch_sub(val, MEMORY_ORDER) : NOT_FOUND); + } - iterator(const Metrics &m, IdType pos) : _metrics(m), _it(pos) {} + std::string_view name(IdType id) const; - iterator & - operator++() + bool + valid(IdType id) const { - next(); + auto [blob, entry] = _splitID(id); - return *this; + return (id >= 0 && ((blob < _cur_blob && entry < MAX_SIZE) || (blob == _cur_blob && entry <= _cur_off))); } - iterator - operator++(int) + // Static methods to encapsulate access to the atomic's + static void + increment(AtomicType *metric, uint64_t val = 1) { - iterator result = *this; - - next(); - - return result; + ink_assert(metric); + metric->fetch_add(val, MEMORY_ORDER); } - value_type - operator*() const + static void + decrement(AtomicType *metric, uint64_t val = 1) { - std::string_view name; - auto metric = _metrics.lookup(_it, &name); - - return std::make_tuple(name, metric->load()); + ink_assert(metric); + metric->fetch_sub(val, MEMORY_ORDER); } - bool - operator==(const iterator &o) const + static int64_t + read(AtomicType *metric) { - return _it == o._it && std::addressof(_metrics) == std::addressof(o._metrics); + ink_assert(metric); + return metric->load(); } - bool - operator!=(const iterator &o) const + static void + write(AtomicType *metric, int64_t val) { - return _it != o._it || std::addressof(_metrics) != std::addressof(o._metrics); + ink_assert(metric); + return metric->store(val); } - private: - void next(); + class iterator + { + public: + using iterator_category = std::input_iterator_tag; + using value_type = std::tuple; + using difference_type = ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; - const Metrics &_metrics; - IdType _it; - }; + iterator(const Counter &m, IdType pos) : _counter(m), _it(pos) {} - iterator - begin() const - { - return iterator(*this, 0); - } + iterator & + operator++() + { + next(); - iterator - end() const - { - _mutex.lock(); - int16_t blob = _cur_blob; - int16_t offset = _cur_off; - _mutex.unlock(); + return *this; + } - return iterator(*this, _makeId(blob, offset)); - } + iterator + operator++(int) + { + iterator result = *this; - iterator - find(const std::string_view name) const - { - auto id = lookup(name); + next(); + + return result; + } - if (id == NOT_FOUND) { - return end(); - } else { - return iterator(*this, id); + value_type + operator*() const + { + std::string_view name; + auto metric = _counter.lookup(_it, &name); + + return std::make_tuple(name, metric->load()); + } + + bool + operator==(const iterator &o) const + { + return _it == o._it && std::addressof(_counter) == std::addressof(o._counter); + } + + bool + operator!=(const iterator &o) const + { + return _it != o._it || std::addressof(_counter) != std::addressof(o._counter); + } + + private: + void next(); + + const Counter &_counter; + IdType _it; + }; + + iterator + begin() const + { + return iterator(*this, 0); } - } -private: - static constexpr std::tuple - _splitID(IdType value) - { - return std::make_tuple(static_cast(value >> 16), static_cast(value & 0xFFFF)); - } + iterator + end() const + { + _mutex.lock(); + int16_t blob = _cur_blob; + int16_t offset = _cur_off; + _mutex.unlock(); - static constexpr IdType - _makeId(uint16_t blob, uint16_t offset) - { - return (blob << 16 | offset); - } + return iterator(*this, _makeId(blob, offset)); + } - static constexpr IdType - _makeId(std::tuple id) - { - return _makeId(std::get<0>(id), std::get<1>(id)); - } + iterator + find(const std::string_view name) const + { + auto id = lookup(name); + + if (id == NOT_FOUND) { + return end(); + } else { + return iterator(*this, id); + } + } + + private: + static constexpr std::tuple + _splitID(IdType value) + { + return std::make_tuple(static_cast(value >> 16), static_cast(value & 0xFFFF)); + } + + static constexpr IdType + _makeId(uint16_t blob, uint16_t offset) + { + return (blob << 16 | offset); + } + + static constexpr IdType + _makeId(std::tuple id) + { + return _makeId(std::get<0>(id), std::get<1>(id)); + } + + void _addBlob(); - void _addBlob(); + mutable std::mutex _mutex; + LookupTable _lookups; + BlobStorage _blobs; + uint16_t _cur_blob = 0; + uint16_t _cur_off = 0; - mutable std::mutex _mutex; - LookupTable _lookups; - MetricBlobs _blobs; - uint16_t _cur_blob = 0; - uint16_t _cur_off = 0; + }; // class Counter -}; // class Metrics +} // namespace Metrics } // namespace ts diff --git a/include/iocore/net/quic/QUICStats.h b/include/iocore/net/quic/QUICStats.h index c429f836616..81fbf84e694 100644 --- a/include/iocore/net/quic/QUICStats.h +++ b/include/iocore/net/quic/QUICStats.h @@ -24,10 +24,11 @@ #pragma once #include "api/Metrics.h" -using ts::Metrics; + +using ts::Metrics::Counter; struct QuicStatsBlock { - Metrics::IntType *total_packets_sent; + Counter::AtomicType *total_packets_sent; }; extern QuicStatsBlock quic_rsb; diff --git a/include/proxy/http/HttpCacheSM.h b/include/proxy/http/HttpCacheSM.h index cb4cd7a10d1..d51e7d4c28e 100644 --- a/include/proxy/http/HttpCacheSM.h +++ b/include/proxy/http/HttpCacheSM.h @@ -160,7 +160,7 @@ class HttpCacheSM : public Continuation abort_read() { if (cache_read_vc) { - Metrics::decrement(http_rsb.current_cache_connections); + Counter::decrement(http_rsb.current_cache_connections); cache_read_vc->do_io_close(0); // passing zero as aborting read is not an error cache_read_vc = nullptr; } @@ -169,7 +169,7 @@ class HttpCacheSM : public Continuation abort_write() { if (cache_write_vc) { - Metrics::decrement(http_rsb.current_cache_connections); + Counter::decrement(http_rsb.current_cache_connections); cache_write_vc->do_io_close(0); // passing zero as aborting write is not an error cache_write_vc = nullptr; } @@ -178,7 +178,7 @@ class HttpCacheSM : public Continuation close_write() { if (cache_write_vc) { - Metrics::decrement(http_rsb.current_cache_connections); + Counter::decrement(http_rsb.current_cache_connections); cache_write_vc->do_io_close(); cache_write_vc = nullptr; } @@ -187,7 +187,7 @@ class HttpCacheSM : public Continuation close_read() { if (cache_read_vc) { - Metrics::decrement(http_rsb.current_cache_connections); + Counter::decrement(http_rsb.current_cache_connections); cache_read_vc->do_io_close(); cache_read_vc = nullptr; } diff --git a/include/proxy/http/HttpConfig.h b/include/proxy/http/HttpConfig.h index da253a150fb..f149db01936 100644 --- a/include/proxy/http/HttpConfig.h +++ b/include/proxy/http/HttpConfig.h @@ -55,254 +55,254 @@ #include "tscpp/util/ts_ip.h" #include "api/Metrics.h" -using ts::Metrics; +using ts::Metrics::Counter; static const unsigned HTTP_STATUS_NUMBER = 600; using HttpStatusBitset = std::bitset; struct HttpStatsBlock { // Need two stats for these for counts and times - ts::Metrics::IntType *background_fill_bytes_aborted; - ts::Metrics::IntType *background_fill_bytes_completed; - ts::Metrics::IntType *background_fill_current_count; - ts::Metrics::IntType *background_fill_total_count; - ts::Metrics::IntType *broken_server_connections; - ts::Metrics::IntType *cache_deletes; - ts::Metrics::IntType *cache_hit_fresh; - ts::Metrics::IntType *cache_hit_ims; - ts::Metrics::IntType *cache_hit_mem_fresh; - ts::Metrics::IntType *cache_hit_reval; - ts::Metrics::IntType *cache_hit_rww; - ts::Metrics::IntType *cache_hit_stale_served; - ts::Metrics::IntType *cache_lookups; - ts::Metrics::IntType *cache_miss_changed; - ts::Metrics::IntType *cache_miss_client_no_cache; - ts::Metrics::IntType *cache_miss_cold; - ts::Metrics::IntType *cache_miss_ims; - ts::Metrics::IntType *cache_miss_uncacheable; - ts::Metrics::IntType *cache_open_read_begin_time; - ts::Metrics::IntType *cache_open_read_end_time; - ts::Metrics::IntType *cache_open_write_adjust_thread; - ts::Metrics::IntType *cache_open_write_begin_time; - ts::Metrics::IntType *cache_open_write_end_time; - ts::Metrics::IntType *cache_read_error; - ts::Metrics::IntType *cache_read_errors; - ts::Metrics::IntType *cache_updates; - ts::Metrics::IntType *cache_write_errors; - ts::Metrics::IntType *cache_writes; - ts::Metrics::IntType *completed_requests; - ts::Metrics::IntType *connect_requests; - ts::Metrics::IntType *current_active_client_connections; - ts::Metrics::IntType *current_cache_connections; - ts::Metrics::IntType *current_client_connections; - ts::Metrics::IntType *current_client_transactions; - ts::Metrics::IntType *current_parent_proxy_connections; - ts::Metrics::IntType *current_server_connections; - ts::Metrics::IntType *current_server_transactions; - ts::Metrics::IntType *delete_requests; - ts::Metrics::IntType *disallowed_post_100_continue; - ts::Metrics::IntType *dns_lookup_begin_time; - ts::Metrics::IntType *dns_lookup_end_time; - ts::Metrics::IntType *down_server_no_requests; - ts::Metrics::IntType *err_client_abort_count; - ts::Metrics::IntType *err_client_abort_origin_server_bytes; - ts::Metrics::IntType *err_client_abort_user_agent_bytes; - ts::Metrics::IntType *err_client_read_error_count; - ts::Metrics::IntType *err_client_read_error_origin_server_bytes; - ts::Metrics::IntType *err_client_read_error_user_agent_bytes; - ts::Metrics::IntType *err_connect_fail_count; - ts::Metrics::IntType *err_connect_fail_origin_server_bytes; - ts::Metrics::IntType *err_connect_fail_user_agent_bytes; - ts::Metrics::IntType *extension_method_requests; - ts::Metrics::IntType *get_requests; - ts::Metrics::IntType *head_requests; - ts::Metrics::IntType *https_incoming_requests; - ts::Metrics::IntType *https_total_client_connections; - ts::Metrics::IntType *incoming_requests; - ts::Metrics::IntType *incoming_responses; - ts::Metrics::IntType *invalid_client_requests; - ts::Metrics::IntType *misc_count; - ts::Metrics::IntType *misc_origin_server_bytes; - ts::Metrics::IntType *misc_user_agent_bytes; - ts::Metrics::IntType *missing_host_hdr; - ts::Metrics::IntType *options_requests; - ts::Metrics::IntType *origin_body; - ts::Metrics::IntType *origin_close_private; - ts::Metrics::IntType *origin_connect_adjust_thread; - ts::Metrics::IntType *origin_connections_throttled; - ts::Metrics::IntType *origin_make_new; - ts::Metrics::IntType *origin_no_sharing; - ts::Metrics::IntType *origin_not_found; - ts::Metrics::IntType *origin_private; - ts::Metrics::IntType *origin_raw; - ts::Metrics::IntType *origin_reuse; - ts::Metrics::IntType *origin_reuse_fail; - ts::Metrics::IntType *origin_server_request_document_total_size; - ts::Metrics::IntType *origin_server_request_header_total_size; - ts::Metrics::IntType *origin_server_response_document_total_size; - ts::Metrics::IntType *origin_server_response_header_total_size; - ts::Metrics::IntType *origin_shutdown_cleanup_entry; - ts::Metrics::IntType *origin_shutdown_migration_failure; - ts::Metrics::IntType *origin_shutdown_pool_lock_contention; - ts::Metrics::IntType *origin_shutdown_release_invalid_request; - ts::Metrics::IntType *origin_shutdown_release_invalid_response; - ts::Metrics::IntType *origin_shutdown_release_misc; - ts::Metrics::IntType *origin_shutdown_release_modified; - ts::Metrics::IntType *origin_shutdown_release_no_keep_alive; - ts::Metrics::IntType *origin_shutdown_release_no_server; - ts::Metrics::IntType *origin_shutdown_release_no_sharing; - ts::Metrics::IntType *origin_shutdown_tunnel_abort; - ts::Metrics::IntType *origin_shutdown_tunnel_client; - ts::Metrics::IntType *origin_shutdown_tunnel_server; - ts::Metrics::IntType *origin_shutdown_tunnel_server_detach; - ts::Metrics::IntType *origin_shutdown_tunnel_server_eos; - ts::Metrics::IntType *origin_shutdown_tunnel_server_no_keep_alive; - ts::Metrics::IntType *origin_shutdown_tunnel_server_plugin_tunnel; - ts::Metrics::IntType *origin_shutdown_tunnel_transform_read; - ts::Metrics::IntType *outgoing_requests; - ts::Metrics::IntType *parent_count; - ts::Metrics::IntType *parent_proxy_request_total_bytes; - ts::Metrics::IntType *parent_proxy_response_total_bytes; - ts::Metrics::IntType *parent_proxy_transaction_time; - ts::Metrics::IntType *pooled_server_connections; - ts::Metrics::IntType *post_body_too_large; - ts::Metrics::IntType *post_requests; - ts::Metrics::IntType *proxy_loop_detected; - ts::Metrics::IntType *proxy_mh_loop_detected; - ts::Metrics::IntType *purge_requests; - ts::Metrics::IntType *push_requests; - ts::Metrics::IntType *pushed_document_total_size; - ts::Metrics::IntType *pushed_response_header_total_size; - ts::Metrics::IntType *put_requests; - ts::Metrics::IntType *response_status_100_count; - ts::Metrics::IntType *response_status_101_count; - ts::Metrics::IntType *response_status_1xx_count; - ts::Metrics::IntType *response_status_200_count; - ts::Metrics::IntType *response_status_201_count; - ts::Metrics::IntType *response_status_202_count; - ts::Metrics::IntType *response_status_203_count; - ts::Metrics::IntType *response_status_204_count; - ts::Metrics::IntType *response_status_205_count; - ts::Metrics::IntType *response_status_206_count; - ts::Metrics::IntType *response_status_2xx_count; - ts::Metrics::IntType *response_status_300_count; - ts::Metrics::IntType *response_status_301_count; - ts::Metrics::IntType *response_status_302_count; - ts::Metrics::IntType *response_status_303_count; - ts::Metrics::IntType *response_status_304_count; - ts::Metrics::IntType *response_status_305_count; - ts::Metrics::IntType *response_status_307_count; - ts::Metrics::IntType *response_status_308_count; - ts::Metrics::IntType *response_status_3xx_count; - ts::Metrics::IntType *response_status_400_count; - ts::Metrics::IntType *response_status_401_count; - ts::Metrics::IntType *response_status_402_count; - ts::Metrics::IntType *response_status_403_count; - ts::Metrics::IntType *response_status_404_count; - ts::Metrics::IntType *response_status_405_count; - ts::Metrics::IntType *response_status_406_count; - ts::Metrics::IntType *response_status_407_count; - ts::Metrics::IntType *response_status_408_count; - ts::Metrics::IntType *response_status_409_count; - ts::Metrics::IntType *response_status_410_count; - ts::Metrics::IntType *response_status_411_count; - ts::Metrics::IntType *response_status_412_count; - ts::Metrics::IntType *response_status_413_count; - ts::Metrics::IntType *response_status_414_count; - ts::Metrics::IntType *response_status_415_count; - ts::Metrics::IntType *response_status_416_count; - ts::Metrics::IntType *response_status_4xx_count; - ts::Metrics::IntType *response_status_500_count; - ts::Metrics::IntType *response_status_501_count; - ts::Metrics::IntType *response_status_502_count; - ts::Metrics::IntType *response_status_503_count; - ts::Metrics::IntType *response_status_504_count; - ts::Metrics::IntType *response_status_505_count; - ts::Metrics::IntType *response_status_5xx_count; - ts::Metrics::IntType *server_begin_write_time; - ts::Metrics::IntType *server_close_time; - ts::Metrics::IntType *server_connect_end_time; - ts::Metrics::IntType *server_connect_time; - ts::Metrics::IntType *server_first_connect_time; - ts::Metrics::IntType *server_first_read_time; - ts::Metrics::IntType *server_read_header_done_time; - ts::Metrics::IntType *sm_finish_time; - ts::Metrics::IntType *sm_start_time; - ts::Metrics::IntType *tcp_client_refresh_count; - ts::Metrics::IntType *tcp_client_refresh_origin_server_bytes; - ts::Metrics::IntType *tcp_client_refresh_user_agent_bytes; - ts::Metrics::IntType *tcp_expired_miss_count; - ts::Metrics::IntType *tcp_expired_miss_origin_server_bytes; - ts::Metrics::IntType *tcp_expired_miss_user_agent_bytes; - ts::Metrics::IntType *tcp_hit_count; - ts::Metrics::IntType *tcp_hit_origin_server_bytes; - ts::Metrics::IntType *tcp_hit_user_agent_bytes; - ts::Metrics::IntType *tcp_ims_hit_count; - ts::Metrics::IntType *tcp_ims_hit_origin_server_bytes; - ts::Metrics::IntType *tcp_ims_hit_user_agent_bytes; - ts::Metrics::IntType *tcp_ims_miss_count; - ts::Metrics::IntType *tcp_ims_miss_origin_server_bytes; - ts::Metrics::IntType *tcp_ims_miss_user_agent_bytes; - ts::Metrics::IntType *tcp_miss_count; - ts::Metrics::IntType *tcp_miss_origin_server_bytes; - ts::Metrics::IntType *tcp_miss_user_agent_bytes; - ts::Metrics::IntType *tcp_refresh_hit_count; - ts::Metrics::IntType *tcp_refresh_hit_origin_server_bytes; - ts::Metrics::IntType *tcp_refresh_hit_user_agent_bytes; - ts::Metrics::IntType *tcp_refresh_miss_count; - ts::Metrics::IntType *tcp_refresh_miss_origin_server_bytes; - ts::Metrics::IntType *tcp_refresh_miss_user_agent_bytes; - ts::Metrics::IntType *total_client_connections; - ts::Metrics::IntType *total_client_connections_ipv4; - ts::Metrics::IntType *total_client_connections_ipv6; - ts::Metrics::IntType *total_incoming_connections; - ts::Metrics::IntType *total_parent_marked_down_count; - ts::Metrics::IntType *total_parent_proxy_connections; - ts::Metrics::IntType *total_parent_retries; - ts::Metrics::IntType *total_parent_retries_exhausted; - ts::Metrics::IntType *total_parent_switches; - ts::Metrics::IntType *total_server_connections; - ts::Metrics::IntType *total_transactions_time; - ts::Metrics::IntType *total_x_redirect; - ts::Metrics::IntType *trace_requests; - ts::Metrics::IntType *tunnel_current_active_connections; - ts::Metrics::IntType *tunnels; - ts::Metrics::IntType *ua_begin_time; - ts::Metrics::IntType *ua_begin_write_time; - ts::Metrics::IntType *ua_close_time; - ts::Metrics::IntType *ua_counts_errors_aborts; - ts::Metrics::IntType *ua_counts_errors_connect_failed; - ts::Metrics::IntType *ua_counts_errors_other; - ts::Metrics::IntType *ua_counts_errors_possible_aborts; - ts::Metrics::IntType *ua_counts_errors_pre_accept_hangups; - ts::Metrics::IntType *ua_counts_hit_fresh; - ts::Metrics::IntType *ua_counts_hit_fresh_process; - ts::Metrics::IntType *ua_counts_hit_reval; - ts::Metrics::IntType *ua_counts_miss_changed; - ts::Metrics::IntType *ua_counts_miss_client_no_cache; - ts::Metrics::IntType *ua_counts_miss_cold; - ts::Metrics::IntType *ua_counts_miss_uncacheable; - ts::Metrics::IntType *ua_counts_other_unclassified; - ts::Metrics::IntType *ua_first_read_time; - ts::Metrics::IntType *ua_msecs_errors_aborts; - ts::Metrics::IntType *ua_msecs_errors_connect_failed; - ts::Metrics::IntType *ua_msecs_errors_other; - ts::Metrics::IntType *ua_msecs_errors_possible_aborts; - ts::Metrics::IntType *ua_msecs_errors_pre_accept_hangups; - ts::Metrics::IntType *ua_msecs_hit_fresh; - ts::Metrics::IntType *ua_msecs_hit_fresh_process; - ts::Metrics::IntType *ua_msecs_hit_reval; - ts::Metrics::IntType *ua_msecs_miss_changed; - ts::Metrics::IntType *ua_msecs_miss_client_no_cache; - ts::Metrics::IntType *ua_msecs_miss_cold; - ts::Metrics::IntType *ua_msecs_miss_uncacheable; - ts::Metrics::IntType *ua_msecs_other_unclassified; - ts::Metrics::IntType *ua_read_header_done_time; - ts::Metrics::IntType *user_agent_request_document_total_size; - ts::Metrics::IntType *user_agent_request_header_total_size; - ts::Metrics::IntType *user_agent_response_document_total_size; - ts::Metrics::IntType *user_agent_response_header_total_size; - ts::Metrics::IntType *websocket_current_active_client_connections; + Counter::AtomicType *background_fill_bytes_aborted; + Counter::AtomicType *background_fill_bytes_completed; + Counter::AtomicType *background_fill_current_count; + Counter::AtomicType *background_fill_total_count; + Counter::AtomicType *broken_server_connections; + Counter::AtomicType *cache_deletes; + Counter::AtomicType *cache_hit_fresh; + Counter::AtomicType *cache_hit_ims; + Counter::AtomicType *cache_hit_mem_fresh; + Counter::AtomicType *cache_hit_reval; + Counter::AtomicType *cache_hit_rww; + Counter::AtomicType *cache_hit_stale_served; + Counter::AtomicType *cache_lookups; + Counter::AtomicType *cache_miss_changed; + Counter::AtomicType *cache_miss_client_no_cache; + Counter::AtomicType *cache_miss_cold; + Counter::AtomicType *cache_miss_ims; + Counter::AtomicType *cache_miss_uncacheable; + Counter::AtomicType *cache_open_read_begin_time; + Counter::AtomicType *cache_open_read_end_time; + Counter::AtomicType *cache_open_write_adjust_thread; + Counter::AtomicType *cache_open_write_begin_time; + Counter::AtomicType *cache_open_write_end_time; + Counter::AtomicType *cache_read_error; + Counter::AtomicType *cache_read_errors; + Counter::AtomicType *cache_updates; + Counter::AtomicType *cache_write_errors; + Counter::AtomicType *cache_writes; + Counter::AtomicType *completed_requests; + Counter::AtomicType *connect_requests; + Counter::AtomicType *current_active_client_connections; + Counter::AtomicType *current_cache_connections; + Counter::AtomicType *current_client_connections; + Counter::AtomicType *current_client_transactions; + Counter::AtomicType *current_parent_proxy_connections; + Counter::AtomicType *current_server_connections; + Counter::AtomicType *current_server_transactions; + Counter::AtomicType *delete_requests; + Counter::AtomicType *disallowed_post_100_continue; + Counter::AtomicType *dns_lookup_begin_time; + Counter::AtomicType *dns_lookup_end_time; + Counter::AtomicType *down_server_no_requests; + Counter::AtomicType *err_client_abort_count; + Counter::AtomicType *err_client_abort_origin_server_bytes; + Counter::AtomicType *err_client_abort_user_agent_bytes; + Counter::AtomicType *err_client_read_error_count; + Counter::AtomicType *err_client_read_error_origin_server_bytes; + Counter::AtomicType *err_client_read_error_user_agent_bytes; + Counter::AtomicType *err_connect_fail_count; + Counter::AtomicType *err_connect_fail_origin_server_bytes; + Counter::AtomicType *err_connect_fail_user_agent_bytes; + Counter::AtomicType *extension_method_requests; + Counter::AtomicType *get_requests; + Counter::AtomicType *head_requests; + Counter::AtomicType *https_incoming_requests; + Counter::AtomicType *https_total_client_connections; + Counter::AtomicType *incoming_requests; + Counter::AtomicType *incoming_responses; + Counter::AtomicType *invalid_client_requests; + Counter::AtomicType *misc_count; + Counter::AtomicType *misc_origin_server_bytes; + Counter::AtomicType *misc_user_agent_bytes; + Counter::AtomicType *missing_host_hdr; + Counter::AtomicType *options_requests; + Counter::AtomicType *origin_body; + Counter::AtomicType *origin_close_private; + Counter::AtomicType *origin_connect_adjust_thread; + Counter::AtomicType *origin_connections_throttled; + Counter::AtomicType *origin_make_new; + Counter::AtomicType *origin_no_sharing; + Counter::AtomicType *origin_not_found; + Counter::AtomicType *origin_private; + Counter::AtomicType *origin_raw; + Counter::AtomicType *origin_reuse; + Counter::AtomicType *origin_reuse_fail; + Counter::AtomicType *origin_server_request_document_total_size; + Counter::AtomicType *origin_server_request_header_total_size; + Counter::AtomicType *origin_server_response_document_total_size; + Counter::AtomicType *origin_server_response_header_total_size; + Counter::AtomicType *origin_shutdown_cleanup_entry; + Counter::AtomicType *origin_shutdown_migration_failure; + Counter::AtomicType *origin_shutdown_pool_lock_contention; + Counter::AtomicType *origin_shutdown_release_invalid_request; + Counter::AtomicType *origin_shutdown_release_invalid_response; + Counter::AtomicType *origin_shutdown_release_misc; + Counter::AtomicType *origin_shutdown_release_modified; + Counter::AtomicType *origin_shutdown_release_no_keep_alive; + Counter::AtomicType *origin_shutdown_release_no_server; + Counter::AtomicType *origin_shutdown_release_no_sharing; + Counter::AtomicType *origin_shutdown_tunnel_abort; + Counter::AtomicType *origin_shutdown_tunnel_client; + Counter::AtomicType *origin_shutdown_tunnel_server; + Counter::AtomicType *origin_shutdown_tunnel_server_detach; + Counter::AtomicType *origin_shutdown_tunnel_server_eos; + Counter::AtomicType *origin_shutdown_tunnel_server_no_keep_alive; + Counter::AtomicType *origin_shutdown_tunnel_server_plugin_tunnel; + Counter::AtomicType *origin_shutdown_tunnel_transform_read; + Counter::AtomicType *outgoing_requests; + Counter::AtomicType *parent_count; + Counter::AtomicType *parent_proxy_request_total_bytes; + Counter::AtomicType *parent_proxy_response_total_bytes; + Counter::AtomicType *parent_proxy_transaction_time; + Counter::AtomicType *pooled_server_connections; + Counter::AtomicType *post_body_too_large; + Counter::AtomicType *post_requests; + Counter::AtomicType *proxy_loop_detected; + Counter::AtomicType *proxy_mh_loop_detected; + Counter::AtomicType *purge_requests; + Counter::AtomicType *push_requests; + Counter::AtomicType *pushed_document_total_size; + Counter::AtomicType *pushed_response_header_total_size; + Counter::AtomicType *put_requests; + Counter::AtomicType *response_status_100_count; + Counter::AtomicType *response_status_101_count; + Counter::AtomicType *response_status_1xx_count; + Counter::AtomicType *response_status_200_count; + Counter::AtomicType *response_status_201_count; + Counter::AtomicType *response_status_202_count; + Counter::AtomicType *response_status_203_count; + Counter::AtomicType *response_status_204_count; + Counter::AtomicType *response_status_205_count; + Counter::AtomicType *response_status_206_count; + Counter::AtomicType *response_status_2xx_count; + Counter::AtomicType *response_status_300_count; + Counter::AtomicType *response_status_301_count; + Counter::AtomicType *response_status_302_count; + Counter::AtomicType *response_status_303_count; + Counter::AtomicType *response_status_304_count; + Counter::AtomicType *response_status_305_count; + Counter::AtomicType *response_status_307_count; + Counter::AtomicType *response_status_308_count; + Counter::AtomicType *response_status_3xx_count; + Counter::AtomicType *response_status_400_count; + Counter::AtomicType *response_status_401_count; + Counter::AtomicType *response_status_402_count; + Counter::AtomicType *response_status_403_count; + Counter::AtomicType *response_status_404_count; + Counter::AtomicType *response_status_405_count; + Counter::AtomicType *response_status_406_count; + Counter::AtomicType *response_status_407_count; + Counter::AtomicType *response_status_408_count; + Counter::AtomicType *response_status_409_count; + Counter::AtomicType *response_status_410_count; + Counter::AtomicType *response_status_411_count; + Counter::AtomicType *response_status_412_count; + Counter::AtomicType *response_status_413_count; + Counter::AtomicType *response_status_414_count; + Counter::AtomicType *response_status_415_count; + Counter::AtomicType *response_status_416_count; + Counter::AtomicType *response_status_4xx_count; + Counter::AtomicType *response_status_500_count; + Counter::AtomicType *response_status_501_count; + Counter::AtomicType *response_status_502_count; + Counter::AtomicType *response_status_503_count; + Counter::AtomicType *response_status_504_count; + Counter::AtomicType *response_status_505_count; + Counter::AtomicType *response_status_5xx_count; + Counter::AtomicType *server_begin_write_time; + Counter::AtomicType *server_close_time; + Counter::AtomicType *server_connect_end_time; + Counter::AtomicType *server_connect_time; + Counter::AtomicType *server_first_connect_time; + Counter::AtomicType *server_first_read_time; + Counter::AtomicType *server_read_header_done_time; + Counter::AtomicType *sm_finish_time; + Counter::AtomicType *sm_start_time; + Counter::AtomicType *tcp_client_refresh_count; + Counter::AtomicType *tcp_client_refresh_origin_server_bytes; + Counter::AtomicType *tcp_client_refresh_user_agent_bytes; + Counter::AtomicType *tcp_expired_miss_count; + Counter::AtomicType *tcp_expired_miss_origin_server_bytes; + Counter::AtomicType *tcp_expired_miss_user_agent_bytes; + Counter::AtomicType *tcp_hit_count; + Counter::AtomicType *tcp_hit_origin_server_bytes; + Counter::AtomicType *tcp_hit_user_agent_bytes; + Counter::AtomicType *tcp_ims_hit_count; + Counter::AtomicType *tcp_ims_hit_origin_server_bytes; + Counter::AtomicType *tcp_ims_hit_user_agent_bytes; + Counter::AtomicType *tcp_ims_miss_count; + Counter::AtomicType *tcp_ims_miss_origin_server_bytes; + Counter::AtomicType *tcp_ims_miss_user_agent_bytes; + Counter::AtomicType *tcp_miss_count; + Counter::AtomicType *tcp_miss_origin_server_bytes; + Counter::AtomicType *tcp_miss_user_agent_bytes; + Counter::AtomicType *tcp_refresh_hit_count; + Counter::AtomicType *tcp_refresh_hit_origin_server_bytes; + Counter::AtomicType *tcp_refresh_hit_user_agent_bytes; + Counter::AtomicType *tcp_refresh_miss_count; + Counter::AtomicType *tcp_refresh_miss_origin_server_bytes; + Counter::AtomicType *tcp_refresh_miss_user_agent_bytes; + Counter::AtomicType *total_client_connections; + Counter::AtomicType *total_client_connections_ipv4; + Counter::AtomicType *total_client_connections_ipv6; + Counter::AtomicType *total_incoming_connections; + Counter::AtomicType *total_parent_marked_down_count; + Counter::AtomicType *total_parent_proxy_connections; + Counter::AtomicType *total_parent_retries; + Counter::AtomicType *total_parent_retries_exhausted; + Counter::AtomicType *total_parent_switches; + Counter::AtomicType *total_server_connections; + Counter::AtomicType *total_transactions_time; + Counter::AtomicType *total_x_redirect; + Counter::AtomicType *trace_requests; + Counter::AtomicType *tunnel_current_active_connections; + Counter::AtomicType *tunnels; + Counter::AtomicType *ua_begin_time; + Counter::AtomicType *ua_begin_write_time; + Counter::AtomicType *ua_close_time; + Counter::AtomicType *ua_counts_errors_aborts; + Counter::AtomicType *ua_counts_errors_connect_failed; + Counter::AtomicType *ua_counts_errors_other; + Counter::AtomicType *ua_counts_errors_possible_aborts; + Counter::AtomicType *ua_counts_errors_pre_accept_hangups; + Counter::AtomicType *ua_counts_hit_fresh; + Counter::AtomicType *ua_counts_hit_fresh_process; + Counter::AtomicType *ua_counts_hit_reval; + Counter::AtomicType *ua_counts_miss_changed; + Counter::AtomicType *ua_counts_miss_client_no_cache; + Counter::AtomicType *ua_counts_miss_cold; + Counter::AtomicType *ua_counts_miss_uncacheable; + Counter::AtomicType *ua_counts_other_unclassified; + Counter::AtomicType *ua_first_read_time; + Counter::AtomicType *ua_msecs_errors_aborts; + Counter::AtomicType *ua_msecs_errors_connect_failed; + Counter::AtomicType *ua_msecs_errors_other; + Counter::AtomicType *ua_msecs_errors_possible_aborts; + Counter::AtomicType *ua_msecs_errors_pre_accept_hangups; + Counter::AtomicType *ua_msecs_hit_fresh; + Counter::AtomicType *ua_msecs_hit_fresh_process; + Counter::AtomicType *ua_msecs_hit_reval; + Counter::AtomicType *ua_msecs_miss_changed; + Counter::AtomicType *ua_msecs_miss_client_no_cache; + Counter::AtomicType *ua_msecs_miss_cold; + Counter::AtomicType *ua_msecs_miss_uncacheable; + Counter::AtomicType *ua_msecs_other_unclassified; + Counter::AtomicType *ua_read_header_done_time; + Counter::AtomicType *user_agent_request_document_total_size; + Counter::AtomicType *user_agent_request_header_total_size; + Counter::AtomicType *user_agent_response_document_total_size; + Counter::AtomicType *user_agent_response_header_total_size; + Counter::AtomicType *websocket_current_active_client_connections; }; enum CacheOpenWriteFailAction_t { diff --git a/include/proxy/http/PreWarmManager.h b/include/proxy/http/PreWarmManager.h index 469da3d915e..a33dafcd7d1 100644 --- a/include/proxy/http/PreWarmManager.h +++ b/include/proxy/http/PreWarmManager.h @@ -39,6 +39,8 @@ #include "api/Metrics.h" +using ts::Metrics::Counter; + // tscore #include "tscore/CryptoHash.h" #include "tscore/ink_hrtime.h" @@ -121,7 +123,7 @@ enum class Stat { LAST_ENTRY, }; -using StatsIds = std::array(PreWarm::Stat::LAST_ENTRY)>; +using StatsIds = std::array(PreWarm::Stat::LAST_ENTRY)>; using SPtrConstStatsIds = std::shared_ptr; using StatsIdMap = std::unordered_map; } // namespace PreWarm diff --git a/include/proxy/http2/HTTP2.h b/include/proxy/http2/HTTP2.h index a424981f227..59b41b5873b 100644 --- a/include/proxy/http2/HTTP2.h +++ b/include/proxy/http2/HTTP2.h @@ -31,7 +31,7 @@ #include "api/Metrics.h" -using ts::Metrics; +using ts::Metrics::Counter; class HTTPHdr; @@ -77,35 +77,35 @@ const uint8_t HTTP2_PRIORITY_DEFAULT_WEIGHT = 15; // Statistics struct Http2StatsBlock { - Metrics::IntType *current_client_session_count; - Metrics::IntType *current_server_session_count; - Metrics::IntType *current_active_client_connection_count; - Metrics::IntType *current_active_server_connection_count; - Metrics::IntType *current_client_stream_count; - Metrics::IntType *current_server_stream_count; - Metrics::IntType *total_client_stream_count; - Metrics::IntType *total_server_stream_count; - Metrics::IntType *total_transactions_time; - Metrics::IntType *total_client_connection_count; - Metrics::IntType *total_server_connection_count; - Metrics::IntType *stream_errors_count; - Metrics::IntType *connection_errors_count; - Metrics::IntType *session_die_default; - Metrics::IntType *session_die_other; - Metrics::IntType *session_die_active; - Metrics::IntType *session_die_inactive; - Metrics::IntType *session_die_eos; - Metrics::IntType *session_die_error; - Metrics::IntType *session_die_high_error_rate; - Metrics::IntType *max_settings_per_frame_exceeded; - Metrics::IntType *max_settings_per_minute_exceeded; - Metrics::IntType *max_settings_frames_per_minute_exceeded; - Metrics::IntType *max_ping_frames_per_minute_exceeded; - Metrics::IntType *max_priority_frames_per_minute_exceeded; - Metrics::IntType *max_rst_stream_frames_per_minute_exceeded; - Metrics::IntType *insufficient_avg_window_update; - Metrics::IntType *max_concurrent_streams_exceeded_in; - Metrics::IntType *max_concurrent_streams_exceeded_out; + Counter::AtomicType *current_client_session_count; + Counter::AtomicType *current_server_session_count; + Counter::AtomicType *current_active_client_connection_count; + Counter::AtomicType *current_active_server_connection_count; + Counter::AtomicType *current_client_stream_count; + Counter::AtomicType *current_server_stream_count; + Counter::AtomicType *total_client_stream_count; + Counter::AtomicType *total_server_stream_count; + Counter::AtomicType *total_transactions_time; + Counter::AtomicType *total_client_connection_count; + Counter::AtomicType *total_server_connection_count; + Counter::AtomicType *stream_errors_count; + Counter::AtomicType *connection_errors_count; + Counter::AtomicType *session_die_default; + Counter::AtomicType *session_die_other; + Counter::AtomicType *session_die_active; + Counter::AtomicType *session_die_inactive; + Counter::AtomicType *session_die_eos; + Counter::AtomicType *session_die_error; + Counter::AtomicType *session_die_high_error_rate; + Counter::AtomicType *max_settings_per_frame_exceeded; + Counter::AtomicType *max_settings_per_minute_exceeded; + Counter::AtomicType *max_settings_frames_per_minute_exceeded; + Counter::AtomicType *max_ping_frames_per_minute_exceeded; + Counter::AtomicType *max_priority_frames_per_minute_exceeded; + Counter::AtomicType *max_rst_stream_frames_per_minute_exceeded; + Counter::AtomicType *insufficient_avg_window_update; + Counter::AtomicType *max_concurrent_streams_exceeded_in; + Counter::AtomicType *max_concurrent_streams_exceeded_out; }; extern Http2StatsBlock http2_rsb; diff --git a/include/proxy/http2/Http2ServerSession.h b/include/proxy/http2/Http2ServerSession.h index 7599f3d4d48..97f80df8d2b 100644 --- a/include/proxy/http2/Http2ServerSession.h +++ b/include/proxy/http2/Http2ServerSession.h @@ -72,13 +72,13 @@ class Http2ServerSession : public PoolableSession, public Http2CommonSession void increment_current_active_connections_stat() override { - Metrics::increment(http2_rsb.current_active_server_connection_count); + Counter::increment(http2_rsb.current_active_server_connection_count); } void decrement_current_active_connections_stat() override { - Metrics::decrement(http2_rsb.current_active_server_connection_count); + Counter::decrement(http2_rsb.current_active_server_connection_count); } // noncopyable diff --git a/include/proxy/http3/Http3.h b/include/proxy/http3/Http3.h index 74f4b7e8106..02febc45b85 100644 --- a/include/proxy/http3/Http3.h +++ b/include/proxy/http3/Http3.h @@ -26,6 +26,8 @@ #include "tscore/ink_defs.h" #include "api/Metrics.h" +using ts::Metrics::Counter; + extern const uint32_t HTTP3_DEFAULT_HEADER_TABLE_SIZE; extern const uint32_t HTTP3_DEFAULT_MAX_FIELD_SECTION_SIZE; extern const uint32_t HTTP3_DEFAULT_QPACK_BLOCKED_STREAMS; @@ -39,9 +41,9 @@ class Http3 // Statistics struct Http3StatsBlock { - // Example: Metrics::IntType *current_client_session_count; + // Example: Counter::AtomicType *current_client_session_count; // Once created, e.g. - // Metrics::increment(http3_rsb.current_client_session_count); + // Counter::increment(http3_rsb.current_client_session_count); }; extern Http3StatsBlock http3_rsb; // Container for statistics. diff --git a/include/proxy/logging/LogConfig.h b/include/proxy/logging/LogConfig.h index 45d9436bfc3..137fa0b4a56 100644 --- a/include/proxy/logging/LogConfig.h +++ b/include/proxy/logging/LogConfig.h @@ -34,34 +34,34 @@ #include "swoc/MemSpan.h" #include "api/Metrics.h" -using ts::Metrics; +using ts::Metrics::Counter; struct LogsStatsBlock { - Metrics::IntType *event_log_error_ok; - Metrics::IntType *event_log_error_skip; - Metrics::IntType *event_log_error_aggr; - Metrics::IntType *event_log_error_full; - Metrics::IntType *event_log_error_fail; - Metrics::IntType *event_log_access_ok; - Metrics::IntType *event_log_access_skip; - Metrics::IntType *event_log_access_aggr; - Metrics::IntType *event_log_access_full; - Metrics::IntType *event_log_access_fail; - Metrics::IntType *num_sent_to_network; - Metrics::IntType *num_lost_before_sent_to_network; - Metrics::IntType *num_received_from_network; - Metrics::IntType *num_flush_to_disk; - Metrics::IntType *num_lost_before_flush_to_disk; - Metrics::IntType *bytes_lost_before_preproc; - Metrics::IntType *bytes_sent_to_network; - Metrics::IntType *bytes_lost_before_sent_to_network; - Metrics::IntType *bytes_received_from_network; - Metrics::IntType *bytes_flush_to_disk; - Metrics::IntType *bytes_lost_before_flush_to_disk; - Metrics::IntType *bytes_written_to_disk; - Metrics::IntType *bytes_lost_before_written_to_disk; - Metrics::IntType *log_files_open; - Metrics::IntType *log_files_space_used; + Counter::AtomicType *event_log_error_ok; + Counter::AtomicType *event_log_error_skip; + Counter::AtomicType *event_log_error_aggr; + Counter::AtomicType *event_log_error_full; + Counter::AtomicType *event_log_error_fail; + Counter::AtomicType *event_log_access_ok; + Counter::AtomicType *event_log_access_skip; + Counter::AtomicType *event_log_access_aggr; + Counter::AtomicType *event_log_access_full; + Counter::AtomicType *event_log_access_fail; + Counter::AtomicType *num_sent_to_network; + Counter::AtomicType *num_lost_before_sent_to_network; + Counter::AtomicType *num_received_from_network; + Counter::AtomicType *num_flush_to_disk; + Counter::AtomicType *num_lost_before_flush_to_disk; + Counter::AtomicType *bytes_lost_before_preproc; + Counter::AtomicType *bytes_sent_to_network; + Counter::AtomicType *bytes_lost_before_sent_to_network; + Counter::AtomicType *bytes_received_from_network; + Counter::AtomicType *bytes_flush_to_disk; + Counter::AtomicType *bytes_lost_before_flush_to_disk; + Counter::AtomicType *bytes_written_to_disk; + Counter::AtomicType *bytes_lost_before_written_to_disk; + Counter::AtomicType *log_files_open; + Counter::AtomicType *log_files_space_used; }; extern LogsStatsBlock log_rsb; diff --git a/src/api/InkAPI.cc b/src/api/InkAPI.cc index b4c791e874e..57a3a59a505 100644 --- a/src/api/InkAPI.cc +++ b/src/api/InkAPI.cc @@ -393,8 +393,8 @@ namespace c } // end namespace c } // end namespace tsapi -ConfigUpdateCbTable *global_config_cbs = nullptr; -static ts::Metrics &global_api_metrics = ts::Metrics::getInstance(); +ConfigUpdateCbTable *global_config_cbs = nullptr; +static ts::Metrics::Counter &global_api_metrics = ts::Metrics::Counter::getInstance(); static char traffic_server_version[128] = ""; static int ts_major_version = 0; @@ -4027,7 +4027,7 @@ tsapi::c::TSMgmtIntGet(const char *var_name, TSMgmtInt *result) if (res == REC_ERR_FAIL) { int id = global_api_metrics.lookup(var_name); - if (id == ts::Metrics::NOT_FOUND) { + if (id == ts::Metrics::Counter::NOT_FOUND) { return TS_ERROR; } else { *result = global_api_metrics[id].load(); @@ -4046,7 +4046,7 @@ tsapi::c::TSMgmtCounterGet(const char *var_name, TSMgmtCounter *result) if (res == REC_ERR_FAIL) { int id = global_api_metrics.lookup(var_name); - if (id == ts::Metrics::NOT_FOUND) { + if (id == ts::Metrics::Counter::NOT_FOUND) { return TS_ERROR; } else { *result = global_api_metrics[id].load(); @@ -6165,20 +6165,20 @@ tsapi::c::TSHttpTxnLookingUpTypeGet(TSHttpTxn txnp) int tsapi::c::TSHttpCurrentClientConnectionsGet() { - return Metrics::read(http_rsb.current_client_connections); + return Counter::read(http_rsb.current_client_connections); } int tsapi::c::TSHttpCurrentActiveClientConnectionsGet() { - return Metrics::read(http_rsb.current_active_client_connections); + return Counter::read(http_rsb.current_active_client_connections); } int tsapi::c::TSHttpCurrentIdleClientConnectionsGet() { - int64_t total = Metrics::read(http_rsb.current_client_connections); - int64_t active = Metrics::read(http_rsb.current_active_client_connections); + int64_t total = Counter::read(http_rsb.current_client_connections); + int64_t active = Counter::read(http_rsb.current_active_client_connections); if (total >= active) { return static_cast(total - active); @@ -6190,13 +6190,13 @@ tsapi::c::TSHttpCurrentIdleClientConnectionsGet() int tsapi::c::TSHttpCurrentCacheConnectionsGet() { - return Metrics::read(http_rsb.current_cache_connections); + return Counter::read(http_rsb.current_cache_connections); } int tsapi::c::TSHttpCurrentServerConnectionsGet() { - return Metrics::read(http_rsb.current_server_connections); + return Counter::read(http_rsb.current_server_connections); } /* HTTP alternate selection */ @@ -6999,9 +6999,9 @@ tsapi::c::TSCacheScan(TSCont contp, TSCacheKey key, int KB_per_second) int tsapi::c::TSStatCreate(const char *the_name, TSRecordDataType the_type, TSStatPersistence persist, TSStatSync sync) { - int id = global_api_metrics.newMetric(the_name); + int id = global_api_metrics.create(the_name); - if (id == ts::Metrics::NOT_FOUND) { + if (id == ts::Metrics::Counter::NOT_FOUND) { return TS_ERROR; } @@ -7012,14 +7012,14 @@ void tsapi::c::TSStatIntIncrement(int id, TSMgmtInt amount) { sdk_assert(sdk_sanity_check_stat_id(id) == TS_SUCCESS); - global_api_metrics[id].fetch_add(amount, ts::Metrics::MEMORY_ORDER); + global_api_metrics[id].fetch_add(amount, ts::Metrics::Counter::MEMORY_ORDER); } void tsapi::c::TSStatIntDecrement(int id, TSMgmtInt amount) { sdk_assert(sdk_sanity_check_stat_id(id) == TS_SUCCESS); - global_api_metrics[id].fetch_sub(amount, ts::Metrics::MEMORY_ORDER); + global_api_metrics[id].fetch_sub(amount, ts::Metrics::Counter::MEMORY_ORDER); } tsapi::c::TSMgmtInt @@ -7044,7 +7044,7 @@ tsapi::c::TSStatFindName(const char *name, int *idp) int id = global_api_metrics.lookup(name); - if (id == ts::Metrics::NOT_FOUND) { + if (id == ts::Metrics::Counter::NOT_FOUND) { return TS_ERROR; } else { *idp = id; diff --git a/src/api/Metrics.cc b/src/api/Metrics.cc index 8a67f9a8b54..5d8e5ae75ee 100644 --- a/src/api/Metrics.cc +++ b/src/api/Metrics.cc @@ -1,6 +1,6 @@ /** @file - The implementations of the Metrics API class. + The implementations of the Counter API class. @section license License @@ -25,164 +25,168 @@ namespace ts { - -// This is the singleton instance of the metrics class. -Metrics & -Metrics::getInstance() +namespace Metrics { - static ts::Metrics _instance; - - return _instance; -} -void -Metrics::_addBlob() // The mutex must be held before calling this! -{ - auto blob = new Metrics::MetricStorage(); + // This is the singleton instance of the metrics class. + Counter & + Counter::getInstance() + { + static Counter _instance; - ink_assert(blob); - ink_assert(_cur_blob < Metrics::METRICS_MAX_BLOBS); + return _instance; + } - _blobs[++_cur_blob] = blob; - _cur_off = 0; -} + void + Counter::_addBlob() // The mutex must be held before calling this! + { + auto blob = new Counter::NamesAndAtomics(); -Metrics::IdType -Metrics::newMetric(std::string_view name) -{ - std::lock_guard lock(_mutex); - auto it = _lookups.find(name); + ink_assert(blob); + ink_assert(_cur_blob < MAX_BLOBS); - if (it != _lookups.end()) { - return it->second; + _blobs[++_cur_blob] = blob; + _cur_off = 0; } - Metrics::IdType id = _makeId(_cur_blob, _cur_off); - Metrics::MetricStorage *blob = _blobs[_cur_blob]; - Metrics::NameContainer &names = std::get<0>(*blob); - Metrics::AtomicContainer &atomics = std::get<1>(*blob); + Counter::IdType + Counter::create(std::string_view name) + { + std::lock_guard lock(_mutex); + auto it = _lookups.find(name); - atomics[_cur_off].store(0); - names[_cur_off] = std::make_tuple(std::string(name), id); - _lookups.emplace(std::get<0>(names[_cur_off]), id); + if (it != _lookups.end()) { + return it->second; + } - if (++_cur_off >= Metrics::METRICS_MAX_SIZE) { - _addBlob(); // This resets _cur_off to 0 as well - } + Counter::IdType id = _makeId(_cur_blob, _cur_off); + Counter::NamesAndAtomics *blob = _blobs[_cur_blob]; + Counter::NameStorage &names = std::get<0>(*blob); + Counter::AtomicStorage &atomics = std::get<1>(*blob); - return id; -} + atomics[_cur_off].store(0); + names[_cur_off] = std::make_tuple(std::string(name), id); + _lookups.emplace(std::get<0>(names[_cur_off]), id); -Metrics::IdType -Metrics::lookup(const std::string_view name) const -{ - std::lock_guard lock(_mutex); - auto it = _lookups.find(name); + if (++_cur_off >= MAX_SIZE) { + _addBlob(); // This resets _cur_off to 0 as well + } - if (it != _lookups.end()) { - return it->second; + return id; } - return NOT_FOUND; -} + Counter::IdType + Counter::lookup(const std::string_view name) const + { + std::lock_guard lock(_mutex); + auto it = _lookups.find(name); -Metrics::IntType * -Metrics::lookup(IdType id, std::string_view *name) const -{ - auto [blob_ix, offset] = _splitID(id); - Metrics::MetricStorage *blob = _blobs[blob_ix]; + if (it != _lookups.end()) { + return it->second; + } - // Do a sanity check on the ID, to make sure we don't index outside of the realm of possibility. - if (!blob || (blob_ix == _cur_blob && offset > _cur_off)) { - blob = _blobs[0]; - offset = 0; + return NOT_FOUND; } - if (name) { - *name = std::get<0>(std::get<0>(*blob)[offset]); - } + Counter::AtomicType * + Counter::lookup(Counter::IdType id, std::string_view *name) const + { + auto [blob_ix, offset] = _splitID(id); + Counter::NamesAndAtomics *blob = _blobs[blob_ix]; - return &((std::get<1>(*blob)[offset])); -} + // Do a sanity check on the ID, to make sure we don't index outside of the realm of possibility. + if (!blob || (blob_ix == _cur_blob && offset > _cur_off)) { + blob = _blobs[0]; + offset = 0; + } -std::string_view -Metrics::name(Metrics::IdType id) const -{ - auto [blob_ix, offset] = _splitID(id); - Metrics::MetricStorage *blob = _blobs[blob_ix]; + if (name) { + *name = std::get<0>(std::get<0>(*blob)[offset]); + } - // Do a sanity check on the ID, to make sure we don't index outside of the realm of possibility. - if (!blob || (blob_ix == _cur_blob && offset > _cur_off)) { - blob = _blobs[0]; - offset = 0; + return &((std::get<1>(*blob)[offset])); } - const std::string &result = std::get<0>(std::get<0>(*blob)[offset]); + std::string_view + Counter::name(Counter::IdType id) const + { + auto [blob_ix, offset] = _splitID(id); + Counter::NamesAndAtomics *blob = _blobs[blob_ix]; - return result; -} + // Do a sanity check on the ID, to make sure we don't index outside of the realm of possibility. + if (!blob || (blob_ix == _cur_blob && offset > _cur_off)) { + blob = _blobs[0]; + offset = 0; + } -Metrics::SpanIntType -Metrics::newMetricSpan(size_t size, IdType *id) -{ - ink_release_assert(size <= Metrics::METRICS_MAX_SIZE); - std::lock_guard lock(_mutex); + const std::string &result = std::get<0>(std::get<0>(*blob)[offset]); - if (_cur_off + size > Metrics::METRICS_MAX_SIZE) { - _addBlob(); + return result; } - Metrics::IdType span_start = _makeId(_cur_blob, _cur_off); - Metrics::MetricStorage *blob = _blobs[_cur_blob]; - Metrics::AtomicContainer &atomics = std::get<1>(*blob); - auto span = Metrics::SpanIntType(&atomics[_cur_off], size); + Counter::SpanType + Counter::createSpan(size_t size, Counter::IdType *id) + { + ink_release_assert(size <= MAX_SIZE); + std::lock_guard lock(_mutex); - std::fill(span.begin(), span.end(), 0); + if (_cur_off + size > MAX_SIZE) { + _addBlob(); + } - if (id) { - *id = span_start; - } + Counter::IdType span_start = _makeId(_cur_blob, _cur_off); + Counter::NamesAndAtomics *blob = _blobs[_cur_blob]; + Counter::AtomicStorage &atomics = std::get<1>(*blob); + Counter::SpanType span = Counter::SpanType(&atomics[_cur_off], size); - _cur_off += size; + std::fill(span.begin(), span.end(), 0); - return span; -} + if (id) { + *id = span_start; + } -bool -Metrics::rename(Metrics::IdType id, std::string_view name) -{ - auto [blob_ix, offset] = _splitID(id); - Metrics::MetricStorage *blob = _blobs[blob_ix]; + _cur_off += size; - // We can only rename metrics that are already allocated - if (!blob || (blob_ix == _cur_blob && offset > _cur_off)) { - return false; + return span; } - std::string &cur = std::get<0>(std::get<0>(*blob)[offset]); + bool + Counter::rename(Counter::IdType id, std::string_view name) + { + auto [blob_ix, offset] = _splitID(id); + Counter::NamesAndAtomics *blob = _blobs[blob_ix]; - std::lock_guard lock(_mutex); - if (cur.length() > 0) { - _lookups.erase(cur); + // We can only rename counter that are already allocated + if (!blob || (blob_ix == _cur_blob && offset > _cur_off)) { + return false; + } + + std::string &cur = std::get<0>(std::get<0>(*blob)[offset]); + std::lock_guard lock(_mutex); + + if (cur.length() > 0) { + _lookups.erase(cur); + } + cur = name; + _lookups.emplace(cur, id); + + return true; } - cur = name; - _lookups.emplace(cur, id); - return true; -} + // Iterator implementation + void + Counter::iterator::next() + { + auto [blob, offset] = _counter._splitID(_it); -// Iterator implementation -void -Metrics::iterator::next() -{ - auto [blob, offset] = _metrics._splitID(_it); + if (++offset == MAX_SIZE) { + ++blob; + offset = 0; + } - if (++offset == METRICS_MAX_SIZE) { - ++blob; - offset = 0; + _it = _makeId(blob, offset); } - _it = _makeId(blob, offset); -} +} // namespace Metrics } // namespace ts diff --git a/src/api/unit_tests/test_Metrics.cc b/src/api/unit_tests/test_Metrics.cc index b08b5e046c3..83061453674 100644 --- a/src/api/unit_tests/test_Metrics.cc +++ b/src/api/unit_tests/test_Metrics.cc @@ -28,7 +28,7 @@ TEST_CASE("Metrics", "[libtsapi][Metrics]") { - ts::Metrics m; + ts::Metrics::Counter m; SECTION("iterator") { @@ -46,7 +46,7 @@ TEST_CASE("Metrics", "[libtsapi][Metrics]") SECTION("New metric") { - auto fooid = m.newMetric("foo"); + auto fooid = m.create("foo"); REQUIRE(fooid == 1); REQUIRE(m.name(fooid) == "foo"); @@ -65,9 +65,9 @@ TEST_CASE("Metrics", "[libtsapi][Metrics]") SECTION("Span allocation") { - ts::Metrics::IdType span_id; - auto fooid = m.newMetric("foo"); // To see that span_id gets to 2 - auto span = m.newMetricSpan(17, &span_id); + ts::Metrics::Counter::IdType span_id; + auto fooid = m.create("foo"); // To see that span_id gets to 2 + auto span = m.createSpan(17, &span_id); REQUIRE(span.size() == 17); REQUIRE(fooid == 1); @@ -82,7 +82,7 @@ TEST_CASE("Metrics", "[libtsapi][Metrics]") REQUIRE(m.name(span_id + 2) == "span.2"); m.rename(fooid, "foo-new"); REQUIRE(m.name(fooid) == "foo-new"); - REQUIRE(m.lookup("foo") == ts::Metrics::NOT_FOUND); + REQUIRE(m.lookup("foo") == ts::Metrics::Counter::NOT_FOUND); REQUIRE(m.lookup("foo-new") == fooid); } @@ -91,7 +91,7 @@ TEST_CASE("Metrics", "[libtsapi][Metrics]") auto nm = m.lookupPtr("notametric"); REQUIRE(!nm); - auto mid = m.newMetric("ametric"); + auto mid = m.create("ametric"); auto fm = m.lookupPtr("ametric"); REQUIRE(fm.has_value()); REQUIRE(fm.value()); diff --git a/src/iocore/aio/AIO.cc b/src/iocore/aio/AIO.cc index 2b517f7d7a2..45da6100844 100644 --- a/src/iocore/aio/AIO.cc +++ b/src/iocore/aio/AIO.cc @@ -107,12 +107,12 @@ ink_aio_init(ts::ModuleVersion v, AIOBackend backend) { ink_release_assert(v.check(AIO_MODULE_INTERNAL_VERSION)); - ts::Metrics &intm = ts::Metrics::getInstance(); + ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); - aio_rsb.read_count = intm.newMetricPtr("proxy.process.cache.aio.read_count"); - aio_rsb.write_count = intm.newMetricPtr("proxy.process.cache.aio.write_count"); - aio_rsb.kb_read = intm.newMetricPtr("proxy.process.cache.aio.KB_read"); - aio_rsb.kb_write = intm.newMetricPtr("proxy.process.cache.aio.KB_write"); + aio_rsb.read_count = metrics.createPtr("proxy.process.cache.aio.read_count"); + aio_rsb.write_count = metrics.createPtr("proxy.process.cache.aio.write_count"); + aio_rsb.kb_read = metrics.createPtr("proxy.process.cache.aio.KB_read"); + aio_rsb.kb_write = metrics.createPtr("proxy.process.cache.aio.KB_write"); memset(&aio_reqs, 0, MAX_DISKS_POSSIBLE * sizeof(AIO_Reqs *)); ink_mutex_init(&insert_mutex); @@ -442,11 +442,11 @@ AIOThreadInfo::aio_thread_main(AIOThreadInfo *thr_info) // update the stats; if (op->aiocb.aio_lio_opcode == LIO_WRITE) { - Metrics::increment(aio_rsb.write_count); - Metrics::increment(aio_rsb.kb_write, op->aiocb.aio_nbytes >> 10); + Counter::increment(aio_rsb.write_count); + Counter::increment(aio_rsb.kb_write, op->aiocb.aio_nbytes >> 10); } else { - Metrics::increment(aio_rsb.read_count); - Metrics::increment(aio_rsb.kb_read, op->aiocb.aio_nbytes >> 10); + Counter::increment(aio_rsb.read_count); + Counter::increment(aio_rsb.kb_read, op->aiocb.aio_nbytes >> 10); } cache_op(reinterpret_cast(op)); ink_atomic_increment(&my_aio_req->requests_queued, -1); @@ -578,11 +578,11 @@ AIOCallbackInternal::handle_complete(io_uring_cqe *cqe) if (op->aio_result > 0) { if (op->aiocb.aio_lio_opcode == LIO_WRITE) { - Metrics::increment(aio_rsb.write_count); - Metrics::increment(aio_rsb.kb_write, op->aiocb.aio_nbytes >> 10); + Counter::increment(aio_rsb.write_count); + Counter::increment(aio_rsb.kb_write, op->aiocb.aio_nbytes >> 10); } else { - Metrics::increment(aio_rsb.read_count); - Metrics::increment(aio_rsb.kb_read, op->aiocb.aio_nbytes >> 10); + Counter::increment(aio_rsb.read_count); + Counter::increment(aio_rsb.kb_read, op->aiocb.aio_nbytes >> 10); } } diff --git a/src/iocore/aio/P_AIO.h b/src/iocore/aio/P_AIO.h index 22336a85a59..6f1b15bf100 100644 --- a/src/iocore/aio/P_AIO.h +++ b/src/iocore/aio/P_AIO.h @@ -39,7 +39,7 @@ #include "api/Metrics.h" -using ts::Metrics; +using ts::Metrics::Counter; // for debugging // #define AIO_STATS 1 @@ -133,10 +133,10 @@ class AIOTestData : public Continuation #endif struct AIOStatsBlock { - Metrics::IntType *read_count; - Metrics::IntType *kb_read; - Metrics::IntType *write_count; - Metrics::IntType *kb_write; + Counter::AtomicType *read_count; + Counter::AtomicType *kb_read; + Counter::AtomicType *write_count; + Counter::AtomicType *kb_write; }; extern AIOStatsBlock aio_rsb; diff --git a/src/iocore/aio/test_AIO.cc b/src/iocore/aio/test_AIO.cc index cc2dac542a0..b1db80a7d97 100644 --- a/src/iocore/aio/test_AIO.cc +++ b/src/iocore/aio/test_AIO.cc @@ -223,11 +223,11 @@ dump_summary() auto &m = Metrics::getInstance(); - Metrics::IntType *completed = m.lookup(m.lookup("proxy.process.io_uring.completed")); - Metrics::IntType *submitted = m.lookup(m.lookup("proxy.process.io_uring.submitted")); + Counter::AtomicType *completed = m.lookup(m.lookup("proxy.process.io_uring.completed")); + Counter::AtomicType *submitted = m.lookup(m.lookup("proxy.process.io_uring.submitted")); - printf("submissions: %lu\n", Metrics::read(submitted)); - printf("completions: %lu\n", Metrics::read(completed)); + printf("submissions: %lu\n", Counter::read(submitted)); + printf("completions: %lu\n", Counter::read(completed)); #endif if (delete_disks) { diff --git a/src/iocore/cache/Cache.cc b/src/iocore/cache/Cache.cc index 76c264072cb..62f4b2ab3e3 100644 --- a/src/iocore/cache/Cache.cc +++ b/src/iocore/cache/Cache.cc @@ -129,69 +129,69 @@ force_link_CacheTestCaller() static void register_cache_stats(CacheStatsBlock *rsb, const std::string prefix) { - ts::Metrics &intm = ts::Metrics::getInstance(); + ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); // These are special, in that we have 7 x 3 metrics here in a structure based on cache operation done - rsb->status[static_cast(CacheOpType::Lookup)].active = intm.newMetricPtr(prefix + ".lookup.active"); - rsb->status[static_cast(CacheOpType::Lookup)].success = intm.newMetricPtr(prefix + ".lookup.success"); - rsb->status[static_cast(CacheOpType::Lookup)].failure = intm.newMetricPtr(prefix + ".lookup.failure"); - rsb->status[static_cast(CacheOpType::Read)].active = intm.newMetricPtr(prefix + ".read.active"); - rsb->status[static_cast(CacheOpType::Read)].success = intm.newMetricPtr(prefix + ".read.success"); - rsb->status[static_cast(CacheOpType::Read)].failure = intm.newMetricPtr(prefix + ".read.failure"); - rsb->status[static_cast(CacheOpType::Write)].active = intm.newMetricPtr(prefix + ".write.active"); - rsb->status[static_cast(CacheOpType::Write)].success = intm.newMetricPtr(prefix + ".write.success"); - rsb->status[static_cast(CacheOpType::Write)].failure = intm.newMetricPtr(prefix + ".write.failure"); - rsb->status[static_cast(CacheOpType::Update)].active = intm.newMetricPtr(prefix + ".update.active"); - rsb->status[static_cast(CacheOpType::Update)].success = intm.newMetricPtr(prefix + ".update.success"); - rsb->status[static_cast(CacheOpType::Update)].failure = intm.newMetricPtr(prefix + ".update.failure"); - rsb->status[static_cast(CacheOpType::Remove)].active = intm.newMetricPtr(prefix + ".remove.active"); - rsb->status[static_cast(CacheOpType::Remove)].success = intm.newMetricPtr(prefix + ".remove.success"); - rsb->status[static_cast(CacheOpType::Remove)].failure = intm.newMetricPtr(prefix + ".remove.failure"); - rsb->status[static_cast(CacheOpType::Evacuate)].active = intm.newMetricPtr(prefix + ".evacuate.active"); - rsb->status[static_cast(CacheOpType::Evacuate)].success = intm.newMetricPtr(prefix + ".evacuate.success"); - rsb->status[static_cast(CacheOpType::Evacuate)].failure = intm.newMetricPtr(prefix + ".evacuate.failure"); - rsb->status[static_cast(CacheOpType::Scan)].active = intm.newMetricPtr(prefix + ".scan.active"); - rsb->status[static_cast(CacheOpType::Scan)].success = intm.newMetricPtr(prefix + ".scan.success"); - rsb->status[static_cast(CacheOpType::Scan)].failure = intm.newMetricPtr(prefix + ".scan.failure"); + rsb->status[static_cast(CacheOpType::Lookup)].active = metrics.createPtr(prefix + ".lookup.active"); + rsb->status[static_cast(CacheOpType::Lookup)].success = metrics.createPtr(prefix + ".lookup.success"); + rsb->status[static_cast(CacheOpType::Lookup)].failure = metrics.createPtr(prefix + ".lookup.failure"); + rsb->status[static_cast(CacheOpType::Read)].active = metrics.createPtr(prefix + ".read.active"); + rsb->status[static_cast(CacheOpType::Read)].success = metrics.createPtr(prefix + ".read.success"); + rsb->status[static_cast(CacheOpType::Read)].failure = metrics.createPtr(prefix + ".read.failure"); + rsb->status[static_cast(CacheOpType::Write)].active = metrics.createPtr(prefix + ".write.active"); + rsb->status[static_cast(CacheOpType::Write)].success = metrics.createPtr(prefix + ".write.success"); + rsb->status[static_cast(CacheOpType::Write)].failure = metrics.createPtr(prefix + ".write.failure"); + rsb->status[static_cast(CacheOpType::Update)].active = metrics.createPtr(prefix + ".update.active"); + rsb->status[static_cast(CacheOpType::Update)].success = metrics.createPtr(prefix + ".update.success"); + rsb->status[static_cast(CacheOpType::Update)].failure = metrics.createPtr(prefix + ".update.failure"); + rsb->status[static_cast(CacheOpType::Remove)].active = metrics.createPtr(prefix + ".remove.active"); + rsb->status[static_cast(CacheOpType::Remove)].success = metrics.createPtr(prefix + ".remove.success"); + rsb->status[static_cast(CacheOpType::Remove)].failure = metrics.createPtr(prefix + ".remove.failure"); + rsb->status[static_cast(CacheOpType::Evacuate)].active = metrics.createPtr(prefix + ".evacuate.active"); + rsb->status[static_cast(CacheOpType::Evacuate)].success = metrics.createPtr(prefix + ".evacuate.success"); + rsb->status[static_cast(CacheOpType::Evacuate)].failure = metrics.createPtr(prefix + ".evacuate.failure"); + rsb->status[static_cast(CacheOpType::Scan)].active = metrics.createPtr(prefix + ".scan.active"); + rsb->status[static_cast(CacheOpType::Scan)].success = metrics.createPtr(prefix + ".scan.success"); + rsb->status[static_cast(CacheOpType::Scan)].failure = metrics.createPtr(prefix + ".scan.failure"); // These are in an array of 1, 2 and 3+ fragment documents - rsb->fragment_document_count[0] = intm.newMetricPtr(prefix + ".frags_per_doc.1"); - rsb->fragment_document_count[1] = intm.newMetricPtr(prefix + ".frags_per_doc.2"); - rsb->fragment_document_count[2] = intm.newMetricPtr(prefix + ".frags_per_doc.3+"); + rsb->fragment_document_count[0] = metrics.createPtr(prefix + ".frags_per_doc.1"); + rsb->fragment_document_count[1] = metrics.createPtr(prefix + ".frags_per_doc.2"); + rsb->fragment_document_count[2] = metrics.createPtr(prefix + ".frags_per_doc.3+"); // And then everything else - rsb->bytes_used = intm.newMetricPtr(prefix + ".bytes_used"); - rsb->bytes_total = intm.newMetricPtr(prefix + ".bytes_total"); - rsb->stripes = intm.newMetricPtr(prefix + ".stripes"); - rsb->ram_cache_bytes_total = intm.newMetricPtr(prefix + ".ram_cache.total_bytes"); - rsb->ram_cache_bytes = intm.newMetricPtr(prefix + ".ram_cache.bytes_used"); - rsb->ram_cache_hits = intm.newMetricPtr(prefix + ".ram_cache.hits"); - rsb->ram_cache_misses = intm.newMetricPtr(prefix + ".ram_cache.misses"); - rsb->pread_count = intm.newMetricPtr(prefix + ".pread_count"); - rsb->percent_full = intm.newMetricPtr(prefix + ".percent_full"); - rsb->read_seek_fail = intm.newMetricPtr(prefix + ".read.seek.failure"); - rsb->read_invalid = intm.newMetricPtr(prefix + ".read.invalid"); - rsb->write_backlog_failure = intm.newMetricPtr(prefix + ".write.backlog.failure"); - rsb->direntries_total = intm.newMetricPtr(prefix + ".direntries.total"); - rsb->direntries_used = intm.newMetricPtr(prefix + ".direntries.used"); - rsb->directory_collision_count = intm.newMetricPtr(prefix + ".directory_collision"); - rsb->read_busy_success = intm.newMetricPtr(prefix + ".read_busy.success"); - rsb->read_busy_failure = intm.newMetricPtr(prefix + ".read_busy.failure"); - rsb->write_bytes = intm.newMetricPtr(prefix + ".write_bytes_stat"); - rsb->hdr_vector_marshal = intm.newMetricPtr(prefix + ".vector_marshals"); - rsb->hdr_marshal = intm.newMetricPtr(prefix + ".hdr_marshals"); - rsb->hdr_marshal_bytes = intm.newMetricPtr(prefix + ".hdr_marshal_bytes"); - rsb->gc_bytes_evacuated = intm.newMetricPtr(prefix + ".gc_bytes_evacuated"); - rsb->gc_frags_evacuated = intm.newMetricPtr(prefix + ".gc_frags_evacuated"); - rsb->directory_wrap = intm.newMetricPtr(prefix + ".wrap_count"); - rsb->directory_sync_count = intm.newMetricPtr(prefix + ".sync.count"); - rsb->directory_sync_bytes = intm.newMetricPtr(prefix + ".sync.bytes"); - rsb->directory_sync_time = intm.newMetricPtr(prefix + ".sync.time"); - rsb->span_errors_read = intm.newMetricPtr(prefix + ".span.errors.read"); - rsb->span_errors_write = intm.newMetricPtr(prefix + ".span.errors.write"); - rsb->span_failing = intm.newMetricPtr(prefix + ".span.failing"); - rsb->span_offline = intm.newMetricPtr(prefix + ".span.offline"); - rsb->span_online = intm.newMetricPtr(prefix + ".span.online"); + rsb->bytes_used = metrics.createPtr(prefix + ".bytes_used"); + rsb->bytes_total = metrics.createPtr(prefix + ".bytes_total"); + rsb->stripes = metrics.createPtr(prefix + ".stripes"); + rsb->ram_cache_bytes_total = metrics.createPtr(prefix + ".ram_cache.total_bytes"); + rsb->ram_cache_bytes = metrics.createPtr(prefix + ".ram_cache.bytes_used"); + rsb->ram_cache_hits = metrics.createPtr(prefix + ".ram_cache.hits"); + rsb->ram_cache_misses = metrics.createPtr(prefix + ".ram_cache.misses"); + rsb->pread_count = metrics.createPtr(prefix + ".pread_count"); + rsb->percent_full = metrics.createPtr(prefix + ".percent_full"); + rsb->read_seek_fail = metrics.createPtr(prefix + ".read.seek.failure"); + rsb->read_invalid = metrics.createPtr(prefix + ".read.invalid"); + rsb->write_backlog_failure = metrics.createPtr(prefix + ".write.backlog.failure"); + rsb->direntries_total = metrics.createPtr(prefix + ".direntries.total"); + rsb->direntries_used = metrics.createPtr(prefix + ".direntries.used"); + rsb->directory_collision_count = metrics.createPtr(prefix + ".directory_collision"); + rsb->read_busy_success = metrics.createPtr(prefix + ".read_busy.success"); + rsb->read_busy_failure = metrics.createPtr(prefix + ".read_busy.failure"); + rsb->write_bytes = metrics.createPtr(prefix + ".write_bytes_stat"); + rsb->hdr_vector_marshal = metrics.createPtr(prefix + ".vector_marshals"); + rsb->hdr_marshal = metrics.createPtr(prefix + ".hdr_marshals"); + rsb->hdr_marshal_bytes = metrics.createPtr(prefix + ".hdr_marshal_bytes"); + rsb->gc_bytes_evacuated = metrics.createPtr(prefix + ".gc_bytes_evacuated"); + rsb->gc_frags_evacuated = metrics.createPtr(prefix + ".gc_frags_evacuated"); + rsb->directory_wrap = metrics.createPtr(prefix + ".wrap_count"); + rsb->directory_sync_count = metrics.createPtr(prefix + ".sync.count"); + rsb->directory_sync_bytes = metrics.createPtr(prefix + ".sync.bytes"); + rsb->directory_sync_time = metrics.createPtr(prefix + ".sync.time"); + rsb->span_errors_read = metrics.createPtr(prefix + ".span.errors.read"); + rsb->span_errors_write = metrics.createPtr(prefix + ".span.errors.write"); + rsb->span_failing = metrics.createPtr(prefix + ".span.failing"); + rsb->span_offline = metrics.createPtr(prefix + ".span.offline"); + rsb->span_online = metrics.createPtr(prefix + ".span.online"); } // ToDo: This gets called as part of librecords collection continuation, probably change this later. @@ -218,7 +218,7 @@ CachePeriodicMetricsUpdate() // volume metric more than once (once per disk). This happens once every sync // period (5s), and nothing else modifies these metrics. for (int vol_ix = 0; vol_ix < gnvol; ++vol_ix) { - Metrics::write(gvol[vol_ix]->cache_vol->vol_rsb.bytes_used, 0); + Counter::write(gvol[vol_ix]->cache_vol->vol_rsb.bytes_used, 0); } if (cacheProcessor.initialized == CACHE_INITIALIZED) { @@ -226,15 +226,15 @@ CachePeriodicMetricsUpdate() Stripe *v = gvol[vol_ix]; int64_t used = cache_bytes_used(vol_ix); - Metrics::increment(v->cache_vol->vol_rsb.bytes_used, used); // This assumes they start at zero + Counter::increment(v->cache_vol->vol_rsb.bytes_used, used); // This assumes they start at zero total_sum += used; } // Also update the global (not per volume) metrics - int64_t total = Metrics::read(cache_rsb.bytes_total); + int64_t total = Counter::read(cache_rsb.bytes_total); - Metrics::write(cache_rsb.bytes_used, total_sum); - Metrics::write(cache_rsb.percent_full, total ? (total_sum * 100) / total : 0); + Counter::write(cache_rsb.bytes_used, total_sum); + Counter::write(cache_rsb.percent_full, total ? (total_sum * 100) / total : 0); } } @@ -511,9 +511,9 @@ CacheProcessor::diskInitialized() /* Practically just took all bad_disks offline so update the stats. */ // ToDo: These don't get update on the per-volume metrics :-/ - Metrics::write(cache_rsb.span_offline, bad_disks); - Metrics::decrement(cache_rsb.span_failing, bad_disks); - Metrics::write(cache_rsb.span_online, gndisks); + Counter::write(cache_rsb.span_offline, bad_disks); + Counter::decrement(cache_rsb.span_failing, bad_disks); + Counter::write(cache_rsb.span_online, gndisks); /* create the cachevol list only if num volumes are greater than 0. */ if (config_volumes.num_volumes == 0) { @@ -659,21 +659,21 @@ CacheProcessor::cacheInitialized() ram_cache_bytes += gvol[i]->dirlen(); Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized - ram_cache_bytes = %" PRId64 " = %" PRId64 "Mb", ram_cache_bytes, ram_cache_bytes / (1024 * 1024)); - Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_bytes_total, gvol[i]->dirlen()); + Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes_total, gvol[i]->dirlen()); } vol_total_cache_bytes = gvol[i]->len - gvol[i]->dirlen(); total_cache_bytes += vol_total_cache_bytes; Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized - total_cache_bytes = %" PRId64 " = %" PRId64 "Mb", total_cache_bytes, total_cache_bytes / (1024 * 1024)); - Metrics::increment(vol->cache_vol->vol_rsb.bytes_total, vol_total_cache_bytes); + Counter::increment(vol->cache_vol->vol_rsb.bytes_total, vol_total_cache_bytes); vol_total_direntries = gvol[i]->buckets * gvol[i]->segments * DIR_DEPTH; total_direntries += vol_total_direntries; - Metrics::increment(vol->cache_vol->vol_rsb.direntries_total, vol_total_direntries); + Counter::increment(vol->cache_vol->vol_rsb.direntries_total, vol_total_direntries); vol_used_direntries = dir_entries_used(gvol[i]); - Metrics::increment(vol->cache_vol->vol_rsb.direntries_used, vol_used_direntries); + Counter::increment(vol->cache_vol->vol_rsb.direntries_used, vol_used_direntries); used_direntries += vol_used_direntries; } @@ -706,7 +706,7 @@ CacheProcessor::cacheInitialized() Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized - factor = %f", factor); gvol[i]->ram_cache->init(static_cast(http_ram_cache_size * factor), vol); ram_cache_bytes += static_cast(http_ram_cache_size * factor); - Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_bytes_total, static_cast(http_ram_cache_size * factor)); + Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes_total, static_cast(http_ram_cache_size * factor)); } else if (gvol[i]->cache_vol->ramcache_enabled) { ink_release_assert(!"Unexpected non-HTTP cache volume"); } @@ -714,17 +714,17 @@ CacheProcessor::cacheInitialized() ram_cache_bytes, ram_cache_bytes / (1024 * 1024)); vol_total_cache_bytes = gvol[i]->len - gvol[i]->dirlen(); total_cache_bytes += vol_total_cache_bytes; - Metrics::increment(vol->cache_vol->vol_rsb.bytes_total, vol_total_cache_bytes); - Metrics::increment(vol->cache_vol->vol_rsb.stripes); + Counter::increment(vol->cache_vol->vol_rsb.bytes_total, vol_total_cache_bytes); + Counter::increment(vol->cache_vol->vol_rsb.stripes); Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized - total_cache_bytes = %" PRId64 " = %" PRId64 "Mb", total_cache_bytes, total_cache_bytes / (1024 * 1024)); vol_total_direntries = gvol[i]->buckets * gvol[i]->segments * DIR_DEPTH; total_direntries += vol_total_direntries; - Metrics::increment(vol->cache_vol->vol_rsb.direntries_total, vol_total_direntries); + Counter::increment(vol->cache_vol->vol_rsb.direntries_total, vol_total_direntries); vol_used_direntries = dir_entries_used(gvol[i]); - Metrics::increment(vol->cache_vol->vol_rsb.direntries_used, vol_used_direntries); + Counter::increment(vol->cache_vol->vol_rsb.direntries_used, vol_used_direntries); used_direntries += vol_used_direntries; } } @@ -743,10 +743,10 @@ CacheProcessor::cacheInitialized() break; } - Metrics::write(cache_rsb.ram_cache_bytes_total, ram_cache_bytes); - Metrics::write(cache_rsb.bytes_total, total_cache_bytes); - Metrics::write(cache_rsb.direntries_total, total_direntries); - Metrics::write(cache_rsb.direntries_used, used_direntries); + Counter::write(cache_rsb.ram_cache_bytes_total, ram_cache_bytes); + Counter::write(cache_rsb.bytes_total, total_cache_bytes); + Counter::write(cache_rsb.direntries_total, total_direntries); + Counter::write(cache_rsb.direntries_used, used_direntries); if (!check) { dir_sync_init(); @@ -1016,14 +1016,14 @@ CacheProcessor::mark_storage_offline(CacheDisk *d, ///< Target disk } } - Metrics::decrement(cache_rsb.bytes_total, total_bytes_delete); - Metrics::decrement(cache_rsb.direntries_total, total_dir_delete); - Metrics::decrement(cache_rsb.direntries_used, used_dir_delete); + Counter::decrement(cache_rsb.bytes_total, total_bytes_delete); + Counter::decrement(cache_rsb.direntries_total, total_dir_delete); + Counter::decrement(cache_rsb.direntries_used, used_dir_delete); /* Update the span metrics, if failing then move the span from "failing" to "offline" bucket * if operator took it offline, move it from "online" to "offline" bucket */ - Metrics::decrement(admin ? cache_rsb.span_online : cache_rsb.span_failing); - Metrics::increment(cache_rsb.span_offline); + Counter::decrement(admin ? cache_rsb.span_online : cache_rsb.span_failing); + Counter::increment(cache_rsb.span_offline); if (theCache) { rebuild_host_table(theCache); @@ -1200,8 +1200,8 @@ Cache::lookup(Continuation *cont, const CacheKey *key, CacheFragType type, const SET_CONTINUATION_HANDLER(c, &CacheVC::openReadStartHead); c->vio.op = VIO::READ; c->op_type = static_cast(CacheOpType::Lookup); - Metrics::increment(cache_rsb.status[c->op_type].active); - Metrics::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); + Counter::increment(cache_rsb.status[c->op_type].active); + Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); c->first_key = c->key = *key; c->frag_type = type; c->f.lookup = 1; @@ -1242,8 +1242,8 @@ Cache::remove(Continuation *cont, const CacheKey *key, CacheFragType type, const c->vio.op = VIO::NONE; c->frag_type = type; c->op_type = static_cast(CacheOpType::Remove); - Metrics::increment(cache_rsb.status[c->op_type].active); - Metrics::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); + Counter::increment(cache_rsb.status[c->op_type].active); + Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); c->first_key = c->key = *key; c->vol = vol; c->dir = result; @@ -1691,7 +1691,7 @@ cplist_reconfigure() } } - Metrics::write(cache_rsb.stripes, gnvol + assignedVol); + Counter::write(cache_rsb.stripes, gnvol + assignedVol); return 0; } diff --git a/src/iocore/cache/CacheDir.cc b/src/iocore/cache/CacheDir.cc index 50cb4508cff..537e09a6b06 100644 --- a/src/iocore/cache/CacheDir.cc +++ b/src/iocore/cache/CacheDir.cc @@ -367,8 +367,8 @@ dir_clean_bucket(Dir *b, int s, Stripe *vol) dir_tag(e), dir_offset(e), b, p, dir_bucket_length(b, s, vol)); } if (dir_offset(e)) { - Metrics::decrement(cache_rsb.direntries_used); - Metrics::decrement(vol->cache_vol->vol_rsb.direntries_used); + Counter::decrement(cache_rsb.direntries_used); + Counter::decrement(vol->cache_vol->vol_rsb.direntries_used); } e = dir_delete_entry(e, p, s, vol); continue; @@ -403,8 +403,8 @@ dir_clear_range(off_t start, off_t end, Stripe *vol) for (off_t i = 0; i < vol->buckets * DIR_DEPTH * vol->segments; i++) { Dir *e = dir_index(vol, i); if (dir_offset(e) >= static_cast(start) && dir_offset(e) < static_cast(end)) { - Metrics::decrement(cache_rsb.direntries_used); - Metrics::decrement(vol->cache_vol->vol_rsb.direntries_used); + Counter::decrement(cache_rsb.direntries_used); + Counter::decrement(vol->cache_vol->vol_rsb.direntries_used); dir_set_offset(e, 0); // delete } } @@ -439,8 +439,8 @@ freelist_clean(int s, Stripe *vol) for (int l = 0; l < DIR_DEPTH; l++) { Dir *e = dir_bucket_row(b, l); if (dir_head(e) && !(n++ % 10)) { - Metrics::decrement(cache_rsb.direntries_used); - Metrics::decrement(vol->cache_vol->vol_rsb.direntries_used); + Counter::decrement(cache_rsb.direntries_used); + Counter::decrement(vol->cache_vol->vol_rsb.direntries_used); dir_set_offset(e, 0); // delete } } @@ -567,8 +567,8 @@ dir_probe(const CacheKey *key, Stripe *vol, Dir *result, Dir **last_collision) // may not accurately reflect the number of documents // having the same first_key DDbg(dbg_ctl_cache_stats, "Incrementing dir collisions"); - Metrics::increment(cache_rsb.directory_collision_count); - Metrics::increment(vol->cache_vol->vol_rsb.directory_collision_count); + Counter::increment(cache_rsb.directory_collision_count); + Counter::increment(vol->cache_vol->vol_rsb.directory_collision_count); } goto Lcont; } @@ -580,8 +580,8 @@ dir_probe(const CacheKey *key, Stripe *vol, Dir *result, Dir **last_collision) ink_assert(dir_offset(e) * CACHE_BLOCK_SIZE < vol->len); return 1; } else { // delete the invalid entry - Metrics::decrement(cache_rsb.direntries_used); - Metrics::decrement(vol->cache_vol->vol_rsb.direntries_used); + Counter::decrement(cache_rsb.direntries_used); + Counter::decrement(vol->cache_vol->vol_rsb.direntries_used); e = dir_delete_entry(e, p, s, vol); continue; } @@ -595,8 +595,8 @@ dir_probe(const CacheKey *key, Stripe *vol, Dir *result, Dir **last_collision) } if (collision) { // last collision no longer in the list, retry DDbg(dbg_ctl_cache_stats, "Incrementing dir collisions"); - Metrics::increment(cache_rsb.directory_collision_count); - Metrics::increment(vol->cache_vol->vol_rsb.directory_collision_count); + Counter::increment(cache_rsb.directory_collision_count); + Counter::increment(vol->cache_vol->vol_rsb.directory_collision_count); collision = nullptr; goto Lagain; } @@ -667,8 +667,8 @@ dir_insert(const CacheKey *key, Stripe *vol, Dir *to_part) bi, e, key->slice32(1), dir_tag(e), dir_offset(e)); CHECK_DIR(d); vol->header->dirty = 1; - Metrics::increment(cache_rsb.direntries_used); - Metrics::increment(vol->cache_vol->vol_rsb.direntries_used); + Counter::increment(cache_rsb.direntries_used); + Counter::increment(vol->cache_vol->vol_rsb.direntries_used); return 1; } @@ -718,8 +718,8 @@ dir_overwrite(const CacheKey *key, Stripe *vol, Dir *dir, Dir *overwrite, bool m // get from this row first e = b; if (dir_is_empty(e)) { - Metrics::increment(cache_rsb.direntries_used); - Metrics::increment(vol->cache_vol->vol_rsb.direntries_used); + Counter::increment(cache_rsb.direntries_used); + Counter::increment(vol->cache_vol->vol_rsb.direntries_used); goto Lfill; } for (l = 1; l < DIR_DEPTH; l++) { @@ -735,8 +735,8 @@ dir_overwrite(const CacheKey *key, Stripe *vol, Dir *dir, Dir *overwrite, bool m goto Lagain; } Llink: - Metrics::increment(cache_rsb.direntries_used); - Metrics::increment(vol->cache_vol->vol_rsb.direntries_used); + Counter::increment(cache_rsb.direntries_used); + Counter::increment(vol->cache_vol->vol_rsb.direntries_used); // as with dir_insert above, need to insert new entries at the tail of the linked list Dir *prev, *last; @@ -784,8 +784,8 @@ dir_delete(const CacheKey *key, Stripe *vol, Dir *del) } #endif if (dir_compare_tag(e, key) && dir_offset(e) == dir_offset(del)) { - Metrics::decrement(cache_rsb.direntries_used); - Metrics::decrement(vol->cache_vol->vol_rsb.direntries_used); + Counter::decrement(cache_rsb.direntries_used); + Counter::decrement(vol->cache_vol->vol_rsb.direntries_used); dir_delete_entry(e, p, s, vol); CHECK_DIR(d); return 1; @@ -1099,8 +1099,8 @@ CacheSync::mainEvent(int event, Event *e) event = EVENT_NONE; goto Ldone; } - Metrics::increment(cache_rsb.directory_sync_bytes, io.aio_result); - Metrics::increment(vol->cache_vol->vol_rsb.directory_sync_bytes, io.aio_result); + Counter::increment(cache_rsb.directory_sync_bytes, io.aio_result); + Counter::increment(vol->cache_vol->vol_rsb.directory_sync_bytes, io.aio_result); trigger = eventProcessor.schedule_in(this, SYNC_DELAY); return EVENT_CONT; } @@ -1193,10 +1193,10 @@ CacheSync::mainEvent(int event, Event *e) writepos += headerlen; } else { vol->dir_sync_in_progress = false; - Metrics::increment(cache_rsb.directory_sync_count); - Metrics::increment(vol->cache_vol->vol_rsb.directory_sync_count); - Metrics::increment(cache_rsb.directory_sync_time, ink_get_hrtime() - start_time); - Metrics::increment(vol->cache_vol->vol_rsb.directory_sync_time, ink_get_hrtime() - start_time); + Counter::increment(cache_rsb.directory_sync_count); + Counter::increment(vol->cache_vol->vol_rsb.directory_sync_count); + Counter::increment(cache_rsb.directory_sync_time, ink_get_hrtime() - start_time); + Counter::increment(vol->cache_vol->vol_rsb.directory_sync_time, ink_get_hrtime() - start_time); start_time = 0; goto Ldone; } diff --git a/src/iocore/cache/CacheDisk.cc b/src/iocore/cache/CacheDisk.cc index 701fbae0a12..588be5a2824 100644 --- a/src/iocore/cache/CacheDisk.cc +++ b/src/iocore/cache/CacheDisk.cc @@ -29,8 +29,8 @@ CacheDisk::incrErrors(const AIOCallback *io) if (0 == this->num_errors) { /* This it the first read/write error on this span since ATS started. * Move the newly failing span from "online" to "failing" bucket. */ - Metrics::decrement(cache_rsb.span_online); - Metrics::increment(cache_rsb.span_failing); + Counter::decrement(cache_rsb.span_online); + Counter::increment(cache_rsb.span_failing); } this->num_errors++; @@ -40,11 +40,11 @@ CacheDisk::incrErrors(const AIOCallback *io) switch (io->aiocb.aio_lio_opcode) { case LIO_READ: opname = "READ"; - Metrics::increment(cache_rsb.span_errors_read); + Counter::increment(cache_rsb.span_errors_read); break; case LIO_WRITE: opname = "WRITE"; - Metrics::increment(cache_rsb.span_errors_write); + Counter::increment(cache_rsb.span_errors_write); break; default: break; diff --git a/src/iocore/cache/CacheHttp.cc b/src/iocore/cache/CacheHttp.cc index 264905b47e9..f9384f3d057 100644 --- a/src/iocore/cache/CacheHttp.cc +++ b/src/iocore/cache/CacheHttp.cc @@ -191,9 +191,9 @@ CacheHTTPInfoVector::marshal(char *buf, int length) count++; } - Metrics::increment(cache_rsb.hdr_vector_marshal); - Metrics::increment(cache_rsb.hdr_marshal, count); - Metrics::increment(cache_rsb.hdr_marshal_bytes, buf - start); + Counter::increment(cache_rsb.hdr_vector_marshal); + Counter::increment(cache_rsb.hdr_marshal, count); + Counter::increment(cache_rsb.hdr_marshal_bytes, buf - start); return buf - start; } diff --git a/src/iocore/cache/CacheRead.cc b/src/iocore/cache/CacheRead.cc index 5a3f5d3e9a0..00981956654 100644 --- a/src/iocore/cache/CacheRead.cc +++ b/src/iocore/cache/CacheRead.cc @@ -61,8 +61,8 @@ Cache::open_read(Continuation *cont, const CacheKey *key, CacheFragType type, co SET_CONTINUATION_HANDLER(c, &CacheVC::openReadStartHead); c->vio.op = VIO::READ; c->op_type = static_cast(CacheOpType::Read); - Metrics::increment(cache_rsb.status[c->op_type].active); - Metrics::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); + Counter::increment(cache_rsb.status[c->op_type].active); + Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); c->first_key = c->key = c->earliest_key = *key; c->vol = vol; c->frag_type = type; @@ -90,8 +90,8 @@ Cache::open_read(Continuation *cont, const CacheKey *key, CacheFragType type, co } } Lmiss: - Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); - Metrics::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); + Counter::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); + Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *)-ECACHE_NO_DOC); return ACTION_RESULT_DONE; Lwriter: @@ -131,8 +131,8 @@ Cache::open_read(Continuation *cont, const CacheKey *key, CacheHTTPHdr *request, c->vol = vol; c->vio.op = VIO::READ; c->op_type = static_cast(CacheOpType::Read); - Metrics::increment(cache_rsb.status[c->op_type].active); - Metrics::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); + Counter::increment(cache_rsb.status[c->op_type].active); + Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); c->request.copy_shallow(request); c->frag_type = CACHE_FRAG_TYPE_HTTP; c->params = params; @@ -163,8 +163,8 @@ Cache::open_read(Continuation *cont, const CacheKey *key, CacheHTTPHdr *request, } } Lmiss: - Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); - Metrics::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); + Counter::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); + Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *)-ECACHE_NO_DOC); return ACTION_RESULT_DONE; Lwriter: @@ -203,10 +203,10 @@ CacheVC::openReadFromWriterFailure(int event, Event *e) { od = nullptr; vector.clear(false); - Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); - Metrics::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); - Metrics::increment(cache_rsb.read_busy_failure); - Metrics::increment(vol->cache_vol->vol_rsb.read_busy_failure); + Counter::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); + Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); + Counter::increment(cache_rsb.read_busy_failure); + Counter::increment(vol->cache_vol->vol_rsb.read_busy_failure); _action.continuation->handleEvent(event, e); free_CacheVC(this); return EVENT_DONE; @@ -454,8 +454,8 @@ CacheVC::openReadFromWriter(int event, Event *e) dir_clean(&first_dir); dir_clean(&earliest_dir); SET_HANDLER(&CacheVC::openReadFromWriterMain); - Metrics::increment(cache_rsb.read_busy_success); - Metrics::increment(vol->cache_vol->vol_rsb.read_busy_success); + Counter::increment(cache_rsb.read_busy_success); + Counter::increment(vol->cache_vol->vol_rsb.read_busy_success); return callcont(CACHE_EVENT_OPEN_READ); } @@ -494,8 +494,8 @@ CacheVC::openReadFromWriter(int event, Event *e) DDbg(dbg_ctl_cache_read_agg, "%p: key: %X %X: single fragment read", this, first_key.slice32(1), key.slice32(0)); MUTEX_RELEASE(writer_lock); SET_HANDLER(&CacheVC::openReadFromWriterMain); - Metrics::increment(cache_rsb.read_busy_success); - Metrics::increment(vol->cache_vol->vol_rsb.read_busy_success); + Counter::increment(cache_rsb.read_busy_success); + Counter::increment(vol->cache_vol->vol_rsb.read_busy_success); return callcont(CACHE_EVENT_OPEN_READ); } @@ -776,8 +776,8 @@ CacheVC::openReadMain(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */) doc->magic = DOC_CORRUPT; - Metrics::increment(cache_rsb.read_seek_fail); - Metrics::increment(vol->cache_vol->vol_rsb.read_seek_fail); + Counter::increment(cache_rsb.read_seek_fail); + Counter::increment(vol->cache_vol->vol_rsb.read_seek_fail); CACHE_TRY_LOCK(lock, vol->mutex, mutex->thread_holding); if (!lock.is_locked()) { @@ -1014,16 +1014,16 @@ CacheVC::openReadStartEarliest(int /* event ATS_UNUSED */, Event * /* e ATS_UNUS vol->close_write(this); } } - Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); - Metrics::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); + Counter::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); + Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); _action.continuation->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *)-ECACHE_NO_DOC); return free_CacheVC(this); Lcallreturn: return handleEvent(AIO_EVENT_DONE, nullptr); // hopefully a tail call Lsuccess: if (write_vc) { - Metrics::increment(cache_rsb.read_busy_success); - Metrics::increment(vol->cache_vol->vol_rsb.read_busy_success); + Counter::increment(cache_rsb.read_busy_success); + Counter::increment(vol->cache_vol->vol_rsb.read_busy_success); } SET_HANDLER(&CacheVC::openReadMain); return callcont(CACHE_EVENT_OPEN_READ); @@ -1074,8 +1074,8 @@ CacheVC::openReadVecWrite(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */ } } - Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); - Metrics::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); + Counter::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); + Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); _action.continuation->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *)-ECACHE_ALT_MISS); return free_CacheVC(this); Lrestart: @@ -1216,8 +1216,8 @@ CacheVC::openReadStartHead(int event, Event *e) if (cl != doc_len) { Warning("OpenReadHead failed for cachekey %X : alternate content length doesn't match doc_len %" PRId64 " != %" PRId64, key.slice32(0), cl, doc_len); - Metrics::increment(cache_rsb.read_invalid); - Metrics::increment(vol->cache_vol->vol_rsb.read_invalid); + Counter::increment(cache_rsb.read_invalid); + Counter::increment(vol->cache_vol->vol_rsb.read_invalid); err = ECACHE_BAD_META_DATA; goto Ldone; } @@ -1282,12 +1282,12 @@ CacheVC::openReadStartHead(int event, Event *e) } Ldone: if (!f.lookup) { - Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); - Metrics::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); + Counter::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); + Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); _action.continuation->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *)-err); } else { - Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Lookup)].failure); - Metrics::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Lookup)].failure); + Counter::increment(cache_rsb.status[static_cast(CacheOpType::Lookup)].failure); + Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Lookup)].failure); _action.continuation->handleEvent(CACHE_EVENT_LOOKUP_FAILED, (void *)-err); } return free_CacheVC(this); @@ -1297,8 +1297,8 @@ CacheVC::openReadStartHead(int event, Event *e) SET_HANDLER(&CacheVC::openReadMain); return callcont(CACHE_EVENT_OPEN_READ); Lookup: - Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Lookup)].failure); - Metrics::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Lookup)].failure); + Counter::increment(cache_rsb.status[static_cast(CacheOpType::Lookup)].failure); + Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Lookup)].failure); _action.continuation->handleEvent(CACHE_EVENT_LOOKUP, nullptr); return free_CacheVC(this); Learliest: diff --git a/src/iocore/cache/CacheVC.cc b/src/iocore/cache/CacheVC.cc index b749c4a35a0..9a31893ae1d 100644 --- a/src/iocore/cache/CacheVC.cc +++ b/src/iocore/cache/CacheVC.cc @@ -513,8 +513,8 @@ CacheVC::handleRead(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */) // ToDo: Why are these for debug only ?? #if DEBUG - Metrics::increment(cache_rsb.pread_count); - Metrics::increment(vol->cache_vol->vol_rsb.pread_count); + Counter::increment(cache_rsb.pread_count); + Counter::increment(vol->cache_vol->vol_rsb.pread_count); #endif return EVENT_CONT; @@ -603,8 +603,8 @@ CacheVC::removeEvent(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */) return ret; } Ldone: - Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Remove)].failure); - Metrics::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Remove)].failure); + Counter::increment(cache_rsb.status[static_cast(CacheOpType::Remove)].failure); + Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Remove)].failure); if (od) { vol->close_write(this); } diff --git a/src/iocore/cache/CacheWrite.cc b/src/iocore/cache/CacheWrite.cc index b3a04363f6e..f348009eb0c 100644 --- a/src/iocore/cache/CacheWrite.cc +++ b/src/iocore/cache/CacheWrite.cc @@ -257,10 +257,10 @@ CacheVC::handleWrite(int event, Event * /* e ATS_UNUSED */) (vio.nbytes != INT64_MAX && (cache_config_max_doc_size < vio.nbytes)))); if (agg_error || max_doc_error) { - Metrics::increment(cache_rsb.write_backlog_failure); - Metrics::increment(vol->cache_vol->vol_rsb.write_backlog_failure); - Metrics::increment(cache_rsb.status[op_type].failure); - Metrics::increment(vol->cache_vol->vol_rsb.status[op_type].failure); + Counter::increment(cache_rsb.write_backlog_failure); + Counter::increment(vol->cache_vol->vol_rsb.write_backlog_failure); + Counter::increment(cache_rsb.status[op_type].failure); + Counter::increment(vol->cache_vol->vol_rsb.status[op_type].failure); vol->agg_todo_size -= agg_len; io.aio_result = AIO_SOFT_FAILURE; if (event == EVENT_CALL) { @@ -441,8 +441,8 @@ new_DocEvacuator(int nbytes, Stripe *vol) { CacheEvacuateDocVC *c = new_CacheEvacuateDocVC(vol); c->op_type = static_cast(CacheOpType::Evacuate); - Metrics::increment(cache_rsb.status[c->op_type].active); - Metrics::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); + Counter::increment(cache_rsb.status[c->op_type].active); + Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); c->buf = new_IOBufferData(iobuffer_size_to_index(nbytes, MAX_BUFFER_SIZE_INDEX), MEMALIGNED); c->vol = vol; c->f.evacuator = 1; @@ -744,8 +744,8 @@ agg_copy(char *p, CacheVC *vc) // ToDo: Why are these for debug only ? #ifdef DEBUG - Metrics::increment(cache_rsb.write_backlog_failure); - Metrics::increment(vol->cache_vol->vol_rsb.write_backlog_failure); + Counter::increment(cache_rsb.write_backlog_failure); + Counter::increment(vol->cache_vol->vol_rsb.write_backlog_failure); #endif } if (vc->f.rewrite_resident_alt) { @@ -786,8 +786,8 @@ agg_copy(char *p, CacheVC *vc) int l = vc->vol->round_to_approx_size(doc->len); #ifdef DEBUG - Metrics::increment(cache_rsb.gc_frags_evacuated); - Metrics::increment(vol->cache_vol->vol_rsb.gc_frags_evacuated); + Counter::increment(cache_rsb.gc_frags_evacuated); + Counter::increment(vol->cache_vol->vol_rsb.gc_frags_evacuated); #endif doc->sync_serial = vc->vol->header->sync_serial; @@ -874,8 +874,8 @@ Stripe::agg_wrap() dir_clean_vol(this); { Stripe *vol = this; - Metrics::increment(cache_rsb.directory_wrap); - Metrics::increment(vol->cache_vol->vol_rsb.directory_wrap); + Counter::increment(cache_rsb.directory_wrap); + Counter::increment(vol->cache_vol->vol_rsb.directory_wrap); Note("Cache volume %d on disk '%s' wraps around", vol->cache_vol->vol_number, vol->hash_text.get()); } periodic_scan(); @@ -1056,8 +1056,8 @@ CacheVC::openWriteCloseDir(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED * if ((closed == 1) && (total_len > 0 || f.allow_empty_doc)) { DDbg(dbg_ctl_cache_stats, "Fragment = %d", fragment); - Metrics::increment(cache_rsb.fragment_document_count[std::clamp(fragment, 0, 2)]); - Metrics::increment(vol->cache_vol->vol_rsb.fragment_document_count[std::clamp(fragment, 0, 2)]); + Counter::increment(cache_rsb.fragment_document_count[std::clamp(fragment, 0, 2)]); + Counter::increment(vol->cache_vol->vol_rsb.fragment_document_count[std::clamp(fragment, 0, 2)]); } if (f.close_complete) { recursive++; @@ -1508,8 +1508,8 @@ CacheVC::openWriteStartDone(int event, Event *e) return callcont(CACHE_EVENT_OPEN_WRITE); Lfailure: - Metrics::increment(cache_rsb.status[op_type].failure); - Metrics::increment(vol->cache_vol->vol_rsb.status[op_type].failure); + Counter::increment(cache_rsb.status[op_type].failure); + Counter::increment(vol->cache_vol->vol_rsb.status[op_type].failure); _action.continuation->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void *)-err); Lcancel: if (od) { @@ -1532,8 +1532,8 @@ CacheVC::openWriteStartBegin(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED return free_CacheVC(this); } if (((err = vol->open_write_lock(this, false, 1)) > 0)) { - Metrics::increment(cache_rsb.status[op_type].failure); - Metrics::increment(vol->cache_vol->vol_rsb.status[op_type].failure); + Counter::increment(cache_rsb.status[op_type].failure); + Counter::increment(vol->cache_vol->vol_rsb.status[op_type].failure); free_CacheVC(this); _action.continuation->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void *)-err); return EVENT_DONE; @@ -1570,8 +1570,8 @@ Cache::open_write(Continuation *cont, const CacheKey *key, CacheFragType frag_ty c->op_type = static_cast(CacheOpType::Write); c->vol = key_to_vol(key, hostname, host_len); Stripe *vol = c->vol; - Metrics::increment(cache_rsb.status[c->op_type].active); - Metrics::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); + Counter::increment(cache_rsb.status[c->op_type].active); + Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); c->first_key = c->key = *key; c->frag_type = frag_type; /* @@ -1594,8 +1594,8 @@ Cache::open_write(Continuation *cont, const CacheKey *key, CacheFragType frag_ty if ((res = c->vol->open_write_lock(c, false, 1)) > 0) { // document currently being written, abort - Metrics::increment(cache_rsb.status[c->op_type].failure); - Metrics::increment(vol->cache_vol->vol_rsb.status[c->op_type].failure); + Counter::increment(cache_rsb.status[c->op_type].failure); + Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].failure); cont->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void *)-res); free_CacheVC(c); return ACTION_RESULT_DONE; @@ -1690,8 +1690,8 @@ Cache::open_write(Continuation *cont, const CacheKey *key, CacheHTTPInfo *info, c->op_type = static_cast(CacheOpType::Write); } - Metrics::increment(cache_rsb.status[c->op_type].active); - Metrics::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); + Counter::increment(cache_rsb.status[c->op_type].active); + Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); // coverity[Y2K38_SAFETY:FALSE] c->pin_in_cache = static_cast(apin_in_cache); @@ -1742,8 +1742,8 @@ Cache::open_write(Continuation *cont, const CacheKey *key, CacheHTTPInfo *info, return ACTION_RESULT_DONE; Lfailure: - Metrics::increment(cache_rsb.status[c->op_type].failure); - Metrics::increment(vol->cache_vol->vol_rsb.status[c->op_type].failure); + Counter::increment(cache_rsb.status[c->op_type].failure); + Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].failure); cont->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void *)-err); if (c->od) { c->openWriteCloseDir(EVENT_IMMEDIATE, nullptr); diff --git a/src/iocore/cache/P_CacheInternal.h b/src/iocore/cache/P_CacheInternal.h index d6d38e424d6..0d8699d471d 100644 --- a/src/iocore/cache/P_CacheInternal.h +++ b/src/iocore/cache/P_CacheInternal.h @@ -34,7 +34,7 @@ #include "iocore/cache/CacheVC.h" #include "iocore/cache/CacheEvacuateDocVC.h" -using ts::Metrics; +using ts::Metrics::Counter; struct EvacuationBlock; @@ -187,11 +187,11 @@ free_CacheVC(CacheVC *cont) Stripe *vol = cont->vol; if (vol) { - Metrics::decrement(cache_rsb.status[cont->op_type].active); - Metrics::decrement(vol->cache_vol->vol_rsb.status[cont->op_type].active); + Counter::decrement(cache_rsb.status[cont->op_type].active); + Counter::decrement(vol->cache_vol->vol_rsb.status[cont->op_type].active); if (cont->closed > 0) { - Metrics::increment(cache_rsb.status[cont->op_type].success); - Metrics::increment(vol->cache_vol->vol_rsb.status[cont->op_type].success); + Counter::increment(cache_rsb.status[cont->op_type].success); + Counter::increment(vol->cache_vol->vol_rsb.status[cont->op_type].success); } // else abort,cancel } ink_assert(mutex->thread_holding == this_ethread()); @@ -397,8 +397,8 @@ Stripe::open_write(CacheVC *cont, int allow_if_writers, int max_writers) } if (agg_error) { - Metrics::increment(cache_rsb.write_backlog_failure); - Metrics::increment(vol->cache_vol->vol_rsb.write_backlog_failure); + Counter::increment(cache_rsb.write_backlog_failure); + Counter::increment(vol->cache_vol->vol_rsb.write_backlog_failure); return ECACHE_WRITE_FAIL; } diff --git a/src/iocore/cache/P_CacheStats.h b/src/iocore/cache/P_CacheStats.h index f5d7b5767f1..a50aed2811f 100644 --- a/src/iocore/cache/P_CacheStats.h +++ b/src/iocore/cache/P_CacheStats.h @@ -28,43 +28,43 @@ enum class CacheOpType { Lookup = 0, Read, Write, Update, Remove, Evacuate, Scan struct CacheStatsBlock { struct { - ts::Metrics::IntType *active = nullptr; - ts::Metrics::IntType *success = nullptr; - ts::Metrics::IntType *failure = nullptr; + Counter::AtomicType *active = nullptr; + Counter::AtomicType *success = nullptr; + Counter::AtomicType *failure = nullptr; } status[static_cast(CacheOpType::Last)]; - ts::Metrics::IntType *fragment_document_count[3] = {nullptr, nullptr, nullptr}; // For 1, 2 and 3+ fragments + Counter::AtomicType *fragment_document_count[3] = {nullptr, nullptr, nullptr}; // For 1, 2 and 3+ fragments - ts::Metrics::IntType *bytes_used = nullptr; - ts::Metrics::IntType *bytes_total = nullptr; - ts::Metrics::IntType *stripes = nullptr; - ts::Metrics::IntType *ram_cache_bytes = nullptr; - ts::Metrics::IntType *ram_cache_bytes_total = nullptr; - ts::Metrics::IntType *direntries_total = nullptr; - ts::Metrics::IntType *direntries_used = nullptr; - ts::Metrics::IntType *ram_cache_hits = nullptr; - ts::Metrics::IntType *ram_cache_misses = nullptr; - ts::Metrics::IntType *pread_count = nullptr; - ts::Metrics::IntType *percent_full = nullptr; - ts::Metrics::IntType *read_seek_fail = nullptr; - ts::Metrics::IntType *read_invalid = nullptr; - ts::Metrics::IntType *write_backlog_failure = nullptr; - ts::Metrics::IntType *directory_collision_count = nullptr; - ts::Metrics::IntType *read_busy_success = nullptr; - ts::Metrics::IntType *read_busy_failure = nullptr; - ts::Metrics::IntType *gc_bytes_evacuated = nullptr; - ts::Metrics::IntType *gc_frags_evacuated = nullptr; - ts::Metrics::IntType *write_bytes = nullptr; - ts::Metrics::IntType *hdr_vector_marshal = nullptr; - ts::Metrics::IntType *hdr_marshal = nullptr; - ts::Metrics::IntType *hdr_marshal_bytes = nullptr; - ts::Metrics::IntType *directory_wrap = nullptr; - ts::Metrics::IntType *directory_sync_count = nullptr; - ts::Metrics::IntType *directory_sync_time = nullptr; - ts::Metrics::IntType *directory_sync_bytes = nullptr; - ts::Metrics::IntType *span_errors_read = nullptr; - ts::Metrics::IntType *span_errors_write = nullptr; - ts::Metrics::IntType *span_offline = nullptr; - ts::Metrics::IntType *span_online = nullptr; - ts::Metrics::IntType *span_failing = nullptr; + Counter::AtomicType *bytes_used = nullptr; + Counter::AtomicType *bytes_total = nullptr; + Counter::AtomicType *stripes = nullptr; + Counter::AtomicType *ram_cache_bytes = nullptr; + Counter::AtomicType *ram_cache_bytes_total = nullptr; + Counter::AtomicType *direntries_total = nullptr; + Counter::AtomicType *direntries_used = nullptr; + Counter::AtomicType *ram_cache_hits = nullptr; + Counter::AtomicType *ram_cache_misses = nullptr; + Counter::AtomicType *pread_count = nullptr; + Counter::AtomicType *percent_full = nullptr; + Counter::AtomicType *read_seek_fail = nullptr; + Counter::AtomicType *read_invalid = nullptr; + Counter::AtomicType *write_backlog_failure = nullptr; + Counter::AtomicType *directory_collision_count = nullptr; + Counter::AtomicType *read_busy_success = nullptr; + Counter::AtomicType *read_busy_failure = nullptr; + Counter::AtomicType *gc_bytes_evacuated = nullptr; + Counter::AtomicType *gc_frags_evacuated = nullptr; + Counter::AtomicType *write_bytes = nullptr; + Counter::AtomicType *hdr_vector_marshal = nullptr; + Counter::AtomicType *hdr_marshal = nullptr; + Counter::AtomicType *hdr_marshal_bytes = nullptr; + Counter::AtomicType *directory_wrap = nullptr; + Counter::AtomicType *directory_sync_count = nullptr; + Counter::AtomicType *directory_sync_time = nullptr; + Counter::AtomicType *directory_sync_bytes = nullptr; + Counter::AtomicType *span_errors_read = nullptr; + Counter::AtomicType *span_errors_write = nullptr; + Counter::AtomicType *span_offline = nullptr; + Counter::AtomicType *span_online = nullptr; + Counter::AtomicType *span_failing = nullptr; }; diff --git a/src/iocore/cache/RamCacheCLFUS.cc b/src/iocore/cache/RamCacheCLFUS.cc index 47fe8b90b8b..556179454fb 100644 --- a/src/iocore/cache/RamCacheCLFUS.cc +++ b/src/iocore/cache/RamCacheCLFUS.cc @@ -301,8 +301,8 @@ RamCacheCLFUS::get(CryptoHash *key, Ptr *ret_data, uint64_t auxkey if (!e->flag_bits.copy) { // don't bother if we have to copy anyway int64_t delta = (static_cast(e->compressed_len)) - static_cast(e->size); this->_bytes += delta; - Metrics::increment(cache_rsb.ram_cache_bytes, delta); - Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); + Counter::increment(cache_rsb.ram_cache_bytes, delta); + Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); e->size = e->compressed_len; check_accounting(this); e->flag_bits.compressed = 0; @@ -317,13 +317,13 @@ RamCacheCLFUS::get(CryptoHash *key, Ptr *ret_data, uint64_t auxkey } (*ret_data) = data; } - Metrics::increment(cache_rsb.ram_cache_hits); - Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_hits); + Counter::increment(cache_rsb.ram_cache_hits); + Counter::increment(vol->cache_vol->vol_rsb.ram_cache_hits); DDbg(dbg_ctl_ram_cache, "get %X %" PRId64 " size %d HIT", key->slice32(3), auxkey, e->size); return ram_hit_state; } else { - Metrics::increment(cache_rsb.ram_cache_misses); - Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_misses); + Counter::increment(cache_rsb.ram_cache_misses); + Counter::increment(vol->cache_vol->vol_rsb.ram_cache_misses); DDbg(dbg_ctl_ram_cache, "get %X %" PRId64 " HISTORY", key->slice32(3), auxkey); return 0; } @@ -333,8 +333,8 @@ RamCacheCLFUS::get(CryptoHash *key, Ptr *ret_data, uint64_t auxkey } DDbg(dbg_ctl_ram_cache, "get %X %" PRId64 " MISS", key->slice32(3), auxkey); Lerror: - Metrics::increment(cache_rsb.ram_cache_misses); - Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_misses); + Counter::increment(cache_rsb.ram_cache_misses); + Counter::increment(vol->cache_vol->vol_rsb.ram_cache_misses); return 0; Lfailed: @@ -407,8 +407,8 @@ RamCacheCLFUS::_destroy(RamCacheCLFUSEntry *e) if (!e->flag_bits.lru) { this->_objects--; this->_bytes -= e->size + ENTRY_OVERHEAD; - Metrics::decrement(cache_rsb.ram_cache_bytes, e->size); - Metrics::decrement(vol->cache_vol->vol_rsb.ram_cache_bytes, e->size); + Counter::decrement(cache_rsb.ram_cache_bytes, e->size); + Counter::decrement(vol->cache_vol->vol_rsb.ram_cache_bytes, e->size); e->data = nullptr; } else { this->_history--; @@ -536,8 +536,8 @@ RamCacheCLFUS::compress_entries(EThread *thread, int do_at_most) e->compressed_len = l; int64_t delta = (static_cast(l)) - static_cast(e->size); this->_bytes += delta; - Metrics::increment(cache_rsb.ram_cache_bytes, delta); - Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); + Counter::increment(cache_rsb.ram_cache_bytes, delta); + Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); e->size = l; } else { ats_free(b); @@ -546,8 +546,8 @@ RamCacheCLFUS::compress_entries(EThread *thread, int do_at_most) memcpy(bb, e->data->data(), e->len); int64_t delta = (static_cast(e->len)) - static_cast(e->size); this->_bytes += delta; - Metrics::increment(cache_rsb.ram_cache_bytes, delta); - Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); + Counter::increment(cache_rsb.ram_cache_bytes, delta); + Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); e->size = e->len; l = e->len; } @@ -578,8 +578,8 @@ RamCacheCLFUS::_requeue_victims(Que(RamCacheCLFUSEntry, lru_link) & victims) RamCacheCLFUSEntry *victim = nullptr; while ((victim = victims.dequeue())) { this->_bytes += victim->size + ENTRY_OVERHEAD; - Metrics::increment(cache_rsb.ram_cache_bytes, victim->size); - Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, victim->size); + Counter::increment(cache_rsb.ram_cache_bytes, victim->size); + Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, victim->size); victim->hits = REQUEUE_HITS(victim->hits); this->_lru[0].enqueue(victim); } @@ -614,8 +614,8 @@ RamCacheCLFUS::put(CryptoHash *key, IOBufferData *data, uint32_t len, bool copy, this->_lru[e->flag_bits.lru].enqueue(e); int64_t delta = (static_cast(size)) - static_cast(e->size); this->_bytes += delta; - Metrics::increment(cache_rsb.ram_cache_bytes, delta); - Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); + Counter::increment(cache_rsb.ram_cache_bytes, delta); + Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); if (!copy) { e->size = size; e->data = data; @@ -676,8 +676,8 @@ RamCacheCLFUS::put(CryptoHash *key, IOBufferData *data, uint32_t len, bool copy, continue; } this->_bytes -= victim->size + ENTRY_OVERHEAD; - Metrics::decrement(cache_rsb.ram_cache_bytes, victim->size); - Metrics::decrement(vol->cache_vol->vol_rsb.ram_cache_bytes, victim->size); + Counter::decrement(cache_rsb.ram_cache_bytes, victim->size); + Counter::decrement(vol->cache_vol->vol_rsb.ram_cache_bytes, victim->size); victims.enqueue(victim); if (victim == this->_compressed) { this->_compressed = nullptr; @@ -705,8 +705,8 @@ RamCacheCLFUS::put(CryptoHash *key, IOBufferData *data, uint32_t len, bool copy, while ((victim = victims.dequeue())) { if (this->_bytes + size + victim->size <= this->_max_bytes) { this->_bytes += victim->size + ENTRY_OVERHEAD; - Metrics::increment(cache_rsb.ram_cache_bytes, victim->size); - Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, victim->size); + Counter::increment(cache_rsb.ram_cache_bytes, victim->size); + Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, victim->size); victim->hits = REQUEUE_HITS(victim->hits); this->_lru[0].enqueue(victim); } else { @@ -738,8 +738,8 @@ RamCacheCLFUS::put(CryptoHash *key, IOBufferData *data, uint32_t len, bool copy, } e->flag_bits.copy = copy; this->_bytes += size + ENTRY_OVERHEAD; - Metrics::increment(cache_rsb.ram_cache_bytes, size); - Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, size); + Counter::increment(cache_rsb.ram_cache_bytes, size); + Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, size); e->size = size; this->_objects++; this->_lru[0].enqueue(e); diff --git a/src/iocore/cache/RamCacheLRU.cc b/src/iocore/cache/RamCacheLRU.cc index e8e33706b27..1fdc1eba30f 100644 --- a/src/iocore/cache/RamCacheLRU.cc +++ b/src/iocore/cache/RamCacheLRU.cc @@ -141,16 +141,16 @@ RamCacheLRU::get(CryptoHash *key, Ptr *ret_data, uint64_t auxkey) lru.enqueue(e); (*ret_data) = e->data; DDbg(dbg_ctl_ram_cache, "get %X %" PRIu64 " HIT", key->slice32(3), auxkey); - Metrics::increment(cache_rsb.ram_cache_hits); - Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_hits); + Counter::increment(cache_rsb.ram_cache_hits); + Counter::increment(vol->cache_vol->vol_rsb.ram_cache_hits); return 1; } e = e->hash_link.next; } DDbg(dbg_ctl_ram_cache, "get %X %" PRIu64 " MISS", key->slice32(3), auxkey); - Metrics::increment(cache_rsb.ram_cache_misses); - Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_misses); + Counter::increment(cache_rsb.ram_cache_misses); + Counter::increment(vol->cache_vol->vol_rsb.ram_cache_misses); return 0; } @@ -163,8 +163,8 @@ RamCacheLRU::remove(RamCacheLRUEntry *e) bucket[b].remove(e); lru.remove(e); bytes -= ENTRY_OVERHEAD + e->data->block_size(); - Metrics::decrement(cache_rsb.ram_cache_bytes, ENTRY_OVERHEAD + e->data->block_size()); - Metrics::decrement(vol->cache_vol->vol_rsb.ram_cache_bytes, ENTRY_OVERHEAD + e->data->block_size()); + Counter::decrement(cache_rsb.ram_cache_bytes, ENTRY_OVERHEAD + e->data->block_size()); + Counter::decrement(vol->cache_vol->vol_rsb.ram_cache_bytes, ENTRY_OVERHEAD + e->data->block_size()); DDbg(dbg_ctl_ram_cache, "put %X %" PRIu64 " FREED", e->key.slice32(3), e->auxkey); e->data = nullptr; @@ -212,8 +212,8 @@ RamCacheLRU::put(CryptoHash *key, IOBufferData *data, uint32_t len, bool, uint64 lru.enqueue(e); bytes += ENTRY_OVERHEAD + data->block_size(); objects++; - Metrics::increment(cache_rsb.ram_cache_bytes, ENTRY_OVERHEAD + data->block_size()); - Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, ENTRY_OVERHEAD + data->block_size()); + Counter::increment(cache_rsb.ram_cache_bytes, ENTRY_OVERHEAD + data->block_size()); + Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, ENTRY_OVERHEAD + data->block_size()); while (bytes > max_bytes) { RamCacheLRUEntry *ee = lru.dequeue(); if (ee) { diff --git a/src/iocore/dns/DNS.cc b/src/iocore/dns/DNS.cc index b1bf81d0acf..c6770da96e0 100644 --- a/src/iocore/dns/DNS.cc +++ b/src/iocore/dns/DNS.cc @@ -470,7 +470,7 @@ DNSHandler::open_cons(sockaddr const *target, bool failed, int icon) bool DNSHandler::reset_tcp_conn(int ndx) { - Metrics::increment(dns_rsb.tcp_reset); + Counter::increment(dns_rsb.tcp_reset); tcpcon[ndx].close(); return open_con(&m_res->nsaddr_list[ndx].sa, true, ndx, true); } @@ -824,7 +824,7 @@ DNSHandler::rr_failure(int ndx) ++(e->retries); // give them another chance } --in_flight; - Metrics::decrement(dns_rsb.in_flight); + Counter::decrement(dns_rsb.in_flight); } } else { // move outstanding requests that were sent to this nameserver to another @@ -835,7 +835,7 @@ DNSHandler::rr_failure(int ndx) ++(e->retries); // give them another chance } --in_flight; - Metrics::decrement(dns_rsb.in_flight); + Counter::decrement(dns_rsb.in_flight); } } } @@ -1079,7 +1079,7 @@ get_entry(DNSHandler *h, char *qname, int qtype) static void write_dns(DNSHandler *h, bool tcp_retry) { - Metrics::increment(dns_rsb.total_lookups); + Counter::increment(dns_rsb.total_lookups); int max_nscount = h->m_res->nscount; if (max_nscount > MAX_NAMED) { max_nscount = MAX_NAMED; @@ -1217,7 +1217,7 @@ write_dns_event(DNSHandler *h, DNSEntry *e, bool over_tcp) e->which_ns = h->name_server; e->once_written_flag = true; ++h->in_flight; - Metrics::increment(dns_rsb.in_flight); + Counter::increment(dns_rsb.in_flight); e->send_time = ink_get_hrtime(); @@ -1302,7 +1302,7 @@ DNSEntry::mainEvent(int event, Event *e) Dbg(dbg_ctl_dns, "marking %s as not-written", qname); written_flag = false; --(dnsH->in_flight); - Metrics::decrement(dns_rsb.in_flight); + Counter::decrement(dns_rsb.in_flight); } timeout = nullptr; dns_result(dnsH, this, result_ent.get(), true); @@ -1349,7 +1349,7 @@ dns_result(DNSHandler *h, DNSEntry *e, HostEnt *ent, bool retry, bool tcp_retry) if (retry && e->retries) { Dbg(dbg_ctl_dns, "doing retry for %s", e->qname); - Metrics::increment(dns_rsb.tcp_retries); + Counter::increment(dns_rsb.tcp_retries); --(e->retries); write_dns(h, tcp_retry); @@ -1385,7 +1385,7 @@ dns_result(DNSHandler *h, DNSEntry *e, HostEnt *ent, bool retry, bool tcp_retry) } } if (retry) { - Metrics::increment(dns_rsb.max_retries_exceeded); + Counter::increment(dns_rsb.max_retries_exceeded); } } if (ent == BAD_DNS_RESULT) { @@ -1397,12 +1397,12 @@ dns_result(DNSHandler *h, DNSEntry *e, HostEnt *ent, bool retry, bool tcp_retry) // These are rolling averages, this requires that the lookup_fail/success counters are incremented later if (!ent || !ent->good) { - Metrics::increment(dns_rsb.fail_time, diff); - Metrics::increment(dns_rsb.lookup_fail); + Counter::increment(dns_rsb.fail_time, diff); + Counter::increment(dns_rsb.lookup_fail); } else { - Metrics::increment(dns_rsb.success_time, diff); + Counter::increment(dns_rsb.success_time, diff); - Metrics::increment(dns_rsb.lookup_success); + Counter::increment(dns_rsb.lookup_success); } } @@ -1559,17 +1559,17 @@ dns_process(DNSHandler *handler, HostEnt *buf, int len) // e->written_flag = false; --(handler->in_flight); - Metrics::decrement(dns_rsb.in_flight); + Counter::decrement(dns_rsb.in_flight); // These are rolling averages ink_hrtime diff = (ink_get_hrtime() - e->send_time) / HRTIME_MSECOND; - Metrics::increment(dns_rsb.response_time, diff); + Counter::increment(dns_rsb.response_time, diff); // retrying over TCP when truncated is set if (dns_conn_mode == DNS_CONN_MODE::TCP_RETRY && h->tc == 1) { Dbg(dbg_ctl_dns, "Retrying DNS query over TCP for [%s]", e->qname); tcp_retry = true; - Metrics::increment(dns_rsb.tcp_retries); + Counter::increment(dns_rsb.tcp_retries); goto Lerror; } @@ -1882,7 +1882,7 @@ dns_process(DNSHandler *handler, HostEnt *buf, int len) } } Lerror:; - Metrics::increment(dns_rsb.lookup_fail); + Counter::increment(dns_rsb.lookup_fail); buf->good = false; dns_result(handler, e, buf, retry, tcp_retry); return server_ok; @@ -1907,19 +1907,19 @@ ink_dns_init(ts::ModuleVersion v) // // Register statistics callbacks // - ts::Metrics &intm = ts::Metrics::getInstance(); - - dns_rsb.fail_time = intm.newMetricPtr("proxy.process.dns.fail_time"); - dns_rsb.in_flight = intm.newMetricPtr("proxy.process.dns.in_flight"); - dns_rsb.lookup_fail = intm.newMetricPtr("proxy.process.dns.lookup_failures"); - dns_rsb.lookup_success = intm.newMetricPtr("proxy.process.dns.lookup_successes"); - dns_rsb.max_retries_exceeded = intm.newMetricPtr("proxy.process.dns.max_retries_exceeded"); - dns_rsb.response_time = intm.newMetricPtr("proxy.process.dns.lookup_time"); - dns_rsb.retries = intm.newMetricPtr("proxy.process.dns.retries"); - dns_rsb.success_time = intm.newMetricPtr("proxy.process.dns.success_time"); - dns_rsb.tcp_reset = intm.newMetricPtr("proxy.process.dns.tcp_reset"); - dns_rsb.tcp_retries = intm.newMetricPtr("proxy.process.dns.tcp_retries"); - dns_rsb.total_lookups = intm.newMetricPtr("proxy.process.dns.total_dns_lookups"); + ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); + + dns_rsb.fail_time = metrics.createPtr("proxy.process.dns.fail_time"); + dns_rsb.in_flight = metrics.createPtr("proxy.process.dns.in_flight"); + dns_rsb.lookup_fail = metrics.createPtr("proxy.process.dns.lookup_failures"); + dns_rsb.lookup_success = metrics.createPtr("proxy.process.dns.lookup_successes"); + dns_rsb.max_retries_exceeded = metrics.createPtr("proxy.process.dns.max_retries_exceeded"); + dns_rsb.response_time = metrics.createPtr("proxy.process.dns.lookup_time"); + dns_rsb.retries = metrics.createPtr("proxy.process.dns.retries"); + dns_rsb.success_time = metrics.createPtr("proxy.process.dns.success_time"); + dns_rsb.tcp_reset = metrics.createPtr("proxy.process.dns.tcp_reset"); + dns_rsb.tcp_retries = metrics.createPtr("proxy.process.dns.tcp_retries"); + dns_rsb.total_lookups = metrics.createPtr("proxy.process.dns.total_dns_lookups"); } #if TS_HAS_TESTS diff --git a/src/iocore/dns/P_DNSProcessor.h b/src/iocore/dns/P_DNSProcessor.h index f3536ea2540..8218e59984c 100644 --- a/src/iocore/dns/P_DNSProcessor.h +++ b/src/iocore/dns/P_DNSProcessor.h @@ -31,8 +31,6 @@ #include "iocore/eventsystem/EThread.h" #include "iocore/eventsystem/Event.h" -#include "api/Metrics.h" - #include "tscore/ink_apidefs.h" #include "tscore/ink_hrtime.h" #include "tscore/ink_inet.h" @@ -45,12 +43,9 @@ #include "ts/DbgCtl.h" -#include - -#include -#include +#include "api/Metrics.h" -using ts::Metrics; +using ts::Metrics::Counter; #define MAX_NAMED 32 #define DEFAULT_DNS_RETRIES 5 @@ -102,17 +97,17 @@ extern unsigned int dns_sequence_number; // Stats struct DNSStatsBlock { - ts::Metrics::IntType *fail_time; - ts::Metrics::IntType *in_flight; - ts::Metrics::IntType *lookup_fail; - ts::Metrics::IntType *lookup_success; - ts::Metrics::IntType *max_retries_exceeded; - ts::Metrics::IntType *response_time; - ts::Metrics::IntType *retries; - ts::Metrics::IntType *success_time; - ts::Metrics::IntType *tcp_reset; - ts::Metrics::IntType *tcp_retries; - ts::Metrics::IntType *total_lookups; + Counter::AtomicType *fail_time; + Counter::AtomicType *in_flight; + Counter::AtomicType *lookup_fail; + Counter::AtomicType *lookup_success; + Counter::AtomicType *max_retries_exceeded; + Counter::AtomicType *response_time; + Counter::AtomicType *retries; + Counter::AtomicType *success_time; + Counter::AtomicType *tcp_reset; + Counter::AtomicType *tcp_retries; + Counter::AtomicType *total_lookups; }; struct HostEnt; diff --git a/src/iocore/hostdb/HostDB.cc b/src/iocore/hostdb/HostDB.cc index 64932273cb3..8c4ec947c2a 100644 --- a/src/iocore/hostdb/HostDB.cc +++ b/src/iocore/hostdb/HostDB.cc @@ -510,7 +510,7 @@ probe(HostDBHash const &hash, bool ignore_timeout) return NO_RECORD; // if we aren't ignoring timeouts, and we are past it-- then remove the record } else if (!ignore_timeout && record->is_ip_timeout() && !record->serve_stale_but_revalidate()) { - Metrics::increment(hostdb_rsb.ttl_expires); + Counter::increment(hostdb_rsb.ttl_expires); return NO_RECORD; } } @@ -518,7 +518,7 @@ probe(HostDBHash const &hash, bool ignore_timeout) // If the record is stale, but we want to revalidate-- lets start that up if ((!ignore_timeout && record->is_ip_configured_stale() && record->record_type != HostDBType::HOST) || (record->is_ip_timeout() && record->serve_stale_but_revalidate())) { - Metrics::increment(hostdb_rsb.total_serve_stale); + Counter::increment(hostdb_rsb.total_serve_stale); if (hostDB.is_pending_dns_for_hash(hash.hash)) { Dbg(dbg_ctl_hostdb, "%s", swoc::bwprint(ts::bw_dbg, "stale {} {} {}, using with pending refresh", record->ip_age(), @@ -556,11 +556,11 @@ HostDBProcessor::getby(Continuation *cont, cb_process_result_pfn cb_process_resu } else if (opt.flags & HOSTDB_FORCE_DNS_RELOAD) { force_dns = hostdb_re_dns_on_reload; if (force_dns) { - Metrics::increment(hostdb_rsb.re_dns_on_reload); + Counter::increment(hostdb_rsb.re_dns_on_reload); } } - Metrics::increment(hostdb_rsb.total_lookups); + Counter::increment(hostdb_rsb.total_lookups); if (!hostdb_enable || // if the HostDB is disabled, (hash.host_name && !*hash.host_name) || // or host_name is empty string @@ -604,7 +604,7 @@ HostDBProcessor::getby(Continuation *cont, cb_process_result_pfn cb_process_resu } else { Dbg(dbg_ctl_hostdb, "immediate answer for %s", hash.ip.isValid() ? hash.ip.toString(ipb, sizeof ipb) : ""); } - Metrics::increment(hostdb_rsb.total_hits); + Counter::increment(hostdb_rsb.total_hits); if (cb_process_result) { (cont->*cb_process_result)(r.get()); } else { @@ -749,7 +749,7 @@ HostDBProcessor::iterate(Continuation *cont) ink_assert(cont->mutex->thread_holding == this_ethread()); EThread *thread = cont->mutex->thread_holding; - Metrics::increment(hostdb_rsb.total_lookups); + Counter::increment(hostdb_rsb.total_lookups); HostDBContinuation *c = hostDBContAllocator.alloc(); HostDBContinuation::Options copt; @@ -814,7 +814,7 @@ HostDBContinuation::lookup_done(TextView query_name, ts_seconds answer_ttl, SRVH } break; } - Metrics::increment(hostdb_rsb.ttl, answer_ttl.count()); + Counter::increment(hostdb_rsb.ttl, answer_ttl.count()); // update the TTL record->ip_timestamp = hostdb_current_timestamp; @@ -1184,7 +1184,7 @@ HostDBContinuation::probeEvent(int /* event ATS_UNUSED */, Event *e) Ptr r = probe(hash, false); if (r) { - Metrics::increment(hostdb_rsb.total_hits); + Counter::increment(hostdb_rsb.total_hits); } if (action.continuation && r) { @@ -1212,7 +1212,7 @@ HostDBContinuation::set_check_pending_dns() Queue &q = hostDB.pending_dns_for_hash(hash.hash); this->setThreadAffinity(this_ethread()); if (q.in(this)) { - Metrics::increment(hostdb_rsb.insert_duplicate_to_pending_dns); + Counter::increment(hostdb_rsb.insert_duplicate_to_pending_dns); Dbg(dbg_ctl_hostdb, "Skip the insertion of the same continuation to pending dns"); return false; } @@ -1790,15 +1790,15 @@ ink_hostdb_init(ts::ModuleVersion v) // // Register stats // - ts::Metrics &intm = ts::Metrics::getInstance(); - - hostdb_rsb.total_lookups = intm.newMetricPtr("proxy.process.hostdb.total_lookups"); - hostdb_rsb.total_hits = intm.newMetricPtr("proxy.process.hostdb.total_hits"); - hostdb_rsb.total_serve_stale = intm.newMetricPtr("proxy.process.hostdb.total_serve_stale"); - hostdb_rsb.ttl = intm.newMetricPtr("proxy.process.hostdb.ttl"); - hostdb_rsb.ttl_expires = intm.newMetricPtr("proxy.process.hostdb.ttl_expires"); - hostdb_rsb.re_dns_on_reload = intm.newMetricPtr("proxy.process.hostdb.re_dns_on_reload"); - hostdb_rsb.insert_duplicate_to_pending_dns = intm.newMetricPtr("proxy.process.hostdb.insert_duplicate_to_pending_dns"); + ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); + + hostdb_rsb.total_lookups = metrics.createPtr("proxy.process.hostdb.total_lookups"); + hostdb_rsb.total_hits = metrics.createPtr("proxy.process.hostdb.total_hits"); + hostdb_rsb.total_serve_stale = metrics.createPtr("proxy.process.hostdb.total_serve_stale"); + hostdb_rsb.ttl = metrics.createPtr("proxy.process.hostdb.ttl"); + hostdb_rsb.ttl_expires = metrics.createPtr("proxy.process.hostdb.ttl_expires"); + hostdb_rsb.re_dns_on_reload = metrics.createPtr("proxy.process.hostdb.re_dns_on_reload"); + hostdb_rsb.insert_duplicate_to_pending_dns = metrics.createPtr("proxy.process.hostdb.insert_duplicate_to_pending_dns"); ts_host_res_global_init(); } diff --git a/src/iocore/hostdb/P_HostDBProcessor.h b/src/iocore/hostdb/P_HostDBProcessor.h index f91f1316078..1d7604f4651 100644 --- a/src/iocore/hostdb/P_HostDBProcessor.h +++ b/src/iocore/hostdb/P_HostDBProcessor.h @@ -37,7 +37,7 @@ #include "tscore/PendingAction.h" #include "api/Metrics.h" -using ts::Metrics; +using ts::Metrics::Counter; // // Data @@ -120,13 +120,13 @@ struct HostEnt; // Stats struct HostDBStatsBlock { - ts::Metrics::IntType *total_lookups; - ts::Metrics::IntType *total_hits; - ts::Metrics::IntType *total_serve_stale; - ts::Metrics::IntType *ttl; - ts::Metrics::IntType *ttl_expires; - ts::Metrics::IntType *re_dns_on_reload; - ts::Metrics::IntType *insert_duplicate_to_pending_dns; + Counter::AtomicType *total_lookups; + Counter::AtomicType *total_hits; + Counter::AtomicType *total_serve_stale; + Counter::AtomicType *ttl; + Counter::AtomicType *ttl_expires; + Counter::AtomicType *re_dns_on_reload; + Counter::AtomicType *insert_duplicate_to_pending_dns; }; extern HostDBStatsBlock hostdb_rsb; diff --git a/src/iocore/hostdb/P_RefCountCache.h b/src/iocore/hostdb/P_RefCountCache.h index 7adc5588454..b0332f0fe11 100644 --- a/src/iocore/hostdb/P_RefCountCache.h +++ b/src/iocore/hostdb/P_RefCountCache.h @@ -39,7 +39,7 @@ #include #include -using ts::Metrics; +using ts::Metrics::Counter; #define REFCOUNT_CACHE_EVENT_SYNC REFCOUNT_CACHE_EVENT_EVENTS_START @@ -51,15 +51,15 @@ static constexpr ts::VersionNumber REFCOUNTCACHE_VERSION(1, 0); // Stats struct RefCountCacheBlock { - Metrics::IntType *refcountcache_current_items; - Metrics::IntType *refcountcache_current_size; - Metrics::IntType *refcountcache_total_inserts; - Metrics::IntType *refcountcache_total_failed_inserts; - Metrics::IntType *refcountcache_total_lookups; - Metrics::IntType *refcountcache_total_hits; - Metrics::IntType *refcountcache_last_sync_time; - Metrics::IntType *refcountcache_last_total_items; - Metrics::IntType *refcountcache_last_total_size; + Counter::AtomicType *refcountcache_current_items; + Counter::AtomicType *refcountcache_current_size; + Counter::AtomicType *refcountcache_total_inserts; + Counter::AtomicType *refcountcache_total_failed_inserts; + Counter::AtomicType *refcountcache_total_lookups; + Counter::AtomicType *refcountcache_total_hits; + Counter::AtomicType *refcountcache_last_sync_time; + Counter::AtomicType *refcountcache_last_total_items; + Counter::AtomicType *refcountcache_last_total_size; }; struct RefCountCacheItemMeta { @@ -204,10 +204,10 @@ template Ptr RefCountCachePartition::get(uint64_t key) { - Metrics::increment(this->rsb->refcountcache_total_lookups); + Counter::increment(this->rsb->refcountcache_total_lookups); if (auto it = this->item_map.find(key); it != this->item_map.end()) { // found - Metrics::increment(this->rsb->refcountcache_total_hits); + Counter::increment(this->rsb->refcountcache_total_hits); return make_ptr(static_cast(it->item.get())); } else { return Ptr(); @@ -218,7 +218,7 @@ template void RefCountCachePartition::put(uint64_t key, C *item, int size, int expire_time) { - Metrics::increment(this->rsb->refcountcache_total_inserts); + Counter::increment(this->rsb->refcountcache_total_inserts); size += sizeof(C); // Remove any colliding entries this->erase(key); @@ -226,7 +226,7 @@ RefCountCachePartition::put(uint64_t key, C *item, int size, int expire_time) // if we are full, and can't make space-- then don't store the item if (this->is_full() && !this->make_space_for(size)) { Dbg(dbg_ctl, "partition %d is full-- not storing item key=%" PRIu64, this->part_num, key); - Metrics::increment(this->rsb->refcountcache_total_failed_inserts); + Counter::increment(this->rsb->refcountcache_total_failed_inserts); return; } @@ -247,8 +247,8 @@ RefCountCachePartition::put(uint64_t key, C *item, int size, int expire_time) this->item_map.insert(val); this->size += val->meta.size; this->items++; - Metrics::increment(this->rsb->refcountcache_current_size, (int64_t)val->meta.size); - Metrics::increment(this->rsb->refcountcache_current_items); + Counter::increment(this->rsb->refcountcache_current_size, (int64_t)val->meta.size); + Counter::increment(this->rsb->refcountcache_current_items); } template @@ -273,8 +273,8 @@ RefCountCachePartition::dealloc_entry(hash_type::iterator ptr) this->size -= ptr->meta.size; this->items--; - Metrics::decrement(this->rsb->refcountcache_current_size, ptr->meta.size); - Metrics::decrement(this->rsb->refcountcache_current_items); + Counter::decrement(this->rsb->refcountcache_current_size, ptr->meta.size); + Counter::decrement(this->rsb->refcountcache_current_items); // remove from expiry queue if (ptr->expiry_entry != nullptr) { @@ -428,21 +428,21 @@ RefCountCache::RefCountCache(unsigned int num_partitions, int size, int items const std::string metrics_prefix) : header(RefCountCacheHeader(object_version)) { - ts::Metrics &intm = ts::Metrics::getInstance(); + ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); this->max_size = size; this->max_items = items; this->num_partitions = num_partitions; - this->rsb.refcountcache_current_items = intm.newMetricPtr((metrics_prefix + "current_items").c_str()); - this->rsb.refcountcache_current_size = intm.newMetricPtr((metrics_prefix + "current_size").c_str()); - this->rsb.refcountcache_total_inserts = intm.newMetricPtr((metrics_prefix + "total_inserts").c_str()); - this->rsb.refcountcache_total_failed_inserts = intm.newMetricPtr((metrics_prefix + "total_failed_inserts").c_str()); - this->rsb.refcountcache_total_lookups = intm.newMetricPtr((metrics_prefix + "total_lookups").c_str()); - this->rsb.refcountcache_total_hits = intm.newMetricPtr((metrics_prefix + "total_hits").c_str()); - this->rsb.refcountcache_last_sync_time = intm.newMetricPtr((metrics_prefix + "last_sync.time").c_str()); - this->rsb.refcountcache_last_total_items = intm.newMetricPtr((metrics_prefix + "last_sync.total_items").c_str()); - this->rsb.refcountcache_last_total_size = intm.newMetricPtr((metrics_prefix + "last_sync.total_size").c_str()); + this->rsb.refcountcache_current_items = metrics.createPtr((metrics_prefix + "current_items").c_str()); + this->rsb.refcountcache_current_size = metrics.createPtr((metrics_prefix + "current_size").c_str()); + this->rsb.refcountcache_total_inserts = metrics.createPtr((metrics_prefix + "total_inserts").c_str()); + this->rsb.refcountcache_total_failed_inserts = metrics.createPtr((metrics_prefix + "total_failed_inserts").c_str()); + this->rsb.refcountcache_total_lookups = metrics.createPtr((metrics_prefix + "total_lookups").c_str()); + this->rsb.refcountcache_total_hits = metrics.createPtr((metrics_prefix + "total_hits").c_str()); + this->rsb.refcountcache_last_sync_time = metrics.createPtr((metrics_prefix + "last_sync.time").c_str()); + this->rsb.refcountcache_last_total_items = metrics.createPtr((metrics_prefix + "last_sync.total_items").c_str()); + this->rsb.refcountcache_last_total_size = metrics.createPtr((metrics_prefix + "last_sync.total_size").c_str()); // Now lets create all the partitions this->partitions.reserve(num_partitions); diff --git a/src/iocore/io_uring/io_uring.cc b/src/iocore/io_uring/io_uring.cc index 81ab2318c83..9107e074455 100644 --- a/src/iocore/io_uring/io_uring.cc +++ b/src/iocore/io_uring/io_uring.cc @@ -33,22 +33,21 @@ Linux io_uring helper library #include "tscore/Diags.h" #include - -using ts::Metrics; +using ts::Metrics::Counter; std::atomic main_wq_fd; IOUringConfig IOUringContext::config; struct IOUringStatsBlock { - Metrics::IntType *io_uring_submitted; - Metrics::IntType *io_uring_completed; + Counter::AtomicType *io_uring_submitted; + Counter::AtomicType *io_uring_completed; }; static IOUringStatsBlock io_uring_rsb = []() { auto &intm = Metrics::getInstance(); - return IOUringStatsBlock{intm.newMetricPtr("proxy.process.io_uring.submitted"), - intm.newMetricPtr("proxy.process.io_uring.completed")}; + return IOUringStatsBlock{metrics.createPtr("proxy.process.io_uring.submitted"), + metrics.createPtr("proxy.process.io_uring.completed")}; }(); void @@ -143,7 +142,7 @@ IOUringContext::get_wq_max_workers() void IOUringContext::submit() { - Metrics::increment(io_uring_rsb.io_uring_submitted, io_uring_submit(&ring)); + Counter::increment(io_uring_rsb.io_uring_submitted, io_uring_submit(&ring)); } void @@ -161,7 +160,7 @@ IOUringContext::service() io_uring_peek_cqe(&ring, &cqe); while (cqe) { handle_cqe(cqe); - Metrics::increment(io_uring_rsb.io_uring_completed); + Counter::increment(io_uring_rsb.io_uring_completed); io_uring_cqe_seen(&ring, cqe); cqe = nullptr; @@ -183,10 +182,10 @@ IOUringContext::submit_and_wait(ink_hrtime t) int count = io_uring_submit_and_wait_timeout(&ring, &cqe, 1, &timeout, nullptr); - Metrics::increment(io_uring_rsb.io_uring_submitted, count); + Counter::increment(io_uring_rsb.io_uring_submitted, count); while (cqe) { handle_cqe(cqe); - Metrics::increment(io_uring_rsb.io_uring_completed); + Counter::increment(io_uring_rsb.io_uring_completed); io_uring_cqe_seen(&ring, cqe); cqe = nullptr; diff --git a/src/iocore/io_uring/unit_tests/test_diskIO.cc b/src/iocore/io_uring/unit_tests/test_diskIO.cc index 7f536419478..3cdbeb03cc9 100644 --- a/src/iocore/io_uring/unit_tests/test_diskIO.cc +++ b/src/iocore/io_uring/unit_tests/test_diskIO.cc @@ -36,8 +36,7 @@ #include "tscore/ink_hrtime.h" #include "api/Metrics.h" - -using ts::Metrics; +using ts::Metrics::Counter; swoc::file::path temp_prefix(const char *basename) @@ -268,12 +267,12 @@ TEST_CASE("net_io", "[io_uring]") auto &m = Metrics::getInstance(); - Metrics::IntType *completed = m.lookup(m.lookup("proxy.process.io_uring.completed")); + Counter::AtomicType *completed = m.lookup(m.lookup("proxy.process.io_uring.completed")); - uint64_t completions_before = Metrics::read(completed); + uint64_t completions_before = Counter::read(completed); uint64_t needed = 2; - while ((Metrics::read(completed) - completions_before) < needed) { + while ((Counter::read(completed) - completions_before) < needed) { ctx.submit_and_wait(1 * HRTIME_SECOND); } diff --git a/src/iocore/net/BIO_fastopen.cc b/src/iocore/net/BIO_fastopen.cc index 822d7e81ef3..c836e8517e4 100644 --- a/src/iocore/net/BIO_fastopen.cc +++ b/src/iocore/net/BIO_fastopen.cc @@ -120,10 +120,10 @@ fastopen_bwrite(BIO *bio, const char *in, int insz) // sent without data and we should retry. const sockaddr *dst = reinterpret_cast(BIO_get_data(bio)); - Metrics::increment(net_rsb.fastopen_attempts); + Counter::increment(net_rsb.fastopen_attempts); err = SocketManager::sendto(fd, (void *)in, insz, MSG_FASTOPEN, dst, ats_ip_size(dst)); if (err >= 0) { - Metrics::increment(net_rsb.fastopen_successes); + Counter::increment(net_rsb.fastopen_successes); } BIO_set_data(bio, nullptr); diff --git a/src/iocore/net/Net.cc b/src/iocore/net/Net.cc index 8c5c55727cc..2795c771dac 100644 --- a/src/iocore/net/Net.cc +++ b/src/iocore/net/Net.cc @@ -80,58 +80,58 @@ configure_net() static inline void register_net_stats() { - ts::Metrics &intm = ts::Metrics::getInstance(); - - net_rsb.accepts_currently_open = intm.newMetricPtr("proxy.process.net.accepts_currently_open"); - net_rsb.calls_to_read = intm.newMetricPtr("proxy.process.net.calls_to_read"); - net_rsb.calls_to_read_nodata = intm.newMetricPtr("proxy.process.net.calls_to_read_nodata"); - net_rsb.calls_to_readfromnet = intm.newMetricPtr("proxy.process.net.calls_to_readfromnet"); - net_rsb.calls_to_write = intm.newMetricPtr("proxy.process.net.calls_to_write"); - net_rsb.calls_to_write_nodata = intm.newMetricPtr("proxy.process.net.calls_to_write_nodata"); - net_rsb.calls_to_writetonet = intm.newMetricPtr("proxy.process.net.calls_to_writetonet"); - net_rsb.connections_currently_open = intm.newMetricPtr("proxy.process.net.connections_currently_open"); - net_rsb.connections_throttled_in = intm.newMetricPtr("proxy.process.net.connections_throttled_in"); - net_rsb.connections_throttled_out = intm.newMetricPtr("proxy.process.net.connections_throttled_out"); - net_rsb.tunnel_total_client_connections_blind_tcp = intm.newMetricPtr("proxy.process.tunnel.total_client_connections_blind_tcp"); + ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); + + net_rsb.accepts_currently_open = metrics.createPtr("proxy.process.net.accepts_currently_open"); + net_rsb.calls_to_read = metrics.createPtr("proxy.process.net.calls_to_read"); + net_rsb.calls_to_read_nodata = metrics.createPtr("proxy.process.net.calls_to_read_nodata"); + net_rsb.calls_to_readfromnet = metrics.createPtr("proxy.process.net.calls_to_readfromnet"); + net_rsb.calls_to_write = metrics.createPtr("proxy.process.net.calls_to_write"); + net_rsb.calls_to_write_nodata = metrics.createPtr("proxy.process.net.calls_to_write_nodata"); + net_rsb.calls_to_writetonet = metrics.createPtr("proxy.process.net.calls_to_writetonet"); + net_rsb.connections_currently_open = metrics.createPtr("proxy.process.net.connections_currently_open"); + net_rsb.connections_throttled_in = metrics.createPtr("proxy.process.net.connections_throttled_in"); + net_rsb.connections_throttled_out = metrics.createPtr("proxy.process.net.connections_throttled_out"); + net_rsb.tunnel_total_client_connections_blind_tcp = metrics.createPtr("proxy.process.tunnel.total_client_connections_blind_tcp"); net_rsb.tunnel_current_client_connections_blind_tcp = - intm.newMetricPtr("proxy.process.tunnel.current_client_connections_blind_tcp"); - net_rsb.tunnel_total_server_connections_blind_tcp = intm.newMetricPtr("proxy.process.tunnel.total_server_connections_blind_tcp"); + metrics.createPtr("proxy.process.tunnel.current_client_connections_blind_tcp"); + net_rsb.tunnel_total_server_connections_blind_tcp = metrics.createPtr("proxy.process.tunnel.total_server_connections_blind_tcp"); net_rsb.tunnel_current_server_connections_blind_tcp = - intm.newMetricPtr("proxy.process.tunnel.current_server_connections_blind_tcp"); + metrics.createPtr("proxy.process.tunnel.current_server_connections_blind_tcp"); net_rsb.tunnel_total_client_connections_tls_tunnel = - intm.newMetricPtr("proxy.process.tunnel.total_client_connections_tls_tunnel"); + metrics.createPtr("proxy.process.tunnel.total_client_connections_tls_tunnel"); net_rsb.tunnel_current_client_connections_tls_tunnel = - intm.newMetricPtr("proxy.process.tunnel.current_client_connections_tls_tunnel"); + metrics.createPtr("proxy.process.tunnel.current_client_connections_tls_tunnel"); net_rsb.tunnel_total_client_connections_tls_forward = - intm.newMetricPtr("proxy.process.tunnel.total_client_connections_tls_forward"); + metrics.createPtr("proxy.process.tunnel.total_client_connections_tls_forward"); net_rsb.tunnel_current_client_connections_tls_forward = - intm.newMetricPtr("proxy.process.tunnel.current_client_connections_tls_forward"); + metrics.createPtr("proxy.process.tunnel.current_client_connections_tls_forward"); net_rsb.tunnel_total_client_connections_tls_partial_blind = - intm.newMetricPtr("proxy.process.tunnel.total_client_connections_tls_partial_blind"); + metrics.createPtr("proxy.process.tunnel.total_client_connections_tls_partial_blind"); net_rsb.tunnel_current_client_connections_tls_partial_blind = - intm.newMetricPtr("proxy.process.tunnel.current_client_connections_tls_partial_blind"); - net_rsb.tunnel_total_client_connections_tls_http = intm.newMetricPtr("proxy.process.tunnel.total_client_connections_tls_http"); + metrics.createPtr("proxy.process.tunnel.current_client_connections_tls_partial_blind"); + net_rsb.tunnel_total_client_connections_tls_http = metrics.createPtr("proxy.process.tunnel.total_client_connections_tls_http"); net_rsb.tunnel_current_client_connections_tls_http = - intm.newMetricPtr("proxy.process.tunnel.current_client_connections_tls_http"); - net_rsb.tunnel_total_server_connections_tls = intm.newMetricPtr("proxy.process.tunnel.total_server_connections_tls"); - net_rsb.tunnel_current_server_connections_tls = intm.newMetricPtr("proxy.process.tunnel.current_server_connections_tls"); - net_rsb.default_inactivity_timeout_applied = intm.newMetricPtr("proxy.process.net.default_inactivity_timeout_applied"); - net_rsb.default_inactivity_timeout_count = intm.newMetricPtr("proxy.process.net.default_inactivity_timeout_count"); - net_rsb.fastopen_attempts = intm.newMetricPtr("proxy.process.net.fastopen_out.attempts"); - net_rsb.fastopen_successes = intm.newMetricPtr("proxy.process.net.fastopen_out.successes"); - net_rsb.handler_run = intm.newMetricPtr("proxy.process.net.net_handler_run"); - net_rsb.inactivity_cop_lock_acquire_failure = intm.newMetricPtr("proxy.process.net.inactivity_cop_lock_acquire_failure"); - net_rsb.keep_alive_queue_timeout_count = intm.newMetricPtr("proxy.process.net.dynamic_keep_alive_timeout_in_count"); - net_rsb.keep_alive_queue_timeout_total = intm.newMetricPtr("proxy.process.net.dynamic_keep_alive_timeout_in_total"); - net_rsb.read_bytes = intm.newMetricPtr("proxy.process.net.read_bytes"); - net_rsb.read_bytes_count = intm.newMetricPtr("proxy.process.net.read_bytes_count"); - net_rsb.requests_max_throttled_in = intm.newMetricPtr("proxy.process.net.max.requests_throttled_in"); - net_rsb.socks_connections_currently_open = intm.newMetricPtr("proxy.process.socks.connections_currently_open"); - net_rsb.socks_connections_successful = intm.newMetricPtr("proxy.process.socks.connections_successful"); - net_rsb.socks_connections_unsuccessful = intm.newMetricPtr("proxy.process.socks.connections_unsuccessful"); - net_rsb.tcp_accept = intm.newMetricPtr("proxy.process.tcp.total_accepts"); - net_rsb.write_bytes = intm.newMetricPtr("proxy.process.net.write_bytes"); - net_rsb.write_bytes_count = intm.newMetricPtr("proxy.process.net.write_bytes_count"); + metrics.createPtr("proxy.process.tunnel.current_client_connections_tls_http"); + net_rsb.tunnel_total_server_connections_tls = metrics.createPtr("proxy.process.tunnel.total_server_connections_tls"); + net_rsb.tunnel_current_server_connections_tls = metrics.createPtr("proxy.process.tunnel.current_server_connections_tls"); + net_rsb.default_inactivity_timeout_applied = metrics.createPtr("proxy.process.net.default_inactivity_timeout_applied"); + net_rsb.default_inactivity_timeout_count = metrics.createPtr("proxy.process.net.default_inactivity_timeout_count"); + net_rsb.fastopen_attempts = metrics.createPtr("proxy.process.net.fastopen_out.attempts"); + net_rsb.fastopen_successes = metrics.createPtr("proxy.process.net.fastopen_out.successes"); + net_rsb.handler_run = metrics.createPtr("proxy.process.net.net_handler_run"); + net_rsb.inactivity_cop_lock_acquire_failure = metrics.createPtr("proxy.process.net.inactivity_cop_lock_acquire_failure"); + net_rsb.keep_alive_queue_timeout_count = metrics.createPtr("proxy.process.net.dynamic_keep_alive_timeout_in_count"); + net_rsb.keep_alive_queue_timeout_total = metrics.createPtr("proxy.process.net.dynamic_keep_alive_timeout_in_total"); + net_rsb.read_bytes = metrics.createPtr("proxy.process.net.read_bytes"); + net_rsb.read_bytes_count = metrics.createPtr("proxy.process.net.read_bytes_count"); + net_rsb.requests_max_throttled_in = metrics.createPtr("proxy.process.net.max.requests_throttled_in"); + net_rsb.socks_connections_currently_open = metrics.createPtr("proxy.process.socks.connections_currently_open"); + net_rsb.socks_connections_successful = metrics.createPtr("proxy.process.socks.connections_successful"); + net_rsb.socks_connections_unsuccessful = metrics.createPtr("proxy.process.socks.connections_unsuccessful"); + net_rsb.tcp_accept = metrics.createPtr("proxy.process.tcp.total_accepts"); + net_rsb.write_bytes = metrics.createPtr("proxy.process.net.write_bytes"); + net_rsb.write_bytes_count = metrics.createPtr("proxy.process.net.write_bytes_count"); } void diff --git a/src/iocore/net/NetHandler.cc b/src/iocore/net/NetHandler.cc index ead1ac8c0be..397ee71858d 100644 --- a/src/iocore/net/NetHandler.cc +++ b/src/iocore/net/NetHandler.cc @@ -326,7 +326,7 @@ NetHandler::waitForActivity(ink_hrtime timeout) IOUringContext *ur = IOUringContext::local_context(); #endif - Metrics::increment(net_rsb.handler_run); + Counter::increment(net_rsb.handler_run); SCOPED_MUTEX_LOCK(lock, mutex, this->thread); process_enabled_list(); @@ -481,8 +481,8 @@ NetHandler::_close_ne(NetEvent *ne, ink_hrtime now, int &handle_event, int &clos if (diff > 0) { total_idle_time += diff; ++total_idle_count; - Metrics::increment(net_rsb.keep_alive_queue_timeout_total, diff); - Metrics::increment(net_rsb.keep_alive_queue_timeout_count); + Counter::increment(net_rsb.keep_alive_queue_timeout_total, diff); + Counter::increment(net_rsb.keep_alive_queue_timeout_count); } Debug("net_queue", "closing connection NetEvent=%p idle: %u now: %" PRId64 " at: %" PRId64 " in: %" PRId64 " diff: %" PRId64, ne, keep_alive_queue_size, ink_hrtime_to_sec(now), ink_hrtime_to_sec(ne->next_inactivity_timeout_at), @@ -560,7 +560,7 @@ NetHandler::add_to_active_queue(NetEvent *ne) } else { if (active_queue_full) { // there is no room left in the queue - Metrics::increment(net_rsb.requests_max_throttled_in); + Counter::increment(net_rsb.requests_max_throttled_in); return false; } // in the keep-alive queue or no queue, new to this queue diff --git a/src/iocore/net/OCSPStapling.cc b/src/iocore/net/OCSPStapling.cc index f427cf85493..f56da3b51e2 100644 --- a/src/iocore/net/OCSPStapling.cc +++ b/src/iocore/net/OCSPStapling.cc @@ -985,10 +985,10 @@ stapling_check_response(certinfo *cinf, TS_OCSP_RESPONSE *rsp) case TS_OCSP_CERTSTATUS_GOOD: break; case TS_OCSP_CERTSTATUS_REVOKED: - Metrics::increment(ssl_rsb.ocsp_revoked_cert); + Counter::increment(ssl_rsb.ocsp_revoked_cert); break; case TS_OCSP_CERTSTATUS_UNKNOWN: - Metrics::increment(ssl_rsb.ocsp_unknown_cert); + Counter::increment(ssl_rsb.ocsp_unknown_cert); break; default: break; @@ -1281,10 +1281,10 @@ ocsp_update() ink_mutex_release(&cinf->stapling_mutex); if (stapling_refresh_response(cinf, &resp)) { Debug("ssl_ocsp", "Successfully refreshed OCSP for %s certificate. url=%s", cinf->certname, cinf->uri); - Metrics::increment(ssl_rsb.ocsp_refreshed_cert); + Counter::increment(ssl_rsb.ocsp_refreshed_cert); } else { Error("Failed to refresh OCSP for %s certificate. url=%s", cinf->certname, cinf->uri); - Metrics::increment(ssl_rsb.ocsp_refresh_cert_failure); + Counter::increment(ssl_rsb.ocsp_refresh_cert_failure); } } else { ink_mutex_release(&cinf->stapling_mutex); diff --git a/src/iocore/net/P_Net.h b/src/iocore/net/P_Net.h index 2a141ec2c2c..65f9c09c84c 100644 --- a/src/iocore/net/P_Net.h +++ b/src/iocore/net/P_Net.h @@ -31,53 +31,52 @@ #include "api/Metrics.h" -using ts::Metrics; - // Net Stats +using ts::Metrics::Counter; struct NetStatsBlock { - Metrics::IntType *accepts_currently_open; - Metrics::IntType *calls_to_read_nodata; - Metrics::IntType *calls_to_read; - Metrics::IntType *calls_to_readfromnet; - Metrics::IntType *calls_to_write_nodata; - Metrics::IntType *calls_to_write; - Metrics::IntType *calls_to_writetonet; - Metrics::IntType *connections_currently_open; - Metrics::IntType *connections_throttled_in; - Metrics::IntType *connections_throttled_out; - Metrics::IntType *default_inactivity_timeout_applied; - Metrics::IntType *default_inactivity_timeout_count; - Metrics::IntType *fastopen_attempts; - Metrics::IntType *fastopen_successes; - Metrics::IntType *handler_run; - Metrics::IntType *handler_run_count; - Metrics::IntType *inactivity_cop_lock_acquire_failure; - Metrics::IntType *keep_alive_queue_timeout_count; - Metrics::IntType *keep_alive_queue_timeout_total; - Metrics::IntType *read_bytes; - Metrics::IntType *read_bytes_count; - Metrics::IntType *requests_max_throttled_in; - Metrics::IntType *tunnel_total_client_connections_blind_tcp; - Metrics::IntType *tunnel_current_client_connections_blind_tcp; - Metrics::IntType *tunnel_total_server_connections_blind_tcp; - Metrics::IntType *tunnel_current_server_connections_blind_tcp; - Metrics::IntType *tunnel_total_client_connections_tls_tunnel; - Metrics::IntType *tunnel_current_client_connections_tls_tunnel; - Metrics::IntType *tunnel_total_server_connections_tls; - Metrics::IntType *tunnel_current_server_connections_tls; - Metrics::IntType *tunnel_total_client_connections_tls_forward; - Metrics::IntType *tunnel_current_client_connections_tls_forward; - Metrics::IntType *tunnel_total_client_connections_tls_partial_blind; - Metrics::IntType *tunnel_current_client_connections_tls_partial_blind; - Metrics::IntType *tunnel_total_client_connections_tls_http; - Metrics::IntType *tunnel_current_client_connections_tls_http; - Metrics::IntType *socks_connections_currently_open; - Metrics::IntType *socks_connections_successful; - Metrics::IntType *socks_connections_unsuccessful; - Metrics::IntType *tcp_accept; - Metrics::IntType *write_bytes; - Metrics::IntType *write_bytes_count; + Counter::AtomicType *accepts_currently_open; + Counter::AtomicType *calls_to_read_nodata; + Counter::AtomicType *calls_to_read; + Counter::AtomicType *calls_to_readfromnet; + Counter::AtomicType *calls_to_write_nodata; + Counter::AtomicType *calls_to_write; + Counter::AtomicType *calls_to_writetonet; + Counter::AtomicType *connections_currently_open; + Counter::AtomicType *connections_throttled_in; + Counter::AtomicType *connections_throttled_out; + Counter::AtomicType *default_inactivity_timeout_applied; + Counter::AtomicType *default_inactivity_timeout_count; + Counter::AtomicType *fastopen_attempts; + Counter::AtomicType *fastopen_successes; + Counter::AtomicType *handler_run; + Counter::AtomicType *handler_run_count; + Counter::AtomicType *inactivity_cop_lock_acquire_failure; + Counter::AtomicType *keep_alive_queue_timeout_count; + Counter::AtomicType *keep_alive_queue_timeout_total; + Counter::AtomicType *read_bytes; + Counter::AtomicType *read_bytes_count; + Counter::AtomicType *requests_max_throttled_in; + Counter::AtomicType *tunnel_total_client_connections_blind_tcp; + Counter::AtomicType *tunnel_current_client_connections_blind_tcp; + Counter::AtomicType *tunnel_total_server_connections_blind_tcp; + Counter::AtomicType *tunnel_current_server_connections_blind_tcp; + Counter::AtomicType *tunnel_total_client_connections_tls_tunnel; + Counter::AtomicType *tunnel_current_client_connections_tls_tunnel; + Counter::AtomicType *tunnel_total_server_connections_tls; + Counter::AtomicType *tunnel_current_server_connections_tls; + Counter::AtomicType *tunnel_total_client_connections_tls_forward; + Counter::AtomicType *tunnel_current_client_connections_tls_forward; + Counter::AtomicType *tunnel_total_client_connections_tls_partial_blind; + Counter::AtomicType *tunnel_current_client_connections_tls_partial_blind; + Counter::AtomicType *tunnel_total_client_connections_tls_http; + Counter::AtomicType *tunnel_current_client_connections_tls_http; + Counter::AtomicType *socks_connections_currently_open; + Counter::AtomicType *socks_connections_successful; + Counter::AtomicType *socks_connections_unsuccessful; + Counter::AtomicType *tcp_accept; + Counter::AtomicType *write_bytes; + Counter::AtomicType *write_bytes_count; }; extern NetStatsBlock net_rsb; diff --git a/src/iocore/net/P_UnixNet.h b/src/iocore/net/P_UnixNet.h index e4a8b00fddd..7d6399f53f3 100644 --- a/src/iocore/net/P_UnixNet.h +++ b/src/iocore/net/P_UnixNet.h @@ -93,7 +93,7 @@ TS_INLINE int net_connections_to_throttle(ThrottleType t) { double headroom = t == ACCEPT ? NET_THROTTLE_ACCEPT_HEADROOM : NET_THROTTLE_CONNECT_HEADROOM; - int currently_open = static_cast(Metrics::read(net_rsb.connections_currently_open)); + int currently_open = static_cast(Counter::read(net_rsb.connections_currently_open)); // deal with race if we got to multiple net threads if (currently_open < 0) { diff --git a/src/iocore/net/QUICNetProcessor.cc b/src/iocore/net/QUICNetProcessor.cc index 2c734c41be0..52ad0f5f9be 100644 --- a/src/iocore/net/QUICNetProcessor.cc +++ b/src/iocore/net/QUICNetProcessor.cc @@ -204,7 +204,7 @@ QUICNetProcessor::main_accept(Continuation *cont, SOCKET fd, AcceptOptions const if (accept_threads < 0) { REC_ReadConfigInteger(accept_threads, "proxy.config.accept_threads"); } - Metrics::increment(net_rsb.accepts_currently_open); + Counter::increment(net_rsb.accepts_currently_open); if (opt.localhost_only) { accept_ip.setToLoopback(opt.ip_family); diff --git a/src/iocore/net/QUICNetProcessor_quiche.cc b/src/iocore/net/QUICNetProcessor_quiche.cc index ff94792663f..1ddb087d405 100644 --- a/src/iocore/net/QUICNetProcessor_quiche.cc +++ b/src/iocore/net/QUICNetProcessor_quiche.cc @@ -227,7 +227,7 @@ QUICNetProcessor::main_accept(Continuation *cont, SOCKET fd, AcceptOptions const if (accept_threads < 0) { REC_ReadConfigInteger(accept_threads, "proxy.config.accept_threads"); } - Metrics::increment(net_rsb.accepts_currently_open); + Counter::increment(net_rsb.accepts_currently_open); if (opt.localhost_only) { accept_ip.setToLoopback(opt.ip_family); diff --git a/src/iocore/net/QUICNetVConnection.cc b/src/iocore/net/QUICNetVConnection.cc index ed2cefc5e73..61f791f5bb4 100644 --- a/src/iocore/net/QUICNetVConnection.cc +++ b/src/iocore/net/QUICNetVConnection.cc @@ -1570,7 +1570,7 @@ QUICNetVConnection::_state_common_send_packet() this->_context->trigger(QUICContext::CallbackEvent::METRICS_UPDATE, this->_congestion_controller->congestion_window(), this->_congestion_controller->bytes_in_flight(), this->_congestion_controller->current_ssthresh()); - Metrics::increment(quic_rsb.total_packets_sent_stat, packet_count); + Counter::increment(quic_rsb.total_packets_sent_stat, packet_count); net_activity(this, this_ethread()); } diff --git a/src/iocore/net/SSLDiags.cc b/src/iocore/net/SSLDiags.cc index d2e5483bfc8..9fc039f93d1 100644 --- a/src/iocore/net/SSLDiags.cc +++ b/src/iocore/net/SSLDiags.cc @@ -37,7 +37,7 @@ increment_ssl_client_error(unsigned long err) { // we only look for LIB_SSL errors atm if (ERR_LIB_SSL != ERR_GET_LIB(err)) { - Metrics::increment(ssl_rsb.user_agent_other_errors); + Counter::increment(ssl_rsb.user_agent_other_errors); return false; } @@ -46,31 +46,31 @@ increment_ssl_client_error(unsigned long err) // the error came from, hope that's ok?) switch (ERR_GET_REASON(err)) { case SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED: - Metrics::increment(ssl_rsb.user_agent_expired_cert); + Counter::increment(ssl_rsb.user_agent_expired_cert); break; case SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED: - Metrics::increment(ssl_rsb.user_agent_revoked_cert); + Counter::increment(ssl_rsb.user_agent_revoked_cert); break; case SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN: - Metrics::increment(ssl_rsb.user_agent_unknown_cert); + Counter::increment(ssl_rsb.user_agent_unknown_cert); break; case SSL_R_CERTIFICATE_VERIFY_FAILED: - Metrics::increment(ssl_rsb.user_agent_cert_verify_failed); + Counter::increment(ssl_rsb.user_agent_cert_verify_failed); break; case SSL_R_SSLV3_ALERT_BAD_CERTIFICATE: - Metrics::increment(ssl_rsb.user_agent_bad_cert); + Counter::increment(ssl_rsb.user_agent_bad_cert); break; case SSL_R_TLSV1_ALERT_DECRYPTION_FAILED: - Metrics::increment(ssl_rsb.user_agent_decryption_failed); + Counter::increment(ssl_rsb.user_agent_decryption_failed); break; case SSL_R_WRONG_VERSION_NUMBER: - Metrics::increment(ssl_rsb.user_agent_wrong_version); + Counter::increment(ssl_rsb.user_agent_wrong_version); break; case SSL_R_TLSV1_ALERT_UNKNOWN_CA: - Metrics::increment(ssl_rsb.user_agent_unknown_ca); + Counter::increment(ssl_rsb.user_agent_unknown_ca); break; default: - Metrics::increment(ssl_rsb.user_agent_other_errors); + Counter::increment(ssl_rsb.user_agent_other_errors); return false; } @@ -84,7 +84,7 @@ increment_ssl_server_error(unsigned long err) { // we only look for LIB_SSL errors atm if (ERR_LIB_SSL != ERR_GET_LIB(err)) { - Metrics::increment(ssl_rsb.origin_server_other_errors); + Counter::increment(ssl_rsb.origin_server_other_errors); return false; } @@ -93,31 +93,31 @@ increment_ssl_server_error(unsigned long err) // the error came from, hope that's ok?) switch (ERR_GET_REASON(err)) { case SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED: - Metrics::increment(ssl_rsb.origin_server_expired_cert); + Counter::increment(ssl_rsb.origin_server_expired_cert); break; case SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED: - Metrics::increment(ssl_rsb.origin_server_revoked_cert); + Counter::increment(ssl_rsb.origin_server_revoked_cert); break; case SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN: - Metrics::increment(ssl_rsb.origin_server_unknown_cert); + Counter::increment(ssl_rsb.origin_server_unknown_cert); break; case SSL_R_CERTIFICATE_VERIFY_FAILED: - Metrics::increment(ssl_rsb.origin_server_cert_verify_failed); + Counter::increment(ssl_rsb.origin_server_cert_verify_failed); break; case SSL_R_SSLV3_ALERT_BAD_CERTIFICATE: - Metrics::increment(ssl_rsb.origin_server_bad_cert); + Counter::increment(ssl_rsb.origin_server_bad_cert); break; case SSL_R_TLSV1_ALERT_DECRYPTION_FAILED: - Metrics::increment(ssl_rsb.origin_server_decryption_failed); + Counter::increment(ssl_rsb.origin_server_decryption_failed); break; case SSL_R_WRONG_VERSION_NUMBER: - Metrics::increment(ssl_rsb.origin_server_wrong_version); + Counter::increment(ssl_rsb.origin_server_wrong_version); break; case SSL_R_TLSV1_ALERT_UNKNOWN_CA: - Metrics::increment(ssl_rsb.origin_server_unknown_ca); + Counter::increment(ssl_rsb.origin_server_unknown_ca); break; default: - Metrics::increment(ssl_rsb.origin_server_other_errors); + Counter::increment(ssl_rsb.origin_server_other_errors); return false; } diff --git a/src/iocore/net/SSLNetVConnection.cc b/src/iocore/net/SSLNetVConnection.cc index 4f36f41ff12..91b96d7e52c 100644 --- a/src/iocore/net/SSLNetVConnection.cc +++ b/src/iocore/net/SSLNetVConnection.cc @@ -349,7 +349,7 @@ SSLNetVConnection::_ssl_read_from_net(EThread *lthread, int64_t &ret) case SSL_ERROR_SYSCALL: if (nread != 0) { // not EOF - Metrics::increment(ssl_rsb.error_syscall); + Counter::increment(ssl_rsb.error_syscall); event = SSL_READ_ERROR; ret = errno; Dbg(dbg_ctl_ssl_error, "SSL_ERROR_SYSCALL, underlying IO error: %s", strerror(errno)); @@ -370,7 +370,7 @@ SSLNetVConnection::_ssl_read_from_net(EThread *lthread, int64_t &ret) event = SSL_READ_ERROR; ret = errno; SSLVCDebug(this, "errno=%d", errno); - Metrics::increment(ssl_rsb.error_ssl); + Counter::increment(ssl_rsb.error_ssl); } break; } // switch } // while @@ -421,7 +421,7 @@ SSLNetVConnection::read_raw_data() b = b->next.get(); r = SocketManager::read(this->con.fd, buffer, buf_len); - Metrics::increment(net_rsb.calls_to_read); + Counter::increment(net_rsb.calls_to_read); total_read += rattempted; Dbg(dbg_ctl_ssl, "read_raw_data r=%" PRId64 " rattempted=%" PRId64 " total_read=%" PRId64 " fd=%d", r, rattempted, total_read, @@ -443,8 +443,8 @@ SSLNetVConnection::read_raw_data() r = total_read - rattempted + r; } } - Metrics::increment(net_rsb.read_bytes, r); - Metrics::increment(net_rsb.read_bytes_count); + Counter::increment(net_rsb.read_bytes, r); + Counter::increment(net_rsb.read_bytes_count); swoc::IPRangeSet *pp_ipmap; pp_ipmap = SSLConfigParams::proxy_protocol_ip_addrs; @@ -514,7 +514,7 @@ SSLNetVConnection::read_raw_data() // check for errors if (r <= 0) { if (r == -EAGAIN || r == -ENOTCONN) { - Metrics::increment(net_rsb.calls_to_read_nodata); + Counter::increment(net_rsb.calls_to_read_nodata); } } @@ -838,10 +838,10 @@ SSLNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor &buf } else if (SSLConfigParams::ssl_maxrecord == -1) { if (sslTotalBytesSent < SSL_DEF_TLS_RECORD_BYTE_THRESHOLD) { dynamic_tls_record_size = SSL_DEF_TLS_RECORD_SIZE; - Metrics::increment(ssl_rsb.total_dyn_def_tls_record_count); + Counter::increment(ssl_rsb.total_dyn_def_tls_record_count); } else { dynamic_tls_record_size = SSL_MAX_TLS_RECORD_SIZE; - Metrics::increment(ssl_rsb.total_dyn_max_tls_record_count); + Counter::increment(ssl_rsb.total_dyn_max_tls_record_count); } if (l > dynamic_tls_record_size) { l = dynamic_tls_record_size; @@ -866,7 +866,7 @@ SSLNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor &buf Dbg(dbg_ctl_ssl, "try_to_write=%" PRId64 " written=%" PRId64 " total_written=%" PRId64, try_to_write, num_really_written, total_written); - Metrics::increment(net_rsb.calls_to_write); + Counter::increment(net_rsb.calls_to_write); } while (num_really_written == try_to_write && total_written < towrite); if (total_written > 0) { @@ -903,7 +903,7 @@ SSLNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor &buf // SSL_ERROR_SYSCALL is an IO error. errno is likely 0, so set EPIPE, as // we do with SSL_ERROR_SSL below, to indicate a connection error. num_really_written = -EPIPE; - Metrics::increment(ssl_rsb.error_syscall); + Counter::increment(ssl_rsb.error_syscall); Dbg(dbg_ctl_ssl_error, "SSL_write-SSL_ERROR_SYSCALL"); break; // end of stream @@ -916,7 +916,7 @@ SSLNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor &buf // Treat SSL_ERROR_SSL as EPIPE error. num_really_written = -EPIPE; SSLVCDebug(this, "SSL_write-SSL_ERROR_SSL errno=%d", errno); - Metrics::increment(ssl_rsb.error_ssl); + Counter::increment(ssl_rsb.error_ssl); } break; } } @@ -1031,14 +1031,14 @@ SSLNetVConnection::free_thread(EThread *t) // close socket fd if (con.fd != NO_FD) { - Metrics::decrement(net_rsb.connections_currently_open); + Counter::decrement(net_rsb.connections_currently_open); } con.close(); if (is_tunnel_endpoint()) { ink_assert(get_context() != NET_VCONNECTION_UNSET); - Metrics::decrement(([&]() -> Metrics::IntType * { + Counter::decrement(([&]() -> Counter::AtomicType * { if (get_context() == NET_VCONNECTION_IN) { switch (get_tunnel_type()) { case SNIRoutingType::BLIND: @@ -1251,7 +1251,7 @@ SSLNetVConnection::sslStartHandShake(int event, int &err) Dbg(dbg_ctl_ssl, "using SNI name '%s' for client handshake", tlsext_host_name.get()); } else { Dbg(dbg_ctl_ssl_error, "failed to set SNI name '%s' for client handshake", tlsext_host_name.get()); - Metrics::increment(ssl_rsb.sni_name_set_failure); + Counter::increment(ssl_rsb.sni_name_set_failure); } } @@ -1285,7 +1285,7 @@ SSLNetVConnection::sslServerHandShakeEvent(int &err) // Go do the preaccept hooks if (sslHandshakeHookState == HANDSHAKE_HOOKS_PRE) { - Metrics::increment(ssl_rsb.total_attempts_handshake_count_in); + Counter::increment(ssl_rsb.total_attempts_handshake_count_in); if (!curHook) { Dbg(dbg_ctl_ssl, "Initialize preaccept curHook from NULL"); curHook = g_ssl_hooks->get(TSSslHookInternalID(TS_VCONN_START_HOOK)); @@ -1435,7 +1435,7 @@ SSLNetVConnection::sslServerHandShakeEvent(int &err) if (this->get_tls_handshake_begin_time()) { this->_record_tls_handshake_end_time(); - Metrics::increment(ssl_rsb.total_success_handshake_count_in); + Counter::increment(ssl_rsb.total_success_handshake_count_in); } if (this->get_tunnel_type() != SNIRoutingType::NONE) { @@ -1517,7 +1517,7 @@ SSLNetVConnection::sslServerHandShakeEvent(int &err) #if TS_USE_TLS_ASYNC case SSL_ERROR_WANT_ASYNC: - Metrics::increment(ssl_rsb.error_async); + Counter::increment(ssl_rsb.error_async); return SSL_WAIT_FOR_ASYNC; #endif @@ -1587,7 +1587,7 @@ SSLNetVConnection::sslClientHandShakeEvent(int &err) // Go do the preaccept hooks if (sslHandshakeHookState == HANDSHAKE_HOOKS_OUTBOUND_PRE) { - Metrics::increment(ssl_rsb.total_attempts_handshake_count_out); + Counter::increment(ssl_rsb.total_attempts_handshake_count_out); if (!curHook) { Dbg(dbg_ctl_ssl, "Initialize outbound connect curHook from NULL"); curHook = g_ssl_hooks->get(TSSslHookInternalID(TS_VCONN_OUTBOUND_START_HOOK)); @@ -1637,7 +1637,7 @@ SSLNetVConnection::sslClientHandShakeEvent(int &err) writeReschedule(nh); } - Metrics::increment(ssl_rsb.total_success_handshake_count_out); + Counter::increment(ssl_rsb.total_success_handshake_count_out); sslHandshakeStatus = SSLHandshakeStatus::SSL_HANDSHAKE_DONE; return EVENT_DONE; @@ -1670,7 +1670,7 @@ SSLNetVConnection::sslClientHandShakeEvent(int &err) case SSL_ERROR_SYSCALL: err = errno; - Metrics::increment(ssl_rsb.error_syscall); + Counter::increment(ssl_rsb.error_syscall); Dbg(dbg_ctl_ssl_error, "syscall"); return EVENT_ERROR; break; @@ -1683,7 +1683,7 @@ SSLNetVConnection::sslClientHandShakeEvent(int &err) ERR_error_string_n(e, buf, sizeof(buf)); // FIXME -- This triggers a retry on cases of cert validation errors... SSLVCDebug(this, "SSL_ERROR_SSL errno=%d", errno); - Metrics::increment(ssl_rsb.error_ssl); + Counter::increment(ssl_rsb.error_ssl); Dbg(dbg_ctl_ssl_error, "SSL_ERROR_SSL"); if (e) { if (this->options.sni_servername) { @@ -1986,7 +1986,7 @@ SSLNetVConnection::_in_context_tunnel() { ink_assert(get_context() == NET_VCONNECTION_IN); - Metrics::IntType *t, *c; + Counter::AtomicType *t, *c; switch (get_tunnel_type()) { case SNIRoutingType::BLIND: @@ -2006,8 +2006,8 @@ SSLNetVConnection::_in_context_tunnel() c = net_rsb.tunnel_current_client_connections_tls_http; break; } - Metrics::increment(t); - Metrics::increment(c); + Counter::increment(t); + Counter::increment(c); } void @@ -2018,8 +2018,8 @@ SSLNetVConnection::_out_context_tunnel() // Never a tunnel type for out (to server) context. ink_assert(get_tunnel_type() == SNIRoutingType::NONE); - Metrics::increment(net_rsb.tunnel_total_server_connections_tls); - Metrics::increment(net_rsb.tunnel_current_server_connections_tls); + Counter::increment(net_rsb.tunnel_total_server_connections_tls); + Counter::increment(net_rsb.tunnel_current_server_connections_tls); } void @@ -2027,20 +2027,20 @@ SSLNetVConnection::increment_ssl_version_metric(int version) const { switch (version) { case SSL3_VERSION: - Metrics::increment(ssl_rsb.total_sslv3); + Counter::increment(ssl_rsb.total_sslv3); break; case TLS1_VERSION: - Metrics::increment(ssl_rsb.total_tlsv1); + Counter::increment(ssl_rsb.total_tlsv1); break; case TLS1_1_VERSION: - Metrics::increment(ssl_rsb.total_tlsv11); + Counter::increment(ssl_rsb.total_tlsv11); break; case TLS1_2_VERSION: - Metrics::increment(ssl_rsb.total_tlsv12); + Counter::increment(ssl_rsb.total_tlsv12); break; #ifdef TLS1_3_VERSION case TLS1_3_VERSION: - Metrics::increment(ssl_rsb.total_tlsv13); + Counter::increment(ssl_rsb.total_tlsv13); break; #endif default: @@ -2384,7 +2384,7 @@ SSLNetVConnection::_ssl_accept() } block->fill(nread); this->_early_data_buf->append_block(block); - Metrics::increment(ssl_rsb.early_data_received_count); + Counter::increment(ssl_rsb.early_data_received_count); if (dbg_ctl_ssl_early_data_show_received.on()) { std::string early_data_str(reinterpret_cast(block->buf()), nread); @@ -2459,7 +2459,7 @@ SSLNetVConnection::_ssl_connect() if (ret > 0) { if (SSL_session_reused(ssl)) { - Metrics::increment(ssl_rsb.origin_session_reused_count); + Counter::increment(ssl_rsb.origin_session_reused_count); Dbg(dbg_ctl_ssl_origin_session_cache, "reused session to origin server"); } else { Dbg(dbg_ctl_ssl_origin_session_cache, "new session to origin server"); @@ -2611,7 +2611,7 @@ SSLNetVConnection::_ssl_read_buffer(void *buf, int64_t nbytes, int64_t &nread) } else { if ((nread = read_bytes) > 0) { this->_increment_early_data_len(read_bytes); - Metrics::increment(ssl_rsb.early_data_received_count); + Counter::increment(ssl_rsb.early_data_received_count); if (dbg_ctl_ssl_early_data_show_received.on()) { std::string early_data_str(reinterpret_cast(buf), nread); DbgPrint(dbg_ctl_ssl_early_data_show_received, "Early data buffer: \n%s", early_data_str.c_str()); diff --git a/src/iocore/net/SSLSessionCache.cc b/src/iocore/net/SSLSessionCache.cc index e978ffc3d22..1f8ef388dcd 100644 --- a/src/iocore/net/SSLSessionCache.cc +++ b/src/iocore/net/SSLSessionCache.cc @@ -91,7 +91,7 @@ SSLSessionCache::removeSession(const SSLSessionID &sid) Debug("ssl.session_cache.remove", "SessionCache using bucket %" PRId64 " (%p): Removing session '%s' (hash: %" PRIX64 ").", target_bucket, bucket, buf, hash); } - Metrics::increment(ssl_rsb.session_cache_eviction); + Counter::increment(ssl_rsb.session_cache_eviction); bucket->removeSession(sid); } @@ -118,7 +118,7 @@ SSLSessionBucket::insertSession(const SSLSessionID &id, SSL_SESSION *sess, SSL * { std::shared_lock r_lock(mutex, std::try_to_lock); if (!r_lock.owns_lock()) { - Metrics::increment(ssl_rsb.session_cache_lock_contention); + Counter::increment(ssl_rsb.session_cache_lock_contention); if (SSLConfigParams::session_cache_skip_on_lock_contention) { return; } @@ -162,7 +162,7 @@ SSLSessionBucket::insertSession(const SSLSessionID &id, SSL_SESSION *sess, SSL * std::unique_lock w_lock(mutex, std::try_to_lock); if (!w_lock.owns_lock()) { - Metrics::increment(ssl_rsb.session_cache_lock_contention); + Counter::increment(ssl_rsb.session_cache_lock_contention); if (SSLConfigParams::session_cache_skip_on_lock_contention) { return; } @@ -171,7 +171,7 @@ SSLSessionBucket::insertSession(const SSLSessionID &id, SSL_SESSION *sess, SSL * PRINT_BUCKET("insertSession before") if (bucket_map.size() >= SSLConfigParams::session_cache_max_bucket_size) { - Metrics::increment(ssl_rsb.session_cache_eviction); + Counter::increment(ssl_rsb.session_cache_eviction); removeOldestSession(w_lock); } @@ -189,7 +189,7 @@ SSLSessionBucket::getSessionBuffer(const SSLSessionID &id, char *buffer, int &le int true_len = 0; std::shared_lock lock(mutex, std::try_to_lock); if (!lock.owns_lock()) { - Metrics::increment(ssl_rsb.session_cache_lock_contention); + Counter::increment(ssl_rsb.session_cache_lock_contention); if (SSLConfigParams::session_cache_skip_on_lock_contention) { return true_len; } @@ -222,7 +222,7 @@ SSLSessionBucket::getSession(const SSLSessionID &id, SSL_SESSION **sess, ssl_ses std::shared_lock lock(mutex, std::try_to_lock); if (!lock.owns_lock()) { - Metrics::increment(ssl_rsb.session_cache_lock_contention); + Counter::increment(ssl_rsb.session_cache_lock_contention); if (SSLConfigParams::session_cache_skip_on_lock_contention) { return false; } diff --git a/src/iocore/net/SSLStats.cc b/src/iocore/net/SSLStats.cc index 6518d937f6c..a3f328bea8a 100644 --- a/src/iocore/net/SSLStats.cc +++ b/src/iocore/net/SSLStats.cc @@ -30,7 +30,7 @@ #include "../../records/P_RecProcess.h" SSLStatsBlock ssl_rsb; -std::unordered_map cipher_map; +std::unordered_map cipher_map; // ToDo: This gets called once per global sync, for now at least. void @@ -60,10 +60,10 @@ SSLPeriodicMetricsUpdate() } } - Metrics::write(ssl_rsb.user_agent_sessions, sessions); - Metrics::write(ssl_rsb.user_agent_session_hit, hits); - Metrics::write(ssl_rsb.user_agent_session_miss, misses); - Metrics::write(ssl_rsb.user_agent_session_timeout, timeouts); + Counter::write(ssl_rsb.user_agent_sessions, sessions); + Counter::write(ssl_rsb.user_agent_session_hit, hits); + Counter::write(ssl_rsb.user_agent_session_miss, misses); + Counter::write(ssl_rsb.user_agent_session_timeout, timeouts); } static void @@ -71,8 +71,8 @@ add_cipher_stat(const char *cipherName, const std::string &statName) { // If not already registered ... if (cipherName && cipher_map.find(cipherName) == cipher_map.end()) { - ts::Metrics &intm = ts::Metrics::getInstance(); - ts::Metrics::IntType *metric = intm.newMetricPtr(statName); + ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); + Counter::AtomicType *metric = metrics.createPtr(statName); cipher_map.emplace(cipherName, metric); Debug("ssl", "registering SSL cipher metric '%s'", statName.c_str()); @@ -85,69 +85,69 @@ SSLInitializeStatistics() SSL_CTX *ctx; SSL *ssl; STACK_OF(SSL_CIPHER) * ciphers; - ts::Metrics &intm = ts::Metrics::getInstance(); + ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); // For now, register with the librecords global sync. RecRegNewSyncStatSync(SSLPeriodicMetricsUpdate); - ssl_rsb.early_data_received_count = intm.newMetricPtr("proxy.process.ssl.early_data_received"); - ssl_rsb.error_async = intm.newMetricPtr("proxy.process.ssl.ssl_error_async"); - ssl_rsb.error_ssl = intm.newMetricPtr("proxy.process.ssl.ssl_error_ssl"); - ssl_rsb.error_syscall = intm.newMetricPtr("proxy.process.ssl.ssl_error_syscall"); - ssl_rsb.ocsp_refresh_cert_failure = intm.newMetricPtr("proxy.process.ssl.ssl_ocsp_refresh_cert_failure"); - ssl_rsb.ocsp_refreshed_cert = intm.newMetricPtr("proxy.process.ssl.ssl_ocsp_refreshed_cert"); - ssl_rsb.ocsp_revoked_cert = intm.newMetricPtr("proxy.process.ssl.ssl_ocsp_revoked_cert"); - ssl_rsb.ocsp_unknown_cert = intm.newMetricPtr("proxy.process.ssl.ssl_ocsp_unknown_cert"); - ssl_rsb.origin_server_bad_cert = intm.newMetricPtr("proxy.process.ssl.origin_server_bad_cert"); - ssl_rsb.origin_server_cert_verify_failed = intm.newMetricPtr("proxy.process.ssl.origin_server_cert_verify_failed"); - ssl_rsb.origin_server_decryption_failed = intm.newMetricPtr("proxy.process.ssl.origin_server_decryption_failed"); - ssl_rsb.origin_server_expired_cert = intm.newMetricPtr("proxy.process.ssl.origin_server_expired_cert"); - ssl_rsb.origin_server_other_errors = intm.newMetricPtr("proxy.process.ssl.origin_server_other_errors"); - ssl_rsb.origin_server_revoked_cert = intm.newMetricPtr("proxy.process.ssl.origin_server_revoked_cert"); - ssl_rsb.origin_server_unknown_ca = intm.newMetricPtr("proxy.process.ssl.origin_server_unknown_ca"); - ssl_rsb.origin_server_unknown_cert = intm.newMetricPtr("proxy.process.ssl.origin_server_unknown_cert"); - ssl_rsb.origin_server_wrong_version = intm.newMetricPtr("proxy.process.ssl.origin_server_wrong_version"); - ssl_rsb.origin_session_reused_count = intm.newMetricPtr("proxy.process.ssl.origin_session_reused"); - ssl_rsb.sni_name_set_failure = intm.newMetricPtr("proxy.process.ssl.ssl_sni_name_set_failure"); - ssl_rsb.origin_session_cache_hit = intm.newMetricPtr("proxy.process.ssl.ssl_origin_session_cache_hit"); - ssl_rsb.origin_session_cache_miss = intm.newMetricPtr("proxy.process.ssl.ssl_origin_session_cache_miss"); - ssl_rsb.session_cache_eviction = intm.newMetricPtr("proxy.process.ssl.ssl_session_cache_eviction"); - ssl_rsb.session_cache_hit = intm.newMetricPtr("proxy.process.ssl.ssl_session_cache_hit"); - ssl_rsb.session_cache_lock_contention = intm.newMetricPtr("proxy.process.ssl.ssl_session_cache_lock_contention"); - ssl_rsb.session_cache_miss = intm.newMetricPtr("proxy.process.ssl.ssl_session_cache_miss"); - ssl_rsb.session_cache_new_session = intm.newMetricPtr("proxy.process.ssl.ssl_session_cache_new_session"); - ssl_rsb.total_attempts_handshake_count_in = intm.newMetricPtr("proxy.process.ssl.total_attempts_handshake_count_in"); - ssl_rsb.total_attempts_handshake_count_out = intm.newMetricPtr("proxy.process.ssl.total_attempts_handshake_count_out"); - ssl_rsb.total_dyn_def_tls_record_count = intm.newMetricPtr("proxy.process.ssl.default_record_size_count"); - ssl_rsb.total_dyn_max_tls_record_count = intm.newMetricPtr("proxy.process.ssl.max_record_size_count"); - ssl_rsb.total_dyn_redo_tls_record_count = intm.newMetricPtr("proxy.process.ssl.redo_record_size_count"); - ssl_rsb.total_handshake_time = intm.newMetricPtr("proxy.process.ssl.total_handshake_time"); - ssl_rsb.total_sslv3 = intm.newMetricPtr("proxy.process.ssl.ssl_total_sslv3"); - ssl_rsb.total_success_handshake_count_in = intm.newMetricPtr("proxy.process.ssl.total_success_handshake_count_in"); - ssl_rsb.total_success_handshake_count_out = intm.newMetricPtr("proxy.process.ssl.total_success_handshake_count_out"); - ssl_rsb.total_ticket_keys_renewed = intm.newMetricPtr("proxy.process.ssl.total_ticket_keys_renewed"); - ssl_rsb.total_tickets_created = intm.newMetricPtr("proxy.process.ssl.total_tickets_created"); - ssl_rsb.total_tickets_not_found = intm.newMetricPtr("proxy.process.ssl.total_tickets_not_found"); - ssl_rsb.total_tickets_renewed = intm.newMetricPtr("proxy.process.ssl.total_tickets_renewed"); // ToDo: Not used? - ssl_rsb.total_tickets_verified = intm.newMetricPtr("proxy.process.ssl.total_tickets_verified"); - ssl_rsb.total_tickets_verified_old_key = intm.newMetricPtr("proxy.process.ssl.total_tickets_verified_old_key"); - ssl_rsb.total_tlsv1 = intm.newMetricPtr("proxy.process.ssl.ssl_total_tlsv1"); - ssl_rsb.total_tlsv11 = intm.newMetricPtr("proxy.process.ssl.ssl_total_tlsv11"); - ssl_rsb.total_tlsv12 = intm.newMetricPtr("proxy.process.ssl.ssl_total_tlsv12"); - ssl_rsb.total_tlsv13 = intm.newMetricPtr("proxy.process.ssl.ssl_total_tlsv13"); - ssl_rsb.user_agent_bad_cert = intm.newMetricPtr("proxy.process.ssl.user_agent_bad_cert"); - ssl_rsb.user_agent_cert_verify_failed = intm.newMetricPtr("proxy.process.ssl.user_agent_cert_verify_failed"); - ssl_rsb.user_agent_decryption_failed = intm.newMetricPtr("proxy.process.ssl.user_agent_decryption_failed"); - ssl_rsb.user_agent_expired_cert = intm.newMetricPtr("proxy.process.ssl.user_agent_expired_cert"); - ssl_rsb.user_agent_other_errors = intm.newMetricPtr("proxy.process.ssl.user_agent_other_errors"); - ssl_rsb.user_agent_revoked_cert = intm.newMetricPtr("proxy.process.ssl.user_agent_revoked_cert"); - ssl_rsb.user_agent_session_hit = intm.newMetricPtr("proxy.process.ssl.user_agent_session_hit"); - ssl_rsb.user_agent_session_miss = intm.newMetricPtr("proxy.process.ssl.user_agent_session_miss"); - ssl_rsb.user_agent_session_timeout = intm.newMetricPtr("proxy.process.ssl.user_agent_session_timeout"); - ssl_rsb.user_agent_sessions = intm.newMetricPtr("proxy.process.ssl.user_agent_sessions"); - ssl_rsb.user_agent_unknown_ca = intm.newMetricPtr("proxy.process.ssl.user_agent_unknown_ca"); - ssl_rsb.user_agent_unknown_cert = intm.newMetricPtr("proxy.process.ssl.user_agent_unknown_cert"); - ssl_rsb.user_agent_wrong_version = intm.newMetricPtr("proxy.process.ssl.user_agent_wrong_version"); + ssl_rsb.early_data_received_count = metrics.createPtr("proxy.process.ssl.early_data_received"); + ssl_rsb.error_async = metrics.createPtr("proxy.process.ssl.ssl_error_async"); + ssl_rsb.error_ssl = metrics.createPtr("proxy.process.ssl.ssl_error_ssl"); + ssl_rsb.error_syscall = metrics.createPtr("proxy.process.ssl.ssl_error_syscall"); + ssl_rsb.ocsp_refresh_cert_failure = metrics.createPtr("proxy.process.ssl.ssl_ocsp_refresh_cert_failure"); + ssl_rsb.ocsp_refreshed_cert = metrics.createPtr("proxy.process.ssl.ssl_ocsp_refreshed_cert"); + ssl_rsb.ocsp_revoked_cert = metrics.createPtr("proxy.process.ssl.ssl_ocsp_revoked_cert"); + ssl_rsb.ocsp_unknown_cert = metrics.createPtr("proxy.process.ssl.ssl_ocsp_unknown_cert"); + ssl_rsb.origin_server_bad_cert = metrics.createPtr("proxy.process.ssl.origin_server_bad_cert"); + ssl_rsb.origin_server_cert_verify_failed = metrics.createPtr("proxy.process.ssl.origin_server_cert_verify_failed"); + ssl_rsb.origin_server_decryption_failed = metrics.createPtr("proxy.process.ssl.origin_server_decryption_failed"); + ssl_rsb.origin_server_expired_cert = metrics.createPtr("proxy.process.ssl.origin_server_expired_cert"); + ssl_rsb.origin_server_other_errors = metrics.createPtr("proxy.process.ssl.origin_server_other_errors"); + ssl_rsb.origin_server_revoked_cert = metrics.createPtr("proxy.process.ssl.origin_server_revoked_cert"); + ssl_rsb.origin_server_unknown_ca = metrics.createPtr("proxy.process.ssl.origin_server_unknown_ca"); + ssl_rsb.origin_server_unknown_cert = metrics.createPtr("proxy.process.ssl.origin_server_unknown_cert"); + ssl_rsb.origin_server_wrong_version = metrics.createPtr("proxy.process.ssl.origin_server_wrong_version"); + ssl_rsb.origin_session_reused_count = metrics.createPtr("proxy.process.ssl.origin_session_reused"); + ssl_rsb.sni_name_set_failure = metrics.createPtr("proxy.process.ssl.ssl_sni_name_set_failure"); + ssl_rsb.origin_session_cache_hit = metrics.createPtr("proxy.process.ssl.ssl_origin_session_cache_hit"); + ssl_rsb.origin_session_cache_miss = metrics.createPtr("proxy.process.ssl.ssl_origin_session_cache_miss"); + ssl_rsb.session_cache_eviction = metrics.createPtr("proxy.process.ssl.ssl_session_cache_eviction"); + ssl_rsb.session_cache_hit = metrics.createPtr("proxy.process.ssl.ssl_session_cache_hit"); + ssl_rsb.session_cache_lock_contention = metrics.createPtr("proxy.process.ssl.ssl_session_cache_lock_contention"); + ssl_rsb.session_cache_miss = metrics.createPtr("proxy.process.ssl.ssl_session_cache_miss"); + ssl_rsb.session_cache_new_session = metrics.createPtr("proxy.process.ssl.ssl_session_cache_new_session"); + ssl_rsb.total_attempts_handshake_count_in = metrics.createPtr("proxy.process.ssl.total_attempts_handshake_count_in"); + ssl_rsb.total_attempts_handshake_count_out = metrics.createPtr("proxy.process.ssl.total_attempts_handshake_count_out"); + ssl_rsb.total_dyn_def_tls_record_count = metrics.createPtr("proxy.process.ssl.default_record_size_count"); + ssl_rsb.total_dyn_max_tls_record_count = metrics.createPtr("proxy.process.ssl.max_record_size_count"); + ssl_rsb.total_dyn_redo_tls_record_count = metrics.createPtr("proxy.process.ssl.redo_record_size_count"); + ssl_rsb.total_handshake_time = metrics.createPtr("proxy.process.ssl.total_handshake_time"); + ssl_rsb.total_sslv3 = metrics.createPtr("proxy.process.ssl.ssl_total_sslv3"); + ssl_rsb.total_success_handshake_count_in = metrics.createPtr("proxy.process.ssl.total_success_handshake_count_in"); + ssl_rsb.total_success_handshake_count_out = metrics.createPtr("proxy.process.ssl.total_success_handshake_count_out"); + ssl_rsb.total_ticket_keys_renewed = metrics.createPtr("proxy.process.ssl.total_ticket_keys_renewed"); + ssl_rsb.total_tickets_created = metrics.createPtr("proxy.process.ssl.total_tickets_created"); + ssl_rsb.total_tickets_not_found = metrics.createPtr("proxy.process.ssl.total_tickets_not_found"); + ssl_rsb.total_tickets_renewed = metrics.createPtr("proxy.process.ssl.total_tickets_renewed"); // ToDo: Not used? + ssl_rsb.total_tickets_verified = metrics.createPtr("proxy.process.ssl.total_tickets_verified"); + ssl_rsb.total_tickets_verified_old_key = metrics.createPtr("proxy.process.ssl.total_tickets_verified_old_key"); + ssl_rsb.total_tlsv1 = metrics.createPtr("proxy.process.ssl.ssl_total_tlsv1"); + ssl_rsb.total_tlsv11 = metrics.createPtr("proxy.process.ssl.ssl_total_tlsv11"); + ssl_rsb.total_tlsv12 = metrics.createPtr("proxy.process.ssl.ssl_total_tlsv12"); + ssl_rsb.total_tlsv13 = metrics.createPtr("proxy.process.ssl.ssl_total_tlsv13"); + ssl_rsb.user_agent_bad_cert = metrics.createPtr("proxy.process.ssl.user_agent_bad_cert"); + ssl_rsb.user_agent_cert_verify_failed = metrics.createPtr("proxy.process.ssl.user_agent_cert_verify_failed"); + ssl_rsb.user_agent_decryption_failed = metrics.createPtr("proxy.process.ssl.user_agent_decryption_failed"); + ssl_rsb.user_agent_expired_cert = metrics.createPtr("proxy.process.ssl.user_agent_expired_cert"); + ssl_rsb.user_agent_other_errors = metrics.createPtr("proxy.process.ssl.user_agent_other_errors"); + ssl_rsb.user_agent_revoked_cert = metrics.createPtr("proxy.process.ssl.user_agent_revoked_cert"); + ssl_rsb.user_agent_session_hit = metrics.createPtr("proxy.process.ssl.user_agent_session_hit"); + ssl_rsb.user_agent_session_miss = metrics.createPtr("proxy.process.ssl.user_agent_session_miss"); + ssl_rsb.user_agent_session_timeout = metrics.createPtr("proxy.process.ssl.user_agent_session_timeout"); + ssl_rsb.user_agent_sessions = metrics.createPtr("proxy.process.ssl.user_agent_sessions"); + ssl_rsb.user_agent_unknown_ca = metrics.createPtr("proxy.process.ssl.user_agent_unknown_ca"); + ssl_rsb.user_agent_unknown_cert = metrics.createPtr("proxy.process.ssl.user_agent_unknown_cert"); + ssl_rsb.user_agent_wrong_version = metrics.createPtr("proxy.process.ssl.user_agent_wrong_version"); // Get and register the SSL cipher stats. Note that we are using the default SSL context to obtain // the cipher list. This means that the set of ciphers is fixed by the build configuration and not diff --git a/src/iocore/net/SSLStats.h b/src/iocore/net/SSLStats.h index b57150846f3..a3d0c267ab9 100644 --- a/src/iocore/net/SSLStats.h +++ b/src/iocore/net/SSLStats.h @@ -30,75 +30,75 @@ #include "api/Metrics.h" -using ts::Metrics; +using ts::Metrics::Counter; // For some odd reason, these have to be initialized with nullptr, because the order // of initialization and how we load certs is weird... In reality only the metric // for ssl_rsb.total_ticket_keys_renewed needs this initialization, but lets be // consistent at least. struct SSLStatsBlock { - ts::Metrics::IntType *early_data_received_count = nullptr; - ts::Metrics::IntType *error_async = nullptr; - ts::Metrics::IntType *error_ssl = nullptr; - ts::Metrics::IntType *error_syscall = nullptr; - ts::Metrics::IntType *ocsp_refresh_cert_failure = nullptr; - ts::Metrics::IntType *ocsp_refreshed_cert = nullptr; - ts::Metrics::IntType *ocsp_revoked_cert = nullptr; - ts::Metrics::IntType *ocsp_unknown_cert = nullptr; - ts::Metrics::IntType *origin_server_bad_cert = nullptr; - ts::Metrics::IntType *origin_server_cert_verify_failed = nullptr; - ts::Metrics::IntType *origin_server_decryption_failed = nullptr; - ts::Metrics::IntType *origin_server_expired_cert = nullptr; - ts::Metrics::IntType *origin_server_other_errors = nullptr; - ts::Metrics::IntType *origin_server_revoked_cert = nullptr; - ts::Metrics::IntType *origin_server_unknown_ca = nullptr; - ts::Metrics::IntType *origin_server_unknown_cert = nullptr; - ts::Metrics::IntType *origin_server_wrong_version = nullptr; - ts::Metrics::IntType *origin_session_cache_hit = nullptr; - ts::Metrics::IntType *origin_session_cache_miss = nullptr; - ts::Metrics::IntType *origin_session_reused_count = nullptr; - ts::Metrics::IntType *session_cache_eviction = nullptr; - ts::Metrics::IntType *session_cache_hit = nullptr; - ts::Metrics::IntType *session_cache_lock_contention = nullptr; - ts::Metrics::IntType *session_cache_miss = nullptr; - ts::Metrics::IntType *session_cache_new_session = nullptr; - ts::Metrics::IntType *sni_name_set_failure = nullptr; - ts::Metrics::IntType *total_attempts_handshake_count_in = nullptr; - ts::Metrics::IntType *total_attempts_handshake_count_out = nullptr; - ts::Metrics::IntType *total_dyn_def_tls_record_count = nullptr; - ts::Metrics::IntType *total_dyn_max_tls_record_count = nullptr; - ts::Metrics::IntType *total_dyn_redo_tls_record_count = nullptr; - ts::Metrics::IntType *total_handshake_time = nullptr; - ts::Metrics::IntType *total_sslv3 = nullptr; - ts::Metrics::IntType *total_success_handshake_count_in = nullptr; - ts::Metrics::IntType *total_success_handshake_count_out = nullptr; - ts::Metrics::IntType *total_ticket_keys_renewed = nullptr; - ts::Metrics::IntType *total_tickets_created = nullptr; - ts::Metrics::IntType *total_tickets_not_found = nullptr; - ts::Metrics::IntType *total_tickets_renewed = nullptr; - ts::Metrics::IntType *total_tickets_verified_old_key = nullptr; - ts::Metrics::IntType *total_tickets_verified = nullptr; - ts::Metrics::IntType *total_tlsv1 = nullptr; - ts::Metrics::IntType *total_tlsv11 = nullptr; - ts::Metrics::IntType *total_tlsv12 = nullptr; - ts::Metrics::IntType *total_tlsv13 = nullptr; - ts::Metrics::IntType *user_agent_bad_cert = nullptr; - ts::Metrics::IntType *user_agent_cert_verify_failed = nullptr; - ts::Metrics::IntType *user_agent_decryption_failed = nullptr; - ts::Metrics::IntType *user_agent_expired_cert = nullptr; - ts::Metrics::IntType *user_agent_other_errors = nullptr; - ts::Metrics::IntType *user_agent_revoked_cert = nullptr; - ts::Metrics::IntType *user_agent_session_hit = nullptr; - ts::Metrics::IntType *user_agent_session_miss = nullptr; - ts::Metrics::IntType *user_agent_session_timeout = nullptr; - ts::Metrics::IntType *user_agent_sessions = nullptr; - ts::Metrics::IntType *user_agent_unknown_ca = nullptr; - ts::Metrics::IntType *user_agent_unknown_cert = nullptr; - ts::Metrics::IntType *user_agent_wrong_version = nullptr; + Counter::AtomicType *early_data_received_count = nullptr; + Counter::AtomicType *error_async = nullptr; + Counter::AtomicType *error_ssl = nullptr; + Counter::AtomicType *error_syscall = nullptr; + Counter::AtomicType *ocsp_refresh_cert_failure = nullptr; + Counter::AtomicType *ocsp_refreshed_cert = nullptr; + Counter::AtomicType *ocsp_revoked_cert = nullptr; + Counter::AtomicType *ocsp_unknown_cert = nullptr; + Counter::AtomicType *origin_server_bad_cert = nullptr; + Counter::AtomicType *origin_server_cert_verify_failed = nullptr; + Counter::AtomicType *origin_server_decryption_failed = nullptr; + Counter::AtomicType *origin_server_expired_cert = nullptr; + Counter::AtomicType *origin_server_other_errors = nullptr; + Counter::AtomicType *origin_server_revoked_cert = nullptr; + Counter::AtomicType *origin_server_unknown_ca = nullptr; + Counter::AtomicType *origin_server_unknown_cert = nullptr; + Counter::AtomicType *origin_server_wrong_version = nullptr; + Counter::AtomicType *origin_session_cache_hit = nullptr; + Counter::AtomicType *origin_session_cache_miss = nullptr; + Counter::AtomicType *origin_session_reused_count = nullptr; + Counter::AtomicType *session_cache_eviction = nullptr; + Counter::AtomicType *session_cache_hit = nullptr; + Counter::AtomicType *session_cache_lock_contention = nullptr; + Counter::AtomicType *session_cache_miss = nullptr; + Counter::AtomicType *session_cache_new_session = nullptr; + Counter::AtomicType *sni_name_set_failure = nullptr; + Counter::AtomicType *total_attempts_handshake_count_in = nullptr; + Counter::AtomicType *total_attempts_handshake_count_out = nullptr; + Counter::AtomicType *total_dyn_def_tls_record_count = nullptr; + Counter::AtomicType *total_dyn_max_tls_record_count = nullptr; + Counter::AtomicType *total_dyn_redo_tls_record_count = nullptr; + Counter::AtomicType *total_handshake_time = nullptr; + Counter::AtomicType *total_sslv3 = nullptr; + Counter::AtomicType *total_success_handshake_count_in = nullptr; + Counter::AtomicType *total_success_handshake_count_out = nullptr; + Counter::AtomicType *total_ticket_keys_renewed = nullptr; + Counter::AtomicType *total_tickets_created = nullptr; + Counter::AtomicType *total_tickets_not_found = nullptr; + Counter::AtomicType *total_tickets_renewed = nullptr; + Counter::AtomicType *total_tickets_verified_old_key = nullptr; + Counter::AtomicType *total_tickets_verified = nullptr; + Counter::AtomicType *total_tlsv1 = nullptr; + Counter::AtomicType *total_tlsv11 = nullptr; + Counter::AtomicType *total_tlsv12 = nullptr; + Counter::AtomicType *total_tlsv13 = nullptr; + Counter::AtomicType *user_agent_bad_cert = nullptr; + Counter::AtomicType *user_agent_cert_verify_failed = nullptr; + Counter::AtomicType *user_agent_decryption_failed = nullptr; + Counter::AtomicType *user_agent_expired_cert = nullptr; + Counter::AtomicType *user_agent_other_errors = nullptr; + Counter::AtomicType *user_agent_revoked_cert = nullptr; + Counter::AtomicType *user_agent_session_hit = nullptr; + Counter::AtomicType *user_agent_session_miss = nullptr; + Counter::AtomicType *user_agent_session_timeout = nullptr; + Counter::AtomicType *user_agent_sessions = nullptr; + Counter::AtomicType *user_agent_unknown_ca = nullptr; + Counter::AtomicType *user_agent_unknown_cert = nullptr; + Counter::AtomicType *user_agent_wrong_version = nullptr; }; extern SSLStatsBlock ssl_rsb; -extern std::unordered_map cipher_map; +extern std::unordered_map cipher_map; // Initialize SSL statistics. void SSLInitializeStatistics(); diff --git a/src/iocore/net/SSLUtils.cc b/src/iocore/net/SSLUtils.cc index 793e1b8e7d4..46f17b26aad 100644 --- a/src/iocore/net/SSLUtils.cc +++ b/src/iocore/net/SSLUtils.cc @@ -228,7 +228,7 @@ ssl_new_cached_session(SSL *ssl, SSL_SESSION *sess) } } - Metrics::increment(ssl_rsb.session_cache_new_session); + Counter::increment(ssl_rsb.session_cache_new_session); session_cache->insertSession(sid, sess, ssl); // Call hook after new session is created @@ -651,7 +651,7 @@ ssl_context_enable_tickets(SSL_CTX *ctx, const char *ticket_key_path) // On the "first run" the metrics have not been initialized, so this has to check it. if (ssl_rsb.total_ticket_keys_renewed) { - Metrics::increment(ssl_rsb.total_ticket_keys_renewed); + Counter::increment(ssl_rsb.total_ticket_keys_renewed); } // Setting the callback can only fail if OpenSSL does not recognize the @@ -1136,7 +1136,7 @@ ssl_callback_info(const SSL *ssl, int where, int ret) it = cipher_map.find(SSL_CIPHER_STAT_OTHER); ink_assert(it != cipher_map.end()); } - Metrics::increment(it->second); + Counter::increment(it->second); } } } diff --git a/src/iocore/net/Socks.cc b/src/iocore/net/Socks.cc index 9a198bc3a71..cb3273adfd0 100644 --- a/src/iocore/net/Socks.cc +++ b/src/iocore/net/Socks.cc @@ -164,7 +164,7 @@ SocksEntry::free() if (!action_.cancelled) { if (lerrno || !netVConnection) { Dbg(dbg_ctl_Socks, "retryevent: Sent errno %d to HTTP", lerrno); - Metrics::increment(net_rsb.socks_connections_unsuccessful); + Counter::increment(net_rsb.socks_connections_unsuccessful); action_.continuation->handleEvent(NET_EVENT_OPEN_FAILED, (void *)static_cast(-lerrno)); } else { netVConnection->do_io_read(this, 0, nullptr); @@ -172,7 +172,7 @@ SocksEntry::free() netVConnection->action_ = action_; // assign the original continuation netVConnection->con.setRemote(&server_addr.sa); Dbg(dbg_ctl_Socks, "Sent success to HTTP"); - Metrics::increment(net_rsb.socks_connections_successful); + Counter::increment(net_rsb.socks_connections_successful); action_.continuation->handleEvent(NET_EVENT_OPEN, netVConnection); } } diff --git a/src/iocore/net/TLSBasicSupport.cc b/src/iocore/net/TLSBasicSupport.cc index 5bae93d0050..1644130e264 100644 --- a/src/iocore/net/TLSBasicSupport.cc +++ b/src/iocore/net/TLSBasicSupport.cc @@ -167,5 +167,5 @@ TLSBasicSupport::_record_tls_handshake_end_time() const ink_hrtime ssl_handshake_time = this->_tls_handshake_end_time - this->_tls_handshake_begin_time; Debug("ssl", "ssl handshake time:%" PRId64, ssl_handshake_time); - Metrics::increment(ssl_rsb.total_handshake_time, ssl_handshake_time); + Counter::increment(ssl_rsb.total_handshake_time, ssl_handshake_time); } diff --git a/src/iocore/net/TLSSessionResumptionSupport.cc b/src/iocore/net/TLSSessionResumptionSupport.cc index 1e213eb7dbe..3e7b260af5d 100644 --- a/src/iocore/net/TLSSessionResumptionSupport.cc +++ b/src/iocore/net/TLSSessionResumptionSupport.cc @@ -165,7 +165,7 @@ TLSSessionResumptionSupport::getSession(SSL *ssl, const unsigned char *id, int l // Double check the timeout if (is_ssl_session_timed_out(session)) { - Metrics::increment(ssl_rsb.session_cache_miss); + Counter::increment(ssl_rsb.session_cache_miss); // Due to bug in openssl, the timeout is checked, but only removed // from the openssl built-in hash table. The external remove cb is not called #if 0 // This is currently eliminated, since it breaks things in odd ways (see TS-3710) @@ -174,12 +174,12 @@ TLSSessionResumptionSupport::getSession(SSL *ssl, const unsigned char *id, int l SSL_SESSION_free(session); session = nullptr; } else { - Metrics::increment(ssl_rsb.session_cache_hit); + Counter::increment(ssl_rsb.session_cache_hit); this->_setSSLSessionCacheHit(true); this->_setSSLCurveNID(exdata->curve); } } else { - Metrics::increment(ssl_rsb.session_cache_miss); + Counter::increment(ssl_rsb.session_cache_miss); } return session; } @@ -193,16 +193,16 @@ TLSSessionResumptionSupport::getOriginSession(SSL *ssl, const std::string &looku if (shared_sess != nullptr) { // Double check the timeout if (is_ssl_session_timed_out(shared_sess.get())) { - Metrics::increment(ssl_rsb.origin_session_cache_miss); + Counter::increment(ssl_rsb.origin_session_cache_miss); origin_sess_cache->remove_session(lookup_key); shared_sess.reset(); } else { - Metrics::increment(ssl_rsb.origin_session_cache_hit); + Counter::increment(ssl_rsb.origin_session_cache_hit); this->_setSSLOriginSessionCacheHit(true); this->_setSSLCurveNID(curve); } } else { - Metrics::increment(ssl_rsb.origin_session_cache_miss); + Counter::increment(ssl_rsb.origin_session_cache_miss); } return shared_sess; } @@ -248,7 +248,7 @@ TLSSessionResumptionSupport::_setSessionInformation(ssl_ticket_key_block *keyblo #endif Debug("ssl_session_ticket", "create ticket for a new session."); - Metrics::increment(ssl_rsb.total_tickets_created); + Counter::increment(ssl_rsb.total_tickets_created); return 1; } @@ -284,10 +284,10 @@ TLSSessionResumptionSupport::_getSessionInformation(ssl_ticket_key_block *keyblo Debug("ssl_session_ticket", "verify the ticket for an existing session."); // Increase the total number of decrypted tickets. - Metrics::increment(ssl_rsb.total_tickets_verified); + Counter::increment(ssl_rsb.total_tickets_verified); if (i != 0) { // The number of tickets decrypted with "older" keys. - Metrics::increment(ssl_rsb.total_tickets_verified_old_key); + Counter::increment(ssl_rsb.total_tickets_verified_old_key); } this->_setSSLSessionCacheHit(true); @@ -305,7 +305,7 @@ TLSSessionResumptionSupport::_getSessionInformation(ssl_ticket_key_block *keyblo } Debug("ssl_session_ticket", "keyname is not consistent."); - Metrics::increment(ssl_rsb.total_tickets_not_found); + Counter::increment(ssl_rsb.total_tickets_not_found); return 0; } diff --git a/src/iocore/net/UnixNet.cc b/src/iocore/net/UnixNet.cc index 3f970c6f611..dd065d23bfb 100644 --- a/src/iocore/net/UnixNet.cc +++ b/src/iocore/net/UnixNet.cc @@ -90,7 +90,7 @@ class InactivityCop : public Continuation // If we cannot get the lock don't stop just keep cleaning MUTEX_TRY_LOCK(lock, ne->get_mutex(), this_ethread()); if (!lock.is_locked()) { - Metrics::increment(net_rsb.inactivity_cop_lock_acquire_failure); + Counter::increment(net_rsb.inactivity_cop_lock_acquire_failure); continue; } @@ -117,20 +117,20 @@ class InactivityCop : public Continuation ne->use_default_inactivity_timeout = true; ne->next_inactivity_timeout_at = ink_get_hrtime() + ne->default_inactivity_timeout_in; ne->inactivity_timeout_in = 0; - Metrics::increment(net_rsb.default_inactivity_timeout_applied); + Counter::increment(net_rsb.default_inactivity_timeout_applied); } if (ne->next_inactivity_timeout_at && ne->next_inactivity_timeout_at < now) { if (ne->is_default_inactivity_timeout()) { // track the connections that timed out due to default inactivity Dbg(dbg_ctl_inactivity_cop, "vc: %p timed out due to default inactivity timeout", ne); - Metrics::increment(net_rsb.default_inactivity_timeout_count); + Counter::increment(net_rsb.default_inactivity_timeout_count); } if (nh.keep_alive_queue.in(ne)) { // only stat if the connection is in keep-alive, there can be other inactivity timeouts ink_hrtime diff = (now - (ne->next_inactivity_timeout_at - ne->inactivity_timeout_in)) / HRTIME_SECOND; - Metrics::increment(net_rsb.keep_alive_queue_timeout_total, diff); - Metrics::increment(net_rsb.keep_alive_queue_timeout_count); + Counter::increment(net_rsb.keep_alive_queue_timeout_total, diff); + Counter::increment(net_rsb.keep_alive_queue_timeout_count); } Dbg(dbg_ctl_inactivity_cop_verbose, "ne: %p now: %" PRId64 " timeout at: %" PRId64 " timeout in: %" PRId64, ne, ink_hrtime_to_sec(now), ne->next_inactivity_timeout_at, ne->inactivity_timeout_in); diff --git a/src/iocore/net/UnixNetAccept.cc b/src/iocore/net/UnixNetAccept.cc index f08e5d8b43b..7a1d42fbdc8 100644 --- a/src/iocore/net/UnixNetAccept.cc +++ b/src/iocore/net/UnixNetAccept.cc @@ -80,7 +80,7 @@ net_accept(NetAccept *na, void *ep, bool blockable) count = res; goto Ldone; } - Metrics::increment(net_rsb.tcp_accept); + Counter::increment(net_rsb.tcp_accept); vc = static_cast(na->getNetProcessor()->allocate_vc(e->ethread)); if (!vc) { @@ -88,7 +88,7 @@ net_accept(NetAccept *na, void *ep, bool blockable) } count++; - Metrics::increment(net_rsb.connections_currently_open); + Counter::increment(net_rsb.connections_currently_open); vc->id = net_next_connection_number(); vc->con.move(con); vc->set_remote_addr(con.addr); @@ -338,7 +338,7 @@ NetAccept::do_blocking_accept(EThread *t) check_throttle_warning(ACCEPT); // close the connection as we are in throttle state con.close(); - Metrics::increment(net_rsb.connections_throttled_in); + Counter::increment(net_rsb.connections_throttled_in); continue; } @@ -346,7 +346,7 @@ NetAccept::do_blocking_accept(EThread *t) return -1; } - Metrics::increment(net_rsb.tcp_accept); + Counter::increment(net_rsb.tcp_accept); // Use 'nullptr' to Bypass thread allocator vc = (UnixNetVConnection *)this->getNetProcessor()->allocate_vc(nullptr); @@ -355,7 +355,7 @@ NetAccept::do_blocking_accept(EThread *t) } count++; - Metrics::increment(net_rsb.connections_currently_open); + Counter::increment(net_rsb.connections_currently_open); vc->id = net_next_connection_number(); vc->con.move(con); vc->set_remote_addr(con.addr); @@ -410,14 +410,14 @@ NetAccept::acceptEvent(int event, void *ep) if (lock.is_locked()) { if (action_->cancelled) { e->cancel(); - Metrics::decrement(net_rsb.accepts_currently_open); + Counter::decrement(net_rsb.accepts_currently_open); delete this; return EVENT_DONE; } int res; if ((res = accept_fn(this, e, false)) < 0) { - Metrics::decrement(net_rsb.accepts_currently_open); + Counter::decrement(net_rsb.accepts_currently_open); /* INKqa11179 */ Warning("Accept on port %d failed with error no %d", ats_ip_port_host_order(&server.addr), res); Warning("Traffic Server may be unable to accept more network" @@ -458,11 +458,11 @@ NetAccept::acceptFastEvent(int event, void *ep) if (check_net_throttle(ACCEPT)) { // close the connection as we are in throttle state con.close(); - Metrics::increment(net_rsb.connections_throttled_in); + Counter::increment(net_rsb.connections_throttled_in); continue; } Dbg(dbg_ctl_iocore_net, "accepted a new socket: %d", fd); - Metrics::increment(net_rsb.tcp_accept); + Counter::increment(net_rsb.tcp_accept); if (opt.send_bufsize > 0) { if (unlikely(SocketManager::set_sndbuf_size(fd, opt.send_bufsize))) { bufsz = ROUNDUP(opt.send_bufsize, 1024); @@ -512,7 +512,7 @@ NetAccept::acceptFastEvent(int event, void *ep) ink_release_assert(vc); count++; - Metrics::increment(net_rsb.connections_currently_open); + Counter::increment(net_rsb.connections_currently_open); vc->id = net_next_connection_number(); vc->con.move(con); vc->set_remote_addr(con.addr); @@ -560,7 +560,7 @@ NetAccept::acceptFastEvent(int event, void *ep) Lerror: server.close(); e->cancel(); - Metrics::decrement(net_rsb.accepts_currently_open); + Counter::decrement(net_rsb.accepts_currently_open); delete this; return EVENT_DONE; } @@ -577,7 +577,7 @@ NetAccept::acceptLoopEvent(int event, Event *e) } // Don't think this ever happens ... - Metrics::decrement(net_rsb.accepts_currently_open); + Counter::decrement(net_rsb.accepts_currently_open); delete this; return EVENT_DONE; } diff --git a/src/iocore/net/UnixNetProcessor.cc b/src/iocore/net/UnixNetProcessor.cc index 45e199a9201..3c4dcee744d 100644 --- a/src/iocore/net/UnixNetProcessor.cc +++ b/src/iocore/net/UnixNetProcessor.cc @@ -97,7 +97,7 @@ UnixNetProcessor::accept_internal(Continuation *cont, int fd, AcceptOptions cons Fatal("Please disable accept_threads or exec_thread.listen"); } - Metrics::increment(net_rsb.accepts_currently_open); + Counter::increment(net_rsb.accepts_currently_open); // We've handled the config stuff at start up, but there are a few cases // we must handle at this point. diff --git a/src/iocore/net/UnixNetVConnection.cc b/src/iocore/net/UnixNetVConnection.cc index a8b03640f4b..0e866a0ebac 100644 --- a/src/iocore/net/UnixNetVConnection.cc +++ b/src/iocore/net/UnixNetVConnection.cc @@ -262,7 +262,7 @@ read_from_net(NetHandler *nh, UnixNetVConnection *vc, EThread *thread) msg.msg_iovlen = niov; r = SocketManager::recvmsg(vc->con.fd, &msg, 0); - Metrics::increment(net_rsb.calls_to_read); + Counter::increment(net_rsb.calls_to_read); total_read += rattempted; } while (rattempted && r == rattempted && total_read < toread); @@ -278,7 +278,7 @@ read_from_net(NetHandler *nh, UnixNetVConnection *vc, EThread *thread) // check for errors if (r <= 0) { if (r == -EAGAIN || r == -ENOTCONN) { - Metrics::increment(net_rsb.calls_to_read_nodata); + Counter::increment(net_rsb.calls_to_read_nodata); vc->read.triggered = 0; nh->read_ready_list.remove(vc); return; @@ -294,8 +294,8 @@ read_from_net(NetHandler *nh, UnixNetVConnection *vc, EThread *thread) read_signal_error(nh, vc, static_cast(-r)); return; } - Metrics::increment(net_rsb.read_bytes, r); - Metrics::increment(net_rsb.read_bytes_count); + Counter::increment(net_rsb.read_bytes, r); + Counter::increment(net_rsb.read_bytes_count); // Add data to buffer and signal continuation. buf.writer()->fill(r); @@ -347,7 +347,7 @@ read_from_net(NetHandler *nh, UnixNetVConnection *vc, EThread *thread) void write_to_net(NetHandler *nh, UnixNetVConnection *vc, EThread *thread) { - Metrics::increment(net_rsb.calls_to_writetonet); + Counter::increment(net_rsb.calls_to_writetonet); write_to_net_io(nh, vc, thread); } @@ -472,8 +472,8 @@ write_to_net_io(NetHandler *nh, UnixNetVConnection *vc, EThread *thread) int64_t r = vc->load_buffer_and_write(towrite, buf, total_written, needs); if (total_written > 0) { - Metrics::increment(net_rsb.write_bytes, total_written); - Metrics::increment(net_rsb.write_bytes_count); + Counter::increment(net_rsb.write_bytes, total_written); + Counter::increment(net_rsb.write_bytes_count); s->vio.ndone += total_written; net_activity(vc, thread); } @@ -484,7 +484,7 @@ write_to_net_io(NetHandler *nh, UnixNetVConnection *vc, EThread *thread) // check for errors if (r < 0) { // if the socket was not ready, add to WaitList if (r == -EAGAIN || r == -ENOTCONN || -r == EINPROGRESS) { - Metrics::increment(net_rsb.calls_to_write_nodata); + Counter::increment(net_rsb.calls_to_write_nodata); if ((needs & EVENTIO_WRITE) == EVENTIO_WRITE) { vc->write.triggered = 0; nh->write_ready_list.remove(vc); @@ -916,7 +916,7 @@ UnixNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor &bu int flags = 0; if (!this->con.is_connected && this->options.f_tcp_fastopen) { - Metrics::increment(net_rsb.fastopen_attempts); + Counter::increment(net_rsb.fastopen_attempts); flags = MSG_FASTOPEN; } r = SocketManager::sendmsg(con.fd, &msg, flags); @@ -926,7 +926,7 @@ UnixNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor &bu this->con.is_connected = true; } } else { - Metrics::increment(net_rsb.fastopen_successes); + Counter::increment(net_rsb.fastopen_successes); this->con.is_connected = true; } } @@ -936,7 +936,7 @@ UnixNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor &bu total_written += r; } - Metrics::increment(net_rsb.calls_to_write); + Counter::increment(net_rsb.calls_to_write); } while (r == try_to_write && total_written < towrite); tmp_reader->dealloc(); @@ -1159,7 +1159,7 @@ UnixNetVConnection::connectUp(EThread *t, int fd) if (check_net_throttle(CONNECT)) { check_throttle_warning(CONNECT); res = -ENET_THROTTLING; - Metrics::increment(net_rsb.connections_throttled_out); + Counter::increment(net_rsb.connections_throttled_out); goto fail; } @@ -1212,7 +1212,7 @@ UnixNetVConnection::connectUp(EThread *t, int fd) } // Did not fail, increment connection count - Metrics::increment(net_rsb.connections_currently_open); + Counter::increment(net_rsb.connections_currently_open); ink_release_assert(con.fd != NO_FD); // Setup a timeout callback handler. @@ -1290,14 +1290,14 @@ UnixNetVConnection::free_thread(EThread *t) // close socket fd if (con.fd != NO_FD) { - Metrics::decrement(net_rsb.connections_currently_open); + Counter::decrement(net_rsb.connections_currently_open); } con.close(); if (is_tunnel_endpoint()) { Debug("iocore_net", "Freeing UnixNetVConnection that is tunnel endpoint"); - Metrics::decrement(([&]() -> Metrics::IntType * { + Counter::decrement(([&]() -> Counter::AtomicType * { switch (get_context()) { case NET_VCONNECTION_IN: return net_rsb.tunnel_current_client_connections_blind_tcp; @@ -1533,13 +1533,13 @@ UnixNetVConnection::mark_as_tunnel_endpoint() void UnixNetVConnection::_in_context_tunnel() { - Metrics::increment(net_rsb.tunnel_total_client_connections_blind_tcp); - Metrics::increment(net_rsb.tunnel_current_client_connections_blind_tcp); + Counter::increment(net_rsb.tunnel_total_client_connections_blind_tcp); + Counter::increment(net_rsb.tunnel_current_client_connections_blind_tcp); } void UnixNetVConnection::_out_context_tunnel() { - Metrics::increment(net_rsb.tunnel_total_server_connections_blind_tcp); - Metrics::increment(net_rsb.tunnel_current_server_connections_blind_tcp); + Counter::increment(net_rsb.tunnel_total_server_connections_blind_tcp); + Counter::increment(net_rsb.tunnel_current_server_connections_blind_tcp); } diff --git a/src/iocore/net/quic/QUICGlobals.cc b/src/iocore/net/quic/QUICGlobals.cc index e39085a60ff..f0d25c8b73c 100644 --- a/src/iocore/net/quic/QUICGlobals.cc +++ b/src/iocore/net/quic/QUICGlobals.cc @@ -73,10 +73,10 @@ QUIC::ssl_client_new_session(SSL *ssl, SSL_SESSION *session) void QUIC::_register_stats() { - ts::Metrics &intm = ts::Metrics::getInstance(); + ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); // Transferred packet counts - quic_rsb.total_packets_sent = intm.newMetricPtr("proxy.process.quic.total_packets_sent"); + quic_rsb.total_packets_sent = metrics.createPtr("proxy.process.quic.total_packets_sent"); - // quic_rsb.total_packets_retransmitted = intm.newMetricPtr("proxy.process.quic.total_packets_retransmitted"); - // quic_rsb.total_packets_received = intm.newMetricPtr("proxy.process.quic.total_packets_received"); + // quic_rsb.total_packets_retransmitted = metrics.createPtr("proxy.process.quic.total_packets_retransmitted"); + // quic_rsb.total_packets_received = metrics.createPtr("proxy.process.quic.total_packets_received"); } diff --git a/src/mgmt/rpc/handlers/config/Configuration.cc b/src/mgmt/rpc/handlers/config/Configuration.cc index 06999267ebd..846593d9d25 100644 --- a/src/mgmt/rpc/handlers/config/Configuration.cc +++ b/src/mgmt/rpc/handlers/config/Configuration.cc @@ -184,9 +184,9 @@ set_config_records(std::string_view const &id, YAML::Node const ¶ms) ts::Rv reload_config(std::string_view const &id, YAML::Node const ¶ms) { - ts::Metrics &intm = ts::Metrics::getInstance(); - static auto reconf_time = intm.lookup("proxy.process.proxy.reconfigure_time"); - static auto reconf_req = intm.lookup("proxy.process.proxy.reconfigure_required"); + ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); + static auto reconf_time = metrics.lookup("proxy.process.proxy.reconfigure_time"); + static auto reconf_req = metrics.lookup("proxy.process.proxy.reconfigure_required"); ts::Rv resp; Debug("RPC", "invoke plugin callbacks"); // if there is any error, report it back. @@ -196,8 +196,8 @@ reload_config(std::string_view const &id, YAML::Node const ¶ms) // If any callback was register(TSMgmtUpdateRegister) for config notifications, then it will be eventually notify. FileManager::instance().invokeConfigPluginCallbacks(); - intm[reconf_time] = time(nullptr); - intm[reconf_req] = 0; + metrics[reconf_time] = time(nullptr); + metrics[reconf_req] = 0; return resp; } diff --git a/src/mgmt/rpc/handlers/server/Server.cc b/src/mgmt/rpc/handlers/server/Server.cc index 1a87f251a7e..8b457b09e50 100644 --- a/src/mgmt/rpc/handlers/server/Server.cc +++ b/src/mgmt/rpc/handlers/server/Server.cc @@ -63,20 +63,20 @@ namespace err = rpc::handlers::errors; static bool is_server_draining() { - ts::Metrics &intm = ts::Metrics::getInstance(); - static auto drain_id = intm.lookup("proxy.process.proxy.draining"); + ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); + static auto drain_id = metrics.lookup("proxy.process.proxy.draining"); - return (intm[drain_id] != 0); + return (metrics[drain_id] != 0); } static void set_server_drain(bool drain) { - ts::Metrics &intm = ts::Metrics::getInstance(); - static auto drain_id = intm.lookup("proxy.process.proxy.draining"); + ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); + static auto drain_id = metrics.lookup("proxy.process.proxy.draining"); TSSystemState::drain(drain); - intm[drain_id] = TSSystemState::is_draining() ? 1 : 0; + metrics[drain_id] = TSSystemState::is_draining() ? 1 : 0; } ts::Rv diff --git a/src/proxy/http/Http1ClientSession.cc b/src/proxy/http/Http1ClientSession.cc index cd06da46004..746f83497b5 100644 --- a/src/proxy/http/Http1ClientSession.cc +++ b/src/proxy/http/Http1ClientSession.cc @@ -118,7 +118,7 @@ Http1ClientSession::free() #endif if (conn_decrease) { - Metrics::decrement(http_rsb.current_client_connections); + Counter::decrement(http_rsb.current_client_connections); conn_decrease = false; } @@ -154,26 +154,26 @@ Http1ClientSession::new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOB schedule_event = nullptr; - Metrics::increment(http_rsb.current_client_connections); + Counter::increment(http_rsb.current_client_connections); conn_decrease = true; - Metrics::increment(http_rsb.total_client_connections); + Counter::increment(http_rsb.total_client_connections); if (static_cast(new_vc->attributes) == HttpProxyPort::TRANSPORT_SSL) { - Metrics::increment(http_rsb.https_total_client_connections); + Counter::increment(http_rsb.https_total_client_connections); } /* inbound requests stat should be incremented here, not after the * header has been read */ - Metrics::increment(http_rsb.total_incoming_connections); + Counter::increment(http_rsb.total_incoming_connections); // check what type of socket address we just accepted // by looking at the address family value of sockaddr_storage // and logging to stat system switch (new_vc->get_remote_addr()->sa_family) { case AF_INET: - Metrics::increment(http_rsb.total_client_connections_ipv4); + Counter::increment(http_rsb.total_client_connections_ipv4); break; case AF_INET6: - Metrics::increment(http_rsb.total_client_connections_ipv6); + Counter::increment(http_rsb.total_client_connections_ipv6); break; default: // don't do anything if the address family is not ipv4 or ipv6 @@ -513,12 +513,12 @@ Http1ClientSession::attach_server_session(PoolableSession *ssession, bool transa void Http1ClientSession::increment_current_active_connections_stat() { - Metrics::increment(http_rsb.current_active_client_connections); + Counter::increment(http_rsb.current_active_client_connections); } void Http1ClientSession::decrement_current_active_connections_stat() { - Metrics::decrement(http_rsb.current_active_client_connections); + Counter::decrement(http_rsb.current_active_client_connections); } void diff --git a/src/proxy/http/Http1ClientTransaction.cc b/src/proxy/http/Http1ClientTransaction.cc index f5ebdb25ee0..dcde861aae2 100644 --- a/src/proxy/http/Http1ClientTransaction.cc +++ b/src/proxy/http/Http1ClientTransaction.cc @@ -59,11 +59,11 @@ Http1ClientTransaction::allow_half_open() const void Http1ClientTransaction::increment_transactions_stat() { - Metrics::increment(http_rsb.current_client_transactions); + Counter::increment(http_rsb.current_client_transactions); } void Http1ClientTransaction::decrement_transactions_stat() { - Metrics::decrement(http_rsb.current_client_transactions); + Counter::decrement(http_rsb.current_client_transactions); } diff --git a/src/proxy/http/Http1ServerSession.cc b/src/proxy/http/Http1ServerSession.cc index ed6e6fdac80..0102abfd82c 100644 --- a/src/proxy/http/Http1ServerSession.cc +++ b/src/proxy/http/Http1ServerSession.cc @@ -80,8 +80,8 @@ Http1ServerSession::new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOB con_id = ProxySession::next_connection_id(); magic = HTTP_SS_MAGIC_ALIVE; - Metrics::increment(http_rsb.current_server_connections); - Metrics::increment(http_rsb.total_server_connections); + Counter::increment(http_rsb.current_server_connections); + Counter::increment(http_rsb.total_server_connections); if (iobuf == nullptr) { read_buffer = new_MIOBuffer(HTTP_SERVER_RESP_HDR_BUFFER_INDEX); @@ -110,7 +110,7 @@ Http1ServerSession::do_io_close(int alerrno) w.print("[{}] session close: nevtc {:x}", con_id, _vc); } - Metrics::decrement(http_rsb.current_server_connections); + Counter::decrement(http_rsb.current_server_connections); // Update upstream connection tracking data if present. this->release_outbound_connection_tracking(); @@ -125,7 +125,7 @@ Http1ServerSession::do_io_close(int alerrno) _vc = nullptr; if (to_parent_proxy) { - Metrics::decrement(http_rsb.current_parent_proxy_connections); + Counter::decrement(http_rsb.current_parent_proxy_connections); } } @@ -207,7 +207,7 @@ Http1ServerSession ::release_transaction() // Private sessions are never released back to the shared pool if (this->is_private() || sharing_match == 0) { if (this->is_private()) { - Metrics::increment(http_rsb.origin_close_private); + Counter::increment(http_rsb.origin_close_private); } this->do_io_close(); } else if (state == SSN_TO_RELEASE) { @@ -225,7 +225,7 @@ Http1ServerSession ::release_transaction() // due to lock contention // FIX: should retry instead of closing do_io_close(HTTP_ERRNO); - Metrics::increment(http_rsb.origin_shutdown_pool_lock_contention); + Counter::increment(http_rsb.origin_shutdown_pool_lock_contention); } else { // The session was successfully put into the session // manager and it will manage it diff --git a/src/proxy/http/Http1ServerTransaction.cc b/src/proxy/http/Http1ServerTransaction.cc index ed20bc06917..3207da850f8 100644 --- a/src/proxy/http/Http1ServerTransaction.cc +++ b/src/proxy/http/Http1ServerTransaction.cc @@ -33,13 +33,13 @@ Http1ServerTransaction::release() void Http1ServerTransaction::increment_transactions_stat() { - Metrics::increment(http_rsb.current_server_transactions); + Counter::increment(http_rsb.current_server_transactions); } void Http1ServerTransaction::decrement_transactions_stat() { - Metrics::decrement(http_rsb.current_server_transactions); + Counter::decrement(http_rsb.current_server_transactions); } void diff --git a/src/proxy/http/HttpCacheSM.cc b/src/proxy/http/HttpCacheSM.cc index fdfadc44a40..7db70a81494 100644 --- a/src/proxy/http/HttpCacheSM.cc +++ b/src/proxy/http/HttpCacheSM.cc @@ -107,7 +107,7 @@ HttpCacheSM::state_cache_open_read(int event, void *data) switch (event) { case CACHE_EVENT_OPEN_READ: - Metrics::increment(http_rsb.current_cache_connections); + Counter::increment(http_rsb.current_cache_connections); ink_assert((cache_read_vc == nullptr) || master_sm->t_state.redirect_info.redirect_in_process); if (cache_read_vc) { // redirect follow in progress, close the previous cache_read_vc @@ -186,7 +186,7 @@ HttpCacheSM::state_cache_open_write(int event, void *data) switch (event) { case CACHE_EVENT_OPEN_WRITE: - Metrics::increment(http_rsb.current_cache_connections); + Counter::increment(http_rsb.current_cache_connections); ink_assert(cache_write_vc == nullptr); cache_write_vc = static_cast(data); open_write_cb = true; diff --git a/src/proxy/http/HttpConfig.cc b/src/proxy/http/HttpConfig.cc index d938d390957..e6c68dcc45e 100644 --- a/src/proxy/http/HttpConfig.cc +++ b/src/proxy/http/HttpConfig.cc @@ -259,262 +259,262 @@ http_insert_forwarded_cb(const char *name, RecDataT dtype, RecData data, void *c void register_stat_callbacks() { - ts::Metrics &intm = ts::Metrics::getInstance(); - - http_rsb.background_fill_bytes_aborted = intm.newMetricPtr("proxy.process.http.background_fill_bytes_aborted"); - http_rsb.background_fill_bytes_completed = intm.newMetricPtr("proxy.process.http.background_fill_bytes_completed"); - http_rsb.background_fill_current_count = intm.newMetricPtr("proxy.process.http.background_fill_current_count"); - http_rsb.background_fill_total_count = intm.newMetricPtr("proxy.process.http.background_fill_total_count"); - http_rsb.broken_server_connections = intm.newMetricPtr("proxy.process.http.broken_server_connections"); - http_rsb.cache_deletes = intm.newMetricPtr("proxy.process.http.cache_deletes"); - http_rsb.cache_hit_fresh = intm.newMetricPtr("proxy.process.http.cache_hit_fresh"); - http_rsb.cache_hit_ims = intm.newMetricPtr("proxy.process.http.cache_hit_ims"); - http_rsb.cache_hit_mem_fresh = intm.newMetricPtr("proxy.process.http.cache_hit_mem_fresh"); - http_rsb.cache_hit_reval = intm.newMetricPtr("proxy.process.http.cache_hit_revalidated"); - http_rsb.cache_hit_rww = intm.newMetricPtr("proxy.process.http.cache_hit_rww"); - http_rsb.cache_hit_stale_served = intm.newMetricPtr("proxy.process.http.cache_hit_stale_served"); - http_rsb.cache_lookups = intm.newMetricPtr("proxy.process.http.cache_lookups"); - http_rsb.cache_miss_changed = intm.newMetricPtr("proxy.process.http.cache_miss_changed"); - http_rsb.cache_miss_client_no_cache = intm.newMetricPtr("proxy.process.http.cache_miss_client_no_cache"); - http_rsb.cache_miss_cold = intm.newMetricPtr("proxy.process.http.cache_miss_cold"); - http_rsb.cache_miss_ims = intm.newMetricPtr("proxy.process.http.cache_miss_ims"); - http_rsb.cache_miss_uncacheable = intm.newMetricPtr("proxy.process.http.cache_miss_client_not_cacheable"); - http_rsb.cache_open_read_begin_time = intm.newMetricPtr("proxy.process.http.milestone.cache_open_read_begin"); - http_rsb.cache_open_read_end_time = intm.newMetricPtr("proxy.process.http.milestone.cache_open_read_end"); - http_rsb.cache_open_write_adjust_thread = intm.newMetricPtr("proxy.process.http.cache.open_write.adjust_thread"); - http_rsb.cache_open_write_begin_time = intm.newMetricPtr("proxy.process.http.milestone.cache_open_write_begin"); - http_rsb.cache_open_write_end_time = intm.newMetricPtr("proxy.process.http.milestone.cache_open_write_end"); - http_rsb.cache_read_error = intm.newMetricPtr("proxy.process.http.cache_read_error"); - http_rsb.cache_read_errors = intm.newMetricPtr("proxy.process.http.cache_read_errors"); - http_rsb.cache_updates = intm.newMetricPtr("proxy.process.http.cache_updates"); - http_rsb.cache_write_errors = intm.newMetricPtr("proxy.process.http.cache_write_errors"); - http_rsb.cache_writes = intm.newMetricPtr("proxy.process.http.cache_writes"); - http_rsb.completed_requests = intm.newMetricPtr("proxy.process.http.completed_requests"); - http_rsb.connect_requests = intm.newMetricPtr("proxy.process.http.connect_requests"); - http_rsb.current_active_client_connections = intm.newMetricPtr("proxy.process.http.current_active_client_connections"); - http_rsb.current_cache_connections = intm.newMetricPtr("proxy.process.http.current_cache_connections"); - http_rsb.current_client_connections = intm.newMetricPtr("proxy.process.http.current_client_connections"); - http_rsb.current_client_transactions = intm.newMetricPtr("proxy.process.http.current_client_transactions"); - http_rsb.current_parent_proxy_connections = intm.newMetricPtr("proxy.process.http.current_parent_proxy_connections"); - http_rsb.current_server_connections = intm.newMetricPtr("proxy.process.http.current_server_connections"); - http_rsb.current_server_transactions = intm.newMetricPtr("proxy.process.http.current_server_transactions"); - http_rsb.delete_requests = intm.newMetricPtr("proxy.process.http.delete_requests"); - http_rsb.disallowed_post_100_continue = intm.newMetricPtr("proxy.process.http.disallowed_post_100_continue"); - http_rsb.dns_lookup_begin_time = intm.newMetricPtr("proxy.process.http.milestone.dns_lookup_begin"); - http_rsb.dns_lookup_end_time = intm.newMetricPtr("proxy.process.http.milestone.dns_lookup_end"); - http_rsb.down_server_no_requests = intm.newMetricPtr("proxy.process.http.down_server.no_requests"); - http_rsb.err_client_abort_count = intm.newMetricPtr("proxy.process.http.err_client_abort_count"); - http_rsb.err_client_abort_origin_server_bytes = intm.newMetricPtr("proxy.process.http.err_client_abort_origin_server_bytes"); - http_rsb.err_client_abort_user_agent_bytes = intm.newMetricPtr("proxy.process.http.err_client_abort_user_agent_bytes"); - http_rsb.err_client_read_error_count = intm.newMetricPtr("proxy.process.http.err_client_read_error_count"); + ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); + + http_rsb.background_fill_bytes_aborted = metrics.createPtr("proxy.process.http.background_fill_bytes_aborted"); + http_rsb.background_fill_bytes_completed = metrics.createPtr("proxy.process.http.background_fill_bytes_completed"); + http_rsb.background_fill_current_count = metrics.createPtr("proxy.process.http.background_fill_current_count"); + http_rsb.background_fill_total_count = metrics.createPtr("proxy.process.http.background_fill_total_count"); + http_rsb.broken_server_connections = metrics.createPtr("proxy.process.http.broken_server_connections"); + http_rsb.cache_deletes = metrics.createPtr("proxy.process.http.cache_deletes"); + http_rsb.cache_hit_fresh = metrics.createPtr("proxy.process.http.cache_hit_fresh"); + http_rsb.cache_hit_ims = metrics.createPtr("proxy.process.http.cache_hit_ims"); + http_rsb.cache_hit_mem_fresh = metrics.createPtr("proxy.process.http.cache_hit_mem_fresh"); + http_rsb.cache_hit_reval = metrics.createPtr("proxy.process.http.cache_hit_revalidated"); + http_rsb.cache_hit_rww = metrics.createPtr("proxy.process.http.cache_hit_rww"); + http_rsb.cache_hit_stale_served = metrics.createPtr("proxy.process.http.cache_hit_stale_served"); + http_rsb.cache_lookups = metrics.createPtr("proxy.process.http.cache_lookups"); + http_rsb.cache_miss_changed = metrics.createPtr("proxy.process.http.cache_miss_changed"); + http_rsb.cache_miss_client_no_cache = metrics.createPtr("proxy.process.http.cache_miss_client_no_cache"); + http_rsb.cache_miss_cold = metrics.createPtr("proxy.process.http.cache_miss_cold"); + http_rsb.cache_miss_ims = metrics.createPtr("proxy.process.http.cache_miss_ims"); + http_rsb.cache_miss_uncacheable = metrics.createPtr("proxy.process.http.cache_miss_client_not_cacheable"); + http_rsb.cache_open_read_begin_time = metrics.createPtr("proxy.process.http.milestone.cache_open_read_begin"); + http_rsb.cache_open_read_end_time = metrics.createPtr("proxy.process.http.milestone.cache_open_read_end"); + http_rsb.cache_open_write_adjust_thread = metrics.createPtr("proxy.process.http.cache.open_write.adjust_thread"); + http_rsb.cache_open_write_begin_time = metrics.createPtr("proxy.process.http.milestone.cache_open_write_begin"); + http_rsb.cache_open_write_end_time = metrics.createPtr("proxy.process.http.milestone.cache_open_write_end"); + http_rsb.cache_read_error = metrics.createPtr("proxy.process.http.cache_read_error"); + http_rsb.cache_read_errors = metrics.createPtr("proxy.process.http.cache_read_errors"); + http_rsb.cache_updates = metrics.createPtr("proxy.process.http.cache_updates"); + http_rsb.cache_write_errors = metrics.createPtr("proxy.process.http.cache_write_errors"); + http_rsb.cache_writes = metrics.createPtr("proxy.process.http.cache_writes"); + http_rsb.completed_requests = metrics.createPtr("proxy.process.http.completed_requests"); + http_rsb.connect_requests = metrics.createPtr("proxy.process.http.connect_requests"); + http_rsb.current_active_client_connections = metrics.createPtr("proxy.process.http.current_active_client_connections"); + http_rsb.current_cache_connections = metrics.createPtr("proxy.process.http.current_cache_connections"); + http_rsb.current_client_connections = metrics.createPtr("proxy.process.http.current_client_connections"); + http_rsb.current_client_transactions = metrics.createPtr("proxy.process.http.current_client_transactions"); + http_rsb.current_parent_proxy_connections = metrics.createPtr("proxy.process.http.current_parent_proxy_connections"); + http_rsb.current_server_connections = metrics.createPtr("proxy.process.http.current_server_connections"); + http_rsb.current_server_transactions = metrics.createPtr("proxy.process.http.current_server_transactions"); + http_rsb.delete_requests = metrics.createPtr("proxy.process.http.delete_requests"); + http_rsb.disallowed_post_100_continue = metrics.createPtr("proxy.process.http.disallowed_post_100_continue"); + http_rsb.dns_lookup_begin_time = metrics.createPtr("proxy.process.http.milestone.dns_lookup_begin"); + http_rsb.dns_lookup_end_time = metrics.createPtr("proxy.process.http.milestone.dns_lookup_end"); + http_rsb.down_server_no_requests = metrics.createPtr("proxy.process.http.down_server.no_requests"); + http_rsb.err_client_abort_count = metrics.createPtr("proxy.process.http.err_client_abort_count"); + http_rsb.err_client_abort_origin_server_bytes = metrics.createPtr("proxy.process.http.err_client_abort_origin_server_bytes"); + http_rsb.err_client_abort_user_agent_bytes = metrics.createPtr("proxy.process.http.err_client_abort_user_agent_bytes"); + http_rsb.err_client_read_error_count = metrics.createPtr("proxy.process.http.err_client_read_error_count"); http_rsb.err_client_read_error_origin_server_bytes = - intm.newMetricPtr("proxy.process.http.err_client_read_error_origin_server_bytes"); - http_rsb.err_client_read_error_user_agent_bytes = intm.newMetricPtr("proxy.process.http.err_client_read_error_user_agent_bytes"); - http_rsb.err_connect_fail_count = intm.newMetricPtr("proxy.process.http.err_connect_fail_count"); - http_rsb.err_connect_fail_origin_server_bytes = intm.newMetricPtr("proxy.process.http.err_connect_fail_origin_server_bytes"); - http_rsb.err_connect_fail_user_agent_bytes = intm.newMetricPtr("proxy.process.http.err_connect_fail_user_agent_bytes"); - http_rsb.extension_method_requests = intm.newMetricPtr("proxy.process.http.extension_method_requests"); - http_rsb.get_requests = intm.newMetricPtr("proxy.process.http.get_requests"); - http_rsb.head_requests = intm.newMetricPtr("proxy.process.http.head_requests"); - http_rsb.https_incoming_requests = intm.newMetricPtr("proxy.process.https.incoming_requests"); - http_rsb.https_total_client_connections = intm.newMetricPtr("proxy.process.https.total_client_connections"); - http_rsb.incoming_requests = intm.newMetricPtr("proxy.process.http.incoming_requests"); - http_rsb.incoming_responses = intm.newMetricPtr("proxy.process.http.incoming_responses"); - http_rsb.invalid_client_requests = intm.newMetricPtr("proxy.process.http.invalid_client_requests"); - http_rsb.misc_count = intm.newMetricPtr("proxy.process.http.misc_count"); - http_rsb.misc_origin_server_bytes = intm.newMetricPtr("proxy.process.http.http_misc_origin_server_bytes"); - http_rsb.misc_user_agent_bytes = intm.newMetricPtr("proxy.process.http.misc_user_agent_bytes"); - http_rsb.missing_host_hdr = intm.newMetricPtr("proxy.process.http.missing_host_hdr"); - http_rsb.options_requests = intm.newMetricPtr("proxy.process.http.options_requests"); - http_rsb.origin_body = intm.newMetricPtr("proxy.process.http.origin.body"); - http_rsb.origin_close_private = intm.newMetricPtr("proxy.process.http.origin.close_private"); - http_rsb.origin_connect_adjust_thread = intm.newMetricPtr("proxy.process.http.origin.connect.adjust_thread"); - http_rsb.origin_connections_throttled = intm.newMetricPtr("proxy.process.http.origin_connections_throttled_out"); - http_rsb.origin_make_new = intm.newMetricPtr("proxy.process.http.origin.make_new"); - http_rsb.origin_no_sharing = intm.newMetricPtr("proxy.process.http.origin.no_sharing"); - http_rsb.origin_not_found = intm.newMetricPtr("proxy.process.http.origin.not_found"); - http_rsb.origin_private = intm.newMetricPtr("proxy.process.http.origin.private"); - http_rsb.origin_raw = intm.newMetricPtr("proxy.process.http.origin.raw"); - http_rsb.origin_reuse = intm.newMetricPtr("proxy.process.http.origin.reuse"); - http_rsb.origin_reuse_fail = intm.newMetricPtr("proxy.process.http.origin.reuse_fail"); + metrics.createPtr("proxy.process.http.err_client_read_error_origin_server_bytes"); + http_rsb.err_client_read_error_user_agent_bytes = metrics.createPtr("proxy.process.http.err_client_read_error_user_agent_bytes"); + http_rsb.err_connect_fail_count = metrics.createPtr("proxy.process.http.err_connect_fail_count"); + http_rsb.err_connect_fail_origin_server_bytes = metrics.createPtr("proxy.process.http.err_connect_fail_origin_server_bytes"); + http_rsb.err_connect_fail_user_agent_bytes = metrics.createPtr("proxy.process.http.err_connect_fail_user_agent_bytes"); + http_rsb.extension_method_requests = metrics.createPtr("proxy.process.http.extension_method_requests"); + http_rsb.get_requests = metrics.createPtr("proxy.process.http.get_requests"); + http_rsb.head_requests = metrics.createPtr("proxy.process.http.head_requests"); + http_rsb.https_incoming_requests = metrics.createPtr("proxy.process.https.incoming_requests"); + http_rsb.https_total_client_connections = metrics.createPtr("proxy.process.https.total_client_connections"); + http_rsb.incoming_requests = metrics.createPtr("proxy.process.http.incoming_requests"); + http_rsb.incoming_responses = metrics.createPtr("proxy.process.http.incoming_responses"); + http_rsb.invalid_client_requests = metrics.createPtr("proxy.process.http.invalid_client_requests"); + http_rsb.misc_count = metrics.createPtr("proxy.process.http.misc_count"); + http_rsb.misc_origin_server_bytes = metrics.createPtr("proxy.process.http.http_misc_origin_server_bytes"); + http_rsb.misc_user_agent_bytes = metrics.createPtr("proxy.process.http.misc_user_agent_bytes"); + http_rsb.missing_host_hdr = metrics.createPtr("proxy.process.http.missing_host_hdr"); + http_rsb.options_requests = metrics.createPtr("proxy.process.http.options_requests"); + http_rsb.origin_body = metrics.createPtr("proxy.process.http.origin.body"); + http_rsb.origin_close_private = metrics.createPtr("proxy.process.http.origin.close_private"); + http_rsb.origin_connect_adjust_thread = metrics.createPtr("proxy.process.http.origin.connect.adjust_thread"); + http_rsb.origin_connections_throttled = metrics.createPtr("proxy.process.http.origin_connections_throttled_out"); + http_rsb.origin_make_new = metrics.createPtr("proxy.process.http.origin.make_new"); + http_rsb.origin_no_sharing = metrics.createPtr("proxy.process.http.origin.no_sharing"); + http_rsb.origin_not_found = metrics.createPtr("proxy.process.http.origin.not_found"); + http_rsb.origin_private = metrics.createPtr("proxy.process.http.origin.private"); + http_rsb.origin_raw = metrics.createPtr("proxy.process.http.origin.raw"); + http_rsb.origin_reuse = metrics.createPtr("proxy.process.http.origin.reuse"); + http_rsb.origin_reuse_fail = metrics.createPtr("proxy.process.http.origin.reuse_fail"); http_rsb.origin_server_request_document_total_size = - intm.newMetricPtr("proxy.process.http.origin_server_request_document_total_size"); + metrics.createPtr("proxy.process.http.origin_server_request_document_total_size"); http_rsb.origin_server_request_header_total_size = - intm.newMetricPtr("proxy.process.http.origin_server_request_header_total_size"); + metrics.createPtr("proxy.process.http.origin_server_request_header_total_size"); http_rsb.origin_server_response_document_total_size = - intm.newMetricPtr("proxy.process.http.origin_server_response_document_total_size"); + metrics.createPtr("proxy.process.http.origin_server_response_document_total_size"); http_rsb.origin_server_response_header_total_size = - intm.newMetricPtr("proxy.process.http.origin_server_response_header_total_size"); - http_rsb.origin_shutdown_cleanup_entry = intm.newMetricPtr("proxy.process.http.origin_shutdown.cleanup_entry"); - http_rsb.origin_shutdown_migration_failure = intm.newMetricPtr("proxy.process.http.origin_shutdown.migration_failure"); - http_rsb.origin_shutdown_pool_lock_contention = intm.newMetricPtr("proxy.process.http.origin_shutdown.pool_lock_contention"); + metrics.createPtr("proxy.process.http.origin_server_response_header_total_size"); + http_rsb.origin_shutdown_cleanup_entry = metrics.createPtr("proxy.process.http.origin_shutdown.cleanup_entry"); + http_rsb.origin_shutdown_migration_failure = metrics.createPtr("proxy.process.http.origin_shutdown.migration_failure"); + http_rsb.origin_shutdown_pool_lock_contention = metrics.createPtr("proxy.process.http.origin_shutdown.pool_lock_contention"); http_rsb.origin_shutdown_release_invalid_request = - intm.newMetricPtr("proxy.process.http.origin_shutdown.release_invalid_request"); + metrics.createPtr("proxy.process.http.origin_shutdown.release_invalid_request"); http_rsb.origin_shutdown_release_invalid_response = - intm.newMetricPtr("proxy.process.http.origin_shutdown.release_invalid_response"); - http_rsb.origin_shutdown_release_misc = intm.newMetricPtr("proxy.process.http.origin_shutdown.release_misc"); - http_rsb.origin_shutdown_release_modified = intm.newMetricPtr("proxy.process.http.origin_shutdown.release_modified"); - http_rsb.origin_shutdown_release_no_keep_alive = intm.newMetricPtr("proxy.process.http.origin_shutdown.release_no_keep_alive"); - http_rsb.origin_shutdown_release_no_server = intm.newMetricPtr("proxy.process.http.origin_shutdown.release_no_server"); - http_rsb.origin_shutdown_release_no_sharing = intm.newMetricPtr("proxy.process.http.origin_shutdown.release_no_sharing"); - http_rsb.origin_shutdown_tunnel_abort = intm.newMetricPtr("proxy.process.http.origin_shutdown.tunnel_abort"); - http_rsb.origin_shutdown_tunnel_client = intm.newMetricPtr("proxy.process.http.origin_shutdown.tunnel_client"); - http_rsb.origin_shutdown_tunnel_server = intm.newMetricPtr("proxy.process.http.origin_shutdown.tunnel_server"); - http_rsb.origin_shutdown_tunnel_server_detach = intm.newMetricPtr("proxy.process.http.origin_shutdown.tunnel_server_detach"); - http_rsb.origin_shutdown_tunnel_server_eos = intm.newMetricPtr("proxy.process.http.origin_shutdown.tunnel_server_eos"); + metrics.createPtr("proxy.process.http.origin_shutdown.release_invalid_response"); + http_rsb.origin_shutdown_release_misc = metrics.createPtr("proxy.process.http.origin_shutdown.release_misc"); + http_rsb.origin_shutdown_release_modified = metrics.createPtr("proxy.process.http.origin_shutdown.release_modified"); + http_rsb.origin_shutdown_release_no_keep_alive = metrics.createPtr("proxy.process.http.origin_shutdown.release_no_keep_alive"); + http_rsb.origin_shutdown_release_no_server = metrics.createPtr("proxy.process.http.origin_shutdown.release_no_server"); + http_rsb.origin_shutdown_release_no_sharing = metrics.createPtr("proxy.process.http.origin_shutdown.release_no_sharing"); + http_rsb.origin_shutdown_tunnel_abort = metrics.createPtr("proxy.process.http.origin_shutdown.tunnel_abort"); + http_rsb.origin_shutdown_tunnel_client = metrics.createPtr("proxy.process.http.origin_shutdown.tunnel_client"); + http_rsb.origin_shutdown_tunnel_server = metrics.createPtr("proxy.process.http.origin_shutdown.tunnel_server"); + http_rsb.origin_shutdown_tunnel_server_detach = metrics.createPtr("proxy.process.http.origin_shutdown.tunnel_server_detach"); + http_rsb.origin_shutdown_tunnel_server_eos = metrics.createPtr("proxy.process.http.origin_shutdown.tunnel_server_eos"); http_rsb.origin_shutdown_tunnel_server_no_keep_alive = - intm.newMetricPtr("proxy.process.http.origin_shutdown.tunnel_server_no_keep_alive"); + metrics.createPtr("proxy.process.http.origin_shutdown.tunnel_server_no_keep_alive"); http_rsb.origin_shutdown_tunnel_server_plugin_tunnel = - intm.newMetricPtr("proxy.process.http.origin_shutdown.tunnel_server_plugin_tunnel"); - http_rsb.origin_shutdown_tunnel_transform_read = intm.newMetricPtr("proxy.process.http.origin_shutdown.tunnel_transform_read"); - http_rsb.outgoing_requests = intm.newMetricPtr("proxy.process.http.outgoing_requests"); - http_rsb.parent_count = intm.newMetricPtr("proxy.process.http_parent_count"); - http_rsb.parent_proxy_request_total_bytes = intm.newMetricPtr("proxy.process.http.parent_proxy_request_total_bytes"); - http_rsb.parent_proxy_response_total_bytes = intm.newMetricPtr("proxy.process.http.parent_proxy_response_total_bytes"); - http_rsb.parent_proxy_transaction_time = intm.newMetricPtr("proxy.process.http.parent_proxy_transaction_time"); - http_rsb.pooled_server_connections = intm.newMetricPtr("proxy.process.http.pooled_server_connections"); - http_rsb.post_body_too_large = intm.newMetricPtr("proxy.process.http.post_body_too_large"); - http_rsb.post_requests = intm.newMetricPtr("proxy.process.http.post_requests"); - http_rsb.proxy_loop_detected = intm.newMetricPtr("proxy.process.http.http_proxy_loop_detected"); - http_rsb.proxy_mh_loop_detected = intm.newMetricPtr("proxy.process.http.http_proxy_mh_loop_detected"); - http_rsb.purge_requests = intm.newMetricPtr("proxy.process.http.purge_requests"); - http_rsb.push_requests = intm.newMetricPtr("proxy.process.http.push_requests"); - http_rsb.pushed_document_total_size = intm.newMetricPtr("proxy.process.http.pushed_document_total_size"); - http_rsb.pushed_response_header_total_size = intm.newMetricPtr("proxy.process.http.pushed_response_header_total_size"); - http_rsb.put_requests = intm.newMetricPtr("proxy.process.http.put_requests"); - http_rsb.response_status_100_count = intm.newMetricPtr("proxy.process.http.100_responses"); - http_rsb.response_status_101_count = intm.newMetricPtr("proxy.process.http.101_responses"); - http_rsb.response_status_1xx_count = intm.newMetricPtr("proxy.process.http.1xx_responses"); - http_rsb.response_status_200_count = intm.newMetricPtr("proxy.process.http.200_responses"); - http_rsb.response_status_201_count = intm.newMetricPtr("proxy.process.http.201_responses"); - http_rsb.response_status_202_count = intm.newMetricPtr("proxy.process.http.202_responses"); - http_rsb.response_status_203_count = intm.newMetricPtr("proxy.process.http.203_responses"); - http_rsb.response_status_204_count = intm.newMetricPtr("proxy.process.http.204_responses"); - http_rsb.response_status_205_count = intm.newMetricPtr("proxy.process.http.205_responses"); - http_rsb.response_status_206_count = intm.newMetricPtr("proxy.process.http.206_responses"); - http_rsb.response_status_2xx_count = intm.newMetricPtr("proxy.process.http.2xx_responses"); - http_rsb.response_status_300_count = intm.newMetricPtr("proxy.process.http.300_responses"); - http_rsb.response_status_301_count = intm.newMetricPtr("proxy.process.http.301_responses"); - http_rsb.response_status_302_count = intm.newMetricPtr("proxy.process.http.302_responses"); - http_rsb.response_status_303_count = intm.newMetricPtr("proxy.process.http.303_responses"); - http_rsb.response_status_304_count = intm.newMetricPtr("proxy.process.http.304_responses"); - http_rsb.response_status_305_count = intm.newMetricPtr("proxy.process.http.305_responses"); - http_rsb.response_status_307_count = intm.newMetricPtr("proxy.process.http.307_responses"); - http_rsb.response_status_308_count = intm.newMetricPtr("proxy.process.http.308_responses"); - http_rsb.response_status_3xx_count = intm.newMetricPtr("proxy.process.http.3xx_responses"); - http_rsb.response_status_400_count = intm.newMetricPtr("proxy.process.http.400_responses"); - http_rsb.response_status_401_count = intm.newMetricPtr("proxy.process.http.401_responses"); - http_rsb.response_status_402_count = intm.newMetricPtr("proxy.process.http.402_responses"); - http_rsb.response_status_403_count = intm.newMetricPtr("proxy.process.http.403_responses"); - http_rsb.response_status_404_count = intm.newMetricPtr("proxy.process.http.404_responses"); - http_rsb.response_status_405_count = intm.newMetricPtr("proxy.process.http.405_responses"); - http_rsb.response_status_406_count = intm.newMetricPtr("proxy.process.http.406_responses"); - http_rsb.response_status_407_count = intm.newMetricPtr("proxy.process.http.407_responses"); - http_rsb.response_status_408_count = intm.newMetricPtr("proxy.process.http.408_responses"); - http_rsb.response_status_409_count = intm.newMetricPtr("proxy.process.http.409_responses"); - http_rsb.response_status_410_count = intm.newMetricPtr("proxy.process.http.410_responses"); - http_rsb.response_status_411_count = intm.newMetricPtr("proxy.process.http.411_responses"); - http_rsb.response_status_412_count = intm.newMetricPtr("proxy.process.http.412_responses"); - http_rsb.response_status_413_count = intm.newMetricPtr("proxy.process.http.413_responses"); - http_rsb.response_status_414_count = intm.newMetricPtr("proxy.process.http.414_responses"); - http_rsb.response_status_415_count = intm.newMetricPtr("proxy.process.http.415_responses"); - http_rsb.response_status_416_count = intm.newMetricPtr("proxy.process.http.416_responses"); - http_rsb.response_status_4xx_count = intm.newMetricPtr("proxy.process.http.4xx_responses"); - http_rsb.response_status_500_count = intm.newMetricPtr("proxy.process.http.500_responses"); - http_rsb.response_status_501_count = intm.newMetricPtr("proxy.process.http.501_responses"); - http_rsb.response_status_502_count = intm.newMetricPtr("proxy.process.http.502_responses"); - http_rsb.response_status_503_count = intm.newMetricPtr("proxy.process.http.503_responses"); - http_rsb.response_status_504_count = intm.newMetricPtr("proxy.process.http.504_responses"); - http_rsb.response_status_505_count = intm.newMetricPtr("proxy.process.http.505_responses"); - http_rsb.response_status_5xx_count = intm.newMetricPtr("proxy.process.http.5xx_responses"); - http_rsb.server_begin_write_time = intm.newMetricPtr("proxy.process.http.milestone.server_begin_write"); - http_rsb.server_close_time = intm.newMetricPtr("proxy.process.http.milestone.server_close"); - http_rsb.server_connect_end_time = intm.newMetricPtr("proxy.process.http.milestone.server_connect_end"); - http_rsb.server_connect_time = intm.newMetricPtr("proxy.process.http.milestone.server_connect"); - http_rsb.server_first_connect_time = intm.newMetricPtr("proxy.process.http.milestone.server_first_connect"); - http_rsb.server_first_read_time = intm.newMetricPtr("proxy.process.http.milestone.server_first_read"); - http_rsb.server_read_header_done_time = intm.newMetricPtr("proxy.process.http.milestone.server_read_header_done"); - http_rsb.sm_finish_time = intm.newMetricPtr("proxy.process.http.milestone.sm_finish"); - http_rsb.sm_start_time = intm.newMetricPtr("proxy.process.http.milestone.sm_start"); - http_rsb.tcp_client_refresh_count = intm.newMetricPtr("proxy.process.http.tcp_client_refresh_count"); - http_rsb.tcp_client_refresh_origin_server_bytes = intm.newMetricPtr("proxy.process.http.tcp_client_refresh_origin_server_bytes"); - http_rsb.tcp_client_refresh_user_agent_bytes = intm.newMetricPtr("proxy.process.http.tcp_client_refresh_user_agent_bytes"); - http_rsb.tcp_expired_miss_count = intm.newMetricPtr("proxy.process.http.tcp_expired_miss_count"); - http_rsb.tcp_expired_miss_origin_server_bytes = intm.newMetricPtr("proxy.process.http.tcp_expired_miss_origin_server_bytes"); - http_rsb.tcp_expired_miss_user_agent_bytes = intm.newMetricPtr("proxy.process.http.tcp_expired_miss_user_agent_bytes"); - http_rsb.tcp_hit_count = intm.newMetricPtr("proxy.process.http.tcp_hit_count"); - http_rsb.tcp_hit_origin_server_bytes = intm.newMetricPtr("proxy.process.http.tcp_hit_origin_server_bytes"); - http_rsb.tcp_hit_user_agent_bytes = intm.newMetricPtr("proxy.process.http.tcp_hit_user_agent_bytes"); - http_rsb.tcp_ims_hit_count = intm.newMetricPtr("proxy.process.http.tcp_ims_hit_count"); - http_rsb.tcp_ims_hit_origin_server_bytes = intm.newMetricPtr("proxy.process.http.tcp_ims_hit_origin_server_bytes"); - http_rsb.tcp_ims_hit_user_agent_bytes = intm.newMetricPtr("proxy.process.http.tcp_ims_hit_user_agent_bytes"); - http_rsb.tcp_ims_miss_count = intm.newMetricPtr("proxy.process.http.tcp_ims_miss_count"); - http_rsb.tcp_ims_miss_origin_server_bytes = intm.newMetricPtr("proxy.process.http.tcp_ims_miss_origin_server_bytes"); - http_rsb.tcp_ims_miss_user_agent_bytes = intm.newMetricPtr("proxy.process.http.tcp_ims_miss_user_agent_bytes"); - http_rsb.tcp_miss_count = intm.newMetricPtr("proxy.process.http.tcp_miss_count"); - http_rsb.tcp_miss_origin_server_bytes = intm.newMetricPtr("proxy.process.http.tcp_miss_origin_server_bytes"); - http_rsb.tcp_miss_user_agent_bytes = intm.newMetricPtr("proxy.process.http.tcp_miss_user_agent_bytes"); - http_rsb.tcp_refresh_hit_count = intm.newMetricPtr("proxy.process.http.tcp_refresh_hit_count"); - http_rsb.tcp_refresh_hit_origin_server_bytes = intm.newMetricPtr("proxy.process.http.tcp_refresh_hit_origin_server_bytes"); - http_rsb.tcp_refresh_hit_user_agent_bytes = intm.newMetricPtr("proxy.process.http.tcp_refresh_hit_user_agent_bytes"); - http_rsb.tcp_refresh_miss_count = intm.newMetricPtr("proxy.process.http.tcp_refresh_miss_count"); - http_rsb.tcp_refresh_miss_origin_server_bytes = intm.newMetricPtr("proxy.process.http.tcp_refresh_miss_origin_server_bytes"); - http_rsb.tcp_refresh_miss_user_agent_bytes = intm.newMetricPtr("proxy.process.http.tcp_refresh_miss_user_agent_bytes"); - http_rsb.total_client_connections = intm.newMetricPtr("proxy.process.http.total_client_connections"); - http_rsb.total_client_connections_ipv4 = intm.newMetricPtr("proxy.process.http.total_client_connections_ipv4"); - http_rsb.total_client_connections_ipv6 = intm.newMetricPtr("proxy.process.http.total_client_connections_ipv6"); - http_rsb.total_incoming_connections = intm.newMetricPtr("proxy.process.http.total_incoming_connections"); - http_rsb.total_parent_marked_down_count = intm.newMetricPtr("proxy.process.http.total_parent_marked_down_count"); - http_rsb.total_parent_proxy_connections = intm.newMetricPtr("proxy.process.http.total_parent_proxy_connections"); - http_rsb.total_parent_retries = intm.newMetricPtr("proxy.process.http.total_parent_retries"); - http_rsb.total_parent_retries_exhausted = intm.newMetricPtr("proxy.process.http.total_parent_retries_exhausted"); - http_rsb.total_parent_switches = intm.newMetricPtr("proxy.process.http.total_parent_switches"); - http_rsb.total_server_connections = intm.newMetricPtr("proxy.process.http.total_server_connections"); - http_rsb.total_transactions_time = intm.newMetricPtr("proxy.process.http.total_transactions_time"); - http_rsb.total_x_redirect = intm.newMetricPtr("proxy.process.http.total_x_redirect_count"); - http_rsb.trace_requests = intm.newMetricPtr("proxy.process.http.trace_requests"); - http_rsb.tunnel_current_active_connections = intm.newMetricPtr("proxy.process.tunnel.current_active_connections"); - http_rsb.tunnels = intm.newMetricPtr("proxy.process.http.tunnels"); - http_rsb.ua_begin_time = intm.newMetricPtr("proxy.process.http.milestone.ua_begin"); - http_rsb.ua_begin_write_time = intm.newMetricPtr("proxy.process.http.milestone.ua_begin_write"); - http_rsb.ua_close_time = intm.newMetricPtr("proxy.process.http.milestone.ua_close"); - http_rsb.ua_counts_errors_aborts = intm.newMetricPtr("proxy.process.http.transaction_counts.errors.aborts"); - http_rsb.ua_counts_errors_connect_failed = intm.newMetricPtr("proxy.process.http.transaction_counts.errors.connect_failed"); - http_rsb.ua_counts_errors_other = intm.newMetricPtr("proxy.process.http.transaction_counts.errors.other"); - http_rsb.ua_counts_errors_possible_aborts = intm.newMetricPtr("proxy.process.http.transaction_counts.errors.possible_aborts"); + metrics.createPtr("proxy.process.http.origin_shutdown.tunnel_server_plugin_tunnel"); + http_rsb.origin_shutdown_tunnel_transform_read = metrics.createPtr("proxy.process.http.origin_shutdown.tunnel_transform_read"); + http_rsb.outgoing_requests = metrics.createPtr("proxy.process.http.outgoing_requests"); + http_rsb.parent_count = metrics.createPtr("proxy.process.http_parent_count"); + http_rsb.parent_proxy_request_total_bytes = metrics.createPtr("proxy.process.http.parent_proxy_request_total_bytes"); + http_rsb.parent_proxy_response_total_bytes = metrics.createPtr("proxy.process.http.parent_proxy_response_total_bytes"); + http_rsb.parent_proxy_transaction_time = metrics.createPtr("proxy.process.http.parent_proxy_transaction_time"); + http_rsb.pooled_server_connections = metrics.createPtr("proxy.process.http.pooled_server_connections"); + http_rsb.post_body_too_large = metrics.createPtr("proxy.process.http.post_body_too_large"); + http_rsb.post_requests = metrics.createPtr("proxy.process.http.post_requests"); + http_rsb.proxy_loop_detected = metrics.createPtr("proxy.process.http.http_proxy_loop_detected"); + http_rsb.proxy_mh_loop_detected = metrics.createPtr("proxy.process.http.http_proxy_mh_loop_detected"); + http_rsb.purge_requests = metrics.createPtr("proxy.process.http.purge_requests"); + http_rsb.push_requests = metrics.createPtr("proxy.process.http.push_requests"); + http_rsb.pushed_document_total_size = metrics.createPtr("proxy.process.http.pushed_document_total_size"); + http_rsb.pushed_response_header_total_size = metrics.createPtr("proxy.process.http.pushed_response_header_total_size"); + http_rsb.put_requests = metrics.createPtr("proxy.process.http.put_requests"); + http_rsb.response_status_100_count = metrics.createPtr("proxy.process.http.100_responses"); + http_rsb.response_status_101_count = metrics.createPtr("proxy.process.http.101_responses"); + http_rsb.response_status_1xx_count = metrics.createPtr("proxy.process.http.1xx_responses"); + http_rsb.response_status_200_count = metrics.createPtr("proxy.process.http.200_responses"); + http_rsb.response_status_201_count = metrics.createPtr("proxy.process.http.201_responses"); + http_rsb.response_status_202_count = metrics.createPtr("proxy.process.http.202_responses"); + http_rsb.response_status_203_count = metrics.createPtr("proxy.process.http.203_responses"); + http_rsb.response_status_204_count = metrics.createPtr("proxy.process.http.204_responses"); + http_rsb.response_status_205_count = metrics.createPtr("proxy.process.http.205_responses"); + http_rsb.response_status_206_count = metrics.createPtr("proxy.process.http.206_responses"); + http_rsb.response_status_2xx_count = metrics.createPtr("proxy.process.http.2xx_responses"); + http_rsb.response_status_300_count = metrics.createPtr("proxy.process.http.300_responses"); + http_rsb.response_status_301_count = metrics.createPtr("proxy.process.http.301_responses"); + http_rsb.response_status_302_count = metrics.createPtr("proxy.process.http.302_responses"); + http_rsb.response_status_303_count = metrics.createPtr("proxy.process.http.303_responses"); + http_rsb.response_status_304_count = metrics.createPtr("proxy.process.http.304_responses"); + http_rsb.response_status_305_count = metrics.createPtr("proxy.process.http.305_responses"); + http_rsb.response_status_307_count = metrics.createPtr("proxy.process.http.307_responses"); + http_rsb.response_status_308_count = metrics.createPtr("proxy.process.http.308_responses"); + http_rsb.response_status_3xx_count = metrics.createPtr("proxy.process.http.3xx_responses"); + http_rsb.response_status_400_count = metrics.createPtr("proxy.process.http.400_responses"); + http_rsb.response_status_401_count = metrics.createPtr("proxy.process.http.401_responses"); + http_rsb.response_status_402_count = metrics.createPtr("proxy.process.http.402_responses"); + http_rsb.response_status_403_count = metrics.createPtr("proxy.process.http.403_responses"); + http_rsb.response_status_404_count = metrics.createPtr("proxy.process.http.404_responses"); + http_rsb.response_status_405_count = metrics.createPtr("proxy.process.http.405_responses"); + http_rsb.response_status_406_count = metrics.createPtr("proxy.process.http.406_responses"); + http_rsb.response_status_407_count = metrics.createPtr("proxy.process.http.407_responses"); + http_rsb.response_status_408_count = metrics.createPtr("proxy.process.http.408_responses"); + http_rsb.response_status_409_count = metrics.createPtr("proxy.process.http.409_responses"); + http_rsb.response_status_410_count = metrics.createPtr("proxy.process.http.410_responses"); + http_rsb.response_status_411_count = metrics.createPtr("proxy.process.http.411_responses"); + http_rsb.response_status_412_count = metrics.createPtr("proxy.process.http.412_responses"); + http_rsb.response_status_413_count = metrics.createPtr("proxy.process.http.413_responses"); + http_rsb.response_status_414_count = metrics.createPtr("proxy.process.http.414_responses"); + http_rsb.response_status_415_count = metrics.createPtr("proxy.process.http.415_responses"); + http_rsb.response_status_416_count = metrics.createPtr("proxy.process.http.416_responses"); + http_rsb.response_status_4xx_count = metrics.createPtr("proxy.process.http.4xx_responses"); + http_rsb.response_status_500_count = metrics.createPtr("proxy.process.http.500_responses"); + http_rsb.response_status_501_count = metrics.createPtr("proxy.process.http.501_responses"); + http_rsb.response_status_502_count = metrics.createPtr("proxy.process.http.502_responses"); + http_rsb.response_status_503_count = metrics.createPtr("proxy.process.http.503_responses"); + http_rsb.response_status_504_count = metrics.createPtr("proxy.process.http.504_responses"); + http_rsb.response_status_505_count = metrics.createPtr("proxy.process.http.505_responses"); + http_rsb.response_status_5xx_count = metrics.createPtr("proxy.process.http.5xx_responses"); + http_rsb.server_begin_write_time = metrics.createPtr("proxy.process.http.milestone.server_begin_write"); + http_rsb.server_close_time = metrics.createPtr("proxy.process.http.milestone.server_close"); + http_rsb.server_connect_end_time = metrics.createPtr("proxy.process.http.milestone.server_connect_end"); + http_rsb.server_connect_time = metrics.createPtr("proxy.process.http.milestone.server_connect"); + http_rsb.server_first_connect_time = metrics.createPtr("proxy.process.http.milestone.server_first_connect"); + http_rsb.server_first_read_time = metrics.createPtr("proxy.process.http.milestone.server_first_read"); + http_rsb.server_read_header_done_time = metrics.createPtr("proxy.process.http.milestone.server_read_header_done"); + http_rsb.sm_finish_time = metrics.createPtr("proxy.process.http.milestone.sm_finish"); + http_rsb.sm_start_time = metrics.createPtr("proxy.process.http.milestone.sm_start"); + http_rsb.tcp_client_refresh_count = metrics.createPtr("proxy.process.http.tcp_client_refresh_count"); + http_rsb.tcp_client_refresh_origin_server_bytes = metrics.createPtr("proxy.process.http.tcp_client_refresh_origin_server_bytes"); + http_rsb.tcp_client_refresh_user_agent_bytes = metrics.createPtr("proxy.process.http.tcp_client_refresh_user_agent_bytes"); + http_rsb.tcp_expired_miss_count = metrics.createPtr("proxy.process.http.tcp_expired_miss_count"); + http_rsb.tcp_expired_miss_origin_server_bytes = metrics.createPtr("proxy.process.http.tcp_expired_miss_origin_server_bytes"); + http_rsb.tcp_expired_miss_user_agent_bytes = metrics.createPtr("proxy.process.http.tcp_expired_miss_user_agent_bytes"); + http_rsb.tcp_hit_count = metrics.createPtr("proxy.process.http.tcp_hit_count"); + http_rsb.tcp_hit_origin_server_bytes = metrics.createPtr("proxy.process.http.tcp_hit_origin_server_bytes"); + http_rsb.tcp_hit_user_agent_bytes = metrics.createPtr("proxy.process.http.tcp_hit_user_agent_bytes"); + http_rsb.tcp_ims_hit_count = metrics.createPtr("proxy.process.http.tcp_ims_hit_count"); + http_rsb.tcp_ims_hit_origin_server_bytes = metrics.createPtr("proxy.process.http.tcp_ims_hit_origin_server_bytes"); + http_rsb.tcp_ims_hit_user_agent_bytes = metrics.createPtr("proxy.process.http.tcp_ims_hit_user_agent_bytes"); + http_rsb.tcp_ims_miss_count = metrics.createPtr("proxy.process.http.tcp_ims_miss_count"); + http_rsb.tcp_ims_miss_origin_server_bytes = metrics.createPtr("proxy.process.http.tcp_ims_miss_origin_server_bytes"); + http_rsb.tcp_ims_miss_user_agent_bytes = metrics.createPtr("proxy.process.http.tcp_ims_miss_user_agent_bytes"); + http_rsb.tcp_miss_count = metrics.createPtr("proxy.process.http.tcp_miss_count"); + http_rsb.tcp_miss_origin_server_bytes = metrics.createPtr("proxy.process.http.tcp_miss_origin_server_bytes"); + http_rsb.tcp_miss_user_agent_bytes = metrics.createPtr("proxy.process.http.tcp_miss_user_agent_bytes"); + http_rsb.tcp_refresh_hit_count = metrics.createPtr("proxy.process.http.tcp_refresh_hit_count"); + http_rsb.tcp_refresh_hit_origin_server_bytes = metrics.createPtr("proxy.process.http.tcp_refresh_hit_origin_server_bytes"); + http_rsb.tcp_refresh_hit_user_agent_bytes = metrics.createPtr("proxy.process.http.tcp_refresh_hit_user_agent_bytes"); + http_rsb.tcp_refresh_miss_count = metrics.createPtr("proxy.process.http.tcp_refresh_miss_count"); + http_rsb.tcp_refresh_miss_origin_server_bytes = metrics.createPtr("proxy.process.http.tcp_refresh_miss_origin_server_bytes"); + http_rsb.tcp_refresh_miss_user_agent_bytes = metrics.createPtr("proxy.process.http.tcp_refresh_miss_user_agent_bytes"); + http_rsb.total_client_connections = metrics.createPtr("proxy.process.http.total_client_connections"); + http_rsb.total_client_connections_ipv4 = metrics.createPtr("proxy.process.http.total_client_connections_ipv4"); + http_rsb.total_client_connections_ipv6 = metrics.createPtr("proxy.process.http.total_client_connections_ipv6"); + http_rsb.total_incoming_connections = metrics.createPtr("proxy.process.http.total_incoming_connections"); + http_rsb.total_parent_marked_down_count = metrics.createPtr("proxy.process.http.total_parent_marked_down_count"); + http_rsb.total_parent_proxy_connections = metrics.createPtr("proxy.process.http.total_parent_proxy_connections"); + http_rsb.total_parent_retries = metrics.createPtr("proxy.process.http.total_parent_retries"); + http_rsb.total_parent_retries_exhausted = metrics.createPtr("proxy.process.http.total_parent_retries_exhausted"); + http_rsb.total_parent_switches = metrics.createPtr("proxy.process.http.total_parent_switches"); + http_rsb.total_server_connections = metrics.createPtr("proxy.process.http.total_server_connections"); + http_rsb.total_transactions_time = metrics.createPtr("proxy.process.http.total_transactions_time"); + http_rsb.total_x_redirect = metrics.createPtr("proxy.process.http.total_x_redirect_count"); + http_rsb.trace_requests = metrics.createPtr("proxy.process.http.trace_requests"); + http_rsb.tunnel_current_active_connections = metrics.createPtr("proxy.process.tunnel.current_active_connections"); + http_rsb.tunnels = metrics.createPtr("proxy.process.http.tunnels"); + http_rsb.ua_begin_time = metrics.createPtr("proxy.process.http.milestone.ua_begin"); + http_rsb.ua_begin_write_time = metrics.createPtr("proxy.process.http.milestone.ua_begin_write"); + http_rsb.ua_close_time = metrics.createPtr("proxy.process.http.milestone.ua_close"); + http_rsb.ua_counts_errors_aborts = metrics.createPtr("proxy.process.http.transaction_counts.errors.aborts"); + http_rsb.ua_counts_errors_connect_failed = metrics.createPtr("proxy.process.http.transaction_counts.errors.connect_failed"); + http_rsb.ua_counts_errors_other = metrics.createPtr("proxy.process.http.transaction_counts.errors.other"); + http_rsb.ua_counts_errors_possible_aborts = metrics.createPtr("proxy.process.http.transaction_counts.errors.possible_aborts"); http_rsb.ua_counts_errors_pre_accept_hangups = - intm.newMetricPtr("proxy.process.http.transaction_counts.errors.pre_accept_hangups"); - http_rsb.ua_counts_hit_fresh = intm.newMetricPtr("proxy.process.http.transaction_counts.hit_fresh"); - http_rsb.ua_counts_hit_fresh_process = intm.newMetricPtr("proxy.process.http.transaction_counts.hit_fresh.process"); - http_rsb.ua_counts_hit_reval = intm.newMetricPtr("proxy.process.http.transaction_counts.hit_revalidated"); - http_rsb.ua_counts_miss_changed = intm.newMetricPtr("proxy.process.http.transaction_counts.miss_changed"); - http_rsb.ua_counts_miss_client_no_cache = intm.newMetricPtr("proxy.process.http.transaction_counts.miss_client_no_cache"); - http_rsb.ua_counts_miss_cold = intm.newMetricPtr("proxy.process.http.transaction_counts.miss_cold"); - http_rsb.ua_counts_miss_uncacheable = intm.newMetricPtr("proxy.process.http.transaction_counts.miss_not_cacheable"); - http_rsb.ua_counts_other_unclassified = intm.newMetricPtr("proxy.process.http.transaction_counts.other.unclassified"); - http_rsb.ua_first_read_time = intm.newMetricPtr("proxy.process.http.milestone.ua_first_read"); - http_rsb.ua_msecs_errors_aborts = intm.newMetricPtr("proxy.process.http.transaction_totaltime.errors.aborts"); - http_rsb.ua_msecs_errors_connect_failed = intm.newMetricPtr("proxy.process.http.transaction_totaltime.errors.connect_failed"); - http_rsb.ua_msecs_errors_other = intm.newMetricPtr("proxy.process.http.transaction_totaltime.errors.other"); - http_rsb.ua_msecs_errors_possible_aborts = intm.newMetricPtr("proxy.process.http.transaction_totaltime.errors.possible_aborts"); + metrics.createPtr("proxy.process.http.transaction_counts.errors.pre_accept_hangups"); + http_rsb.ua_counts_hit_fresh = metrics.createPtr("proxy.process.http.transaction_counts.hit_fresh"); + http_rsb.ua_counts_hit_fresh_process = metrics.createPtr("proxy.process.http.transaction_counts.hit_fresh.process"); + http_rsb.ua_counts_hit_reval = metrics.createPtr("proxy.process.http.transaction_counts.hit_revalidated"); + http_rsb.ua_counts_miss_changed = metrics.createPtr("proxy.process.http.transaction_counts.miss_changed"); + http_rsb.ua_counts_miss_client_no_cache = metrics.createPtr("proxy.process.http.transaction_counts.miss_client_no_cache"); + http_rsb.ua_counts_miss_cold = metrics.createPtr("proxy.process.http.transaction_counts.miss_cold"); + http_rsb.ua_counts_miss_uncacheable = metrics.createPtr("proxy.process.http.transaction_counts.miss_not_cacheable"); + http_rsb.ua_counts_other_unclassified = metrics.createPtr("proxy.process.http.transaction_counts.other.unclassified"); + http_rsb.ua_first_read_time = metrics.createPtr("proxy.process.http.milestone.ua_first_read"); + http_rsb.ua_msecs_errors_aborts = metrics.createPtr("proxy.process.http.transaction_totaltime.errors.aborts"); + http_rsb.ua_msecs_errors_connect_failed = metrics.createPtr("proxy.process.http.transaction_totaltime.errors.connect_failed"); + http_rsb.ua_msecs_errors_other = metrics.createPtr("proxy.process.http.transaction_totaltime.errors.other"); + http_rsb.ua_msecs_errors_possible_aborts = metrics.createPtr("proxy.process.http.transaction_totaltime.errors.possible_aborts"); http_rsb.ua_msecs_errors_pre_accept_hangups = - intm.newMetricPtr("proxy.process.http.transaction_totaltime.errors.pre_accept_hangups"); - http_rsb.ua_msecs_hit_fresh = intm.newMetricPtr("proxy.process.http.transaction_totaltime.hit_fresh"); - http_rsb.ua_msecs_hit_fresh_process = intm.newMetricPtr("proxy.process.http.transaction_totaltime.hit_fresh.process"); - http_rsb.ua_msecs_hit_reval = intm.newMetricPtr("proxy.process.http.transaction_totaltime.hit_revalidated"); - http_rsb.ua_msecs_miss_changed = intm.newMetricPtr("proxy.process.http.transaction_totaltime.miss_changed"); - http_rsb.ua_msecs_miss_client_no_cache = intm.newMetricPtr("proxy.process.http.transaction_totaltime.miss_client_no_cache"); - http_rsb.ua_msecs_miss_cold = intm.newMetricPtr("proxy.process.http.transaction_totaltime.miss_cold"); - http_rsb.ua_msecs_miss_uncacheable = intm.newMetricPtr("proxy.process.http.transaction_totaltime.miss_not_cacheable"); - http_rsb.ua_msecs_other_unclassified = intm.newMetricPtr("proxy.process.http.transaction_totaltime.other.unclassified"); - http_rsb.ua_read_header_done_time = intm.newMetricPtr("proxy.process.http.milestone.ua_read_header_done"); - http_rsb.user_agent_request_document_total_size = intm.newMetricPtr("proxy.process.http.user_agent_request_document_total_size"); - http_rsb.user_agent_request_header_total_size = intm.newMetricPtr("proxy.process.http.user_agent_request_header_total_size"); + metrics.createPtr("proxy.process.http.transaction_totaltime.errors.pre_accept_hangups"); + http_rsb.ua_msecs_hit_fresh = metrics.createPtr("proxy.process.http.transaction_totaltime.hit_fresh"); + http_rsb.ua_msecs_hit_fresh_process = metrics.createPtr("proxy.process.http.transaction_totaltime.hit_fresh.process"); + http_rsb.ua_msecs_hit_reval = metrics.createPtr("proxy.process.http.transaction_totaltime.hit_revalidated"); + http_rsb.ua_msecs_miss_changed = metrics.createPtr("proxy.process.http.transaction_totaltime.miss_changed"); + http_rsb.ua_msecs_miss_client_no_cache = metrics.createPtr("proxy.process.http.transaction_totaltime.miss_client_no_cache"); + http_rsb.ua_msecs_miss_cold = metrics.createPtr("proxy.process.http.transaction_totaltime.miss_cold"); + http_rsb.ua_msecs_miss_uncacheable = metrics.createPtr("proxy.process.http.transaction_totaltime.miss_not_cacheable"); + http_rsb.ua_msecs_other_unclassified = metrics.createPtr("proxy.process.http.transaction_totaltime.other.unclassified"); + http_rsb.ua_read_header_done_time = metrics.createPtr("proxy.process.http.milestone.ua_read_header_done"); + http_rsb.user_agent_request_document_total_size = metrics.createPtr("proxy.process.http.user_agent_request_document_total_size"); + http_rsb.user_agent_request_header_total_size = metrics.createPtr("proxy.process.http.user_agent_request_header_total_size"); http_rsb.user_agent_response_document_total_size = - intm.newMetricPtr("proxy.process.http.user_agent_response_document_total_size"); - http_rsb.user_agent_response_header_total_size = intm.newMetricPtr("proxy.process.http.user_agent_response_header_total_size"); + metrics.createPtr("proxy.process.http.user_agent_response_document_total_size"); + http_rsb.user_agent_response_header_total_size = metrics.createPtr("proxy.process.http.user_agent_response_header_total_size"); http_rsb.websocket_current_active_client_connections = - intm.newMetricPtr("proxy.process.http.websocket.current_active_client_connections"); + metrics.createPtr("proxy.process.http.websocket.current_active_client_connections"); } static bool diff --git a/src/proxy/http/HttpSM.cc b/src/proxy/http/HttpSM.cc index e987911eafc..eb4d5f39ffe 100644 --- a/src/proxy/http/HttpSM.cc +++ b/src/proxy/http/HttpSM.cc @@ -1609,7 +1609,7 @@ HttpSM::handle_api_return() // a blind tunnel. IOBufferReader *initial_data = nullptr; if (t_state.is_websocket) { - Metrics::increment(http_rsb.websocket_current_active_client_connections); + Counter::increment(http_rsb.websocket_current_active_client_connections); if (server_txn) { initial_data = server_txn->get_remote_reader(); } @@ -1726,8 +1726,8 @@ HttpSM::create_server_txn(PoolableSession *new_session) server_txn->attach_transaction(this); if (t_state.current.request_to == ResolveInfo::PARENT_PROXY) { new_session->to_parent_proxy = true; - Metrics::increment(http_rsb.current_parent_proxy_connections); - Metrics::increment(http_rsb.total_parent_proxy_connections); + Counter::increment(http_rsb.current_parent_proxy_connections); + Counter::increment(http_rsb.total_parent_proxy_connections); } else { new_session->to_parent_proxy = false; } @@ -1847,7 +1847,7 @@ HttpSM::state_http_server_open(int event, void *data) t_state.client_info.keep_alive = HTTP_NO_KEEPALIVE; // part of the problem, clear it. terminate_sm = true; } else if (ENET_THROTTLING == t_state.current.server->connect_result) { - Metrics::increment(http_rsb.origin_connections_throttled); + Counter::increment(http_rsb.origin_connections_throttled); send_origin_throttled_response(); } else { // Go ahead and release the failed server session. Since it didn't receive a response, the release logic will @@ -2457,7 +2457,7 @@ HttpSM::state_cache_open_write(int event, void *data) if (_ua.get_txn()) { pending_action = _ua.get_txn()->adjust_thread(this, event, data); if (!pending_action.empty()) { - Metrics::increment(http_rsb.cache_open_write_adjust_thread); + Counter::increment(http_rsb.cache_open_write_adjust_thread); return 0; // Go away if we reschedule } NetVConnection *vc = _ua.get_txn()->get_netvc(); @@ -3009,7 +3009,7 @@ HttpSM::tunnel_handler(int event, void *data) terminate_sm = true; if (unlikely(t_state.is_websocket)) { - Metrics::decrement(http_rsb.websocket_current_active_client_connections); + Counter::decrement(http_rsb.websocket_current_active_client_connections); } return 0; @@ -3070,11 +3070,11 @@ HttpSM::tunnel_handler_server(int event, HttpTunnelProducer *p) close_connection = false; } else { if (t_state.current.server->keep_alive != HTTP_KEEPALIVE) { - Metrics::increment(http_rsb.origin_shutdown_tunnel_server_no_keep_alive); + Counter::increment(http_rsb.origin_shutdown_tunnel_server_no_keep_alive); } else if (server_entry->eos == true) { - Metrics::increment(http_rsb.origin_shutdown_tunnel_server_eos); + Counter::increment(http_rsb.origin_shutdown_tunnel_server_eos); } else { - Metrics::increment(http_rsb.origin_shutdown_tunnel_server_plugin_tunnel); + Counter::increment(http_rsb.origin_shutdown_tunnel_server_plugin_tunnel); } close_connection = true; } @@ -3103,7 +3103,7 @@ HttpSM::tunnel_handler_server(int event, HttpTunnelProducer *p) t_state.current.server->state = HttpTransact::TRANSACTION_COMPLETE; break; } - Metrics::increment(http_rsb.origin_shutdown_tunnel_server); + Counter::increment(http_rsb.origin_shutdown_tunnel_server); close_connection = true; ink_assert(p->vc_type == HT_HTTP_SERVER); @@ -3181,7 +3181,7 @@ HttpSM::tunnel_handler_server(int event, HttpTunnelProducer *p) p->read_success = true; t_state.current.server->state = HttpTransact::TRANSACTION_COMPLETE; t_state.current.server->abort = HttpTransact::DIDNOT_ABORT; - Metrics::increment(http_rsb.origin_shutdown_tunnel_server_detach); + Counter::increment(http_rsb.origin_shutdown_tunnel_server_detach); close_connection = true; break; @@ -3202,7 +3202,7 @@ HttpSM::tunnel_handler_server(int event, HttpTunnelProducer *p) // If we had a ground fill, check update our status if (background_fill == BACKGROUND_FILL_STARTED) { background_fill = p->read_success ? BACKGROUND_FILL_COMPLETED : BACKGROUND_FILL_ABORTED; - Metrics::decrement(http_rsb.background_fill_current_count); + Counter::decrement(http_rsb.background_fill_current_count); } // We handled the event. Now either shutdown the connection or // setup it up for keep-alive @@ -3449,8 +3449,8 @@ HttpSM::tunnel_handler_ua(int event, HttpTunnelConsumer *c) // There is another consumer (cache write) so // detach the user agent if (background_fill == BACKGROUND_FILL_STARTED) { - Metrics::increment(http_rsb.background_fill_current_count); - Metrics::increment(http_rsb.background_fill_total_count); + Counter::increment(http_rsb.background_fill_current_count); + Counter::increment(http_rsb.background_fill_total_count); ink_assert(c->is_downstream_from(server_txn)); server_txn->set_active_timeout(HRTIME_SECONDS(t_state.txn_conf->background_fill_active_timeout)); @@ -3667,7 +3667,7 @@ HttpSM::tunnel_handler_cache_read(int event, HttpTunnelProducer *p) p->vc->do_io_close(EHTTP_ERROR); p->read_vio = nullptr; tunnel.chain_abort_all(p); - Metrics::increment(http_rsb.cache_read_errors); + Counter::increment(http_rsb.cache_read_errors); break; } else { tunnel.local_finish_all(p); @@ -3688,7 +3688,7 @@ HttpSM::tunnel_handler_cache_read(int event, HttpTunnelProducer *p) break; } - Metrics::decrement(http_rsb.current_cache_connections); + Counter::decrement(http_rsb.current_cache_connections); return 0; } @@ -3709,7 +3709,7 @@ HttpSM::tunnel_handler_cache_write(int event, HttpTunnelConsumer *c) c->write_vio = nullptr; c->vc->do_io_close(EHTTP_ERROR); - Metrics::increment(http_rsb.cache_write_errors); + Counter::increment(http_rsb.cache_write_errors); SMDebug("http", "aborting cache write due %s event from cache", HttpDebugNames::get_event_name(event)); // abort the producer if the cache_writevc is the only consumer. if (c->producer->alive && c->producer->num_consumers == 1) { @@ -3743,7 +3743,7 @@ HttpSM::tunnel_handler_cache_write(int event, HttpTunnelConsumer *c) server_response_body_bytes = c->bytes_written; } - Metrics::decrement(http_rsb.current_cache_connections); + Counter::decrement(http_rsb.current_cache_connections); return 0; } @@ -4233,7 +4233,7 @@ HttpSM::tunnel_handler_transform_read(int event, HttpTunnelProducer *p) // transform hasn't detached yet. If it is still alive, // don't close the transform vc if (p->self_consumer->alive == false) { - Metrics::increment(http_rsb.origin_shutdown_tunnel_transform_read); + Counter::increment(http_rsb.origin_shutdown_tunnel_transform_read); p->vc->do_io_close(); } p->handler_state = HTTP_SM_TRANSFORM_CLOSED; @@ -4936,7 +4936,7 @@ HttpSM::do_cache_lookup_and_read() t_state.request_sent_time = UNDEFINED_TIME; t_state.response_received_time = UNDEFINED_TIME; - Metrics::increment(http_rsb.cache_lookups); + Counter::increment(http_rsb.cache_lookups); milestones[TS_MILESTONE_CACHE_OPEN_READ_BEGIN] = ink_get_hrtime(); t_state.cache_lookup_result = HttpTransact::CACHE_LOOKUP_NONE; @@ -5386,16 +5386,16 @@ HttpSM::do_http_server_open(bool raw, bool only_direct) switch (shared_result) { case HSM_DONE: - Metrics::increment(http_rsb.origin_reuse); + Counter::increment(http_rsb.origin_reuse); hsm_release_assert(server_txn != nullptr); handle_http_server_open(); return; case HSM_NOT_FOUND: - Metrics::increment(http_rsb.origin_not_found); + Counter::increment(http_rsb.origin_not_found); hsm_release_assert(server_txn == nullptr); break; case HSM_RETRY: - Metrics::increment(http_rsb.origin_reuse_fail); + Counter::increment(http_rsb.origin_reuse_fail); // Could not get shared pool lock // FIX: should retry lock break; @@ -5443,15 +5443,15 @@ HttpSM::do_http_server_open(bool raw, bool only_direct) } if (!try_reuse) { - Metrics::increment(http_rsb.origin_make_new); + Counter::increment(http_rsb.origin_make_new); if (TS_SERVER_SESSION_SHARING_MATCH_NONE == t_state.txn_conf->server_session_sharing_match) { - Metrics::increment(http_rsb.origin_no_sharing); + Counter::increment(http_rsb.origin_no_sharing); } else if ((t_state.txn_conf->keep_alive_post_out != 1 && t_state.hdr_info.request_content_length > 0)) { - Metrics::increment(http_rsb.origin_body); + Counter::increment(http_rsb.origin_body); } else if (is_private()) { - Metrics::increment(http_rsb.origin_private); + Counter::increment(http_rsb.origin_private); } else if (raw) { - Metrics::increment(http_rsb.origin_raw); + Counter::increment(http_rsb.origin_raw); } else { ink_release_assert(_ua.get_txn() == nullptr); } @@ -5472,7 +5472,7 @@ HttpSM::do_http_server_open(bool raw, bool only_direct) // Atomically read the current number of connections and check to see // if we have gone above the max allowed. if (t_state.http_config_param->server_max_connections > 0) { - if (Metrics::read(http_rsb.current_server_connections) >= t_state.http_config_param->server_max_connections) { + if (Counter::read(http_rsb.current_server_connections) >= t_state.http_config_param->server_max_connections) { httpSessionManager.purge_keepalives(); // Eventually may want to have a queue as the origin_max_connection does to allow for a combination // of retries and errors. But at this point, we are just going to allow the error case. @@ -5500,7 +5500,7 @@ HttpSM::do_http_server_open(bool raw, bool only_direct) ink_assert(pending_action.empty()); // in case of reschedule must not have already pending. ct_state.blocked(); - Metrics::increment(http_rsb.origin_connections_throttled); + Counter::increment(http_rsb.origin_connections_throttled); ct_state.Warn_Blocked(server_max, sm_id, ccount - 1, &t_state.current.server->dst_addr.sa, debug_on && is_debug_tag_set("http") ? "http" : nullptr); send_origin_throttled_response(); @@ -5882,21 +5882,21 @@ HttpSM::release_server_session(bool serve_from_cache) } else { server_txn->do_io_close(); if (TS_SERVER_SESSION_SHARING_MATCH_NONE == t_state.txn_conf->server_session_sharing_match) { - Metrics::increment(http_rsb.origin_shutdown_release_no_sharing); + Counter::increment(http_rsb.origin_shutdown_release_no_sharing); } else if (t_state.current.server == nullptr) { - Metrics::increment(http_rsb.origin_shutdown_release_no_server); + Counter::increment(http_rsb.origin_shutdown_release_no_server); } else if (t_state.current.server->keep_alive != HTTP_KEEPALIVE) { - Metrics::increment(http_rsb.origin_shutdown_release_no_keep_alive); + Counter::increment(http_rsb.origin_shutdown_release_no_keep_alive); } else if (!t_state.hdr_info.server_response.valid()) { - Metrics::increment(http_rsb.origin_shutdown_release_invalid_response); + Counter::increment(http_rsb.origin_shutdown_release_invalid_response); } else if (!t_state.hdr_info.server_request.valid()) { - Metrics::increment(http_rsb.origin_shutdown_release_invalid_request); + Counter::increment(http_rsb.origin_shutdown_release_invalid_request); } else if (t_state.hdr_info.server_response.status_get() != HTTP_STATUS_NOT_MODIFIED && (t_state.hdr_info.server_request.method_get_wksidx() != HTTP_WKSIDX_HEAD || t_state.www_auth_content == HttpTransact::CACHE_AUTH_NONE)) { - Metrics::increment(http_rsb.origin_shutdown_release_modified); + Counter::increment(http_rsb.origin_shutdown_release_modified); } else { - Metrics::increment(http_rsb.origin_shutdown_release_misc); + Counter::increment(http_rsb.origin_shutdown_release_misc); } } @@ -8271,7 +8271,7 @@ HttpSM::do_redirect() ats_free((void *)redirect_url); redirect_url = nullptr; redirect_url_len = 0; - Metrics::increment(http_rsb.total_x_redirect); + Counter::increment(http_rsb.total_x_redirect); } else { // get the location header and setup the redirect int redir_len = 0; diff --git a/src/proxy/http/HttpSessionAccept.cc b/src/proxy/http/HttpSessionAccept.cc index 803af838dac..ab93610e268 100644 --- a/src/proxy/http/HttpSessionAccept.cc +++ b/src/proxy/http/HttpSessionAccept.cc @@ -81,8 +81,8 @@ HttpSessionAccept::mainEvent(int event, void *data) ///////////////// if (((long)data) == -ECONNABORTED) { // FIX: add time to user_agent_hangup - Metrics::increment(http_rsb.ua_counts_errors_pre_accept_hangups); - // Metrics::increment(http_rsb.ua_msecs_errors_pre_accept_hangups, 0); // ToDo: Weird, but we added 0 here before + Counter::increment(http_rsb.ua_counts_errors_pre_accept_hangups); + // Counter::increment(http_rsb.ua_msecs_errors_pre_accept_hangups, 0); // ToDo: Weird, but we added 0 here before } ink_abort("HTTP accept received fatal error: errno = %d", -(static_cast((intptr_t)data))); diff --git a/src/proxy/http/HttpSessionManager.cc b/src/proxy/http/HttpSessionManager.cc index 93602388f2b..923d4dbcb72 100644 --- a/src/proxy/http/HttpSessionManager.cc +++ b/src/proxy/http/HttpSessionManager.cc @@ -455,7 +455,7 @@ HttpSessionManager::_acquire_session(sockaddr const *ip, CryptoHash const &hostn ink_assert(new_vc == nullptr || new_vc->nh != nullptr); if (!new_vc) { // Close out to_return, we were't able to get a connection - Metrics::increment(http_rsb.origin_shutdown_migration_failure); + Counter::increment(http_rsb.origin_shutdown_migration_failure); to_return->do_io_close(); to_return = nullptr; retval = HSM_NOT_FOUND; @@ -536,7 +536,7 @@ ServerSessionPool::removeSession(PoolableSession *to_remove) } m_fqdn_pool.erase(to_remove); if (m_ip_pool.erase(to_remove)) { - Metrics::decrement(http_rsb.pooled_server_connections); + Counter::decrement(http_rsb.pooled_server_connections); } if (is_debug_tag_set("http_ss")) { Debug("http_ss", "After Remove session %p m_fqdn_pool size=%zu m_ip_pool_size=%zu", to_remove, m_fqdn_pool.count(), @@ -552,7 +552,7 @@ ServerSessionPool::addSession(PoolableSession *ss) // put it in the pools. m_ip_pool.insert(ss); m_fqdn_pool.insert(ss); - Metrics::increment(http_rsb.pooled_server_connections); + Counter::increment(http_rsb.pooled_server_connections); if (is_debug_tag_set("http_ss")) { char peer_ip[INET6_ADDRPORTSTRLEN]; diff --git a/src/proxy/http/HttpTransact.cc b/src/proxy/http/HttpTransact.cc index 55b646ca691..ecd70f61a6a 100644 --- a/src/proxy/http/HttpTransact.cc +++ b/src/proxy/http/HttpTransact.cc @@ -189,7 +189,7 @@ inline static void findParent(HttpTransact::State *s) { url_mapping *mp = s->url_map.getMapping(); - Metrics::increment(http_rsb.parent_count); + Counter::increment(http_rsb.parent_count); if (s->response_action.handled) { s->parent_result.hostname = s->response_action.action.hostname; s->parent_result.port = s->response_action.action.port; @@ -214,7 +214,7 @@ findParent(HttpTransact::State *s) inline static void markParentDown(HttpTransact::State *s) { - Metrics::increment(http_rsb.total_parent_marked_down_count); + Counter::increment(http_rsb.total_parent_marked_down_count); url_mapping *mp = s->url_map.getMapping(); TxnDebug("http_trans", "enable_parent_timeout_markdowns: %d, disable_parent_markdowns: %d", @@ -280,7 +280,7 @@ nextParent(HttpTransact::State *s) TxnDebug("parent_down", "connection to parent %s failed, conn_state: %s, request to origin: %s", s->parent_result.hostname, HttpDebugNames::get_server_state_name(s->current.state), s->request_data.get_host()); url_mapping *mp = s->url_map.getMapping(); - Metrics::increment(http_rsb.parent_count); + Counter::increment(http_rsb.parent_count); if (s->response_action.handled) { s->parent_result.hostname = s->response_action.action.hostname; s->parent_result.port = s->response_action.action.port; @@ -909,7 +909,7 @@ HttpTransact::OriginDown(State *s) TxnDebug("http_trans", "origin server is marked down"); bootstrap_state_variables_from_request(s, &s->hdr_info.client_request); build_error_response(s, HTTP_STATUS_BAD_GATEWAY, "Origin Server Marked Down", "connect#failed_connect"); - Metrics::increment(http_rsb.down_server_no_requests); + Counter::increment(http_rsb.down_server_no_requests); char *url_str = s->hdr_info.client_request.url_string_get(&s->arena); int host_len; const char *host_name_ptr = s->unmapped_url.host_get(&host_len); @@ -1194,7 +1194,7 @@ HttpTransact::EndRemapRequest(State *s) */ if (!s->reverse_proxy && s->state_machine->plugin_tunnel_type == HTTP_NO_PLUGIN_TUNNEL) { TxnDebug("http_trans", "END HttpTransact::EndRemapRequest"); - Metrics::increment(http_rsb.invalid_client_requests); + Counter::increment(http_rsb.invalid_client_requests); TRANSACT_RETURN(SM_ACTION_SEND_ERROR_CACHE_NOOP, nullptr); } else { s->hdr_info.client_response.destroy(); // release the underlying memory. @@ -1489,10 +1489,10 @@ HttpTransact::HandleRequest(State *s) if (!s->state_machine->is_waiting_for_full_body && !s->state_machine->is_using_post_buffer) { ink_assert(!s->hdr_info.server_request.valid()); - Metrics::increment(http_rsb.incoming_requests); + Counter::increment(http_rsb.incoming_requests); if (s->client_info.port_attribute == HttpProxyPort::TRANSPORT_SSL) { - Metrics::increment(http_rsb.https_incoming_requests); + Counter::increment(http_rsb.https_incoming_requests); } /////////////////////////////////////////////// @@ -1500,7 +1500,7 @@ HttpTransact::HandleRequest(State *s) /////////////////////////////////////////////// if (!(is_request_valid(s, &s->hdr_info.client_request))) { - Metrics::increment(http_rsb.invalid_client_requests); + Counter::increment(http_rsb.invalid_client_requests); TxnDebug("http_seq", "request invalid."); s->next_action = SM_ACTION_SEND_ERROR_CACHE_NOOP; // s->next_action = HttpTransact::PROXY_INTERNAL_CACHE_NOOP; @@ -1517,7 +1517,7 @@ HttpTransact::HandleRequest(State *s) initialize_state_variables_from_request(s, &s->hdr_info.client_request); // The following chunk of code will limit the maximum number of websocket connections (TS-3659) if (s->is_upgrade_request && s->is_websocket && s->http_config_param->max_websocket_connections >= 0) { - if (Metrics::read(http_rsb.websocket_current_active_client_connections) >= s->http_config_param->max_websocket_connections) { + if (Counter::read(http_rsb.websocket_current_active_client_connections) >= s->http_config_param->max_websocket_connections) { s->is_websocket = false; // unset to avoid screwing up stats. TxnDebug("http_trans", "Rejecting websocket connection because the limit has been exceeded"); bootstrap_state_variables_from_request(s, &s->hdr_info.client_request); @@ -1531,7 +1531,7 @@ HttpTransact::HandleRequest(State *s) s->hdr_info.request_content_length > s->http_config_param->max_post_size) { TxnDebug("http_trans", "Max post size %" PRId64 " Client tried to post a body that was too large.", s->http_config_param->max_post_size); - Metrics::increment(http_rsb.post_body_too_large); + Counter::increment(http_rsb.post_body_too_large); bootstrap_state_variables_from_request(s, &s->hdr_info.client_request); build_error_response(s, HTTP_STATUS_REQUEST_ENTITY_TOO_LARGE, "Request Entity Too Large", "request#entity_too_large"); s->squid_codes.log_code = SQUID_LOG_ERR_POST_ENTITY_TOO_LARGE; @@ -1549,7 +1549,7 @@ HttpTransact::HandleRequest(State *s) if (ptr_len_casecmp(expect_hdr_val, expect_hdr_val_len, HTTP_VALUE_100_CONTINUE, HTTP_LEN_100_CONTINUE) == 0) { // Let's error out this request. TxnDebug("http_trans", "Client sent a post expect: 100-continue, sending 405."); - Metrics::increment(http_rsb.disallowed_post_100_continue); + Counter::increment(http_rsb.disallowed_post_100_continue); build_error_response(s, HTTP_STATUS_METHOD_NOT_ALLOWED, "Method Not Allowed", "request#method_unsupported"); TRANSACT_RETURN(SM_ACTION_SEND_ERROR_CACHE_NOOP, nullptr); } @@ -1674,7 +1674,7 @@ HttpTransact::setup_plugin_request_intercept(State *s) if (s->cache_info.action != HttpTransact::CACHE_DO_NO_ACTION) { s->cache_info.action = HttpTransact::CACHE_DO_NO_ACTION; s->current.mode = TUNNELLING_PROXY; - Metrics::increment(http_rsb.tunnels); + Counter::increment(http_rsb.tunnels); } // Regardless of the protocol we're gatewaying to // we see the scheme as http @@ -2088,7 +2088,7 @@ HttpTransact::DecideCacheLookup(State *s) } else { s->cache_info.action = CACHE_DO_NO_ACTION; s->current.mode = TUNNELLING_PROXY; - Metrics::increment(http_rsb.tunnels); + Counter::increment(http_rsb.tunnels); } } @@ -3419,7 +3419,7 @@ HttpTransact::HandleResponse(State *s) TxnDebug("http_trans", "response_received_time: %" PRId64, (int64_t)s->response_received_time); DUMP_HEADER("http_hdrs", &s->hdr_info.server_response, s->state_machine_id(), "Incoming O.S. Response"); - Metrics::increment(http_rsb.incoming_responses); + Counter::increment(http_rsb.incoming_responses); ink_release_assert(s->current.request_to != ResolveInfo::UNDEFINED_LOOKUP); if (s->cache_info.action != CACHE_DO_WRITE) { @@ -3639,13 +3639,13 @@ HttpTransact::handle_response_from_parent(State *s) } if (s->current.retry_attempts.get() < (s->txn_conf->parent_connect_attempts - 1)) { - Metrics::increment(http_rsb.total_parent_retries); + Counter::increment(http_rsb.total_parent_retries); s->current.retry_attempts.increment(); // Are we done with this particular parent? if (s->current.retry_attempts.get() % s->txn_conf->per_parent_connect_attempts != 0) { // No we are not done with this parent so retry - Metrics::increment(http_rsb.total_parent_switches); + Counter::increment(http_rsb.total_parent_switches); s->next_action = how_to_open_connection(s); TxnDebug("http_trans", "%s Retrying parent for attempt %d, max %" PRId64, "[handle_response_from_parent]", s->current.retry_attempts.get(), s->txn_conf->per_parent_connect_attempts); @@ -3653,7 +3653,7 @@ HttpTransact::handle_response_from_parent(State *s) } else { TxnDebug("http_trans", "%s %d per parent attempts exhausted", "[handle_response_from_parent]", s->current.retry_attempts.get()); - Metrics::increment(http_rsb.total_parent_retries_exhausted); + Counter::increment(http_rsb.total_parent_retries_exhausted); // Only mark the parent down if we failed to connect // to the parent otherwise slow origin servers cause @@ -3667,7 +3667,7 @@ HttpTransact::handle_response_from_parent(State *s) } else { // Done trying parents... fail over to origin server if that is // appropriate - Metrics::increment(http_rsb.total_parent_retries_exhausted); + Counter::increment(http_rsb.total_parent_retries_exhausted); TxnDebug("http_trans", "Error. No more retries."); if (s->current.state == CONNECTION_ERROR || s->current.state == INACTIVE_TIMEOUT) { markParentDown(s); @@ -3888,7 +3888,7 @@ HttpTransact::handle_server_connection_not_open(State *s) ink_assert(s->current.state != CONNECTION_ALIVE); SET_VIA_STRING(VIA_SERVER_RESULT, VIA_SERVER_ERROR); - Metrics::increment(http_rsb.broken_server_connections); + Counter::increment(http_rsb.broken_server_connections); // Fire off a hostdb update to mark the server as down s->state_machine->do_hostdb_update_if_necessary(); @@ -4349,7 +4349,7 @@ HttpTransact::handle_cache_operation_on_forward_server_response(State *s) base_response->set_expires(exp_time); SET_VIA_STRING(VIA_CACHE_FILL_ACTION, VIA_CACHE_UPDATED); - Metrics::increment(http_rsb.cache_updates); + Counter::increment(http_rsb.cache_updates); // unset Cache-control: "need-revalidate-once" (if it's set) // This directive is used internally by T.S. to invalidate @@ -4552,12 +4552,12 @@ HttpTransact::handle_cache_operation_on_forward_server_response(State *s) case CACHE_DO_DELETE: TxnDebug("http_trans", "[hcoofsr] delete cached copy"); SET_VIA_STRING(VIA_CACHE_FILL_ACTION, VIA_CACHE_DELETED); - Metrics::increment(http_rsb.cache_deletes); + Counter::increment(http_rsb.cache_deletes); break; case CACHE_DO_WRITE: TxnDebug("http_trans", "[hcoofsr] cache write"); SET_VIA_STRING(VIA_CACHE_FILL_ACTION, VIA_CACHE_WRITTEN); - Metrics::increment(http_rsb.cache_writes); + Counter::increment(http_rsb.cache_writes); break; case CACHE_DO_SERVE_AND_UPDATE: // fall through @@ -4566,7 +4566,7 @@ HttpTransact::handle_cache_operation_on_forward_server_response(State *s) case CACHE_DO_REPLACE: TxnDebug("http_trans", "[hcoofsr] cache update/replace"); SET_VIA_STRING(VIA_CACHE_FILL_ACTION, VIA_CACHE_UPDATED); - Metrics::increment(http_rsb.cache_updates); + Counter::increment(http_rsb.cache_updates); break; default: break; @@ -5410,7 +5410,7 @@ HttpTransact::check_request_validity(State *s, HTTPHdr *incoming_hdr) if (!incoming_hdr->presence(MIME_PRESENCE_HOST) && incoming_hdr->version_get() != HTTP_0_9) { // Update the number of incoming 1.0 or 1.1 requests that do // not contain Host header fields. - Metrics::increment(http_rsb.missing_host_hdr); + Counter::increment(http_rsb.missing_host_hdr); } // Did the client send a "TE: identity;q=0"? We have to respond // with an error message because we only support identity @@ -5567,7 +5567,7 @@ HttpTransact::handle_trace_and_options_requests(State *s, HTTPHdr *incoming_hdr) // Trace and Options requests should not be looked up in cache. // s->cache_info.action = CACHE_DO_NO_ACTION; s->current.mode = TUNNELLING_PROXY; - Metrics::increment(http_rsb.tunnels); + Counter::increment(http_rsb.tunnels); return false; } @@ -5633,7 +5633,7 @@ HttpTransact::handle_trace_and_options_requests(State *s, HTTPHdr *incoming_hdr) // Trace and Options requests should not be looked up in cache. // s->cache_info.action = CACHE_DO_NO_ACTION; s->current.mode = TUNNELLING_PROXY; - Metrics::increment(http_rsb.tunnels); + Counter::increment(http_rsb.tunnels); } return false; @@ -5780,27 +5780,27 @@ void HttpTransact::update_method_stat(int method) { if (method == HTTP_WKSIDX_GET) { - Metrics::increment(http_rsb.get_requests); + Counter::increment(http_rsb.get_requests); } else if (method == HTTP_WKSIDX_HEAD) { - Metrics::increment(http_rsb.head_requests); + Counter::increment(http_rsb.head_requests); } else if (method == HTTP_WKSIDX_POST) { - Metrics::increment(http_rsb.post_requests); + Counter::increment(http_rsb.post_requests); } else if (method == HTTP_WKSIDX_PUT) { - Metrics::increment(http_rsb.put_requests); + Counter::increment(http_rsb.put_requests); } else if (method == HTTP_WKSIDX_CONNECT) { - Metrics::increment(http_rsb.connect_requests); + Counter::increment(http_rsb.connect_requests); } else if (method == HTTP_WKSIDX_DELETE) { - Metrics::increment(http_rsb.delete_requests); + Counter::increment(http_rsb.delete_requests); } else if (method == HTTP_WKSIDX_PURGE) { - Metrics::increment(http_rsb.purge_requests); + Counter::increment(http_rsb.purge_requests); } else if (method == HTTP_WKSIDX_TRACE) { - Metrics::increment(http_rsb.trace_requests); + Counter::increment(http_rsb.trace_requests); } else if (method == HTTP_WKSIDX_PUSH) { - Metrics::increment(http_rsb.push_requests); + Counter::increment(http_rsb.push_requests); } else if (method == HTTP_WKSIDX_OPTIONS) { - Metrics::increment(http_rsb.options_requests); + Counter::increment(http_rsb.options_requests); } else { - Metrics::increment(http_rsb.extension_method_requests); + Counter::increment(http_rsb.extension_method_requests); } } @@ -6622,7 +6622,7 @@ HttpTransact::will_this_request_self_loop(State *s) break; } SET_VIA_STRING(VIA_ERROR_TYPE, VIA_ERROR_LOOP_DETECTED); - Metrics::increment(http_rsb.proxy_loop_detected); + Counter::increment(http_rsb.proxy_loop_detected); build_error_response(s, HTTP_STATUS_BAD_REQUEST, "Cycle Detected", "request#cycle_detected"); return true; } @@ -6656,7 +6656,7 @@ HttpTransact::will_this_request_self_loop(State *s) if (count > max_proxy_cycles) { TxnDebug("http_transact", "count = %d > max_proxy_cycles = %d : detected loop", count, max_proxy_cycles); SET_VIA_STRING(VIA_ERROR_TYPE, VIA_ERROR_LOOP_DETECTED); - Metrics::increment(http_rsb.proxy_mh_loop_detected); + Counter::increment(http_rsb.proxy_mh_loop_detected); build_error_response(s, HTTP_STATUS_BAD_REQUEST, "Multi-Hop Cycle Detected", "request#cycle_detected"); return true; } else { @@ -7832,7 +7832,7 @@ HttpTransact::build_request(State *s, HTTPHdr *base_request, HTTPHdr *outgoing_r TxnDebug("http_trans", "request_sent_time: %" PRId64, (int64_t)s->request_sent_time); DUMP_HEADER("http_hdrs", outgoing_request, s->state_machine_id(), "Proxy's Request"); - Metrics::increment(http_rsb.outgoing_requests); + Counter::increment(http_rsb.outgoing_requests); } // build a (status_code) response based upon the given info @@ -8332,68 +8332,68 @@ HttpTransact::client_result_stat(State *s, ink_hrtime total_time, ink_hrtime req switch (s->squid_codes.log_code) { case SQUID_LOG_ERR_CONNECT_FAIL: - Metrics::increment(http_rsb.cache_miss_cold); + Counter::increment(http_rsb.cache_miss_cold); client_transaction_result = CLIENT_TRANSACTION_RESULT_ERROR_CONNECT_FAIL; break; case SQUID_LOG_TCP_CF_HIT: - Metrics::increment(http_rsb.cache_hit_rww); + Counter::increment(http_rsb.cache_hit_rww); client_transaction_result = CLIENT_TRANSACTION_RESULT_HIT_FRESH; break; case SQUID_LOG_TCP_MEM_HIT: - Metrics::increment(http_rsb.cache_hit_mem_fresh); + Counter::increment(http_rsb.cache_hit_mem_fresh); // fallthrough case SQUID_LOG_TCP_HIT: // It's possible to have two stat's instead of one, if needed. - Metrics::increment(http_rsb.cache_hit_fresh); + Counter::increment(http_rsb.cache_hit_fresh); client_transaction_result = CLIENT_TRANSACTION_RESULT_HIT_FRESH; break; case SQUID_LOG_TCP_REFRESH_HIT: - Metrics::increment(http_rsb.cache_hit_reval); + Counter::increment(http_rsb.cache_hit_reval); client_transaction_result = CLIENT_TRANSACTION_RESULT_HIT_REVALIDATED; break; case SQUID_LOG_TCP_IMS_HIT: - Metrics::increment(http_rsb.cache_hit_ims); + Counter::increment(http_rsb.cache_hit_ims); client_transaction_result = CLIENT_TRANSACTION_RESULT_HIT_FRESH; break; case SQUID_LOG_TCP_REF_FAIL_HIT: - Metrics::increment(http_rsb.cache_hit_stale_served); + Counter::increment(http_rsb.cache_hit_stale_served); client_transaction_result = CLIENT_TRANSACTION_RESULT_HIT_FRESH; break; case SQUID_LOG_TCP_MISS: if ((GET_VIA_STRING(VIA_CACHE_RESULT) == VIA_IN_CACHE_NOT_ACCEPTABLE) || (GET_VIA_STRING(VIA_CACHE_RESULT) == VIA_CACHE_MISS)) { - Metrics::increment(http_rsb.cache_miss_cold); + Counter::increment(http_rsb.cache_miss_cold); client_transaction_result = CLIENT_TRANSACTION_RESULT_MISS_COLD; } else { // FIX: what case is this for? can it ever happen? - Metrics::increment(http_rsb.cache_miss_uncacheable); + Counter::increment(http_rsb.cache_miss_uncacheable); client_transaction_result = CLIENT_TRANSACTION_RESULT_MISS_UNCACHABLE; } break; case SQUID_LOG_TCP_REFRESH_MISS: - Metrics::increment(http_rsb.cache_miss_changed); + Counter::increment(http_rsb.cache_miss_changed); client_transaction_result = CLIENT_TRANSACTION_RESULT_MISS_CHANGED; break; case SQUID_LOG_TCP_CLIENT_REFRESH: - Metrics::increment(http_rsb.cache_miss_client_no_cache); + Counter::increment(http_rsb.cache_miss_client_no_cache); client_transaction_result = CLIENT_TRANSACTION_RESULT_MISS_CLIENT_NO_CACHE; break; case SQUID_LOG_TCP_IMS_MISS: - Metrics::increment(http_rsb.cache_miss_ims); + Counter::increment(http_rsb.cache_miss_ims); client_transaction_result = CLIENT_TRANSACTION_RESULT_MISS_COLD; break; case SQUID_LOG_TCP_SWAPFAIL: - Metrics::increment(http_rsb.cache_read_error); + Counter::increment(http_rsb.cache_read_error); client_transaction_result = CLIENT_TRANSACTION_RESULT_HIT_FRESH; break; @@ -8426,143 +8426,143 @@ HttpTransact::client_result_stat(State *s, ink_hrtime total_time, ink_hrtime req if ((s->source != SOURCE_NONE) && (s->client_info.abort == DIDNOT_ABORT)) { switch (client_response_status) { case 100: - Metrics::increment(http_rsb.response_status_100_count); + Counter::increment(http_rsb.response_status_100_count); break; case 101: - Metrics::increment(http_rsb.response_status_101_count); + Counter::increment(http_rsb.response_status_101_count); break; case 200: - Metrics::increment(http_rsb.response_status_200_count); + Counter::increment(http_rsb.response_status_200_count); break; case 201: - Metrics::increment(http_rsb.response_status_201_count); + Counter::increment(http_rsb.response_status_201_count); break; case 202: - Metrics::increment(http_rsb.response_status_202_count); + Counter::increment(http_rsb.response_status_202_count); break; case 203: - Metrics::increment(http_rsb.response_status_203_count); + Counter::increment(http_rsb.response_status_203_count); break; case 204: - Metrics::increment(http_rsb.response_status_204_count); + Counter::increment(http_rsb.response_status_204_count); break; case 205: - Metrics::increment(http_rsb.response_status_205_count); + Counter::increment(http_rsb.response_status_205_count); break; case 206: - Metrics::increment(http_rsb.response_status_206_count); + Counter::increment(http_rsb.response_status_206_count); break; case 300: - Metrics::increment(http_rsb.response_status_300_count); + Counter::increment(http_rsb.response_status_300_count); break; case 301: - Metrics::increment(http_rsb.response_status_301_count); + Counter::increment(http_rsb.response_status_301_count); break; case 302: - Metrics::increment(http_rsb.response_status_302_count); + Counter::increment(http_rsb.response_status_302_count); break; case 303: - Metrics::increment(http_rsb.response_status_303_count); + Counter::increment(http_rsb.response_status_303_count); break; case 304: - Metrics::increment(http_rsb.response_status_304_count); + Counter::increment(http_rsb.response_status_304_count); break; case 305: - Metrics::increment(http_rsb.response_status_305_count); + Counter::increment(http_rsb.response_status_305_count); break; case 307: - Metrics::increment(http_rsb.response_status_307_count); + Counter::increment(http_rsb.response_status_307_count); break; case 308: - Metrics::increment(http_rsb.response_status_308_count); + Counter::increment(http_rsb.response_status_308_count); break; case 400: - Metrics::increment(http_rsb.response_status_400_count); + Counter::increment(http_rsb.response_status_400_count); break; case 401: - Metrics::increment(http_rsb.response_status_401_count); + Counter::increment(http_rsb.response_status_401_count); break; case 402: - Metrics::increment(http_rsb.response_status_402_count); + Counter::increment(http_rsb.response_status_402_count); break; case 403: - Metrics::increment(http_rsb.response_status_403_count); + Counter::increment(http_rsb.response_status_403_count); break; case 404: - Metrics::increment(http_rsb.response_status_404_count); + Counter::increment(http_rsb.response_status_404_count); break; case 405: - Metrics::increment(http_rsb.response_status_405_count); + Counter::increment(http_rsb.response_status_405_count); break; case 406: - Metrics::increment(http_rsb.response_status_406_count); + Counter::increment(http_rsb.response_status_406_count); break; case 407: - Metrics::increment(http_rsb.response_status_407_count); + Counter::increment(http_rsb.response_status_407_count); break; case 408: - Metrics::increment(http_rsb.response_status_408_count); + Counter::increment(http_rsb.response_status_408_count); break; case 409: - Metrics::increment(http_rsb.response_status_409_count); + Counter::increment(http_rsb.response_status_409_count); break; case 410: - Metrics::increment(http_rsb.response_status_410_count); + Counter::increment(http_rsb.response_status_410_count); break; case 411: - Metrics::increment(http_rsb.response_status_411_count); + Counter::increment(http_rsb.response_status_411_count); break; case 412: - Metrics::increment(http_rsb.response_status_412_count); + Counter::increment(http_rsb.response_status_412_count); break; case 413: - Metrics::increment(http_rsb.response_status_413_count); + Counter::increment(http_rsb.response_status_413_count); break; case 414: - Metrics::increment(http_rsb.response_status_414_count); + Counter::increment(http_rsb.response_status_414_count); break; case 415: - Metrics::increment(http_rsb.response_status_415_count); + Counter::increment(http_rsb.response_status_415_count); break; case 416: - Metrics::increment(http_rsb.response_status_416_count); + Counter::increment(http_rsb.response_status_416_count); break; case 500: - Metrics::increment(http_rsb.response_status_500_count); + Counter::increment(http_rsb.response_status_500_count); break; case 501: - Metrics::increment(http_rsb.response_status_501_count); + Counter::increment(http_rsb.response_status_501_count); break; case 502: - Metrics::increment(http_rsb.response_status_502_count); + Counter::increment(http_rsb.response_status_502_count); break; case 503: - Metrics::increment(http_rsb.response_status_503_count); + Counter::increment(http_rsb.response_status_503_count); break; case 504: - Metrics::increment(http_rsb.response_status_504_count); + Counter::increment(http_rsb.response_status_504_count); break; case 505: - Metrics::increment(http_rsb.response_status_505_count); + Counter::increment(http_rsb.response_status_505_count); break; default: break; } switch (client_response_status / 100) { case 1: - Metrics::increment(http_rsb.response_status_1xx_count); + Counter::increment(http_rsb.response_status_1xx_count); break; case 2: - Metrics::increment(http_rsb.response_status_2xx_count); + Counter::increment(http_rsb.response_status_2xx_count); break; case 3: - Metrics::increment(http_rsb.response_status_3xx_count); + Counter::increment(http_rsb.response_status_3xx_count); break; case 4: - Metrics::increment(http_rsb.response_status_4xx_count); + Counter::increment(http_rsb.response_status_4xx_count); break; case 5: - Metrics::increment(http_rsb.response_status_5xx_count); + Counter::increment(http_rsb.response_status_5xx_count); break; default: break; @@ -8570,57 +8570,57 @@ HttpTransact::client_result_stat(State *s, ink_hrtime total_time, ink_hrtime req } // Increment the completed connection count - Metrics::increment(http_rsb.completed_requests); + Counter::increment(http_rsb.completed_requests); // Set the stat now that we know what happend ink_hrtime total_msec = ink_hrtime_to_msec(total_time); ink_hrtime process_msec = ink_hrtime_to_msec(request_process_time); switch (client_transaction_result) { case CLIENT_TRANSACTION_RESULT_HIT_FRESH: - Metrics::increment(http_rsb.ua_counts_hit_fresh); - Metrics::increment(http_rsb.ua_msecs_hit_fresh, total_msec); - Metrics::increment(http_rsb.ua_counts_hit_fresh_process); - Metrics::increment(http_rsb.ua_msecs_hit_fresh_process, process_msec); + Counter::increment(http_rsb.ua_counts_hit_fresh); + Counter::increment(http_rsb.ua_msecs_hit_fresh, total_msec); + Counter::increment(http_rsb.ua_counts_hit_fresh_process); + Counter::increment(http_rsb.ua_msecs_hit_fresh_process, process_msec); break; case CLIENT_TRANSACTION_RESULT_HIT_REVALIDATED: - Metrics::increment(http_rsb.ua_counts_hit_reval); - Metrics::increment(http_rsb.ua_msecs_hit_reval, total_msec); + Counter::increment(http_rsb.ua_counts_hit_reval); + Counter::increment(http_rsb.ua_msecs_hit_reval, total_msec); break; case CLIENT_TRANSACTION_RESULT_MISS_COLD: - Metrics::increment(http_rsb.ua_counts_miss_cold); - Metrics::increment(http_rsb.ua_msecs_miss_cold, total_msec); + Counter::increment(http_rsb.ua_counts_miss_cold); + Counter::increment(http_rsb.ua_msecs_miss_cold, total_msec); break; case CLIENT_TRANSACTION_RESULT_MISS_CHANGED: - Metrics::increment(http_rsb.ua_counts_miss_changed); - Metrics::increment(http_rsb.ua_msecs_miss_changed, total_msec); + Counter::increment(http_rsb.ua_counts_miss_changed); + Counter::increment(http_rsb.ua_msecs_miss_changed, total_msec); break; case CLIENT_TRANSACTION_RESULT_MISS_CLIENT_NO_CACHE: - Metrics::increment(http_rsb.ua_counts_miss_client_no_cache); - Metrics::increment(http_rsb.ua_msecs_miss_client_no_cache, total_msec); + Counter::increment(http_rsb.ua_counts_miss_client_no_cache); + Counter::increment(http_rsb.ua_msecs_miss_client_no_cache, total_msec); break; case CLIENT_TRANSACTION_RESULT_MISS_UNCACHABLE: - Metrics::increment(http_rsb.ua_counts_miss_uncacheable); - Metrics::increment(http_rsb.ua_msecs_miss_uncacheable, total_msec); + Counter::increment(http_rsb.ua_counts_miss_uncacheable); + Counter::increment(http_rsb.ua_msecs_miss_uncacheable, total_msec); break; case CLIENT_TRANSACTION_RESULT_ERROR_ABORT: - Metrics::increment(http_rsb.ua_counts_errors_aborts); - Metrics::increment(http_rsb.ua_msecs_errors_aborts, total_msec); + Counter::increment(http_rsb.ua_counts_errors_aborts); + Counter::increment(http_rsb.ua_msecs_errors_aborts, total_msec); break; case CLIENT_TRANSACTION_RESULT_ERROR_POSSIBLE_ABORT: - Metrics::increment(http_rsb.ua_counts_errors_possible_aborts); - Metrics::increment(http_rsb.ua_msecs_errors_possible_aborts, total_msec); + Counter::increment(http_rsb.ua_counts_errors_possible_aborts); + Counter::increment(http_rsb.ua_msecs_errors_possible_aborts, total_msec); break; case CLIENT_TRANSACTION_RESULT_ERROR_CONNECT_FAIL: - Metrics::increment(http_rsb.ua_counts_errors_connect_failed); - Metrics::increment(http_rsb.ua_msecs_errors_connect_failed, total_msec); + Counter::increment(http_rsb.ua_counts_errors_connect_failed); + Counter::increment(http_rsb.ua_msecs_errors_connect_failed, total_msec); break; case CLIENT_TRANSACTION_RESULT_ERROR_OTHER: - Metrics::increment(http_rsb.ua_counts_errors_other); - Metrics::increment(http_rsb.ua_msecs_errors_other, total_msec); + Counter::increment(http_rsb.ua_counts_errors_other); + Counter::increment(http_rsb.ua_msecs_errors_other, total_msec); break; default: - Metrics::increment(http_rsb.ua_counts_other_unclassified); - Metrics::increment(http_rsb.ua_msecs_other_unclassified, total_msec); + Counter::increment(http_rsb.ua_counts_other_unclassified); + Counter::increment(http_rsb.ua_msecs_other_unclassified, total_msec); // This can happen if a plugin manually sets the status code after an error. TxnDebug("http", "Unclassified statistic"); break; @@ -8649,7 +8649,7 @@ HttpTransact::update_size_and_time_stats(State *s, ink_hrtime total_time, ink_hr case BACKGROUND_FILL_COMPLETED: { int64_t bg_size = origin_server_response_body_size - user_agent_response_body_size; bg_size = std::max(static_cast(0), bg_size); - Metrics::increment(http_rsb.background_fill_bytes_completed, bg_size); + Counter::increment(http_rsb.background_fill_bytes_completed, bg_size); break; } case BACKGROUND_FILL_ABORTED: { @@ -8658,7 +8658,7 @@ HttpTransact::update_size_and_time_stats(State *s, ink_hrtime total_time, ink_hr if (bg_size < 0) { bg_size = 0; } - Metrics::increment(http_rsb.background_fill_bytes_aborted, bg_size); + Counter::increment(http_rsb.background_fill_bytes_aborted, bg_size); break; } case BACKGROUND_FILL_NONE: @@ -8674,133 +8674,133 @@ HttpTransact::update_size_and_time_stats(State *s, ink_hrtime total_time, ink_hr case SQUID_LOG_TCP_MEM_HIT: case SQUID_LOG_TCP_CF_HIT: // It's possible to have two stat's instead of one, if needed. - Metrics::increment(http_rsb.tcp_hit_count); - Metrics::increment(http_rsb.tcp_hit_user_agent_bytes, user_agent_bytes); - Metrics::increment(http_rsb.tcp_hit_origin_server_bytes, origin_server_bytes); + Counter::increment(http_rsb.tcp_hit_count); + Counter::increment(http_rsb.tcp_hit_user_agent_bytes, user_agent_bytes); + Counter::increment(http_rsb.tcp_hit_origin_server_bytes, origin_server_bytes); break; case SQUID_LOG_TCP_MISS: - Metrics::increment(http_rsb.tcp_miss_count); - Metrics::increment(http_rsb.tcp_miss_user_agent_bytes, user_agent_bytes); - Metrics::increment(http_rsb.tcp_miss_origin_server_bytes, origin_server_bytes); + Counter::increment(http_rsb.tcp_miss_count); + Counter::increment(http_rsb.tcp_miss_user_agent_bytes, user_agent_bytes); + Counter::increment(http_rsb.tcp_miss_origin_server_bytes, origin_server_bytes); break; case SQUID_LOG_TCP_EXPIRED_MISS: - Metrics::increment(http_rsb.tcp_expired_miss_count); - Metrics::increment(http_rsb.tcp_expired_miss_user_agent_bytes, user_agent_bytes); - Metrics::increment(http_rsb.tcp_expired_miss_origin_server_bytes, origin_server_bytes); + Counter::increment(http_rsb.tcp_expired_miss_count); + Counter::increment(http_rsb.tcp_expired_miss_user_agent_bytes, user_agent_bytes); + Counter::increment(http_rsb.tcp_expired_miss_origin_server_bytes, origin_server_bytes); break; case SQUID_LOG_TCP_REFRESH_HIT: - Metrics::increment(http_rsb.tcp_refresh_hit_count); - Metrics::increment(http_rsb.tcp_refresh_hit_user_agent_bytes, user_agent_bytes); - Metrics::increment(http_rsb.tcp_refresh_hit_origin_server_bytes, origin_server_bytes); + Counter::increment(http_rsb.tcp_refresh_hit_count); + Counter::increment(http_rsb.tcp_refresh_hit_user_agent_bytes, user_agent_bytes); + Counter::increment(http_rsb.tcp_refresh_hit_origin_server_bytes, origin_server_bytes); break; case SQUID_LOG_TCP_REFRESH_MISS: - Metrics::increment(http_rsb.tcp_refresh_miss_count); - Metrics::increment(http_rsb.tcp_refresh_miss_user_agent_bytes, user_agent_bytes); - Metrics::increment(http_rsb.tcp_refresh_miss_origin_server_bytes, origin_server_bytes); + Counter::increment(http_rsb.tcp_refresh_miss_count); + Counter::increment(http_rsb.tcp_refresh_miss_user_agent_bytes, user_agent_bytes); + Counter::increment(http_rsb.tcp_refresh_miss_origin_server_bytes, origin_server_bytes); break; case SQUID_LOG_TCP_CLIENT_REFRESH: - Metrics::increment(http_rsb.tcp_client_refresh_count); - Metrics::increment(http_rsb.tcp_client_refresh_user_agent_bytes, user_agent_bytes); - Metrics::increment(http_rsb.tcp_client_refresh_origin_server_bytes, origin_server_bytes); + Counter::increment(http_rsb.tcp_client_refresh_count); + Counter::increment(http_rsb.tcp_client_refresh_user_agent_bytes, user_agent_bytes); + Counter::increment(http_rsb.tcp_client_refresh_origin_server_bytes, origin_server_bytes); break; case SQUID_LOG_TCP_IMS_HIT: - Metrics::increment(http_rsb.tcp_ims_hit_count); - Metrics::increment(http_rsb.tcp_ims_hit_user_agent_bytes, user_agent_bytes); - Metrics::increment(http_rsb.tcp_ims_hit_origin_server_bytes, origin_server_bytes); + Counter::increment(http_rsb.tcp_ims_hit_count); + Counter::increment(http_rsb.tcp_ims_hit_user_agent_bytes, user_agent_bytes); + Counter::increment(http_rsb.tcp_ims_hit_origin_server_bytes, origin_server_bytes); break; case SQUID_LOG_TCP_IMS_MISS: - Metrics::increment(http_rsb.tcp_ims_miss_count); - Metrics::increment(http_rsb.tcp_ims_miss_user_agent_bytes, user_agent_bytes); - Metrics::increment(http_rsb.tcp_ims_miss_origin_server_bytes, origin_server_bytes); + Counter::increment(http_rsb.tcp_ims_miss_count); + Counter::increment(http_rsb.tcp_ims_miss_user_agent_bytes, user_agent_bytes); + Counter::increment(http_rsb.tcp_ims_miss_origin_server_bytes, origin_server_bytes); break; case SQUID_LOG_ERR_CLIENT_ABORT: - Metrics::increment(http_rsb.err_client_abort_count); - Metrics::increment(http_rsb.err_client_abort_user_agent_bytes, user_agent_bytes); - Metrics::increment(http_rsb.err_client_abort_origin_server_bytes, origin_server_bytes); + Counter::increment(http_rsb.err_client_abort_count); + Counter::increment(http_rsb.err_client_abort_user_agent_bytes, user_agent_bytes); + Counter::increment(http_rsb.err_client_abort_origin_server_bytes, origin_server_bytes); break; case SQUID_LOG_ERR_CLIENT_READ_ERROR: - Metrics::increment(http_rsb.err_client_read_error_count); - Metrics::increment(http_rsb.err_client_read_error_user_agent_bytes, user_agent_bytes); - Metrics::increment(http_rsb.err_client_read_error_origin_server_bytes, origin_server_bytes); + Counter::increment(http_rsb.err_client_read_error_count); + Counter::increment(http_rsb.err_client_read_error_user_agent_bytes, user_agent_bytes); + Counter::increment(http_rsb.err_client_read_error_origin_server_bytes, origin_server_bytes); break; case SQUID_LOG_ERR_CONNECT_FAIL: - Metrics::increment(http_rsb.err_connect_fail_count); - Metrics::increment(http_rsb.err_connect_fail_user_agent_bytes, user_agent_bytes); - Metrics::increment(http_rsb.err_connect_fail_origin_server_bytes, origin_server_bytes); + Counter::increment(http_rsb.err_connect_fail_count); + Counter::increment(http_rsb.err_connect_fail_user_agent_bytes, user_agent_bytes); + Counter::increment(http_rsb.err_connect_fail_origin_server_bytes, origin_server_bytes); break; default: - Metrics::increment(http_rsb.misc_count); - Metrics::increment(http_rsb.misc_user_agent_bytes, user_agent_bytes); - Metrics::increment(http_rsb.misc_origin_server_bytes, origin_server_bytes); + Counter::increment(http_rsb.misc_count); + Counter::increment(http_rsb.misc_user_agent_bytes, user_agent_bytes); + Counter::increment(http_rsb.misc_origin_server_bytes, origin_server_bytes); break; } // times - Metrics::increment(http_rsb.total_transactions_time, total_time); + Counter::increment(http_rsb.total_transactions_time, total_time); // sizes - Metrics::increment(http_rsb.user_agent_request_header_total_size, user_agent_request_header_size); - Metrics::increment(http_rsb.user_agent_response_header_total_size, user_agent_response_header_size); - Metrics::increment(http_rsb.user_agent_request_document_total_size, user_agent_request_body_size); - Metrics::increment(http_rsb.user_agent_response_document_total_size, user_agent_response_body_size); + Counter::increment(http_rsb.user_agent_request_header_total_size, user_agent_request_header_size); + Counter::increment(http_rsb.user_agent_response_header_total_size, user_agent_response_header_size); + Counter::increment(http_rsb.user_agent_request_document_total_size, user_agent_request_body_size); + Counter::increment(http_rsb.user_agent_response_document_total_size, user_agent_response_body_size); // proxy stats if (s->current.request_to == ResolveInfo::PARENT_PROXY) { - Metrics::increment(http_rsb.parent_proxy_request_total_bytes, + Counter::increment(http_rsb.parent_proxy_request_total_bytes, origin_server_request_header_size + origin_server_request_body_size); - Metrics::increment(http_rsb.parent_proxy_response_total_bytes, + Counter::increment(http_rsb.parent_proxy_response_total_bytes, origin_server_response_header_size + origin_server_response_body_size); - Metrics::increment(http_rsb.parent_proxy_transaction_time, total_time); + Counter::increment(http_rsb.parent_proxy_transaction_time, total_time); } // request header zero means the document was cached. // do not add to stats. if (origin_server_request_header_size > 0) { - Metrics::increment(http_rsb.origin_server_request_header_total_size, origin_server_request_header_size); - Metrics::increment(http_rsb.origin_server_response_header_total_size, origin_server_response_header_size); - Metrics::increment(http_rsb.origin_server_request_document_total_size, origin_server_request_body_size); - Metrics::increment(http_rsb.origin_server_response_document_total_size, origin_server_response_body_size); + Counter::increment(http_rsb.origin_server_request_header_total_size, origin_server_request_header_size); + Counter::increment(http_rsb.origin_server_response_header_total_size, origin_server_response_header_size); + Counter::increment(http_rsb.origin_server_request_document_total_size, origin_server_request_body_size); + Counter::increment(http_rsb.origin_server_response_document_total_size, origin_server_response_body_size); } if (s->method == HTTP_WKSIDX_PUSH) { - Metrics::increment(http_rsb.pushed_response_header_total_size, pushed_response_header_size); - Metrics::increment(http_rsb.pushed_document_total_size, pushed_response_body_size); + Counter::increment(http_rsb.pushed_response_header_total_size, pushed_response_header_size); + Counter::increment(http_rsb.pushed_document_total_size, pushed_response_body_size); } // update milestones stats - Metrics::increment(http_rsb.ua_begin_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_BEGIN, 0)); - Metrics::increment(http_rsb.ua_first_read_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_FIRST_READ, 0)); - Metrics::increment(http_rsb.ua_read_header_done_time, + Counter::increment(http_rsb.ua_begin_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_BEGIN, 0)); + Counter::increment(http_rsb.ua_first_read_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_FIRST_READ, 0)); + Counter::increment(http_rsb.ua_read_header_done_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_READ_HEADER_DONE, 0)); - Metrics::increment(http_rsb.ua_begin_write_time, + Counter::increment(http_rsb.ua_begin_write_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_BEGIN_WRITE, 0)); - Metrics::increment(http_rsb.ua_close_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_CLOSE, 0)); - Metrics::increment(http_rsb.server_first_connect_time, + Counter::increment(http_rsb.ua_close_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_CLOSE, 0)); + Counter::increment(http_rsb.server_first_connect_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_FIRST_CONNECT, 0)); - Metrics::increment(http_rsb.server_connect_time, + Counter::increment(http_rsb.server_connect_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_CONNECT, 0)); - Metrics::increment(http_rsb.server_connect_end_time, + Counter::increment(http_rsb.server_connect_end_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_CONNECT_END, 0)); - Metrics::increment(http_rsb.server_begin_write_time, + Counter::increment(http_rsb.server_begin_write_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_BEGIN_WRITE, 0)); - Metrics::increment(http_rsb.server_first_read_time, + Counter::increment(http_rsb.server_first_read_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_FIRST_READ, 0)); - Metrics::increment(http_rsb.server_read_header_done_time, + Counter::increment(http_rsb.server_read_header_done_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_READ_HEADER_DONE, 0)); - Metrics::increment(http_rsb.server_close_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_CLOSE, 0)); - Metrics::increment(http_rsb.cache_open_read_begin_time, + Counter::increment(http_rsb.server_close_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_CLOSE, 0)); + Counter::increment(http_rsb.cache_open_read_begin_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_CACHE_OPEN_READ_BEGIN, 0)); - Metrics::increment(http_rsb.cache_open_read_end_time, + Counter::increment(http_rsb.cache_open_read_end_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_CACHE_OPEN_READ_END, 0)); - Metrics::increment(http_rsb.cache_open_write_begin_time, + Counter::increment(http_rsb.cache_open_write_begin_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_CACHE_OPEN_WRITE_BEGIN, 0)); - Metrics::increment(http_rsb.cache_open_write_end_time, + Counter::increment(http_rsb.cache_open_write_end_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_CACHE_OPEN_WRITE_END, 0)); - Metrics::increment(http_rsb.dns_lookup_begin_time, + Counter::increment(http_rsb.dns_lookup_begin_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_DNS_LOOKUP_BEGIN, 0)); - Metrics::increment(http_rsb.dns_lookup_end_time, + Counter::increment(http_rsb.dns_lookup_end_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_DNS_LOOKUP_END, 0)); - Metrics::increment(http_rsb.sm_start_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SM_START, 0)); - Metrics::increment(http_rsb.sm_finish_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SM_FINISH, 0)); + Counter::increment(http_rsb.sm_start_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SM_START, 0)); + Counter::increment(http_rsb.sm_finish_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SM_FINISH, 0)); } void diff --git a/src/proxy/http/HttpTunnel.cc b/src/proxy/http/HttpTunnel.cc index b263fef5df3..03a88484d9c 100644 --- a/src/proxy/http/HttpTunnel.cc +++ b/src/proxy/http/HttpTunnel.cc @@ -1484,7 +1484,7 @@ HttpTunnel::chain_abort_all(HttpTunnelProducer *p) } p->read_vio = nullptr; p->vc->do_io_close(EHTTP_ERROR); - Metrics::increment(http_rsb.origin_shutdown_tunnel_abort); + Counter::increment(http_rsb.origin_shutdown_tunnel_abort); update_stats_after_abort(p->vc_type); } } @@ -1601,7 +1601,7 @@ HttpTunnel::chain_abort_cache_write(HttpTunnelProducer *p) c->write_vio = nullptr; c->vc->do_io_close(EHTTP_ERROR); c->alive = false; - Metrics::decrement(http_rsb.current_cache_connections); + Counter::decrement(http_rsb.current_cache_connections); } else if (c->self_producer) { chain_abort_cache_write(c->self_producer); } @@ -1715,7 +1715,7 @@ HttpTunnel::update_stats_after_abort(HttpTunnelType_t t) switch (t) { case HT_CACHE_READ: case HT_CACHE_WRITE: - Metrics::decrement(http_rsb.current_cache_connections); + Counter::decrement(http_rsb.current_cache_connections); break; default: // Handled here: @@ -1740,7 +1740,7 @@ HttpTunnel::mark_tls_tunnel_active() } _tls_tunnel_active = true; - Metrics::increment(http_rsb.tunnel_current_active_connections); + Counter::increment(http_rsb.tunnel_current_active_connections); _schedule_tls_tunnel_activity_check_event(); } @@ -1753,7 +1753,7 @@ HttpTunnel::mark_tls_tunnel_inactive() } _tls_tunnel_active = false; - Metrics::decrement(http_rsb.tunnel_current_active_connections); + Counter::decrement(http_rsb.tunnel_current_active_connections); if (_tls_tunnel_activity_check_event) { _tls_tunnel_activity_check_event->cancel(); diff --git a/src/proxy/http/HttpVCTable.cc b/src/proxy/http/HttpVCTable.cc index 47c81be5f3f..46a1b871afe 100644 --- a/src/proxy/http/HttpVCTable.cc +++ b/src/proxy/http/HttpVCTable.cc @@ -117,7 +117,7 @@ HttpVCTable::cleanup_entry(HttpVCTableEntry *e) ink_assert(e->vc); if (e->in_tunnel == false) { if (e->vc_type == HTTP_SERVER_VC) { - Metrics::increment(http_rsb.origin_shutdown_cleanup_entry); + Counter::increment(http_rsb.origin_shutdown_cleanup_entry); } e->vc->do_io_close(); e->vc = nullptr; diff --git a/src/proxy/http/PreWarmManager.cc b/src/proxy/http/PreWarmManager.cc index f6d067a35d2..f7f4022fcf8 100644 --- a/src/proxy/http/PreWarmManager.cc +++ b/src/proxy/http/PreWarmManager.cc @@ -138,7 +138,7 @@ PreWarmSM::retry() ink_hrtime delay = HRTIME_SECONDS(1 << _retry_counter); ++_retry_counter; - ts::Metrics::increment(_stats_ids->at(static_cast(PreWarm::Stat::RETRY))); + ts::Metrics::Counter::increment(_stats_ids->at(static_cast(PreWarm::Stat::RETRY))); EThread *ethread = this_ethread(); _retry_event = ethread->schedule_in_local(this, delay, EVENT_IMMEDIATE); @@ -628,8 +628,8 @@ PreWarmSM::_record_handshake_time() return; } - ts::Metrics::increment(_stats_ids->at(static_cast(PreWarm::Stat::HANDSHAKE_TIME)), duration); - ts::Metrics::increment(_stats_ids->at(static_cast(PreWarm::Stat::HANDSHAKE_COUNT)), 1); + ts::Metrics::Counter::increment(_stats_ids->at(static_cast(PreWarm::Stat::HANDSHAKE_TIME)), duration); + ts::Metrics::Counter::increment(_stats_ids->at(static_cast(PreWarm::Stat::HANDSHAKE_COUNT)), 1); } //// @@ -702,10 +702,10 @@ PreWarmQueue::state_running(int event, void *data) dst->port, (int)dst->type, dst->alpn_index, info.stat.miss, info.stat.hit, (int)info.init_list->size(), (int)info.open_list->size()); - ts::Metrics::write(info.stats_ids->at(static_cast(PreWarm::Stat::INIT_LIST_SIZE)), info.init_list->size()); - ts::Metrics::write(info.stats_ids->at(static_cast(PreWarm::Stat::OPEN_LIST_SIZE)), info.open_list->size()); - ts::Metrics::increment(info.stats_ids->at(static_cast(PreWarm::Stat::HIT)), info.stat.hit); - ts::Metrics::increment(info.stats_ids->at(static_cast(PreWarm::Stat::MISS)), info.stat.miss); + ts::Metrics::Counter::write(info.stats_ids->at(static_cast(PreWarm::Stat::INIT_LIST_SIZE)), info.init_list->size()); + ts::Metrics::Counter::write(info.stats_ids->at(static_cast(PreWarm::Stat::OPEN_LIST_SIZE)), info.open_list->size()); + ts::Metrics::Counter::increment(info.stats_ids->at(static_cast(PreWarm::Stat::HIT)), info.stat.hit); + ts::Metrics::Counter::increment(info.stats_ids->at(static_cast(PreWarm::Stat::MISS)), info.stat.miss); // clear PreWarmQueue::Stat info.stat.miss = 0; @@ -927,8 +927,8 @@ PreWarmQueue::_reconfigure() // free unexisting entries for (auto &[dst, info] : _map) { if (auto entry = new_conf_list.find(dst); entry == new_conf_list.end()) { - ts::Metrics::write(info.stats_ids->at(static_cast(PreWarm::Stat::INIT_LIST_SIZE)), 0); - ts::Metrics::write(info.stats_ids->at(static_cast(PreWarm::Stat::OPEN_LIST_SIZE)), 0); + ts::Metrics::Counter::write(info.stats_ids->at(static_cast(PreWarm::Stat::INIT_LIST_SIZE)), 0); + ts::Metrics::Counter::write(info.stats_ids->at(static_cast(PreWarm::Stat::OPEN_LIST_SIZE)), 0); _make_queue_empty(info.init_list); delete info.init_list; @@ -1125,14 +1125,13 @@ PreWarmManager::_parse_sni_conf(PreWarm::ParsedSNIConf &parsed_conf, const SNICo void PreWarmManager::_register_stats(const PreWarm::ParsedSNIConf &parsed_conf) { - int stats_counter = 0; - - ts::Metrics &intm = ts::Metrics::getInstance(); + int stats_counter = 0; + ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); for (auto &entry : parsed_conf) { const PreWarm::SPtrConstDst &dst = entry.first; - PreWarm::StatsIds ids; + for (int j = 0; j < static_cast(PreWarm::Stat::LAST_ENTRY); ++j) { char name[STAT_NAME_BUF_LEN]; @@ -1146,11 +1145,11 @@ PreWarmManager::_register_stats(const PreWarm::ParsedSNIConf &parsed_conf) dst->host.data(), dst->port, (dst->type == SNIRoutingType::PARTIAL_BLIND) ? "tls" : "tcp", STAT_ENTRIES[j].data()); } - ts::Metrics::IdType stats_id = intm.lookup(name); - ts::Metrics::IntType *metric = nullptr; + ts::Metrics::Counter::IdType stats_id = metrics.lookup(name); + Counter::AtomicType *metric = nullptr; - if (stats_id == ts::Metrics::NOT_FOUND) { - metric = intm.newMetricPtr(name); + if (stats_id == ts::Metrics::Counter::NOT_FOUND) { + metric = metrics.createPtr(name); if (metric == nullptr) { Error("couldn't register stat name=%s", name); @@ -1158,7 +1157,7 @@ PreWarmManager::_register_stats(const PreWarm::ParsedSNIConf &parsed_conf) ++stats_counter; } } else { - metric = intm.lookup(stats_id); + metric = metrics.lookup(stats_id); } ids[j] = metric; diff --git a/src/proxy/http2/HTTP2.cc b/src/proxy/http2/HTTP2.cc index 8abaec309e0..5d3df2a8be6 100644 --- a/src/proxy/http2/HTTP2.cc +++ b/src/proxy/http2/HTTP2.cc @@ -563,40 +563,40 @@ Http2::init() ink_release_assert(http2_settings_parameter_is_valid({HTTP2_SETTINGS_MAX_HEADER_LIST_SIZE, max_header_list_size})); // Setup statistics - ts::Metrics &intm = ts::Metrics::getInstance(); - - http2_rsb.current_client_session_count = intm.newMetricPtr("proxy.process.http2.current_client_connections"); - http2_rsb.current_server_session_count = intm.newMetricPtr("proxy.process.http2.current_server_connections"); - http2_rsb.current_active_client_connection_count = intm.newMetricPtr("proxy.process.http2.current_active_client_connections"); - http2_rsb.current_active_server_connection_count = intm.newMetricPtr("proxy.process.http2.current_active_server_connections"); - http2_rsb.current_client_stream_count = intm.newMetricPtr("proxy.process.http2.current_client_streams"); - http2_rsb.current_server_stream_count = intm.newMetricPtr("proxy.process.http2.current_server_streams"); - http2_rsb.total_client_stream_count = intm.newMetricPtr("proxy.process.http2.total_client_streams"); - http2_rsb.total_server_stream_count = intm.newMetricPtr("proxy.process.http2.total_server_streams"); - http2_rsb.total_transactions_time = intm.newMetricPtr("proxy.process.http2.total_transactions_time"); - http2_rsb.total_client_connection_count = intm.newMetricPtr("proxy.process.http2.total_client_connections"); - http2_rsb.total_server_connection_count = intm.newMetricPtr("proxy.process.http2.total_server_connections"); - http2_rsb.stream_errors_count = intm.newMetricPtr("proxy.process.http2.stream_errors"); - http2_rsb.connection_errors_count = intm.newMetricPtr("proxy.process.http2.connection_errors"); - http2_rsb.session_die_default = intm.newMetricPtr("proxy.process.http2.session_die_default"); - http2_rsb.session_die_other = intm.newMetricPtr("proxy.process.http2.session_die_other"); - http2_rsb.session_die_active = intm.newMetricPtr("proxy.process.http2.session_die_active"); - http2_rsb.session_die_inactive = intm.newMetricPtr("proxy.process.http2.session_die_inactive"); - http2_rsb.session_die_eos = intm.newMetricPtr("proxy.process.http2.session_die_eos"); - http2_rsb.session_die_error = intm.newMetricPtr("proxy.process.http2.session_die_error"); - http2_rsb.session_die_high_error_rate = intm.newMetricPtr("proxy.process.http2.session_die_high_error_rate"); - http2_rsb.max_settings_per_frame_exceeded = intm.newMetricPtr("proxy.process.http2.max_settings_per_frame_exceeded"); - http2_rsb.max_settings_per_minute_exceeded = intm.newMetricPtr("proxy.process.http2.max_settings_per_minute_exceeded"); + ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); + + http2_rsb.current_client_session_count = metrics.createPtr("proxy.process.http2.current_client_connections"); + http2_rsb.current_server_session_count = metrics.createPtr("proxy.process.http2.current_server_connections"); + http2_rsb.current_active_client_connection_count = metrics.createPtr("proxy.process.http2.current_active_client_connections"); + http2_rsb.current_active_server_connection_count = metrics.createPtr("proxy.process.http2.current_active_server_connections"); + http2_rsb.current_client_stream_count = metrics.createPtr("proxy.process.http2.current_client_streams"); + http2_rsb.current_server_stream_count = metrics.createPtr("proxy.process.http2.current_server_streams"); + http2_rsb.total_client_stream_count = metrics.createPtr("proxy.process.http2.total_client_streams"); + http2_rsb.total_server_stream_count = metrics.createPtr("proxy.process.http2.total_server_streams"); + http2_rsb.total_transactions_time = metrics.createPtr("proxy.process.http2.total_transactions_time"); + http2_rsb.total_client_connection_count = metrics.createPtr("proxy.process.http2.total_client_connections"); + http2_rsb.total_server_connection_count = metrics.createPtr("proxy.process.http2.total_server_connections"); + http2_rsb.stream_errors_count = metrics.createPtr("proxy.process.http2.stream_errors"); + http2_rsb.connection_errors_count = metrics.createPtr("proxy.process.http2.connection_errors"); + http2_rsb.session_die_default = metrics.createPtr("proxy.process.http2.session_die_default"); + http2_rsb.session_die_other = metrics.createPtr("proxy.process.http2.session_die_other"); + http2_rsb.session_die_active = metrics.createPtr("proxy.process.http2.session_die_active"); + http2_rsb.session_die_inactive = metrics.createPtr("proxy.process.http2.session_die_inactive"); + http2_rsb.session_die_eos = metrics.createPtr("proxy.process.http2.session_die_eos"); + http2_rsb.session_die_error = metrics.createPtr("proxy.process.http2.session_die_error"); + http2_rsb.session_die_high_error_rate = metrics.createPtr("proxy.process.http2.session_die_high_error_rate"); + http2_rsb.max_settings_per_frame_exceeded = metrics.createPtr("proxy.process.http2.max_settings_per_frame_exceeded"); + http2_rsb.max_settings_per_minute_exceeded = metrics.createPtr("proxy.process.http2.max_settings_per_minute_exceeded"); http2_rsb.max_settings_frames_per_minute_exceeded = - intm.newMetricPtr("proxy.process.http2.max_settings_frames_per_minute_exceeded"); - http2_rsb.max_ping_frames_per_minute_exceeded = intm.newMetricPtr("proxy.process.http2.max_ping_frames_per_minute_exceeded"); + metrics.createPtr("proxy.process.http2.max_settings_frames_per_minute_exceeded"); + http2_rsb.max_ping_frames_per_minute_exceeded = metrics.createPtr("proxy.process.http2.max_ping_frames_per_minute_exceeded"); http2_rsb.max_priority_frames_per_minute_exceeded = - intm.newMetricPtr("proxy.process.http2.max_priority_frames_per_minute_exceeded"); + metrics.createPtr("proxy.process.http2.max_priority_frames_per_minute_exceeded"); http2_rsb.max_rst_stream_frames_per_minute_exceeded = - intm.newMetricPtr("proxy.process.http2.max_rst_stream_frames_per_minute_exceeded"); - http2_rsb.insufficient_avg_window_update = intm.newMetricPtr("proxy.process.http2.insufficient_avg_window_update"); - http2_rsb.max_concurrent_streams_exceeded_in = intm.newMetricPtr("proxy.process.http2.max_concurrent_streams_exceeded_in"); - http2_rsb.max_concurrent_streams_exceeded_out = intm.newMetricPtr("proxy.process.http2.max_concurrent_streams_exceeded_out"); + metrics.createPtr("proxy.process.http2.max_rst_stream_frames_per_minute_exceeded"); + http2_rsb.insufficient_avg_window_update = metrics.createPtr("proxy.process.http2.insufficient_avg_window_update"); + http2_rsb.max_concurrent_streams_exceeded_in = metrics.createPtr("proxy.process.http2.max_concurrent_streams_exceeded_in"); + http2_rsb.max_concurrent_streams_exceeded_out = metrics.createPtr("proxy.process.http2.max_concurrent_streams_exceeded_out"); http2_init(); } diff --git a/src/proxy/http2/Http2ClientSession.cc b/src/proxy/http2/Http2ClientSession.cc index dd232abbb76..b7d97c0a8a2 100644 --- a/src/proxy/http2/Http2ClientSession.cc +++ b/src/proxy/http2/Http2ClientSession.cc @@ -60,7 +60,7 @@ Http2ClientSession::free() { auto mutex_thread = this->mutex->thread_holding; if (Http2CommonSession::common_free(this)) { - Metrics::decrement(http2_rsb.current_client_session_count); + Counter::decrement(http2_rsb.current_client_session_count); THREAD_FREE(this, http2ClientSessionAllocator, mutex_thread); } } @@ -88,8 +88,8 @@ void Http2ClientSession::new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOBufferReader *reader) { ink_assert(new_vc->mutex->thread_holding == this_ethread()); - Metrics::increment(http2_rsb.current_client_session_count); - Metrics::increment(http2_rsb.total_client_connection_count); + Counter::increment(http2_rsb.current_client_session_count); + Counter::increment(http2_rsb.total_client_connection_count); this->_milestones.mark(Http2SsnMilestone::OPEN); // Unique client session identifier. @@ -254,13 +254,13 @@ Http2ClientSession::main_event_handler(int event, void *edata) void Http2ClientSession::increment_current_active_connections_stat() { - Metrics::increment(http2_rsb.current_active_client_connection_count); + Counter::increment(http2_rsb.current_active_client_connection_count); } void Http2ClientSession::decrement_current_active_connections_stat() { - Metrics::decrement(http2_rsb.current_active_client_connection_count); + Counter::decrement(http2_rsb.current_active_client_connection_count); } sockaddr const * diff --git a/src/proxy/http2/Http2CommonSession.cc b/src/proxy/http2/Http2CommonSession.cc index bea3e8ab983..4de93584ace 100644 --- a/src/proxy/http2/Http2CommonSession.cc +++ b/src/proxy/http2/Http2CommonSession.cc @@ -98,32 +98,32 @@ Http2CommonSession::common_free(ProxySession *ssn) if (cause_of_death != Http2SessionCod::NOT_PROVIDED) { switch (cause_of_death) { case Http2SessionCod::HIGH_ERROR_RATE: - Metrics::increment(http2_rsb.session_die_high_error_rate); + Counter::increment(http2_rsb.session_die_high_error_rate); break; case Http2SessionCod::NOT_PROVIDED: // Can't happen but this case is here to not have default case. - Metrics::increment(http2_rsb.session_die_other); + Counter::increment(http2_rsb.session_die_other); break; } } else { switch (dying_event) { case VC_EVENT_NONE: - Metrics::increment(http2_rsb.session_die_default); + Counter::increment(http2_rsb.session_die_default); break; case VC_EVENT_ACTIVE_TIMEOUT: - Metrics::increment(http2_rsb.session_die_active); + Counter::increment(http2_rsb.session_die_active); break; case VC_EVENT_INACTIVITY_TIMEOUT: - Metrics::increment(http2_rsb.session_die_inactive); + Counter::increment(http2_rsb.session_die_inactive); break; case VC_EVENT_ERROR: - Metrics::increment(http2_rsb.session_die_error); + Counter::increment(http2_rsb.session_die_error); break; case VC_EVENT_EOS: - Metrics::increment(http2_rsb.session_die_eos); + Counter::increment(http2_rsb.session_die_eos); break; default: - Metrics::increment(http2_rsb.session_die_other); + Counter::increment(http2_rsb.session_die_other); break; } } diff --git a/src/proxy/http2/Http2ConnectionState.cc b/src/proxy/http2/Http2ConnectionState.cc index ba50b7e3118..4a28a240d9e 100644 --- a/src/proxy/http2/Http2ConnectionState.cc +++ b/src/proxy/http2/Http2ConnectionState.cc @@ -553,7 +553,7 @@ Http2ConnectionState::rcv_priority_frame(const Http2Frame &frame) // Close this connection if its priority frame count received exceeds a limit if (configured_max_priority_frames_per_minute != 0 && this->get_received_priority_frame_count() > configured_max_priority_frames_per_minute) { - Metrics::increment(http2_rsb.max_priority_frames_per_minute_exceeded); + Counter::increment(http2_rsb.max_priority_frames_per_minute_exceeded); Http2StreamDebug(this->session, stream_id, "Observed too frequent priority changes: %u priority changes within a last minute", this->get_received_priority_frame_count()); return Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_CONNECTION, Http2ErrorCode::HTTP2_ERROR_ENHANCE_YOUR_CALM, @@ -628,7 +628,7 @@ Http2ConnectionState::rcv_rst_stream_frame(const Http2Frame &frame) // Close this connection if its RST_STREAM frame count exceeds a limit if (configured_max_rst_stream_frames_per_minute != 0 && this->get_received_rst_stream_frame_count() > configured_max_rst_stream_frames_per_minute) { - Metrics::increment(http2_rsb.max_rst_stream_frames_per_minute_exceeded); + Counter::increment(http2_rsb.max_rst_stream_frames_per_minute_exceeded); Http2StreamDebug(this->session, stream_id, "Observed too frequent RST_STREAM frames: %u frames within a last minute", this->get_received_rst_stream_frame_count()); return Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_CONNECTION, Http2ErrorCode::HTTP2_ERROR_ENHANCE_YOUR_CALM, @@ -677,7 +677,7 @@ Http2ConnectionState::rcv_settings_frame(const Http2Frame &frame) // Close this connection if its SETTINGS frame count exceeds a limit if (configured_max_settings_frames_per_minute != 0 && this->get_received_settings_frame_count() > configured_max_settings_frames_per_minute) { - Metrics::increment(http2_rsb.max_settings_frames_per_minute_exceeded); + Counter::increment(http2_rsb.max_settings_frames_per_minute_exceeded); Http2StreamDebug(this->session, stream_id, "Observed too frequent SETTINGS frames: %u frames within a last minute", this->get_received_settings_frame_count()); return Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_CONNECTION, Http2ErrorCode::HTTP2_ERROR_ENHANCE_YOUR_CALM, @@ -717,7 +717,7 @@ Http2ConnectionState::rcv_settings_frame(const Http2Frame &frame) uint32_t n_settings = 0; while (nbytes < frame.header().length) { if (n_settings >= Http2::max_settings_per_frame) { - Metrics::increment(http2_rsb.max_settings_per_frame_exceeded); + Counter::increment(http2_rsb.max_settings_per_frame_exceeded); Http2StreamDebug(this->session, stream_id, "Observed too many settings in a frame"); return Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_CONNECTION, Http2ErrorCode::HTTP2_ERROR_ENHANCE_YOUR_CALM, "recv settings too many settings in a frame"); @@ -758,7 +758,7 @@ Http2ConnectionState::rcv_settings_frame(const Http2Frame &frame) this->increment_received_settings_count(n_settings); // Close this connection if its settings count received exceeds a limit if (this->get_received_settings_count() > Http2::max_settings_per_minute) { - Metrics::increment(http2_rsb.max_settings_per_minute_exceeded); + Counter::increment(http2_rsb.max_settings_per_minute_exceeded); Http2StreamDebug(this->session, stream_id, "Observed too frequent setting changes: %u settings within a last minute", this->get_received_settings_count()); return Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_CONNECTION, Http2ErrorCode::HTTP2_ERROR_ENHANCE_YOUR_CALM, @@ -812,7 +812,7 @@ Http2ConnectionState::rcv_ping_frame(const Http2Frame &frame) this->increment_received_ping_frame_count(); // Close this connection if its ping count received exceeds a limit if (configured_max_ping_frames_per_minute != 0 && this->get_received_ping_frame_count() > configured_max_ping_frames_per_minute) { - Metrics::increment(http2_rsb.max_ping_frames_per_minute_exceeded); + Counter::increment(http2_rsb.max_ping_frames_per_minute_exceeded); Http2StreamDebug(this->session, stream_id, "Observed too frequent PING frames: %u PING frames within a last minute", this->get_received_ping_frame_count()); return Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_CONNECTION, Http2ErrorCode::HTTP2_ERROR_ENHANCE_YOUR_CALM, @@ -1683,7 +1683,7 @@ Http2ConnectionState::create_stream(Http2StreamId new_id, Http2Error &error) } // If we haven't got the peers settings yet, just hope for the best if (check_max_concurrent_limit >= 0 && check_count >= check_max_concurrent_limit) { - Metrics::increment(is_client_streamid ? http2_rsb.max_concurrent_streams_exceeded_in : + Counter::increment(is_client_streamid ? http2_rsb.max_concurrent_streams_exceeded_in : http2_rsb.max_concurrent_streams_exceeded_out); error = Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_STREAM, Http2ErrorCode::HTTP2_ERROR_REFUSED_STREAM, "recv headers creating stream beyond max_concurrent limit"); @@ -2441,7 +2441,7 @@ Http2ConnectionState::send_rst_stream_frame(Http2StreamId id, Http2ErrorCode ec) Http2StreamDebug(session, id, "Send RST_STREAM frame"); if (ec != Http2ErrorCode::HTTP2_ERROR_NO_ERROR) { - Metrics::increment(http2_rsb.stream_errors_count); + Counter::increment(http2_rsb.stream_errors_count); ++stream_error_count; } @@ -2549,7 +2549,7 @@ Http2ConnectionState::send_goaway_frame(Http2StreamId id, Http2ErrorCode ec) Http2ConDebug(session, "Send GOAWAY frame, last_stream_id: %d", id); if (ec != Http2ErrorCode::HTTP2_ERROR_NO_ERROR) { - Metrics::increment(http2_rsb.connection_errors_count); + Counter::increment(http2_rsb.connection_errors_count); } this->tx_error_code = {ProxyErrorClass::SSN, static_cast(ec)}; @@ -2649,7 +2649,7 @@ Http2ConnectionState::_adjust_concurrent_stream() return max_concurrent_streams; } - int64_t current_client_streams = Metrics::read(http2_rsb.current_client_stream_count); + int64_t current_client_streams = Counter::read(http2_rsb.current_client_stream_count); Http2ConDebug(session, "current client streams: %" PRId64, current_client_streams); @@ -2718,7 +2718,7 @@ Http2ConnectionState::increment_peer_rwnd(size_t amount) double sum = std::accumulate(this->_recent_rwnd_increment.begin(), this->_recent_rwnd_increment.end(), 0.0); double avg = sum / this->_recent_rwnd_increment.size(); if (avg < Http2::min_avg_window_update) { - Metrics::increment(http2_rsb.insufficient_avg_window_update); + Counter::increment(http2_rsb.insufficient_avg_window_update); return Http2ErrorCode::HTTP2_ERROR_ENHANCE_YOUR_CALM; } return Http2ErrorCode::HTTP2_ERROR_NO_ERROR; diff --git a/src/proxy/http2/Http2ServerSession.cc b/src/proxy/http2/Http2ServerSession.cc index 4d6f50031ff..e53c73a4ba5 100644 --- a/src/proxy/http2/Http2ServerSession.cc +++ b/src/proxy/http2/Http2ServerSession.cc @@ -61,7 +61,7 @@ Http2ServerSession::free() { auto mutex_thread = this->mutex->thread_holding; if (Http2CommonSession::common_free(this)) { - Metrics::decrement(http2_rsb.current_server_session_count); + Counter::decrement(http2_rsb.current_server_session_count); THREAD_FREE(this, http2ServerSessionAllocator, mutex_thread); } } @@ -96,8 +96,8 @@ Http2ServerSession::new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOB { ink_assert(new_vc->mutex->thread_holding == this_ethread()); - Metrics::increment(http2_rsb.current_server_session_count); - Metrics::increment(http2_rsb.total_server_connection_count); + Counter::increment(http2_rsb.current_server_session_count); + Counter::increment(http2_rsb.total_server_connection_count); this->_milestones.mark(Http2SsnMilestone::OPEN); // Unique client session identifier. diff --git a/src/proxy/http2/Http2SessionAccept.cc b/src/proxy/http2/Http2SessionAccept.cc index 02575aa04de..07e038274ce 100644 --- a/src/proxy/http2/Http2SessionAccept.cc +++ b/src/proxy/http2/Http2SessionAccept.cc @@ -81,8 +81,8 @@ Http2SessionAccept::mainEvent(int event, void *data) // XXX We should hoist the error handling so that all the protocols generate the statistics // without code duplication. if (((long)data) == -ECONNABORTED) { - Metrics::increment(http_rsb.ua_counts_errors_pre_accept_hangups); - // Metrics::increment(http_rsb.ua_msecs_errors_pre_accept_hangups, 0); // ToDo: This is odd, but we added 0 before as well + Counter::increment(http_rsb.ua_counts_errors_pre_accept_hangups); + // Counter::increment(http_rsb.ua_msecs_errors_pre_accept_hangups, 0); // ToDo: This is odd, but we added 0 before as well } ink_abort("HTTP/2 accept received fatal error: errno = %d", -(static_cast((intptr_t)data))); diff --git a/src/proxy/http2/Http2Stream.cc b/src/proxy/http2/Http2Stream.cc index 2d2af92645f..91b110cfdd7 100644 --- a/src/proxy/http2/Http2Stream.cc +++ b/src/proxy/http2/Http2Stream.cc @@ -121,7 +121,7 @@ Http2Stream::~Http2Stream() this->_milestones.mark(Http2StreamMilestone::CLOSE); ink_hrtime total_time = this->_milestones.elapsed(Http2StreamMilestone::OPEN, Http2StreamMilestone::CLOSE); - Metrics::increment(http2_rsb.total_transactions_time, total_time); + Counter::increment(http2_rsb.total_transactions_time, total_time); // Slow Log if (Http2::stream_slow_log_threshold != 0 && ink_hrtime_from_msec(Http2::stream_slow_log_threshold) < total_time) { @@ -1030,11 +1030,11 @@ void Http2Stream::increment_transactions_stat() { if (this->is_outbound_connection()) { - Metrics::increment(http2_rsb.current_server_stream_count); - Metrics::increment(http2_rsb.total_server_stream_count); + Counter::increment(http2_rsb.current_server_stream_count); + Counter::increment(http2_rsb.total_server_stream_count); } else { - Metrics::increment(http2_rsb.current_client_stream_count); - Metrics::increment(http2_rsb.total_client_stream_count); + Counter::increment(http2_rsb.current_client_stream_count); + Counter::increment(http2_rsb.total_client_stream_count); } } @@ -1042,9 +1042,9 @@ void Http2Stream::decrement_transactions_stat() { if (this->is_outbound_connection()) { - Metrics::decrement(http2_rsb.current_server_stream_count); + Counter::decrement(http2_rsb.current_server_stream_count); } else { - Metrics::decrement(http2_rsb.current_client_stream_count); + Counter::decrement(http2_rsb.current_client_stream_count); } } diff --git a/src/proxy/http3/Http3.cc b/src/proxy/http3/Http3.cc index 3ec27026176..d18dd16e536 100644 --- a/src/proxy/http3/Http3.cc +++ b/src/proxy/http3/Http3.cc @@ -37,7 +37,7 @@ Http3::init() // Example (remove comments here when addding) // // Setup statistics - // ts::Metrics &intm = ts::Metrics::getInstance(); + // ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); // - // http3_rsb.current_client_session_count = intm.newMetricPtr("proxy.process.http3.current_client_connections"); + // http3_rsb.current_client_session_count = metrics.createPtr("proxy.process.http3.current_client_connections"); } diff --git a/src/proxy/logging/Log.cc b/src/proxy/logging/Log.cc index bb2cb5629f9..8e43209d036 100644 --- a/src/proxy/logging/Log.cc +++ b/src/proxy/logging/Log.cc @@ -1170,7 +1170,7 @@ Log::access(LogAccess *lad) this_sample = sample++; if (this_sample && this_sample % Log::config->sampling_frequency) { Debug("log", "sampling, skipping this entry ..."); - Metrics::increment(log_rsb.event_log_access_skip); + Counter::increment(log_rsb.event_log_access_skip); ret = Log::SKIP; goto done; } else { @@ -1181,7 +1181,7 @@ Log::access(LogAccess *lad) if (Log::config->log_object_manager.get_num_objects() == 0) { Debug("log", "no log objects, skipping this entry ..."); - Metrics::increment(log_rsb.event_log_access_skip); + Counter::increment(log_rsb.event_log_access_skip); ret = Log::SKIP; goto done; } @@ -1225,19 +1225,19 @@ Log::va_error(const char *format, va_list ap) switch (ret_val) { case Log::LOG_OK: - Metrics::increment(log_rsb.event_log_error_ok); + Counter::increment(log_rsb.event_log_error_ok); break; case Log::SKIP: - Metrics::increment(log_rsb.event_log_error_skip); + Counter::increment(log_rsb.event_log_error_skip); break; case Log::AGGR: - Metrics::increment(log_rsb.event_log_error_aggr); + Counter::increment(log_rsb.event_log_error_aggr); break; case Log::FULL: - Metrics::increment(log_rsb.event_log_error_full); + Counter::increment(log_rsb.event_log_error_full); break; case Log::FAIL: - Metrics::increment(log_rsb.event_log_error_fail); + Counter::increment(log_rsb.event_log_error_fail); break; default: ink_release_assert(!"Unexpected result"); @@ -1246,7 +1246,7 @@ Log::va_error(const char *format, va_list ap) return ret_val; } - Metrics::increment(log_rsb.event_log_error_skip); + Counter::increment(log_rsb.event_log_error_skip); return ret_val; } @@ -1349,7 +1349,7 @@ Log::flush_thread_main(void * /* args ATS_UNUSED */) if (!logfile->is_open()) { SiteThrottledWarning("File:%s was closed, have dropped (%d) bytes.", logfile->get_name(), total_bytes); - Metrics::increment(log_rsb.bytes_lost_before_written_to_disk, total_bytes); + Counter::increment(log_rsb.bytes_lost_before_written_to_disk, total_bytes); delete fdata; continue; } @@ -1365,7 +1365,7 @@ Log::flush_thread_main(void * /* args ATS_UNUSED */) Debug("log", "logging space exhausted, failed to write file:%s, have dropped (%d) bytes.", logfile->get_name(), (total_bytes - bytes_written)); - Metrics::increment(log_rsb.bytes_lost_before_written_to_disk, total_bytes - bytes_written); + Counter::increment(log_rsb.bytes_lost_before_written_to_disk, total_bytes - bytes_written); break; } @@ -1375,14 +1375,14 @@ Log::flush_thread_main(void * /* args ATS_UNUSED */) SiteThrottledError("Failed to write log to %s: [tried %d, wrote %d, %s]", logfile->get_name(), total_bytes - bytes_written, bytes_written, strerror(errno)); - Metrics::increment(log_rsb.bytes_lost_before_written_to_disk, total_bytes - bytes_written); + Counter::increment(log_rsb.bytes_lost_before_written_to_disk, total_bytes - bytes_written); break; } Debug("log", "Successfully wrote some stuff to %s", logfile->get_name()); bytes_written += len; } - Metrics::increment(log_rsb.bytes_written_to_disk, bytes_written); + Counter::increment(log_rsb.bytes_written_to_disk, bytes_written); if (logfile->m_log) { ink_atomic_increment(&logfile->m_log->m_bytes_written, bytes_written); diff --git a/src/proxy/logging/LogAccess.cc b/src/proxy/logging/LogAccess.cc index 069a3a79e9e..555369ab0c1 100644 --- a/src/proxy/logging/LogAccess.cc +++ b/src/proxy/logging/LogAccess.cc @@ -216,11 +216,11 @@ LogAccess::marshal_record(char *record, char *buf) // Since, for now at least, String metrics are still in librecords, do that lookup // first, and only do the new metrics lookup on a miss. if (RecGetRecordDataType(record, &stype) != REC_ERR_OKAY) { - ts::Metrics &intm = ts::Metrics::getInstance(); - ts::Metrics::IdType metric = intm[record]; + ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); + ts::Metrics::Counter::IdType mid = metrics[record]; - if (metric != ts::Metrics::NOT_FOUND) { - int64_t val = intm[metric]; + if (mid != ts::Metrics::Counter::NOT_FOUND) { + int64_t val = metrics[mid]; out_buf = int64_to_str(ascii_buf, max_chars, val, &num_chars); ink_assert(out_buf); diff --git a/src/proxy/logging/LogConfig.cc b/src/proxy/logging/LogConfig.cc index 7254b36d171..91a42351bbb 100644 --- a/src/proxy/logging/LogConfig.cc +++ b/src/proxy/logging/LogConfig.cc @@ -508,32 +508,32 @@ LogConfig::register_stat_callbacks() // // events // - ts::Metrics &intm = ts::Metrics::getInstance(); - log_rsb.event_log_error_skip = intm.newMetricPtr("proxy.process.log.event_log_error_skip"); - log_rsb.event_log_error_ok = intm.newMetricPtr("proxy.process.log.event_log_error_ok"); - log_rsb.event_log_error_aggr = intm.newMetricPtr("proxy.process.log.event_log_error_aggr"); - log_rsb.event_log_error_full = intm.newMetricPtr("proxy.process.log.event_log_error_full"); - log_rsb.event_log_error_fail = intm.newMetricPtr("proxy.process.log.event_log_error_fail"); - log_rsb.event_log_access_ok = intm.newMetricPtr("proxy.process.log.event_log_access_ok"); - log_rsb.event_log_access_skip = intm.newMetricPtr("proxy.process.log.event_log_access_skip"); - log_rsb.event_log_access_aggr = intm.newMetricPtr("proxy.process.log.event_log_access_aggr"); - log_rsb.event_log_access_full = intm.newMetricPtr("proxy.process.log.event_log_access_full"); - log_rsb.event_log_access_fail = intm.newMetricPtr("proxy.process.log.event_log_access_fail"); - log_rsb.num_sent_to_network = intm.newMetricPtr("proxy.process.log.num_sent_to_network"); - log_rsb.num_lost_before_sent_to_network = intm.newMetricPtr("proxy.process.log.num_lost_before_sent_to_network"); - log_rsb.num_received_from_network = intm.newMetricPtr("proxy.process.log.num_received_from_network"); - log_rsb.num_flush_to_disk = intm.newMetricPtr("proxy.process.log.num_flush_to_disk"); - log_rsb.num_lost_before_flush_to_disk = intm.newMetricPtr("proxy.process.log.num_lost_before_flush_to_disk"); - log_rsb.bytes_lost_before_preproc = intm.newMetricPtr("proxy.process.log.bytes_lost_before_preproc"); - log_rsb.bytes_sent_to_network = intm.newMetricPtr("proxy.process.log.bytes_sent_to_network"); - log_rsb.bytes_lost_before_sent_to_network = intm.newMetricPtr("proxy.process.log.bytes_lost_before_sent_to_network"); - log_rsb.bytes_received_from_network = intm.newMetricPtr("proxy.process.log.bytes_received_from_network"); - log_rsb.bytes_flush_to_disk = intm.newMetricPtr("proxy.process.log.bytes_flush_to_disk"); - log_rsb.bytes_lost_before_flush_to_disk = intm.newMetricPtr("proxy.process.log.bytes_lost_before_flush_to_disk"); - log_rsb.bytes_written_to_disk = intm.newMetricPtr("proxy.process.log.bytes_written_to_disk"); - log_rsb.bytes_lost_before_written_to_disk = intm.newMetricPtr("proxy.process.log.bytes_lost_before_written_to_disk"); - log_rsb.log_files_open = intm.newMetricPtr("proxy.process.log.log_files_open"); - log_rsb.log_files_space_used = intm.newMetricPtr("proxy.process.log.log_files_space_used"); + ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); + log_rsb.event_log_error_skip = metrics.createPtr("proxy.process.log.event_log_error_skip"); + log_rsb.event_log_error_ok = metrics.createPtr("proxy.process.log.event_log_error_ok"); + log_rsb.event_log_error_aggr = metrics.createPtr("proxy.process.log.event_log_error_aggr"); + log_rsb.event_log_error_full = metrics.createPtr("proxy.process.log.event_log_error_full"); + log_rsb.event_log_error_fail = metrics.createPtr("proxy.process.log.event_log_error_fail"); + log_rsb.event_log_access_ok = metrics.createPtr("proxy.process.log.event_log_access_ok"); + log_rsb.event_log_access_skip = metrics.createPtr("proxy.process.log.event_log_access_skip"); + log_rsb.event_log_access_aggr = metrics.createPtr("proxy.process.log.event_log_access_aggr"); + log_rsb.event_log_access_full = metrics.createPtr("proxy.process.log.event_log_access_full"); + log_rsb.event_log_access_fail = metrics.createPtr("proxy.process.log.event_log_access_fail"); + log_rsb.num_sent_to_network = metrics.createPtr("proxy.process.log.num_sent_to_network"); + log_rsb.num_lost_before_sent_to_network = metrics.createPtr("proxy.process.log.num_lost_before_sent_to_network"); + log_rsb.num_received_from_network = metrics.createPtr("proxy.process.log.num_received_from_network"); + log_rsb.num_flush_to_disk = metrics.createPtr("proxy.process.log.num_flush_to_disk"); + log_rsb.num_lost_before_flush_to_disk = metrics.createPtr("proxy.process.log.num_lost_before_flush_to_disk"); + log_rsb.bytes_lost_before_preproc = metrics.createPtr("proxy.process.log.bytes_lost_before_preproc"); + log_rsb.bytes_sent_to_network = metrics.createPtr("proxy.process.log.bytes_sent_to_network"); + log_rsb.bytes_lost_before_sent_to_network = metrics.createPtr("proxy.process.log.bytes_lost_before_sent_to_network"); + log_rsb.bytes_received_from_network = metrics.createPtr("proxy.process.log.bytes_received_from_network"); + log_rsb.bytes_flush_to_disk = metrics.createPtr("proxy.process.log.bytes_flush_to_disk"); + log_rsb.bytes_lost_before_flush_to_disk = metrics.createPtr("proxy.process.log.bytes_lost_before_flush_to_disk"); + log_rsb.bytes_written_to_disk = metrics.createPtr("proxy.process.log.bytes_written_to_disk"); + log_rsb.bytes_lost_before_written_to_disk = metrics.createPtr("proxy.process.log.bytes_lost_before_written_to_disk"); + log_rsb.log_files_open = metrics.createPtr("proxy.process.log.log_files_open"); + log_rsb.log_files_space_used = metrics.createPtr("proxy.process.log.log_files_space_used"); } /*------------------------------------------------------------------------- @@ -659,7 +659,7 @@ LogConfig::update_space_used() // m_space_used = total_space_used; m_partition_space_left = partition_space_left; - Metrics::write(log_rsb.log_files_space_used, m_space_used); + Counter::write(log_rsb.log_files_space_used, m_space_used); Debug("logspace", "%" PRId64 " bytes being used for logs", m_space_used); Debug("logspace", "%" PRId64 " bytes left on partition", m_partition_space_left); diff --git a/src/proxy/logging/LogFile.cc b/src/proxy/logging/LogFile.cc index 16aef2f5577..459aa8ff703 100644 --- a/src/proxy/logging/LogFile.cc +++ b/src/proxy/logging/LogFile.cc @@ -223,7 +223,7 @@ LogFile::open_file() } } - Metrics::increment(log_rsb.log_files_open); + Counter::increment(log_rsb.log_files_open); Debug("log", "exiting LogFile::open_file(), file=%s presumably open", m_name); return LOG_FILE_NO_ERROR; @@ -244,7 +244,7 @@ LogFile::close_file() Error("Error closing LogFile %s: %s.", m_name, strerror(errno)); } else { Debug("log-file", "LogFile %s (fd=%d) is closed", m_name, m_fd); - Metrics::decrement(log_rsb.log_files_open); + Counter::decrement(log_rsb.log_files_open); } m_fd = -1; } else if (m_log) { @@ -252,7 +252,7 @@ LogFile::close_file() Error("Error closing LogFile %s: %s.", m_log->get_name(), strerror(errno)); } else { Debug("log-file", "LogFile %s is closed", m_log->get_name()); - Metrics::decrement(log_rsb.log_files_open); + Counter::decrement(log_rsb.log_files_open); } } else { Warning("LogFile %s is open but was not closed", m_name); @@ -454,8 +454,8 @@ LogFile::preproc_and_try_delete(LogBuffer *lb) // LogFlushData *flush_data = new LogFlushData(this, lb); - Metrics::increment(log_rsb.num_flush_to_disk, lb->header()->entry_count); - Metrics::increment(log_rsb.bytes_flush_to_disk, lb->header()->byte_count); + Counter::increment(log_rsb.num_flush_to_disk, lb->header()->entry_count); + Counter::increment(log_rsb.bytes_flush_to_disk, lb->header()->byte_count); ink_atomiclist_push(Log::flush_data_list, flush_data); @@ -613,8 +613,8 @@ LogFile::write_ascii_logbuffer3(LogBufferHeader *buffer_header, const char *alt_ } else { Note("Failed to convert LogBuffer to ascii, have dropped (%" PRIu32 ") bytes.", entry_header->entry_len); - Metrics::increment(log_rsb.num_lost_before_flush_to_disk, fmt_entry_count); - Metrics::increment(log_rsb.bytes_lost_before_flush_to_disk, fmt_buf_bytes); + Counter::increment(log_rsb.num_lost_before_flush_to_disk, fmt_entry_count); + Counter::increment(log_rsb.bytes_lost_before_flush_to_disk, fmt_buf_bytes); } // if writing to a pipe, fill the buffer with a single // record to avoid as much as possible overflowing the @@ -633,8 +633,8 @@ LogFile::write_ascii_logbuffer3(LogBufferHeader *buffer_header, const char *alt_ // LogFlushData *flush_data = new LogFlushData(this, ascii_buffer, fmt_buf_bytes); - Metrics::increment(log_rsb.num_flush_to_disk, fmt_entry_count); - Metrics::increment(log_rsb.bytes_flush_to_disk, fmt_buf_bytes); + Counter::increment(log_rsb.num_flush_to_disk, fmt_entry_count); + Counter::increment(log_rsb.bytes_flush_to_disk, fmt_buf_bytes); ink_atomiclist_push(Log::flush_data_list, flush_data); diff --git a/src/proxy/logging/LogObject.cc b/src/proxy/logging/LogObject.cc index d2c98a70149..e39ea2de4e0 100644 --- a/src/proxy/logging/LogObject.cc +++ b/src/proxy/logging/LogObject.cc @@ -66,7 +66,7 @@ LogBufferManager::preproc_buffers(LogBufferSink *sink) } else if (_num_flush_buffers > FLUSH_ARRAY_SIZE) { ink_atomic_increment(&_num_flush_buffers, -1); Warning("Dropping log buffer, can't keep up."); - Metrics::increment(log_rsb.bytes_lost_before_preproc, b->header()->byte_count); + Counter::increment(log_rsb.bytes_lost_before_preproc, b->header()->byte_count); delete b; } else { new_q.push(b); @@ -1349,15 +1349,15 @@ LogObjectManager::log(LogAccess *lad) // The if-statement should keep step with the priority order. // if (unlikely(ret & Log::FAIL)) { - Metrics::increment(log_rsb.event_log_access_fail); + Counter::increment(log_rsb.event_log_access_fail); } else if (unlikely(ret & Log::FULL)) { - Metrics::increment(log_rsb.event_log_access_full); + Counter::increment(log_rsb.event_log_access_full); } else if (likely(ret & Log::LOG_OK)) { - Metrics::increment(log_rsb.event_log_access_ok); + Counter::increment(log_rsb.event_log_access_ok); } else if (unlikely(ret & Log::AGGR)) { - Metrics::increment(log_rsb.event_log_access_aggr); + Counter::increment(log_rsb.event_log_access_aggr); } else if (likely(ret & Log::SKIP)) { - Metrics::increment(log_rsb.event_log_access_skip); + Counter::increment(log_rsb.event_log_access_skip); } else { ink_release_assert(!"Unexpected result"); } diff --git a/src/records/RecCore.cc b/src/records/RecCore.cc index 9b735d7be62..c89defde616 100644 --- a/src/records/RecCore.cc +++ b/src/records/RecCore.cc @@ -39,6 +39,9 @@ #include #include +#include +#include + using ts::Metrics; // This is needed to manage the size of the librecords record. It can't be static, because it needs to be modified @@ -513,11 +516,11 @@ RecGetRecordBool(const char *name, RecBool *rec_bool, bool lock) RecErrT RecLookupRecord(const char *name, void (*callback)(const RecRecord *, void *), void *data, bool lock) { - RecErrT err = REC_ERR_FAIL; - ts::Metrics &intm = ts::Metrics::getInstance(); - auto it = intm.find(name); + RecErrT err = REC_ERR_FAIL; + ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); + auto it = metrics.find(name); - if (it != intm.end()) { + if (it != metrics.end()) { RecRecord r; auto &&[name, val] = *it; @@ -567,7 +570,7 @@ RecLookupMatchingRecords(unsigned rec_type, const char *match, void (*callback)( tmp.rec_type = RECT_ALL; tmp.data_type = RECD_INT; - for (auto &&[name, val] : ts::Metrics::getInstance()) { + for (auto &&[name, val] : ts::Metrics::Counter::getInstance()) { if (regex.match(name.data()) >= 0) { tmp.name = name.data(); tmp.data.rec_int = val; @@ -899,7 +902,7 @@ RecDumpRecords(RecT rec_type, RecDumpEntryCb callback, void *edata) // Dump all new metrics as well (no "type" for them) RecData datum; - for (auto &&[name, val] : ts::Metrics::getInstance()) { + for (auto &&[name, val] : ts::Metrics::Counter::getInstance()) { datum.rec_int = val; callback(RECT_PLUGIN, edata, true, name.data(), TS_RECORDDATATYPE_INT, &datum); } diff --git a/src/traffic_server/traffic_server.cc b/src/traffic_server/traffic_server.cc index 1e66c85cfbb..fbce6aaa46e 100644 --- a/src/traffic_server/traffic_server.cc +++ b/src/traffic_server/traffic_server.cc @@ -269,8 +269,8 @@ class SignalContinuation : public Continuation int periodic(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */) { - ts::Metrics &intm = ts::Metrics::getInstance(); - static auto drain_id = intm.lookup("proxy.process.proxy.draining"); + ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); + static auto drain_id = metrics.lookup("proxy.process.proxy.draining"); if (signal_received[SIGUSR1]) { signal_received[SIGUSR1] = false; @@ -308,7 +308,7 @@ class SignalContinuation : public Continuation RecInt timeout = 0; if (RecGetRecordInt("proxy.config.stop.shutdown_timeout", &timeout) == REC_ERR_OKAY && timeout) { - intm[drain_id] = 1; + metrics[drain_id] = 1; TSSystemState::drain(true); // Close listening sockets here only if TS is running standalone RecInt close_sockets = 0; @@ -426,11 +426,11 @@ class MemoryLimit : public Continuation public: MemoryLimit() : Continuation(new_ProxyMutex()) { - ts::Metrics &intm = ts::Metrics::getInstance(); + ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); memset(&_usage, 0, sizeof(_usage)); SET_HANDLER(&MemoryLimit::periodic); - memory_rss = intm.newMetricPtr("proxy.process.traffic_server.memory.rss"); + memory_rss = metrics.createPtr("proxy.process.traffic_server.memory.rss"); } ~MemoryLimit() override { mutex = nullptr; } @@ -450,7 +450,7 @@ class MemoryLimit : public Continuation _memory_limit = _memory_limit >> 10; // divide by 1024 if (getrusage(RUSAGE_SELF, &_usage) == 0) { - ts::Metrics::write(memory_rss, _usage.ru_maxrss << 10); // * 1024 + ts::Metrics::Counter::write(memory_rss, _usage.ru_maxrss << 10); // * 1024 Debug("server", "memory usage - ru_maxrss: %ld memory limit: %" PRId64, _usage.ru_maxrss, _memory_limit); if (_memory_limit > 0) { if (_usage.ru_maxrss > _memory_limit) { @@ -478,7 +478,7 @@ class MemoryLimit : public Continuation private: int64_t _memory_limit = 0; struct rusage _usage; - ts::Metrics::IntType *memory_rss; + Counter::AtomicType *memory_rss; }; /** Gate the emission of the "Traffic Server is fuly initialized" log message. @@ -805,10 +805,10 @@ CB_After_Cache_Init() emit_fully_initialized_message(); } - ts::Metrics &intm = ts::Metrics::getInstance(); - auto id = intm.lookup("proxy.process.proxy.cache_ready_time"); + ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); + auto id = metrics.lookup("proxy.process.proxy.cache_ready_time"); - intm[id].store(time(nullptr)); + metrics[id].store(time(nullptr)); // Alert the plugins the cache is initialized. hook = g_lifecycle_hooks->get(TS_LIFECYCLE_CACHE_READY_HOOK); @@ -1412,24 +1412,24 @@ struct ShowStats : public Continuation { if (!(cycle++ % 24)) { printf("r:rr w:ww r:rbs w:wbs open polls\n"); } - int64_t d_rb = Metrics::read(net_rsb.calls_to_readfromnet) - last_rb; + int64_t d_rb = Counter::read(net_rsb.calls_to_readfromnet) - last_rb; last_rb += d_rb; - int64_t d_wb = Metrics::read(net_rsb.calls_to_writetonet) - last_wb; + int64_t d_wb = Counter::read(net_rsb.calls_to_writetonet) - last_wb; last_wb += d_wb; - int64_t d_nrb = Metrics::read(net_rsb.read_bytes) - last_nrb; + int64_t d_nrb = Counter::read(net_rsb.read_bytes) - last_nrb; last_nrb += d_nrb; - int64_t d_nr = Metrics::read(net_rsb.read_bytes_count) - last_nr; + int64_t d_nr = Counter::read(net_rsb.read_bytes_count) - last_nr; last_nr += d_nr; - int64_t d_nwb = Metrics::read(net_rsb.write_bytes) - last_nwb; + int64_t d_nwb = Counter::read(net_rsb.write_bytes) - last_nwb; last_nwb += d_nwb; - int64_t d_nw = Metrics::read(net_rsb.write_bytes_count) - last_nw; + int64_t d_nw = Counter::read(net_rsb.write_bytes_count) - last_nw; last_nw += d_nw; - int64_t d_o = Metrics::read(net_rsb.connections_currently_open); - int64_t d_p = Metrics::read(net_rsb.handler_run) - last_p; + int64_t d_o = Counter::read(net_rsb.connections_currently_open); + int64_t d_p = Counter::read(net_rsb.handler_run) - last_p; last_p += d_p; printf("%" PRId64 ":%" PRId64 ":%" PRId64 ":%" PRId64 " %" PRId64 ":%" PRId64 " %" PRId64 " %" PRId64 "\n", d_rb, d_wb, d_nrb, @@ -1856,19 +1856,19 @@ main(int /* argc ATS_UNUSED */, const char **argv) syslog_log_configure(); // Register stats - ts::Metrics &intm = ts::Metrics::getInstance(); + ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); int32_t id; - id = intm.newMetric("proxy.process.proxy.reconfigure_time"); - intm[id] = time(nullptr); - id = intm.newMetric("proxy.process.proxy.start_time"); - intm[id] = time(nullptr); + id = metrics.create("proxy.process.proxy.reconfigure_time"); + metrics[id] = time(nullptr); + id = metrics.create("proxy.process.proxy.start_time"); + metrics[id] = time(nullptr); // These all gets initialied to 0 - intm.newMetric("proxy.process.proxy.reconfigure_required"); - intm.newMetric("proxy.process.proxy.restart_required"); - intm.newMetric("proxy.process.proxy.draining"); + metrics.create("proxy.process.proxy.reconfigure_required"); + metrics.create("proxy.process.proxy.restart_required"); + metrics.create("proxy.process.proxy.draining"); // This gets updated later (in the callback) - intm.newMetric("proxy.process.proxy.cache_ready_time"); + metrics.create("proxy.process.proxy.cache_ready_time"); // init huge pages int enabled; From 10040e42c4d211746e7ba43d3a1a63c192ce840e Mon Sep 17 00:00:00 2001 From: Leif Hedstrom Date: Fri, 27 Oct 2023 12:38:09 -0600 Subject: [PATCH 2/6] Removes most of the instance use --- include/api/Metrics.h | 21 +- src/iocore/aio/AIO.cc | 10 +- src/iocore/cache/Cache.cc | 114 ++++--- src/iocore/dns/DNS.cc | 24 +- src/iocore/hostdb/HostDB.cc | 16 +- src/iocore/hostdb/P_RefCountCache.h | 20 +- src/iocore/io_uring/io_uring.cc | 4 +- src/iocore/net/Net.cc | 84 +++-- src/iocore/net/SSLStats.cc | 120 ++++--- src/iocore/net/quic/QUICGlobals.cc | 6 +- src/proxy/http/HttpConfig.cc | 484 +++++++++++++-------------- src/proxy/http/PreWarmManager.cc | 2 +- src/proxy/http2/HTTP2.cc | 60 ++-- src/proxy/http3/Http3.cc | 4 +- src/proxy/logging/LogConfig.cc | 51 ++- src/traffic_server/traffic_server.cc | 2 +- 16 files changed, 508 insertions(+), 514 deletions(-) diff --git a/include/api/Metrics.h b/include/api/Metrics.h index 519c3951c08..cba66865af0 100644 --- a/include/api/Metrics.h +++ b/include/api/Metrics.h @@ -85,9 +85,6 @@ namespace Metrics ink_release_assert(0 == create("proxy.process.api.metrics.bad_id")); // Reserve slot 0 for errors, this should always be 0 } - // Singleton - static Counter &getInstance(); - // Yes, we don't return objects here, but rather ID's and atomic's directly. Treat // the std::atomic as the underlying class for a single metric, and be happy. IdType create(const std::string_view name); @@ -153,6 +150,24 @@ namespace Metrics } // Static methods to encapsulate access to the atomic's + static Counter &getInstance(); + + static IdType + Create(const std::string_view name) + { + auto &instance = getInstance(); + + return instance.create(name); + } + + static AtomicType * + CreatePtr(const std::string_view name) + { + auto &instance = getInstance(); + + return instance.lookup(instance.create(name)); + } + static void increment(AtomicType *metric, uint64_t val = 1) { diff --git a/src/iocore/aio/AIO.cc b/src/iocore/aio/AIO.cc index 45da6100844..5a20cd39ec7 100644 --- a/src/iocore/aio/AIO.cc +++ b/src/iocore/aio/AIO.cc @@ -107,12 +107,10 @@ ink_aio_init(ts::ModuleVersion v, AIOBackend backend) { ink_release_assert(v.check(AIO_MODULE_INTERNAL_VERSION)); - ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); - - aio_rsb.read_count = metrics.createPtr("proxy.process.cache.aio.read_count"); - aio_rsb.write_count = metrics.createPtr("proxy.process.cache.aio.write_count"); - aio_rsb.kb_read = metrics.createPtr("proxy.process.cache.aio.KB_read"); - aio_rsb.kb_write = metrics.createPtr("proxy.process.cache.aio.KB_write"); + aio_rsb.read_count = Counter::CreatePtr("proxy.process.cache.aio.read_count"); + aio_rsb.write_count = Counter::CreatePtr("proxy.process.cache.aio.write_count"); + aio_rsb.kb_read = Counter::CreatePtr("proxy.process.cache.aio.KB_read"); + aio_rsb.kb_write = Counter::CreatePtr("proxy.process.cache.aio.KB_write"); memset(&aio_reqs, 0, MAX_DISKS_POSSIBLE * sizeof(AIO_Reqs *)); ink_mutex_init(&insert_mutex); diff --git a/src/iocore/cache/Cache.cc b/src/iocore/cache/Cache.cc index 62f4b2ab3e3..f049ae0c31c 100644 --- a/src/iocore/cache/Cache.cc +++ b/src/iocore/cache/Cache.cc @@ -129,69 +129,67 @@ force_link_CacheTestCaller() static void register_cache_stats(CacheStatsBlock *rsb, const std::string prefix) { - ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); - // These are special, in that we have 7 x 3 metrics here in a structure based on cache operation done - rsb->status[static_cast(CacheOpType::Lookup)].active = metrics.createPtr(prefix + ".lookup.active"); - rsb->status[static_cast(CacheOpType::Lookup)].success = metrics.createPtr(prefix + ".lookup.success"); - rsb->status[static_cast(CacheOpType::Lookup)].failure = metrics.createPtr(prefix + ".lookup.failure"); - rsb->status[static_cast(CacheOpType::Read)].active = metrics.createPtr(prefix + ".read.active"); - rsb->status[static_cast(CacheOpType::Read)].success = metrics.createPtr(prefix + ".read.success"); - rsb->status[static_cast(CacheOpType::Read)].failure = metrics.createPtr(prefix + ".read.failure"); - rsb->status[static_cast(CacheOpType::Write)].active = metrics.createPtr(prefix + ".write.active"); - rsb->status[static_cast(CacheOpType::Write)].success = metrics.createPtr(prefix + ".write.success"); - rsb->status[static_cast(CacheOpType::Write)].failure = metrics.createPtr(prefix + ".write.failure"); - rsb->status[static_cast(CacheOpType::Update)].active = metrics.createPtr(prefix + ".update.active"); - rsb->status[static_cast(CacheOpType::Update)].success = metrics.createPtr(prefix + ".update.success"); - rsb->status[static_cast(CacheOpType::Update)].failure = metrics.createPtr(prefix + ".update.failure"); - rsb->status[static_cast(CacheOpType::Remove)].active = metrics.createPtr(prefix + ".remove.active"); - rsb->status[static_cast(CacheOpType::Remove)].success = metrics.createPtr(prefix + ".remove.success"); - rsb->status[static_cast(CacheOpType::Remove)].failure = metrics.createPtr(prefix + ".remove.failure"); - rsb->status[static_cast(CacheOpType::Evacuate)].active = metrics.createPtr(prefix + ".evacuate.active"); - rsb->status[static_cast(CacheOpType::Evacuate)].success = metrics.createPtr(prefix + ".evacuate.success"); - rsb->status[static_cast(CacheOpType::Evacuate)].failure = metrics.createPtr(prefix + ".evacuate.failure"); - rsb->status[static_cast(CacheOpType::Scan)].active = metrics.createPtr(prefix + ".scan.active"); - rsb->status[static_cast(CacheOpType::Scan)].success = metrics.createPtr(prefix + ".scan.success"); - rsb->status[static_cast(CacheOpType::Scan)].failure = metrics.createPtr(prefix + ".scan.failure"); + rsb->status[static_cast(CacheOpType::Lookup)].active = Counter::CreatePtr(prefix + ".lookup.active"); + rsb->status[static_cast(CacheOpType::Lookup)].success = Counter::CreatePtr(prefix + ".lookup.success"); + rsb->status[static_cast(CacheOpType::Lookup)].failure = Counter::CreatePtr(prefix + ".lookup.failure"); + rsb->status[static_cast(CacheOpType::Read)].active = Counter::CreatePtr(prefix + ".read.active"); + rsb->status[static_cast(CacheOpType::Read)].success = Counter::CreatePtr(prefix + ".read.success"); + rsb->status[static_cast(CacheOpType::Read)].failure = Counter::CreatePtr(prefix + ".read.failure"); + rsb->status[static_cast(CacheOpType::Write)].active = Counter::CreatePtr(prefix + ".write.active"); + rsb->status[static_cast(CacheOpType::Write)].success = Counter::CreatePtr(prefix + ".write.success"); + rsb->status[static_cast(CacheOpType::Write)].failure = Counter::CreatePtr(prefix + ".write.failure"); + rsb->status[static_cast(CacheOpType::Update)].active = Counter::CreatePtr(prefix + ".update.active"); + rsb->status[static_cast(CacheOpType::Update)].success = Counter::CreatePtr(prefix + ".update.success"); + rsb->status[static_cast(CacheOpType::Update)].failure = Counter::CreatePtr(prefix + ".update.failure"); + rsb->status[static_cast(CacheOpType::Remove)].active = Counter::CreatePtr(prefix + ".remove.active"); + rsb->status[static_cast(CacheOpType::Remove)].success = Counter::CreatePtr(prefix + ".remove.success"); + rsb->status[static_cast(CacheOpType::Remove)].failure = Counter::CreatePtr(prefix + ".remove.failure"); + rsb->status[static_cast(CacheOpType::Evacuate)].active = Counter::CreatePtr(prefix + ".evacuate.active"); + rsb->status[static_cast(CacheOpType::Evacuate)].success = Counter::CreatePtr(prefix + ".evacuate.success"); + rsb->status[static_cast(CacheOpType::Evacuate)].failure = Counter::CreatePtr(prefix + ".evacuate.failure"); + rsb->status[static_cast(CacheOpType::Scan)].active = Counter::CreatePtr(prefix + ".scan.active"); + rsb->status[static_cast(CacheOpType::Scan)].success = Counter::CreatePtr(prefix + ".scan.success"); + rsb->status[static_cast(CacheOpType::Scan)].failure = Counter::CreatePtr(prefix + ".scan.failure"); // These are in an array of 1, 2 and 3+ fragment documents - rsb->fragment_document_count[0] = metrics.createPtr(prefix + ".frags_per_doc.1"); - rsb->fragment_document_count[1] = metrics.createPtr(prefix + ".frags_per_doc.2"); - rsb->fragment_document_count[2] = metrics.createPtr(prefix + ".frags_per_doc.3+"); + rsb->fragment_document_count[0] = Counter::CreatePtr(prefix + ".frags_per_doc.1"); + rsb->fragment_document_count[1] = Counter::CreatePtr(prefix + ".frags_per_doc.2"); + rsb->fragment_document_count[2] = Counter::CreatePtr(prefix + ".frags_per_doc.3+"); // And then everything else - rsb->bytes_used = metrics.createPtr(prefix + ".bytes_used"); - rsb->bytes_total = metrics.createPtr(prefix + ".bytes_total"); - rsb->stripes = metrics.createPtr(prefix + ".stripes"); - rsb->ram_cache_bytes_total = metrics.createPtr(prefix + ".ram_cache.total_bytes"); - rsb->ram_cache_bytes = metrics.createPtr(prefix + ".ram_cache.bytes_used"); - rsb->ram_cache_hits = metrics.createPtr(prefix + ".ram_cache.hits"); - rsb->ram_cache_misses = metrics.createPtr(prefix + ".ram_cache.misses"); - rsb->pread_count = metrics.createPtr(prefix + ".pread_count"); - rsb->percent_full = metrics.createPtr(prefix + ".percent_full"); - rsb->read_seek_fail = metrics.createPtr(prefix + ".read.seek.failure"); - rsb->read_invalid = metrics.createPtr(prefix + ".read.invalid"); - rsb->write_backlog_failure = metrics.createPtr(prefix + ".write.backlog.failure"); - rsb->direntries_total = metrics.createPtr(prefix + ".direntries.total"); - rsb->direntries_used = metrics.createPtr(prefix + ".direntries.used"); - rsb->directory_collision_count = metrics.createPtr(prefix + ".directory_collision"); - rsb->read_busy_success = metrics.createPtr(prefix + ".read_busy.success"); - rsb->read_busy_failure = metrics.createPtr(prefix + ".read_busy.failure"); - rsb->write_bytes = metrics.createPtr(prefix + ".write_bytes_stat"); - rsb->hdr_vector_marshal = metrics.createPtr(prefix + ".vector_marshals"); - rsb->hdr_marshal = metrics.createPtr(prefix + ".hdr_marshals"); - rsb->hdr_marshal_bytes = metrics.createPtr(prefix + ".hdr_marshal_bytes"); - rsb->gc_bytes_evacuated = metrics.createPtr(prefix + ".gc_bytes_evacuated"); - rsb->gc_frags_evacuated = metrics.createPtr(prefix + ".gc_frags_evacuated"); - rsb->directory_wrap = metrics.createPtr(prefix + ".wrap_count"); - rsb->directory_sync_count = metrics.createPtr(prefix + ".sync.count"); - rsb->directory_sync_bytes = metrics.createPtr(prefix + ".sync.bytes"); - rsb->directory_sync_time = metrics.createPtr(prefix + ".sync.time"); - rsb->span_errors_read = metrics.createPtr(prefix + ".span.errors.read"); - rsb->span_errors_write = metrics.createPtr(prefix + ".span.errors.write"); - rsb->span_failing = metrics.createPtr(prefix + ".span.failing"); - rsb->span_offline = metrics.createPtr(prefix + ".span.offline"); - rsb->span_online = metrics.createPtr(prefix + ".span.online"); + rsb->bytes_used = Counter::CreatePtr(prefix + ".bytes_used"); + rsb->bytes_total = Counter::CreatePtr(prefix + ".bytes_total"); + rsb->stripes = Counter::CreatePtr(prefix + ".stripes"); + rsb->ram_cache_bytes_total = Counter::CreatePtr(prefix + ".ram_cache.total_bytes"); + rsb->ram_cache_bytes = Counter::CreatePtr(prefix + ".ram_cache.bytes_used"); + rsb->ram_cache_hits = Counter::CreatePtr(prefix + ".ram_cache.hits"); + rsb->ram_cache_misses = Counter::CreatePtr(prefix + ".ram_cache.misses"); + rsb->pread_count = Counter::CreatePtr(prefix + ".pread_count"); + rsb->percent_full = Counter::CreatePtr(prefix + ".percent_full"); + rsb->read_seek_fail = Counter::CreatePtr(prefix + ".read.seek.failure"); + rsb->read_invalid = Counter::CreatePtr(prefix + ".read.invalid"); + rsb->write_backlog_failure = Counter::CreatePtr(prefix + ".write.backlog.failure"); + rsb->direntries_total = Counter::CreatePtr(prefix + ".direntries.total"); + rsb->direntries_used = Counter::CreatePtr(prefix + ".direntries.used"); + rsb->directory_collision_count = Counter::CreatePtr(prefix + ".directory_collision"); + rsb->read_busy_success = Counter::CreatePtr(prefix + ".read_busy.success"); + rsb->read_busy_failure = Counter::CreatePtr(prefix + ".read_busy.failure"); + rsb->write_bytes = Counter::CreatePtr(prefix + ".write_bytes_stat"); + rsb->hdr_vector_marshal = Counter::CreatePtr(prefix + ".vector_marshals"); + rsb->hdr_marshal = Counter::CreatePtr(prefix + ".hdr_marshals"); + rsb->hdr_marshal_bytes = Counter::CreatePtr(prefix + ".hdr_marshal_bytes"); + rsb->gc_bytes_evacuated = Counter::CreatePtr(prefix + ".gc_bytes_evacuated"); + rsb->gc_frags_evacuated = Counter::CreatePtr(prefix + ".gc_frags_evacuated"); + rsb->directory_wrap = Counter::CreatePtr(prefix + ".wrap_count"); + rsb->directory_sync_count = Counter::CreatePtr(prefix + ".sync.count"); + rsb->directory_sync_bytes = Counter::CreatePtr(prefix + ".sync.bytes"); + rsb->directory_sync_time = Counter::CreatePtr(prefix + ".sync.time"); + rsb->span_errors_read = Counter::CreatePtr(prefix + ".span.errors.read"); + rsb->span_errors_write = Counter::CreatePtr(prefix + ".span.errors.write"); + rsb->span_failing = Counter::CreatePtr(prefix + ".span.failing"); + rsb->span_offline = Counter::CreatePtr(prefix + ".span.offline"); + rsb->span_online = Counter::CreatePtr(prefix + ".span.online"); } // ToDo: This gets called as part of librecords collection continuation, probably change this later. diff --git a/src/iocore/dns/DNS.cc b/src/iocore/dns/DNS.cc index c6770da96e0..8db24aba743 100644 --- a/src/iocore/dns/DNS.cc +++ b/src/iocore/dns/DNS.cc @@ -1907,19 +1907,17 @@ ink_dns_init(ts::ModuleVersion v) // // Register statistics callbacks // - ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); - - dns_rsb.fail_time = metrics.createPtr("proxy.process.dns.fail_time"); - dns_rsb.in_flight = metrics.createPtr("proxy.process.dns.in_flight"); - dns_rsb.lookup_fail = metrics.createPtr("proxy.process.dns.lookup_failures"); - dns_rsb.lookup_success = metrics.createPtr("proxy.process.dns.lookup_successes"); - dns_rsb.max_retries_exceeded = metrics.createPtr("proxy.process.dns.max_retries_exceeded"); - dns_rsb.response_time = metrics.createPtr("proxy.process.dns.lookup_time"); - dns_rsb.retries = metrics.createPtr("proxy.process.dns.retries"); - dns_rsb.success_time = metrics.createPtr("proxy.process.dns.success_time"); - dns_rsb.tcp_reset = metrics.createPtr("proxy.process.dns.tcp_reset"); - dns_rsb.tcp_retries = metrics.createPtr("proxy.process.dns.tcp_retries"); - dns_rsb.total_lookups = metrics.createPtr("proxy.process.dns.total_dns_lookups"); + dns_rsb.fail_time = Counter::CreatePtr("proxy.process.dns.fail_time"); + dns_rsb.in_flight = Counter::CreatePtr("proxy.process.dns.in_flight"); + dns_rsb.lookup_fail = Counter::CreatePtr("proxy.process.dns.lookup_failures"); + dns_rsb.lookup_success = Counter::CreatePtr("proxy.process.dns.lookup_successes"); + dns_rsb.max_retries_exceeded = Counter::CreatePtr("proxy.process.dns.max_retries_exceeded"); + dns_rsb.response_time = Counter::CreatePtr("proxy.process.dns.lookup_time"); + dns_rsb.retries = Counter::CreatePtr("proxy.process.dns.retries"); + dns_rsb.success_time = Counter::CreatePtr("proxy.process.dns.success_time"); + dns_rsb.tcp_reset = Counter::CreatePtr("proxy.process.dns.tcp_reset"); + dns_rsb.tcp_retries = Counter::CreatePtr("proxy.process.dns.tcp_retries"); + dns_rsb.total_lookups = Counter::CreatePtr("proxy.process.dns.total_dns_lookups"); } #if TS_HAS_TESTS diff --git a/src/iocore/hostdb/HostDB.cc b/src/iocore/hostdb/HostDB.cc index 8c4ec947c2a..471d6836181 100644 --- a/src/iocore/hostdb/HostDB.cc +++ b/src/iocore/hostdb/HostDB.cc @@ -1790,15 +1790,13 @@ ink_hostdb_init(ts::ModuleVersion v) // // Register stats // - ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); - - hostdb_rsb.total_lookups = metrics.createPtr("proxy.process.hostdb.total_lookups"); - hostdb_rsb.total_hits = metrics.createPtr("proxy.process.hostdb.total_hits"); - hostdb_rsb.total_serve_stale = metrics.createPtr("proxy.process.hostdb.total_serve_stale"); - hostdb_rsb.ttl = metrics.createPtr("proxy.process.hostdb.ttl"); - hostdb_rsb.ttl_expires = metrics.createPtr("proxy.process.hostdb.ttl_expires"); - hostdb_rsb.re_dns_on_reload = metrics.createPtr("proxy.process.hostdb.re_dns_on_reload"); - hostdb_rsb.insert_duplicate_to_pending_dns = metrics.createPtr("proxy.process.hostdb.insert_duplicate_to_pending_dns"); + hostdb_rsb.total_lookups = Counter::CreatePtr("proxy.process.hostdb.total_lookups"); + hostdb_rsb.total_hits = Counter::CreatePtr("proxy.process.hostdb.total_hits"); + hostdb_rsb.total_serve_stale = Counter::CreatePtr("proxy.process.hostdb.total_serve_stale"); + hostdb_rsb.ttl = Counter::CreatePtr("proxy.process.hostdb.ttl"); + hostdb_rsb.ttl_expires = Counter::CreatePtr("proxy.process.hostdb.ttl_expires"); + hostdb_rsb.re_dns_on_reload = Counter::CreatePtr("proxy.process.hostdb.re_dns_on_reload"); + hostdb_rsb.insert_duplicate_to_pending_dns = Counter::CreatePtr("proxy.process.hostdb.insert_duplicate_to_pending_dns"); ts_host_res_global_init(); } diff --git a/src/iocore/hostdb/P_RefCountCache.h b/src/iocore/hostdb/P_RefCountCache.h index b0332f0fe11..90fafa427b4 100644 --- a/src/iocore/hostdb/P_RefCountCache.h +++ b/src/iocore/hostdb/P_RefCountCache.h @@ -428,21 +428,19 @@ RefCountCache::RefCountCache(unsigned int num_partitions, int size, int items const std::string metrics_prefix) : header(RefCountCacheHeader(object_version)) { - ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); - this->max_size = size; this->max_items = items; this->num_partitions = num_partitions; - this->rsb.refcountcache_current_items = metrics.createPtr((metrics_prefix + "current_items").c_str()); - this->rsb.refcountcache_current_size = metrics.createPtr((metrics_prefix + "current_size").c_str()); - this->rsb.refcountcache_total_inserts = metrics.createPtr((metrics_prefix + "total_inserts").c_str()); - this->rsb.refcountcache_total_failed_inserts = metrics.createPtr((metrics_prefix + "total_failed_inserts").c_str()); - this->rsb.refcountcache_total_lookups = metrics.createPtr((metrics_prefix + "total_lookups").c_str()); - this->rsb.refcountcache_total_hits = metrics.createPtr((metrics_prefix + "total_hits").c_str()); - this->rsb.refcountcache_last_sync_time = metrics.createPtr((metrics_prefix + "last_sync.time").c_str()); - this->rsb.refcountcache_last_total_items = metrics.createPtr((metrics_prefix + "last_sync.total_items").c_str()); - this->rsb.refcountcache_last_total_size = metrics.createPtr((metrics_prefix + "last_sync.total_size").c_str()); + this->rsb.refcountcache_current_items = Counter::CreatePtr((metrics_prefix + "current_items").c_str()); + this->rsb.refcountcache_current_size = Counter::CreatePtr((metrics_prefix + "current_size").c_str()); + this->rsb.refcountcache_total_inserts = Counter::CreatePtr((metrics_prefix + "total_inserts").c_str()); + this->rsb.refcountcache_total_failed_inserts = Counter::CreatePtr((metrics_prefix + "total_failed_inserts").c_str()); + this->rsb.refcountcache_total_lookups = Counter::CreatePtr((metrics_prefix + "total_lookups").c_str()); + this->rsb.refcountcache_total_hits = Counter::CreatePtr((metrics_prefix + "total_hits").c_str()); + this->rsb.refcountcache_last_sync_time = Counter::CreatePtr((metrics_prefix + "last_sync.time").c_str()); + this->rsb.refcountcache_last_total_items = Counter::CreatePtr((metrics_prefix + "last_sync.total_items").c_str()); + this->rsb.refcountcache_last_total_size = Counter::CreatePtr((metrics_prefix + "last_sync.total_size").c_str()); // Now lets create all the partitions this->partitions.reserve(num_partitions); diff --git a/src/iocore/io_uring/io_uring.cc b/src/iocore/io_uring/io_uring.cc index 9107e074455..19bac433627 100644 --- a/src/iocore/io_uring/io_uring.cc +++ b/src/iocore/io_uring/io_uring.cc @@ -46,8 +46,8 @@ struct IOUringStatsBlock { static IOUringStatsBlock io_uring_rsb = []() { auto &intm = Metrics::getInstance(); - return IOUringStatsBlock{metrics.createPtr("proxy.process.io_uring.submitted"), - metrics.createPtr("proxy.process.io_uring.completed")}; + return IOUringStatsBlock{Counter::CreatePtr("proxy.process.io_uring.submitted"), + Counter::CreatePtr("proxy.process.io_uring.completed")}; }(); void diff --git a/src/iocore/net/Net.cc b/src/iocore/net/Net.cc index 2795c771dac..0a2665650b1 100644 --- a/src/iocore/net/Net.cc +++ b/src/iocore/net/Net.cc @@ -80,58 +80,56 @@ configure_net() static inline void register_net_stats() { - ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); - - net_rsb.accepts_currently_open = metrics.createPtr("proxy.process.net.accepts_currently_open"); - net_rsb.calls_to_read = metrics.createPtr("proxy.process.net.calls_to_read"); - net_rsb.calls_to_read_nodata = metrics.createPtr("proxy.process.net.calls_to_read_nodata"); - net_rsb.calls_to_readfromnet = metrics.createPtr("proxy.process.net.calls_to_readfromnet"); - net_rsb.calls_to_write = metrics.createPtr("proxy.process.net.calls_to_write"); - net_rsb.calls_to_write_nodata = metrics.createPtr("proxy.process.net.calls_to_write_nodata"); - net_rsb.calls_to_writetonet = metrics.createPtr("proxy.process.net.calls_to_writetonet"); - net_rsb.connections_currently_open = metrics.createPtr("proxy.process.net.connections_currently_open"); - net_rsb.connections_throttled_in = metrics.createPtr("proxy.process.net.connections_throttled_in"); - net_rsb.connections_throttled_out = metrics.createPtr("proxy.process.net.connections_throttled_out"); - net_rsb.tunnel_total_client_connections_blind_tcp = metrics.createPtr("proxy.process.tunnel.total_client_connections_blind_tcp"); + net_rsb.accepts_currently_open = Counter::CreatePtr("proxy.process.net.accepts_currently_open"); + net_rsb.calls_to_read = Counter::CreatePtr("proxy.process.net.calls_to_read"); + net_rsb.calls_to_read_nodata = Counter::CreatePtr("proxy.process.net.calls_to_read_nodata"); + net_rsb.calls_to_readfromnet = Counter::CreatePtr("proxy.process.net.calls_to_readfromnet"); + net_rsb.calls_to_write = Counter::CreatePtr("proxy.process.net.calls_to_write"); + net_rsb.calls_to_write_nodata = Counter::CreatePtr("proxy.process.net.calls_to_write_nodata"); + net_rsb.calls_to_writetonet = Counter::CreatePtr("proxy.process.net.calls_to_writetonet"); + net_rsb.connections_currently_open = Counter::CreatePtr("proxy.process.net.connections_currently_open"); + net_rsb.connections_throttled_in = Counter::CreatePtr("proxy.process.net.connections_throttled_in"); + net_rsb.connections_throttled_out = Counter::CreatePtr("proxy.process.net.connections_throttled_out"); + net_rsb.tunnel_total_client_connections_blind_tcp = Counter::CreatePtr("proxy.process.tunnel.total_client_connections_blind_tcp"); net_rsb.tunnel_current_client_connections_blind_tcp = - metrics.createPtr("proxy.process.tunnel.current_client_connections_blind_tcp"); - net_rsb.tunnel_total_server_connections_blind_tcp = metrics.createPtr("proxy.process.tunnel.total_server_connections_blind_tcp"); + Counter::CreatePtr("proxy.process.tunnel.current_client_connections_blind_tcp"); + net_rsb.tunnel_total_server_connections_blind_tcp = Counter::CreatePtr("proxy.process.tunnel.total_server_connections_blind_tcp"); net_rsb.tunnel_current_server_connections_blind_tcp = - metrics.createPtr("proxy.process.tunnel.current_server_connections_blind_tcp"); + Counter::CreatePtr("proxy.process.tunnel.current_server_connections_blind_tcp"); net_rsb.tunnel_total_client_connections_tls_tunnel = - metrics.createPtr("proxy.process.tunnel.total_client_connections_tls_tunnel"); + Counter::CreatePtr("proxy.process.tunnel.total_client_connections_tls_tunnel"); net_rsb.tunnel_current_client_connections_tls_tunnel = - metrics.createPtr("proxy.process.tunnel.current_client_connections_tls_tunnel"); + Counter::CreatePtr("proxy.process.tunnel.current_client_connections_tls_tunnel"); net_rsb.tunnel_total_client_connections_tls_forward = - metrics.createPtr("proxy.process.tunnel.total_client_connections_tls_forward"); + Counter::CreatePtr("proxy.process.tunnel.total_client_connections_tls_forward"); net_rsb.tunnel_current_client_connections_tls_forward = - metrics.createPtr("proxy.process.tunnel.current_client_connections_tls_forward"); + Counter::CreatePtr("proxy.process.tunnel.current_client_connections_tls_forward"); net_rsb.tunnel_total_client_connections_tls_partial_blind = - metrics.createPtr("proxy.process.tunnel.total_client_connections_tls_partial_blind"); + Counter::CreatePtr("proxy.process.tunnel.total_client_connections_tls_partial_blind"); net_rsb.tunnel_current_client_connections_tls_partial_blind = - metrics.createPtr("proxy.process.tunnel.current_client_connections_tls_partial_blind"); - net_rsb.tunnel_total_client_connections_tls_http = metrics.createPtr("proxy.process.tunnel.total_client_connections_tls_http"); + Counter::CreatePtr("proxy.process.tunnel.current_client_connections_tls_partial_blind"); + net_rsb.tunnel_total_client_connections_tls_http = Counter::CreatePtr("proxy.process.tunnel.total_client_connections_tls_http"); net_rsb.tunnel_current_client_connections_tls_http = - metrics.createPtr("proxy.process.tunnel.current_client_connections_tls_http"); - net_rsb.tunnel_total_server_connections_tls = metrics.createPtr("proxy.process.tunnel.total_server_connections_tls"); - net_rsb.tunnel_current_server_connections_tls = metrics.createPtr("proxy.process.tunnel.current_server_connections_tls"); - net_rsb.default_inactivity_timeout_applied = metrics.createPtr("proxy.process.net.default_inactivity_timeout_applied"); - net_rsb.default_inactivity_timeout_count = metrics.createPtr("proxy.process.net.default_inactivity_timeout_count"); - net_rsb.fastopen_attempts = metrics.createPtr("proxy.process.net.fastopen_out.attempts"); - net_rsb.fastopen_successes = metrics.createPtr("proxy.process.net.fastopen_out.successes"); - net_rsb.handler_run = metrics.createPtr("proxy.process.net.net_handler_run"); - net_rsb.inactivity_cop_lock_acquire_failure = metrics.createPtr("proxy.process.net.inactivity_cop_lock_acquire_failure"); - net_rsb.keep_alive_queue_timeout_count = metrics.createPtr("proxy.process.net.dynamic_keep_alive_timeout_in_count"); - net_rsb.keep_alive_queue_timeout_total = metrics.createPtr("proxy.process.net.dynamic_keep_alive_timeout_in_total"); - net_rsb.read_bytes = metrics.createPtr("proxy.process.net.read_bytes"); - net_rsb.read_bytes_count = metrics.createPtr("proxy.process.net.read_bytes_count"); - net_rsb.requests_max_throttled_in = metrics.createPtr("proxy.process.net.max.requests_throttled_in"); - net_rsb.socks_connections_currently_open = metrics.createPtr("proxy.process.socks.connections_currently_open"); - net_rsb.socks_connections_successful = metrics.createPtr("proxy.process.socks.connections_successful"); - net_rsb.socks_connections_unsuccessful = metrics.createPtr("proxy.process.socks.connections_unsuccessful"); - net_rsb.tcp_accept = metrics.createPtr("proxy.process.tcp.total_accepts"); - net_rsb.write_bytes = metrics.createPtr("proxy.process.net.write_bytes"); - net_rsb.write_bytes_count = metrics.createPtr("proxy.process.net.write_bytes_count"); + Counter::CreatePtr("proxy.process.tunnel.current_client_connections_tls_http"); + net_rsb.tunnel_total_server_connections_tls = Counter::CreatePtr("proxy.process.tunnel.total_server_connections_tls"); + net_rsb.tunnel_current_server_connections_tls = Counter::CreatePtr("proxy.process.tunnel.current_server_connections_tls"); + net_rsb.default_inactivity_timeout_applied = Counter::CreatePtr("proxy.process.net.default_inactivity_timeout_applied"); + net_rsb.default_inactivity_timeout_count = Counter::CreatePtr("proxy.process.net.default_inactivity_timeout_count"); + net_rsb.fastopen_attempts = Counter::CreatePtr("proxy.process.net.fastopen_out.attempts"); + net_rsb.fastopen_successes = Counter::CreatePtr("proxy.process.net.fastopen_out.successes"); + net_rsb.handler_run = Counter::CreatePtr("proxy.process.net.net_handler_run"); + net_rsb.inactivity_cop_lock_acquire_failure = Counter::CreatePtr("proxy.process.net.inactivity_cop_lock_acquire_failure"); + net_rsb.keep_alive_queue_timeout_count = Counter::CreatePtr("proxy.process.net.dynamic_keep_alive_timeout_in_count"); + net_rsb.keep_alive_queue_timeout_total = Counter::CreatePtr("proxy.process.net.dynamic_keep_alive_timeout_in_total"); + net_rsb.read_bytes = Counter::CreatePtr("proxy.process.net.read_bytes"); + net_rsb.read_bytes_count = Counter::CreatePtr("proxy.process.net.read_bytes_count"); + net_rsb.requests_max_throttled_in = Counter::CreatePtr("proxy.process.net.max.requests_throttled_in"); + net_rsb.socks_connections_currently_open = Counter::CreatePtr("proxy.process.socks.connections_currently_open"); + net_rsb.socks_connections_successful = Counter::CreatePtr("proxy.process.socks.connections_successful"); + net_rsb.socks_connections_unsuccessful = Counter::CreatePtr("proxy.process.socks.connections_unsuccessful"); + net_rsb.tcp_accept = Counter::CreatePtr("proxy.process.tcp.total_accepts"); + net_rsb.write_bytes = Counter::CreatePtr("proxy.process.net.write_bytes"); + net_rsb.write_bytes_count = Counter::CreatePtr("proxy.process.net.write_bytes_count"); } void diff --git a/src/iocore/net/SSLStats.cc b/src/iocore/net/SSLStats.cc index a3f328bea8a..1cecef4338b 100644 --- a/src/iocore/net/SSLStats.cc +++ b/src/iocore/net/SSLStats.cc @@ -71,8 +71,7 @@ add_cipher_stat(const char *cipherName, const std::string &statName) { // If not already registered ... if (cipherName && cipher_map.find(cipherName) == cipher_map.end()) { - ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); - Counter::AtomicType *metric = metrics.createPtr(statName); + Counter::AtomicType *metric = Counter::CreatePtr(statName); cipher_map.emplace(cipherName, metric); Debug("ssl", "registering SSL cipher metric '%s'", statName.c_str()); @@ -85,69 +84,68 @@ SSLInitializeStatistics() SSL_CTX *ctx; SSL *ssl; STACK_OF(SSL_CIPHER) * ciphers; - ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); // For now, register with the librecords global sync. RecRegNewSyncStatSync(SSLPeriodicMetricsUpdate); - ssl_rsb.early_data_received_count = metrics.createPtr("proxy.process.ssl.early_data_received"); - ssl_rsb.error_async = metrics.createPtr("proxy.process.ssl.ssl_error_async"); - ssl_rsb.error_ssl = metrics.createPtr("proxy.process.ssl.ssl_error_ssl"); - ssl_rsb.error_syscall = metrics.createPtr("proxy.process.ssl.ssl_error_syscall"); - ssl_rsb.ocsp_refresh_cert_failure = metrics.createPtr("proxy.process.ssl.ssl_ocsp_refresh_cert_failure"); - ssl_rsb.ocsp_refreshed_cert = metrics.createPtr("proxy.process.ssl.ssl_ocsp_refreshed_cert"); - ssl_rsb.ocsp_revoked_cert = metrics.createPtr("proxy.process.ssl.ssl_ocsp_revoked_cert"); - ssl_rsb.ocsp_unknown_cert = metrics.createPtr("proxy.process.ssl.ssl_ocsp_unknown_cert"); - ssl_rsb.origin_server_bad_cert = metrics.createPtr("proxy.process.ssl.origin_server_bad_cert"); - ssl_rsb.origin_server_cert_verify_failed = metrics.createPtr("proxy.process.ssl.origin_server_cert_verify_failed"); - ssl_rsb.origin_server_decryption_failed = metrics.createPtr("proxy.process.ssl.origin_server_decryption_failed"); - ssl_rsb.origin_server_expired_cert = metrics.createPtr("proxy.process.ssl.origin_server_expired_cert"); - ssl_rsb.origin_server_other_errors = metrics.createPtr("proxy.process.ssl.origin_server_other_errors"); - ssl_rsb.origin_server_revoked_cert = metrics.createPtr("proxy.process.ssl.origin_server_revoked_cert"); - ssl_rsb.origin_server_unknown_ca = metrics.createPtr("proxy.process.ssl.origin_server_unknown_ca"); - ssl_rsb.origin_server_unknown_cert = metrics.createPtr("proxy.process.ssl.origin_server_unknown_cert"); - ssl_rsb.origin_server_wrong_version = metrics.createPtr("proxy.process.ssl.origin_server_wrong_version"); - ssl_rsb.origin_session_reused_count = metrics.createPtr("proxy.process.ssl.origin_session_reused"); - ssl_rsb.sni_name_set_failure = metrics.createPtr("proxy.process.ssl.ssl_sni_name_set_failure"); - ssl_rsb.origin_session_cache_hit = metrics.createPtr("proxy.process.ssl.ssl_origin_session_cache_hit"); - ssl_rsb.origin_session_cache_miss = metrics.createPtr("proxy.process.ssl.ssl_origin_session_cache_miss"); - ssl_rsb.session_cache_eviction = metrics.createPtr("proxy.process.ssl.ssl_session_cache_eviction"); - ssl_rsb.session_cache_hit = metrics.createPtr("proxy.process.ssl.ssl_session_cache_hit"); - ssl_rsb.session_cache_lock_contention = metrics.createPtr("proxy.process.ssl.ssl_session_cache_lock_contention"); - ssl_rsb.session_cache_miss = metrics.createPtr("proxy.process.ssl.ssl_session_cache_miss"); - ssl_rsb.session_cache_new_session = metrics.createPtr("proxy.process.ssl.ssl_session_cache_new_session"); - ssl_rsb.total_attempts_handshake_count_in = metrics.createPtr("proxy.process.ssl.total_attempts_handshake_count_in"); - ssl_rsb.total_attempts_handshake_count_out = metrics.createPtr("proxy.process.ssl.total_attempts_handshake_count_out"); - ssl_rsb.total_dyn_def_tls_record_count = metrics.createPtr("proxy.process.ssl.default_record_size_count"); - ssl_rsb.total_dyn_max_tls_record_count = metrics.createPtr("proxy.process.ssl.max_record_size_count"); - ssl_rsb.total_dyn_redo_tls_record_count = metrics.createPtr("proxy.process.ssl.redo_record_size_count"); - ssl_rsb.total_handshake_time = metrics.createPtr("proxy.process.ssl.total_handshake_time"); - ssl_rsb.total_sslv3 = metrics.createPtr("proxy.process.ssl.ssl_total_sslv3"); - ssl_rsb.total_success_handshake_count_in = metrics.createPtr("proxy.process.ssl.total_success_handshake_count_in"); - ssl_rsb.total_success_handshake_count_out = metrics.createPtr("proxy.process.ssl.total_success_handshake_count_out"); - ssl_rsb.total_ticket_keys_renewed = metrics.createPtr("proxy.process.ssl.total_ticket_keys_renewed"); - ssl_rsb.total_tickets_created = metrics.createPtr("proxy.process.ssl.total_tickets_created"); - ssl_rsb.total_tickets_not_found = metrics.createPtr("proxy.process.ssl.total_tickets_not_found"); - ssl_rsb.total_tickets_renewed = metrics.createPtr("proxy.process.ssl.total_tickets_renewed"); // ToDo: Not used? - ssl_rsb.total_tickets_verified = metrics.createPtr("proxy.process.ssl.total_tickets_verified"); - ssl_rsb.total_tickets_verified_old_key = metrics.createPtr("proxy.process.ssl.total_tickets_verified_old_key"); - ssl_rsb.total_tlsv1 = metrics.createPtr("proxy.process.ssl.ssl_total_tlsv1"); - ssl_rsb.total_tlsv11 = metrics.createPtr("proxy.process.ssl.ssl_total_tlsv11"); - ssl_rsb.total_tlsv12 = metrics.createPtr("proxy.process.ssl.ssl_total_tlsv12"); - ssl_rsb.total_tlsv13 = metrics.createPtr("proxy.process.ssl.ssl_total_tlsv13"); - ssl_rsb.user_agent_bad_cert = metrics.createPtr("proxy.process.ssl.user_agent_bad_cert"); - ssl_rsb.user_agent_cert_verify_failed = metrics.createPtr("proxy.process.ssl.user_agent_cert_verify_failed"); - ssl_rsb.user_agent_decryption_failed = metrics.createPtr("proxy.process.ssl.user_agent_decryption_failed"); - ssl_rsb.user_agent_expired_cert = metrics.createPtr("proxy.process.ssl.user_agent_expired_cert"); - ssl_rsb.user_agent_other_errors = metrics.createPtr("proxy.process.ssl.user_agent_other_errors"); - ssl_rsb.user_agent_revoked_cert = metrics.createPtr("proxy.process.ssl.user_agent_revoked_cert"); - ssl_rsb.user_agent_session_hit = metrics.createPtr("proxy.process.ssl.user_agent_session_hit"); - ssl_rsb.user_agent_session_miss = metrics.createPtr("proxy.process.ssl.user_agent_session_miss"); - ssl_rsb.user_agent_session_timeout = metrics.createPtr("proxy.process.ssl.user_agent_session_timeout"); - ssl_rsb.user_agent_sessions = metrics.createPtr("proxy.process.ssl.user_agent_sessions"); - ssl_rsb.user_agent_unknown_ca = metrics.createPtr("proxy.process.ssl.user_agent_unknown_ca"); - ssl_rsb.user_agent_unknown_cert = metrics.createPtr("proxy.process.ssl.user_agent_unknown_cert"); - ssl_rsb.user_agent_wrong_version = metrics.createPtr("proxy.process.ssl.user_agent_wrong_version"); + ssl_rsb.early_data_received_count = Counter::CreatePtr("proxy.process.ssl.early_data_received"); + ssl_rsb.error_async = Counter::CreatePtr("proxy.process.ssl.ssl_error_async"); + ssl_rsb.error_ssl = Counter::CreatePtr("proxy.process.ssl.ssl_error_ssl"); + ssl_rsb.error_syscall = Counter::CreatePtr("proxy.process.ssl.ssl_error_syscall"); + ssl_rsb.ocsp_refresh_cert_failure = Counter::CreatePtr("proxy.process.ssl.ssl_ocsp_refresh_cert_failure"); + ssl_rsb.ocsp_refreshed_cert = Counter::CreatePtr("proxy.process.ssl.ssl_ocsp_refreshed_cert"); + ssl_rsb.ocsp_revoked_cert = Counter::CreatePtr("proxy.process.ssl.ssl_ocsp_revoked_cert"); + ssl_rsb.ocsp_unknown_cert = Counter::CreatePtr("proxy.process.ssl.ssl_ocsp_unknown_cert"); + ssl_rsb.origin_server_bad_cert = Counter::CreatePtr("proxy.process.ssl.origin_server_bad_cert"); + ssl_rsb.origin_server_cert_verify_failed = Counter::CreatePtr("proxy.process.ssl.origin_server_cert_verify_failed"); + ssl_rsb.origin_server_decryption_failed = Counter::CreatePtr("proxy.process.ssl.origin_server_decryption_failed"); + ssl_rsb.origin_server_expired_cert = Counter::CreatePtr("proxy.process.ssl.origin_server_expired_cert"); + ssl_rsb.origin_server_other_errors = Counter::CreatePtr("proxy.process.ssl.origin_server_other_errors"); + ssl_rsb.origin_server_revoked_cert = Counter::CreatePtr("proxy.process.ssl.origin_server_revoked_cert"); + ssl_rsb.origin_server_unknown_ca = Counter::CreatePtr("proxy.process.ssl.origin_server_unknown_ca"); + ssl_rsb.origin_server_unknown_cert = Counter::CreatePtr("proxy.process.ssl.origin_server_unknown_cert"); + ssl_rsb.origin_server_wrong_version = Counter::CreatePtr("proxy.process.ssl.origin_server_wrong_version"); + ssl_rsb.origin_session_reused_count = Counter::CreatePtr("proxy.process.ssl.origin_session_reused"); + ssl_rsb.sni_name_set_failure = Counter::CreatePtr("proxy.process.ssl.ssl_sni_name_set_failure"); + ssl_rsb.origin_session_cache_hit = Counter::CreatePtr("proxy.process.ssl.ssl_origin_session_cache_hit"); + ssl_rsb.origin_session_cache_miss = Counter::CreatePtr("proxy.process.ssl.ssl_origin_session_cache_miss"); + ssl_rsb.session_cache_eviction = Counter::CreatePtr("proxy.process.ssl.ssl_session_cache_eviction"); + ssl_rsb.session_cache_hit = Counter::CreatePtr("proxy.process.ssl.ssl_session_cache_hit"); + ssl_rsb.session_cache_lock_contention = Counter::CreatePtr("proxy.process.ssl.ssl_session_cache_lock_contention"); + ssl_rsb.session_cache_miss = Counter::CreatePtr("proxy.process.ssl.ssl_session_cache_miss"); + ssl_rsb.session_cache_new_session = Counter::CreatePtr("proxy.process.ssl.ssl_session_cache_new_session"); + ssl_rsb.total_attempts_handshake_count_in = Counter::CreatePtr("proxy.process.ssl.total_attempts_handshake_count_in"); + ssl_rsb.total_attempts_handshake_count_out = Counter::CreatePtr("proxy.process.ssl.total_attempts_handshake_count_out"); + ssl_rsb.total_dyn_def_tls_record_count = Counter::CreatePtr("proxy.process.ssl.default_record_size_count"); + ssl_rsb.total_dyn_max_tls_record_count = Counter::CreatePtr("proxy.process.ssl.max_record_size_count"); + ssl_rsb.total_dyn_redo_tls_record_count = Counter::CreatePtr("proxy.process.ssl.redo_record_size_count"); + ssl_rsb.total_handshake_time = Counter::CreatePtr("proxy.process.ssl.total_handshake_time"); + ssl_rsb.total_sslv3 = Counter::CreatePtr("proxy.process.ssl.ssl_total_sslv3"); + ssl_rsb.total_success_handshake_count_in = Counter::CreatePtr("proxy.process.ssl.total_success_handshake_count_in"); + ssl_rsb.total_success_handshake_count_out = Counter::CreatePtr("proxy.process.ssl.total_success_handshake_count_out"); + ssl_rsb.total_ticket_keys_renewed = Counter::CreatePtr("proxy.process.ssl.total_ticket_keys_renewed"); + ssl_rsb.total_tickets_created = Counter::CreatePtr("proxy.process.ssl.total_tickets_created"); + ssl_rsb.total_tickets_not_found = Counter::CreatePtr("proxy.process.ssl.total_tickets_not_found"); + ssl_rsb.total_tickets_renewed = Counter::CreatePtr("proxy.process.ssl.total_tickets_renewed"); // ToDo: Not used? + ssl_rsb.total_tickets_verified = Counter::CreatePtr("proxy.process.ssl.total_tickets_verified"); + ssl_rsb.total_tickets_verified_old_key = Counter::CreatePtr("proxy.process.ssl.total_tickets_verified_old_key"); + ssl_rsb.total_tlsv1 = Counter::CreatePtr("proxy.process.ssl.ssl_total_tlsv1"); + ssl_rsb.total_tlsv11 = Counter::CreatePtr("proxy.process.ssl.ssl_total_tlsv11"); + ssl_rsb.total_tlsv12 = Counter::CreatePtr("proxy.process.ssl.ssl_total_tlsv12"); + ssl_rsb.total_tlsv13 = Counter::CreatePtr("proxy.process.ssl.ssl_total_tlsv13"); + ssl_rsb.user_agent_bad_cert = Counter::CreatePtr("proxy.process.ssl.user_agent_bad_cert"); + ssl_rsb.user_agent_cert_verify_failed = Counter::CreatePtr("proxy.process.ssl.user_agent_cert_verify_failed"); + ssl_rsb.user_agent_decryption_failed = Counter::CreatePtr("proxy.process.ssl.user_agent_decryption_failed"); + ssl_rsb.user_agent_expired_cert = Counter::CreatePtr("proxy.process.ssl.user_agent_expired_cert"); + ssl_rsb.user_agent_other_errors = Counter::CreatePtr("proxy.process.ssl.user_agent_other_errors"); + ssl_rsb.user_agent_revoked_cert = Counter::CreatePtr("proxy.process.ssl.user_agent_revoked_cert"); + ssl_rsb.user_agent_session_hit = Counter::CreatePtr("proxy.process.ssl.user_agent_session_hit"); + ssl_rsb.user_agent_session_miss = Counter::CreatePtr("proxy.process.ssl.user_agent_session_miss"); + ssl_rsb.user_agent_session_timeout = Counter::CreatePtr("proxy.process.ssl.user_agent_session_timeout"); + ssl_rsb.user_agent_sessions = Counter::CreatePtr("proxy.process.ssl.user_agent_sessions"); + ssl_rsb.user_agent_unknown_ca = Counter::CreatePtr("proxy.process.ssl.user_agent_unknown_ca"); + ssl_rsb.user_agent_unknown_cert = Counter::CreatePtr("proxy.process.ssl.user_agent_unknown_cert"); + ssl_rsb.user_agent_wrong_version = Counter::CreatePtr("proxy.process.ssl.user_agent_wrong_version"); // Get and register the SSL cipher stats. Note that we are using the default SSL context to obtain // the cipher list. This means that the set of ciphers is fixed by the build configuration and not diff --git a/src/iocore/net/quic/QUICGlobals.cc b/src/iocore/net/quic/QUICGlobals.cc index f0d25c8b73c..409566006c0 100644 --- a/src/iocore/net/quic/QUICGlobals.cc +++ b/src/iocore/net/quic/QUICGlobals.cc @@ -75,8 +75,8 @@ QUIC::_register_stats() { ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); // Transferred packet counts - quic_rsb.total_packets_sent = metrics.createPtr("proxy.process.quic.total_packets_sent"); + quic_rsb.total_packets_sent = Counter::CreatePtr("proxy.process.quic.total_packets_sent"); - // quic_rsb.total_packets_retransmitted = metrics.createPtr("proxy.process.quic.total_packets_retransmitted"); - // quic_rsb.total_packets_received = metrics.createPtr("proxy.process.quic.total_packets_received"); + // quic_rsb.total_packets_retransmitted = Counter::CreatePtr("proxy.process.quic.total_packets_retransmitted"); + // quic_rsb.total_packets_received = Counter::CreatePtr("proxy.process.quic.total_packets_received"); } diff --git a/src/proxy/http/HttpConfig.cc b/src/proxy/http/HttpConfig.cc index e6c68dcc45e..c227eae7b3d 100644 --- a/src/proxy/http/HttpConfig.cc +++ b/src/proxy/http/HttpConfig.cc @@ -259,262 +259,260 @@ http_insert_forwarded_cb(const char *name, RecDataT dtype, RecData data, void *c void register_stat_callbacks() { - ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); - - http_rsb.background_fill_bytes_aborted = metrics.createPtr("proxy.process.http.background_fill_bytes_aborted"); - http_rsb.background_fill_bytes_completed = metrics.createPtr("proxy.process.http.background_fill_bytes_completed"); - http_rsb.background_fill_current_count = metrics.createPtr("proxy.process.http.background_fill_current_count"); - http_rsb.background_fill_total_count = metrics.createPtr("proxy.process.http.background_fill_total_count"); - http_rsb.broken_server_connections = metrics.createPtr("proxy.process.http.broken_server_connections"); - http_rsb.cache_deletes = metrics.createPtr("proxy.process.http.cache_deletes"); - http_rsb.cache_hit_fresh = metrics.createPtr("proxy.process.http.cache_hit_fresh"); - http_rsb.cache_hit_ims = metrics.createPtr("proxy.process.http.cache_hit_ims"); - http_rsb.cache_hit_mem_fresh = metrics.createPtr("proxy.process.http.cache_hit_mem_fresh"); - http_rsb.cache_hit_reval = metrics.createPtr("proxy.process.http.cache_hit_revalidated"); - http_rsb.cache_hit_rww = metrics.createPtr("proxy.process.http.cache_hit_rww"); - http_rsb.cache_hit_stale_served = metrics.createPtr("proxy.process.http.cache_hit_stale_served"); - http_rsb.cache_lookups = metrics.createPtr("proxy.process.http.cache_lookups"); - http_rsb.cache_miss_changed = metrics.createPtr("proxy.process.http.cache_miss_changed"); - http_rsb.cache_miss_client_no_cache = metrics.createPtr("proxy.process.http.cache_miss_client_no_cache"); - http_rsb.cache_miss_cold = metrics.createPtr("proxy.process.http.cache_miss_cold"); - http_rsb.cache_miss_ims = metrics.createPtr("proxy.process.http.cache_miss_ims"); - http_rsb.cache_miss_uncacheable = metrics.createPtr("proxy.process.http.cache_miss_client_not_cacheable"); - http_rsb.cache_open_read_begin_time = metrics.createPtr("proxy.process.http.milestone.cache_open_read_begin"); - http_rsb.cache_open_read_end_time = metrics.createPtr("proxy.process.http.milestone.cache_open_read_end"); - http_rsb.cache_open_write_adjust_thread = metrics.createPtr("proxy.process.http.cache.open_write.adjust_thread"); - http_rsb.cache_open_write_begin_time = metrics.createPtr("proxy.process.http.milestone.cache_open_write_begin"); - http_rsb.cache_open_write_end_time = metrics.createPtr("proxy.process.http.milestone.cache_open_write_end"); - http_rsb.cache_read_error = metrics.createPtr("proxy.process.http.cache_read_error"); - http_rsb.cache_read_errors = metrics.createPtr("proxy.process.http.cache_read_errors"); - http_rsb.cache_updates = metrics.createPtr("proxy.process.http.cache_updates"); - http_rsb.cache_write_errors = metrics.createPtr("proxy.process.http.cache_write_errors"); - http_rsb.cache_writes = metrics.createPtr("proxy.process.http.cache_writes"); - http_rsb.completed_requests = metrics.createPtr("proxy.process.http.completed_requests"); - http_rsb.connect_requests = metrics.createPtr("proxy.process.http.connect_requests"); - http_rsb.current_active_client_connections = metrics.createPtr("proxy.process.http.current_active_client_connections"); - http_rsb.current_cache_connections = metrics.createPtr("proxy.process.http.current_cache_connections"); - http_rsb.current_client_connections = metrics.createPtr("proxy.process.http.current_client_connections"); - http_rsb.current_client_transactions = metrics.createPtr("proxy.process.http.current_client_transactions"); - http_rsb.current_parent_proxy_connections = metrics.createPtr("proxy.process.http.current_parent_proxy_connections"); - http_rsb.current_server_connections = metrics.createPtr("proxy.process.http.current_server_connections"); - http_rsb.current_server_transactions = metrics.createPtr("proxy.process.http.current_server_transactions"); - http_rsb.delete_requests = metrics.createPtr("proxy.process.http.delete_requests"); - http_rsb.disallowed_post_100_continue = metrics.createPtr("proxy.process.http.disallowed_post_100_continue"); - http_rsb.dns_lookup_begin_time = metrics.createPtr("proxy.process.http.milestone.dns_lookup_begin"); - http_rsb.dns_lookup_end_time = metrics.createPtr("proxy.process.http.milestone.dns_lookup_end"); - http_rsb.down_server_no_requests = metrics.createPtr("proxy.process.http.down_server.no_requests"); - http_rsb.err_client_abort_count = metrics.createPtr("proxy.process.http.err_client_abort_count"); - http_rsb.err_client_abort_origin_server_bytes = metrics.createPtr("proxy.process.http.err_client_abort_origin_server_bytes"); - http_rsb.err_client_abort_user_agent_bytes = metrics.createPtr("proxy.process.http.err_client_abort_user_agent_bytes"); - http_rsb.err_client_read_error_count = metrics.createPtr("proxy.process.http.err_client_read_error_count"); + http_rsb.background_fill_bytes_aborted = Counter::CreatePtr("proxy.process.http.background_fill_bytes_aborted"); + http_rsb.background_fill_bytes_completed = Counter::CreatePtr("proxy.process.http.background_fill_bytes_completed"); + http_rsb.background_fill_current_count = Counter::CreatePtr("proxy.process.http.background_fill_current_count"); + http_rsb.background_fill_total_count = Counter::CreatePtr("proxy.process.http.background_fill_total_count"); + http_rsb.broken_server_connections = Counter::CreatePtr("proxy.process.http.broken_server_connections"); + http_rsb.cache_deletes = Counter::CreatePtr("proxy.process.http.cache_deletes"); + http_rsb.cache_hit_fresh = Counter::CreatePtr("proxy.process.http.cache_hit_fresh"); + http_rsb.cache_hit_ims = Counter::CreatePtr("proxy.process.http.cache_hit_ims"); + http_rsb.cache_hit_mem_fresh = Counter::CreatePtr("proxy.process.http.cache_hit_mem_fresh"); + http_rsb.cache_hit_reval = Counter::CreatePtr("proxy.process.http.cache_hit_revalidated"); + http_rsb.cache_hit_rww = Counter::CreatePtr("proxy.process.http.cache_hit_rww"); + http_rsb.cache_hit_stale_served = Counter::CreatePtr("proxy.process.http.cache_hit_stale_served"); + http_rsb.cache_lookups = Counter::CreatePtr("proxy.process.http.cache_lookups"); + http_rsb.cache_miss_changed = Counter::CreatePtr("proxy.process.http.cache_miss_changed"); + http_rsb.cache_miss_client_no_cache = Counter::CreatePtr("proxy.process.http.cache_miss_client_no_cache"); + http_rsb.cache_miss_cold = Counter::CreatePtr("proxy.process.http.cache_miss_cold"); + http_rsb.cache_miss_ims = Counter::CreatePtr("proxy.process.http.cache_miss_ims"); + http_rsb.cache_miss_uncacheable = Counter::CreatePtr("proxy.process.http.cache_miss_client_not_cacheable"); + http_rsb.cache_open_read_begin_time = Counter::CreatePtr("proxy.process.http.milestone.cache_open_read_begin"); + http_rsb.cache_open_read_end_time = Counter::CreatePtr("proxy.process.http.milestone.cache_open_read_end"); + http_rsb.cache_open_write_adjust_thread = Counter::CreatePtr("proxy.process.http.cache.open_write.adjust_thread"); + http_rsb.cache_open_write_begin_time = Counter::CreatePtr("proxy.process.http.milestone.cache_open_write_begin"); + http_rsb.cache_open_write_end_time = Counter::CreatePtr("proxy.process.http.milestone.cache_open_write_end"); + http_rsb.cache_read_error = Counter::CreatePtr("proxy.process.http.cache_read_error"); + http_rsb.cache_read_errors = Counter::CreatePtr("proxy.process.http.cache_read_errors"); + http_rsb.cache_updates = Counter::CreatePtr("proxy.process.http.cache_updates"); + http_rsb.cache_write_errors = Counter::CreatePtr("proxy.process.http.cache_write_errors"); + http_rsb.cache_writes = Counter::CreatePtr("proxy.process.http.cache_writes"); + http_rsb.completed_requests = Counter::CreatePtr("proxy.process.http.completed_requests"); + http_rsb.connect_requests = Counter::CreatePtr("proxy.process.http.connect_requests"); + http_rsb.current_active_client_connections = Counter::CreatePtr("proxy.process.http.current_active_client_connections"); + http_rsb.current_cache_connections = Counter::CreatePtr("proxy.process.http.current_cache_connections"); + http_rsb.current_client_connections = Counter::CreatePtr("proxy.process.http.current_client_connections"); + http_rsb.current_client_transactions = Counter::CreatePtr("proxy.process.http.current_client_transactions"); + http_rsb.current_parent_proxy_connections = Counter::CreatePtr("proxy.process.http.current_parent_proxy_connections"); + http_rsb.current_server_connections = Counter::CreatePtr("proxy.process.http.current_server_connections"); + http_rsb.current_server_transactions = Counter::CreatePtr("proxy.process.http.current_server_transactions"); + http_rsb.delete_requests = Counter::CreatePtr("proxy.process.http.delete_requests"); + http_rsb.disallowed_post_100_continue = Counter::CreatePtr("proxy.process.http.disallowed_post_100_continue"); + http_rsb.dns_lookup_begin_time = Counter::CreatePtr("proxy.process.http.milestone.dns_lookup_begin"); + http_rsb.dns_lookup_end_time = Counter::CreatePtr("proxy.process.http.milestone.dns_lookup_end"); + http_rsb.down_server_no_requests = Counter::CreatePtr("proxy.process.http.down_server.no_requests"); + http_rsb.err_client_abort_count = Counter::CreatePtr("proxy.process.http.err_client_abort_count"); + http_rsb.err_client_abort_origin_server_bytes = Counter::CreatePtr("proxy.process.http.err_client_abort_origin_server_bytes"); + http_rsb.err_client_abort_user_agent_bytes = Counter::CreatePtr("proxy.process.http.err_client_abort_user_agent_bytes"); + http_rsb.err_client_read_error_count = Counter::CreatePtr("proxy.process.http.err_client_read_error_count"); http_rsb.err_client_read_error_origin_server_bytes = - metrics.createPtr("proxy.process.http.err_client_read_error_origin_server_bytes"); - http_rsb.err_client_read_error_user_agent_bytes = metrics.createPtr("proxy.process.http.err_client_read_error_user_agent_bytes"); - http_rsb.err_connect_fail_count = metrics.createPtr("proxy.process.http.err_connect_fail_count"); - http_rsb.err_connect_fail_origin_server_bytes = metrics.createPtr("proxy.process.http.err_connect_fail_origin_server_bytes"); - http_rsb.err_connect_fail_user_agent_bytes = metrics.createPtr("proxy.process.http.err_connect_fail_user_agent_bytes"); - http_rsb.extension_method_requests = metrics.createPtr("proxy.process.http.extension_method_requests"); - http_rsb.get_requests = metrics.createPtr("proxy.process.http.get_requests"); - http_rsb.head_requests = metrics.createPtr("proxy.process.http.head_requests"); - http_rsb.https_incoming_requests = metrics.createPtr("proxy.process.https.incoming_requests"); - http_rsb.https_total_client_connections = metrics.createPtr("proxy.process.https.total_client_connections"); - http_rsb.incoming_requests = metrics.createPtr("proxy.process.http.incoming_requests"); - http_rsb.incoming_responses = metrics.createPtr("proxy.process.http.incoming_responses"); - http_rsb.invalid_client_requests = metrics.createPtr("proxy.process.http.invalid_client_requests"); - http_rsb.misc_count = metrics.createPtr("proxy.process.http.misc_count"); - http_rsb.misc_origin_server_bytes = metrics.createPtr("proxy.process.http.http_misc_origin_server_bytes"); - http_rsb.misc_user_agent_bytes = metrics.createPtr("proxy.process.http.misc_user_agent_bytes"); - http_rsb.missing_host_hdr = metrics.createPtr("proxy.process.http.missing_host_hdr"); - http_rsb.options_requests = metrics.createPtr("proxy.process.http.options_requests"); - http_rsb.origin_body = metrics.createPtr("proxy.process.http.origin.body"); - http_rsb.origin_close_private = metrics.createPtr("proxy.process.http.origin.close_private"); - http_rsb.origin_connect_adjust_thread = metrics.createPtr("proxy.process.http.origin.connect.adjust_thread"); - http_rsb.origin_connections_throttled = metrics.createPtr("proxy.process.http.origin_connections_throttled_out"); - http_rsb.origin_make_new = metrics.createPtr("proxy.process.http.origin.make_new"); - http_rsb.origin_no_sharing = metrics.createPtr("proxy.process.http.origin.no_sharing"); - http_rsb.origin_not_found = metrics.createPtr("proxy.process.http.origin.not_found"); - http_rsb.origin_private = metrics.createPtr("proxy.process.http.origin.private"); - http_rsb.origin_raw = metrics.createPtr("proxy.process.http.origin.raw"); - http_rsb.origin_reuse = metrics.createPtr("proxy.process.http.origin.reuse"); - http_rsb.origin_reuse_fail = metrics.createPtr("proxy.process.http.origin.reuse_fail"); + Counter::CreatePtr("proxy.process.http.err_client_read_error_origin_server_bytes"); + http_rsb.err_client_read_error_user_agent_bytes = Counter::CreatePtr("proxy.process.http.err_client_read_error_user_agent_bytes"); + http_rsb.err_connect_fail_count = Counter::CreatePtr("proxy.process.http.err_connect_fail_count"); + http_rsb.err_connect_fail_origin_server_bytes = Counter::CreatePtr("proxy.process.http.err_connect_fail_origin_server_bytes"); + http_rsb.err_connect_fail_user_agent_bytes = Counter::CreatePtr("proxy.process.http.err_connect_fail_user_agent_bytes"); + http_rsb.extension_method_requests = Counter::CreatePtr("proxy.process.http.extension_method_requests"); + http_rsb.get_requests = Counter::CreatePtr("proxy.process.http.get_requests"); + http_rsb.head_requests = Counter::CreatePtr("proxy.process.http.head_requests"); + http_rsb.https_incoming_requests = Counter::CreatePtr("proxy.process.https.incoming_requests"); + http_rsb.https_total_client_connections = Counter::CreatePtr("proxy.process.https.total_client_connections"); + http_rsb.incoming_requests = Counter::CreatePtr("proxy.process.http.incoming_requests"); + http_rsb.incoming_responses = Counter::CreatePtr("proxy.process.http.incoming_responses"); + http_rsb.invalid_client_requests = Counter::CreatePtr("proxy.process.http.invalid_client_requests"); + http_rsb.misc_count = Counter::CreatePtr("proxy.process.http.misc_count"); + http_rsb.misc_origin_server_bytes = Counter::CreatePtr("proxy.process.http.http_misc_origin_server_bytes"); + http_rsb.misc_user_agent_bytes = Counter::CreatePtr("proxy.process.http.misc_user_agent_bytes"); + http_rsb.missing_host_hdr = Counter::CreatePtr("proxy.process.http.missing_host_hdr"); + http_rsb.options_requests = Counter::CreatePtr("proxy.process.http.options_requests"); + http_rsb.origin_body = Counter::CreatePtr("proxy.process.http.origin.body"); + http_rsb.origin_close_private = Counter::CreatePtr("proxy.process.http.origin.close_private"); + http_rsb.origin_connect_adjust_thread = Counter::CreatePtr("proxy.process.http.origin.connect.adjust_thread"); + http_rsb.origin_connections_throttled = Counter::CreatePtr("proxy.process.http.origin_connections_throttled_out"); + http_rsb.origin_make_new = Counter::CreatePtr("proxy.process.http.origin.make_new"); + http_rsb.origin_no_sharing = Counter::CreatePtr("proxy.process.http.origin.no_sharing"); + http_rsb.origin_not_found = Counter::CreatePtr("proxy.process.http.origin.not_found"); + http_rsb.origin_private = Counter::CreatePtr("proxy.process.http.origin.private"); + http_rsb.origin_raw = Counter::CreatePtr("proxy.process.http.origin.raw"); + http_rsb.origin_reuse = Counter::CreatePtr("proxy.process.http.origin.reuse"); + http_rsb.origin_reuse_fail = Counter::CreatePtr("proxy.process.http.origin.reuse_fail"); http_rsb.origin_server_request_document_total_size = - metrics.createPtr("proxy.process.http.origin_server_request_document_total_size"); + Counter::CreatePtr("proxy.process.http.origin_server_request_document_total_size"); http_rsb.origin_server_request_header_total_size = - metrics.createPtr("proxy.process.http.origin_server_request_header_total_size"); + Counter::CreatePtr("proxy.process.http.origin_server_request_header_total_size"); http_rsb.origin_server_response_document_total_size = - metrics.createPtr("proxy.process.http.origin_server_response_document_total_size"); + Counter::CreatePtr("proxy.process.http.origin_server_response_document_total_size"); http_rsb.origin_server_response_header_total_size = - metrics.createPtr("proxy.process.http.origin_server_response_header_total_size"); - http_rsb.origin_shutdown_cleanup_entry = metrics.createPtr("proxy.process.http.origin_shutdown.cleanup_entry"); - http_rsb.origin_shutdown_migration_failure = metrics.createPtr("proxy.process.http.origin_shutdown.migration_failure"); - http_rsb.origin_shutdown_pool_lock_contention = metrics.createPtr("proxy.process.http.origin_shutdown.pool_lock_contention"); + Counter::CreatePtr("proxy.process.http.origin_server_response_header_total_size"); + http_rsb.origin_shutdown_cleanup_entry = Counter::CreatePtr("proxy.process.http.origin_shutdown.cleanup_entry"); + http_rsb.origin_shutdown_migration_failure = Counter::CreatePtr("proxy.process.http.origin_shutdown.migration_failure"); + http_rsb.origin_shutdown_pool_lock_contention = Counter::CreatePtr("proxy.process.http.origin_shutdown.pool_lock_contention"); http_rsb.origin_shutdown_release_invalid_request = - metrics.createPtr("proxy.process.http.origin_shutdown.release_invalid_request"); + Counter::CreatePtr("proxy.process.http.origin_shutdown.release_invalid_request"); http_rsb.origin_shutdown_release_invalid_response = - metrics.createPtr("proxy.process.http.origin_shutdown.release_invalid_response"); - http_rsb.origin_shutdown_release_misc = metrics.createPtr("proxy.process.http.origin_shutdown.release_misc"); - http_rsb.origin_shutdown_release_modified = metrics.createPtr("proxy.process.http.origin_shutdown.release_modified"); - http_rsb.origin_shutdown_release_no_keep_alive = metrics.createPtr("proxy.process.http.origin_shutdown.release_no_keep_alive"); - http_rsb.origin_shutdown_release_no_server = metrics.createPtr("proxy.process.http.origin_shutdown.release_no_server"); - http_rsb.origin_shutdown_release_no_sharing = metrics.createPtr("proxy.process.http.origin_shutdown.release_no_sharing"); - http_rsb.origin_shutdown_tunnel_abort = metrics.createPtr("proxy.process.http.origin_shutdown.tunnel_abort"); - http_rsb.origin_shutdown_tunnel_client = metrics.createPtr("proxy.process.http.origin_shutdown.tunnel_client"); - http_rsb.origin_shutdown_tunnel_server = metrics.createPtr("proxy.process.http.origin_shutdown.tunnel_server"); - http_rsb.origin_shutdown_tunnel_server_detach = metrics.createPtr("proxy.process.http.origin_shutdown.tunnel_server_detach"); - http_rsb.origin_shutdown_tunnel_server_eos = metrics.createPtr("proxy.process.http.origin_shutdown.tunnel_server_eos"); + Counter::CreatePtr("proxy.process.http.origin_shutdown.release_invalid_response"); + http_rsb.origin_shutdown_release_misc = Counter::CreatePtr("proxy.process.http.origin_shutdown.release_misc"); + http_rsb.origin_shutdown_release_modified = Counter::CreatePtr("proxy.process.http.origin_shutdown.release_modified"); + http_rsb.origin_shutdown_release_no_keep_alive = Counter::CreatePtr("proxy.process.http.origin_shutdown.release_no_keep_alive"); + http_rsb.origin_shutdown_release_no_server = Counter::CreatePtr("proxy.process.http.origin_shutdown.release_no_server"); + http_rsb.origin_shutdown_release_no_sharing = Counter::CreatePtr("proxy.process.http.origin_shutdown.release_no_sharing"); + http_rsb.origin_shutdown_tunnel_abort = Counter::CreatePtr("proxy.process.http.origin_shutdown.tunnel_abort"); + http_rsb.origin_shutdown_tunnel_client = Counter::CreatePtr("proxy.process.http.origin_shutdown.tunnel_client"); + http_rsb.origin_shutdown_tunnel_server = Counter::CreatePtr("proxy.process.http.origin_shutdown.tunnel_server"); + http_rsb.origin_shutdown_tunnel_server_detach = Counter::CreatePtr("proxy.process.http.origin_shutdown.tunnel_server_detach"); + http_rsb.origin_shutdown_tunnel_server_eos = Counter::CreatePtr("proxy.process.http.origin_shutdown.tunnel_server_eos"); http_rsb.origin_shutdown_tunnel_server_no_keep_alive = - metrics.createPtr("proxy.process.http.origin_shutdown.tunnel_server_no_keep_alive"); + Counter::CreatePtr("proxy.process.http.origin_shutdown.tunnel_server_no_keep_alive"); http_rsb.origin_shutdown_tunnel_server_plugin_tunnel = - metrics.createPtr("proxy.process.http.origin_shutdown.tunnel_server_plugin_tunnel"); - http_rsb.origin_shutdown_tunnel_transform_read = metrics.createPtr("proxy.process.http.origin_shutdown.tunnel_transform_read"); - http_rsb.outgoing_requests = metrics.createPtr("proxy.process.http.outgoing_requests"); - http_rsb.parent_count = metrics.createPtr("proxy.process.http_parent_count"); - http_rsb.parent_proxy_request_total_bytes = metrics.createPtr("proxy.process.http.parent_proxy_request_total_bytes"); - http_rsb.parent_proxy_response_total_bytes = metrics.createPtr("proxy.process.http.parent_proxy_response_total_bytes"); - http_rsb.parent_proxy_transaction_time = metrics.createPtr("proxy.process.http.parent_proxy_transaction_time"); - http_rsb.pooled_server_connections = metrics.createPtr("proxy.process.http.pooled_server_connections"); - http_rsb.post_body_too_large = metrics.createPtr("proxy.process.http.post_body_too_large"); - http_rsb.post_requests = metrics.createPtr("proxy.process.http.post_requests"); - http_rsb.proxy_loop_detected = metrics.createPtr("proxy.process.http.http_proxy_loop_detected"); - http_rsb.proxy_mh_loop_detected = metrics.createPtr("proxy.process.http.http_proxy_mh_loop_detected"); - http_rsb.purge_requests = metrics.createPtr("proxy.process.http.purge_requests"); - http_rsb.push_requests = metrics.createPtr("proxy.process.http.push_requests"); - http_rsb.pushed_document_total_size = metrics.createPtr("proxy.process.http.pushed_document_total_size"); - http_rsb.pushed_response_header_total_size = metrics.createPtr("proxy.process.http.pushed_response_header_total_size"); - http_rsb.put_requests = metrics.createPtr("proxy.process.http.put_requests"); - http_rsb.response_status_100_count = metrics.createPtr("proxy.process.http.100_responses"); - http_rsb.response_status_101_count = metrics.createPtr("proxy.process.http.101_responses"); - http_rsb.response_status_1xx_count = metrics.createPtr("proxy.process.http.1xx_responses"); - http_rsb.response_status_200_count = metrics.createPtr("proxy.process.http.200_responses"); - http_rsb.response_status_201_count = metrics.createPtr("proxy.process.http.201_responses"); - http_rsb.response_status_202_count = metrics.createPtr("proxy.process.http.202_responses"); - http_rsb.response_status_203_count = metrics.createPtr("proxy.process.http.203_responses"); - http_rsb.response_status_204_count = metrics.createPtr("proxy.process.http.204_responses"); - http_rsb.response_status_205_count = metrics.createPtr("proxy.process.http.205_responses"); - http_rsb.response_status_206_count = metrics.createPtr("proxy.process.http.206_responses"); - http_rsb.response_status_2xx_count = metrics.createPtr("proxy.process.http.2xx_responses"); - http_rsb.response_status_300_count = metrics.createPtr("proxy.process.http.300_responses"); - http_rsb.response_status_301_count = metrics.createPtr("proxy.process.http.301_responses"); - http_rsb.response_status_302_count = metrics.createPtr("proxy.process.http.302_responses"); - http_rsb.response_status_303_count = metrics.createPtr("proxy.process.http.303_responses"); - http_rsb.response_status_304_count = metrics.createPtr("proxy.process.http.304_responses"); - http_rsb.response_status_305_count = metrics.createPtr("proxy.process.http.305_responses"); - http_rsb.response_status_307_count = metrics.createPtr("proxy.process.http.307_responses"); - http_rsb.response_status_308_count = metrics.createPtr("proxy.process.http.308_responses"); - http_rsb.response_status_3xx_count = metrics.createPtr("proxy.process.http.3xx_responses"); - http_rsb.response_status_400_count = metrics.createPtr("proxy.process.http.400_responses"); - http_rsb.response_status_401_count = metrics.createPtr("proxy.process.http.401_responses"); - http_rsb.response_status_402_count = metrics.createPtr("proxy.process.http.402_responses"); - http_rsb.response_status_403_count = metrics.createPtr("proxy.process.http.403_responses"); - http_rsb.response_status_404_count = metrics.createPtr("proxy.process.http.404_responses"); - http_rsb.response_status_405_count = metrics.createPtr("proxy.process.http.405_responses"); - http_rsb.response_status_406_count = metrics.createPtr("proxy.process.http.406_responses"); - http_rsb.response_status_407_count = metrics.createPtr("proxy.process.http.407_responses"); - http_rsb.response_status_408_count = metrics.createPtr("proxy.process.http.408_responses"); - http_rsb.response_status_409_count = metrics.createPtr("proxy.process.http.409_responses"); - http_rsb.response_status_410_count = metrics.createPtr("proxy.process.http.410_responses"); - http_rsb.response_status_411_count = metrics.createPtr("proxy.process.http.411_responses"); - http_rsb.response_status_412_count = metrics.createPtr("proxy.process.http.412_responses"); - http_rsb.response_status_413_count = metrics.createPtr("proxy.process.http.413_responses"); - http_rsb.response_status_414_count = metrics.createPtr("proxy.process.http.414_responses"); - http_rsb.response_status_415_count = metrics.createPtr("proxy.process.http.415_responses"); - http_rsb.response_status_416_count = metrics.createPtr("proxy.process.http.416_responses"); - http_rsb.response_status_4xx_count = metrics.createPtr("proxy.process.http.4xx_responses"); - http_rsb.response_status_500_count = metrics.createPtr("proxy.process.http.500_responses"); - http_rsb.response_status_501_count = metrics.createPtr("proxy.process.http.501_responses"); - http_rsb.response_status_502_count = metrics.createPtr("proxy.process.http.502_responses"); - http_rsb.response_status_503_count = metrics.createPtr("proxy.process.http.503_responses"); - http_rsb.response_status_504_count = metrics.createPtr("proxy.process.http.504_responses"); - http_rsb.response_status_505_count = metrics.createPtr("proxy.process.http.505_responses"); - http_rsb.response_status_5xx_count = metrics.createPtr("proxy.process.http.5xx_responses"); - http_rsb.server_begin_write_time = metrics.createPtr("proxy.process.http.milestone.server_begin_write"); - http_rsb.server_close_time = metrics.createPtr("proxy.process.http.milestone.server_close"); - http_rsb.server_connect_end_time = metrics.createPtr("proxy.process.http.milestone.server_connect_end"); - http_rsb.server_connect_time = metrics.createPtr("proxy.process.http.milestone.server_connect"); - http_rsb.server_first_connect_time = metrics.createPtr("proxy.process.http.milestone.server_first_connect"); - http_rsb.server_first_read_time = metrics.createPtr("proxy.process.http.milestone.server_first_read"); - http_rsb.server_read_header_done_time = metrics.createPtr("proxy.process.http.milestone.server_read_header_done"); - http_rsb.sm_finish_time = metrics.createPtr("proxy.process.http.milestone.sm_finish"); - http_rsb.sm_start_time = metrics.createPtr("proxy.process.http.milestone.sm_start"); - http_rsb.tcp_client_refresh_count = metrics.createPtr("proxy.process.http.tcp_client_refresh_count"); - http_rsb.tcp_client_refresh_origin_server_bytes = metrics.createPtr("proxy.process.http.tcp_client_refresh_origin_server_bytes"); - http_rsb.tcp_client_refresh_user_agent_bytes = metrics.createPtr("proxy.process.http.tcp_client_refresh_user_agent_bytes"); - http_rsb.tcp_expired_miss_count = metrics.createPtr("proxy.process.http.tcp_expired_miss_count"); - http_rsb.tcp_expired_miss_origin_server_bytes = metrics.createPtr("proxy.process.http.tcp_expired_miss_origin_server_bytes"); - http_rsb.tcp_expired_miss_user_agent_bytes = metrics.createPtr("proxy.process.http.tcp_expired_miss_user_agent_bytes"); - http_rsb.tcp_hit_count = metrics.createPtr("proxy.process.http.tcp_hit_count"); - http_rsb.tcp_hit_origin_server_bytes = metrics.createPtr("proxy.process.http.tcp_hit_origin_server_bytes"); - http_rsb.tcp_hit_user_agent_bytes = metrics.createPtr("proxy.process.http.tcp_hit_user_agent_bytes"); - http_rsb.tcp_ims_hit_count = metrics.createPtr("proxy.process.http.tcp_ims_hit_count"); - http_rsb.tcp_ims_hit_origin_server_bytes = metrics.createPtr("proxy.process.http.tcp_ims_hit_origin_server_bytes"); - http_rsb.tcp_ims_hit_user_agent_bytes = metrics.createPtr("proxy.process.http.tcp_ims_hit_user_agent_bytes"); - http_rsb.tcp_ims_miss_count = metrics.createPtr("proxy.process.http.tcp_ims_miss_count"); - http_rsb.tcp_ims_miss_origin_server_bytes = metrics.createPtr("proxy.process.http.tcp_ims_miss_origin_server_bytes"); - http_rsb.tcp_ims_miss_user_agent_bytes = metrics.createPtr("proxy.process.http.tcp_ims_miss_user_agent_bytes"); - http_rsb.tcp_miss_count = metrics.createPtr("proxy.process.http.tcp_miss_count"); - http_rsb.tcp_miss_origin_server_bytes = metrics.createPtr("proxy.process.http.tcp_miss_origin_server_bytes"); - http_rsb.tcp_miss_user_agent_bytes = metrics.createPtr("proxy.process.http.tcp_miss_user_agent_bytes"); - http_rsb.tcp_refresh_hit_count = metrics.createPtr("proxy.process.http.tcp_refresh_hit_count"); - http_rsb.tcp_refresh_hit_origin_server_bytes = metrics.createPtr("proxy.process.http.tcp_refresh_hit_origin_server_bytes"); - http_rsb.tcp_refresh_hit_user_agent_bytes = metrics.createPtr("proxy.process.http.tcp_refresh_hit_user_agent_bytes"); - http_rsb.tcp_refresh_miss_count = metrics.createPtr("proxy.process.http.tcp_refresh_miss_count"); - http_rsb.tcp_refresh_miss_origin_server_bytes = metrics.createPtr("proxy.process.http.tcp_refresh_miss_origin_server_bytes"); - http_rsb.tcp_refresh_miss_user_agent_bytes = metrics.createPtr("proxy.process.http.tcp_refresh_miss_user_agent_bytes"); - http_rsb.total_client_connections = metrics.createPtr("proxy.process.http.total_client_connections"); - http_rsb.total_client_connections_ipv4 = metrics.createPtr("proxy.process.http.total_client_connections_ipv4"); - http_rsb.total_client_connections_ipv6 = metrics.createPtr("proxy.process.http.total_client_connections_ipv6"); - http_rsb.total_incoming_connections = metrics.createPtr("proxy.process.http.total_incoming_connections"); - http_rsb.total_parent_marked_down_count = metrics.createPtr("proxy.process.http.total_parent_marked_down_count"); - http_rsb.total_parent_proxy_connections = metrics.createPtr("proxy.process.http.total_parent_proxy_connections"); - http_rsb.total_parent_retries = metrics.createPtr("proxy.process.http.total_parent_retries"); - http_rsb.total_parent_retries_exhausted = metrics.createPtr("proxy.process.http.total_parent_retries_exhausted"); - http_rsb.total_parent_switches = metrics.createPtr("proxy.process.http.total_parent_switches"); - http_rsb.total_server_connections = metrics.createPtr("proxy.process.http.total_server_connections"); - http_rsb.total_transactions_time = metrics.createPtr("proxy.process.http.total_transactions_time"); - http_rsb.total_x_redirect = metrics.createPtr("proxy.process.http.total_x_redirect_count"); - http_rsb.trace_requests = metrics.createPtr("proxy.process.http.trace_requests"); - http_rsb.tunnel_current_active_connections = metrics.createPtr("proxy.process.tunnel.current_active_connections"); - http_rsb.tunnels = metrics.createPtr("proxy.process.http.tunnels"); - http_rsb.ua_begin_time = metrics.createPtr("proxy.process.http.milestone.ua_begin"); - http_rsb.ua_begin_write_time = metrics.createPtr("proxy.process.http.milestone.ua_begin_write"); - http_rsb.ua_close_time = metrics.createPtr("proxy.process.http.milestone.ua_close"); - http_rsb.ua_counts_errors_aborts = metrics.createPtr("proxy.process.http.transaction_counts.errors.aborts"); - http_rsb.ua_counts_errors_connect_failed = metrics.createPtr("proxy.process.http.transaction_counts.errors.connect_failed"); - http_rsb.ua_counts_errors_other = metrics.createPtr("proxy.process.http.transaction_counts.errors.other"); - http_rsb.ua_counts_errors_possible_aborts = metrics.createPtr("proxy.process.http.transaction_counts.errors.possible_aborts"); + Counter::CreatePtr("proxy.process.http.origin_shutdown.tunnel_server_plugin_tunnel"); + http_rsb.origin_shutdown_tunnel_transform_read = Counter::CreatePtr("proxy.process.http.origin_shutdown.tunnel_transform_read"); + http_rsb.outgoing_requests = Counter::CreatePtr("proxy.process.http.outgoing_requests"); + http_rsb.parent_count = Counter::CreatePtr("proxy.process.http_parent_count"); + http_rsb.parent_proxy_request_total_bytes = Counter::CreatePtr("proxy.process.http.parent_proxy_request_total_bytes"); + http_rsb.parent_proxy_response_total_bytes = Counter::CreatePtr("proxy.process.http.parent_proxy_response_total_bytes"); + http_rsb.parent_proxy_transaction_time = Counter::CreatePtr("proxy.process.http.parent_proxy_transaction_time"); + http_rsb.pooled_server_connections = Counter::CreatePtr("proxy.process.http.pooled_server_connections"); + http_rsb.post_body_too_large = Counter::CreatePtr("proxy.process.http.post_body_too_large"); + http_rsb.post_requests = Counter::CreatePtr("proxy.process.http.post_requests"); + http_rsb.proxy_loop_detected = Counter::CreatePtr("proxy.process.http.http_proxy_loop_detected"); + http_rsb.proxy_mh_loop_detected = Counter::CreatePtr("proxy.process.http.http_proxy_mh_loop_detected"); + http_rsb.purge_requests = Counter::CreatePtr("proxy.process.http.purge_requests"); + http_rsb.push_requests = Counter::CreatePtr("proxy.process.http.push_requests"); + http_rsb.pushed_document_total_size = Counter::CreatePtr("proxy.process.http.pushed_document_total_size"); + http_rsb.pushed_response_header_total_size = Counter::CreatePtr("proxy.process.http.pushed_response_header_total_size"); + http_rsb.put_requests = Counter::CreatePtr("proxy.process.http.put_requests"); + http_rsb.response_status_100_count = Counter::CreatePtr("proxy.process.http.100_responses"); + http_rsb.response_status_101_count = Counter::CreatePtr("proxy.process.http.101_responses"); + http_rsb.response_status_1xx_count = Counter::CreatePtr("proxy.process.http.1xx_responses"); + http_rsb.response_status_200_count = Counter::CreatePtr("proxy.process.http.200_responses"); + http_rsb.response_status_201_count = Counter::CreatePtr("proxy.process.http.201_responses"); + http_rsb.response_status_202_count = Counter::CreatePtr("proxy.process.http.202_responses"); + http_rsb.response_status_203_count = Counter::CreatePtr("proxy.process.http.203_responses"); + http_rsb.response_status_204_count = Counter::CreatePtr("proxy.process.http.204_responses"); + http_rsb.response_status_205_count = Counter::CreatePtr("proxy.process.http.205_responses"); + http_rsb.response_status_206_count = Counter::CreatePtr("proxy.process.http.206_responses"); + http_rsb.response_status_2xx_count = Counter::CreatePtr("proxy.process.http.2xx_responses"); + http_rsb.response_status_300_count = Counter::CreatePtr("proxy.process.http.300_responses"); + http_rsb.response_status_301_count = Counter::CreatePtr("proxy.process.http.301_responses"); + http_rsb.response_status_302_count = Counter::CreatePtr("proxy.process.http.302_responses"); + http_rsb.response_status_303_count = Counter::CreatePtr("proxy.process.http.303_responses"); + http_rsb.response_status_304_count = Counter::CreatePtr("proxy.process.http.304_responses"); + http_rsb.response_status_305_count = Counter::CreatePtr("proxy.process.http.305_responses"); + http_rsb.response_status_307_count = Counter::CreatePtr("proxy.process.http.307_responses"); + http_rsb.response_status_308_count = Counter::CreatePtr("proxy.process.http.308_responses"); + http_rsb.response_status_3xx_count = Counter::CreatePtr("proxy.process.http.3xx_responses"); + http_rsb.response_status_400_count = Counter::CreatePtr("proxy.process.http.400_responses"); + http_rsb.response_status_401_count = Counter::CreatePtr("proxy.process.http.401_responses"); + http_rsb.response_status_402_count = Counter::CreatePtr("proxy.process.http.402_responses"); + http_rsb.response_status_403_count = Counter::CreatePtr("proxy.process.http.403_responses"); + http_rsb.response_status_404_count = Counter::CreatePtr("proxy.process.http.404_responses"); + http_rsb.response_status_405_count = Counter::CreatePtr("proxy.process.http.405_responses"); + http_rsb.response_status_406_count = Counter::CreatePtr("proxy.process.http.406_responses"); + http_rsb.response_status_407_count = Counter::CreatePtr("proxy.process.http.407_responses"); + http_rsb.response_status_408_count = Counter::CreatePtr("proxy.process.http.408_responses"); + http_rsb.response_status_409_count = Counter::CreatePtr("proxy.process.http.409_responses"); + http_rsb.response_status_410_count = Counter::CreatePtr("proxy.process.http.410_responses"); + http_rsb.response_status_411_count = Counter::CreatePtr("proxy.process.http.411_responses"); + http_rsb.response_status_412_count = Counter::CreatePtr("proxy.process.http.412_responses"); + http_rsb.response_status_413_count = Counter::CreatePtr("proxy.process.http.413_responses"); + http_rsb.response_status_414_count = Counter::CreatePtr("proxy.process.http.414_responses"); + http_rsb.response_status_415_count = Counter::CreatePtr("proxy.process.http.415_responses"); + http_rsb.response_status_416_count = Counter::CreatePtr("proxy.process.http.416_responses"); + http_rsb.response_status_4xx_count = Counter::CreatePtr("proxy.process.http.4xx_responses"); + http_rsb.response_status_500_count = Counter::CreatePtr("proxy.process.http.500_responses"); + http_rsb.response_status_501_count = Counter::CreatePtr("proxy.process.http.501_responses"); + http_rsb.response_status_502_count = Counter::CreatePtr("proxy.process.http.502_responses"); + http_rsb.response_status_503_count = Counter::CreatePtr("proxy.process.http.503_responses"); + http_rsb.response_status_504_count = Counter::CreatePtr("proxy.process.http.504_responses"); + http_rsb.response_status_505_count = Counter::CreatePtr("proxy.process.http.505_responses"); + http_rsb.response_status_5xx_count = Counter::CreatePtr("proxy.process.http.5xx_responses"); + http_rsb.server_begin_write_time = Counter::CreatePtr("proxy.process.http.milestone.server_begin_write"); + http_rsb.server_close_time = Counter::CreatePtr("proxy.process.http.milestone.server_close"); + http_rsb.server_connect_end_time = Counter::CreatePtr("proxy.process.http.milestone.server_connect_end"); + http_rsb.server_connect_time = Counter::CreatePtr("proxy.process.http.milestone.server_connect"); + http_rsb.server_first_connect_time = Counter::CreatePtr("proxy.process.http.milestone.server_first_connect"); + http_rsb.server_first_read_time = Counter::CreatePtr("proxy.process.http.milestone.server_first_read"); + http_rsb.server_read_header_done_time = Counter::CreatePtr("proxy.process.http.milestone.server_read_header_done"); + http_rsb.sm_finish_time = Counter::CreatePtr("proxy.process.http.milestone.sm_finish"); + http_rsb.sm_start_time = Counter::CreatePtr("proxy.process.http.milestone.sm_start"); + http_rsb.tcp_client_refresh_count = Counter::CreatePtr("proxy.process.http.tcp_client_refresh_count"); + http_rsb.tcp_client_refresh_origin_server_bytes = Counter::CreatePtr("proxy.process.http.tcp_client_refresh_origin_server_bytes"); + http_rsb.tcp_client_refresh_user_agent_bytes = Counter::CreatePtr("proxy.process.http.tcp_client_refresh_user_agent_bytes"); + http_rsb.tcp_expired_miss_count = Counter::CreatePtr("proxy.process.http.tcp_expired_miss_count"); + http_rsb.tcp_expired_miss_origin_server_bytes = Counter::CreatePtr("proxy.process.http.tcp_expired_miss_origin_server_bytes"); + http_rsb.tcp_expired_miss_user_agent_bytes = Counter::CreatePtr("proxy.process.http.tcp_expired_miss_user_agent_bytes"); + http_rsb.tcp_hit_count = Counter::CreatePtr("proxy.process.http.tcp_hit_count"); + http_rsb.tcp_hit_origin_server_bytes = Counter::CreatePtr("proxy.process.http.tcp_hit_origin_server_bytes"); + http_rsb.tcp_hit_user_agent_bytes = Counter::CreatePtr("proxy.process.http.tcp_hit_user_agent_bytes"); + http_rsb.tcp_ims_hit_count = Counter::CreatePtr("proxy.process.http.tcp_ims_hit_count"); + http_rsb.tcp_ims_hit_origin_server_bytes = Counter::CreatePtr("proxy.process.http.tcp_ims_hit_origin_server_bytes"); + http_rsb.tcp_ims_hit_user_agent_bytes = Counter::CreatePtr("proxy.process.http.tcp_ims_hit_user_agent_bytes"); + http_rsb.tcp_ims_miss_count = Counter::CreatePtr("proxy.process.http.tcp_ims_miss_count"); + http_rsb.tcp_ims_miss_origin_server_bytes = Counter::CreatePtr("proxy.process.http.tcp_ims_miss_origin_server_bytes"); + http_rsb.tcp_ims_miss_user_agent_bytes = Counter::CreatePtr("proxy.process.http.tcp_ims_miss_user_agent_bytes"); + http_rsb.tcp_miss_count = Counter::CreatePtr("proxy.process.http.tcp_miss_count"); + http_rsb.tcp_miss_origin_server_bytes = Counter::CreatePtr("proxy.process.http.tcp_miss_origin_server_bytes"); + http_rsb.tcp_miss_user_agent_bytes = Counter::CreatePtr("proxy.process.http.tcp_miss_user_agent_bytes"); + http_rsb.tcp_refresh_hit_count = Counter::CreatePtr("proxy.process.http.tcp_refresh_hit_count"); + http_rsb.tcp_refresh_hit_origin_server_bytes = Counter::CreatePtr("proxy.process.http.tcp_refresh_hit_origin_server_bytes"); + http_rsb.tcp_refresh_hit_user_agent_bytes = Counter::CreatePtr("proxy.process.http.tcp_refresh_hit_user_agent_bytes"); + http_rsb.tcp_refresh_miss_count = Counter::CreatePtr("proxy.process.http.tcp_refresh_miss_count"); + http_rsb.tcp_refresh_miss_origin_server_bytes = Counter::CreatePtr("proxy.process.http.tcp_refresh_miss_origin_server_bytes"); + http_rsb.tcp_refresh_miss_user_agent_bytes = Counter::CreatePtr("proxy.process.http.tcp_refresh_miss_user_agent_bytes"); + http_rsb.total_client_connections = Counter::CreatePtr("proxy.process.http.total_client_connections"); + http_rsb.total_client_connections_ipv4 = Counter::CreatePtr("proxy.process.http.total_client_connections_ipv4"); + http_rsb.total_client_connections_ipv6 = Counter::CreatePtr("proxy.process.http.total_client_connections_ipv6"); + http_rsb.total_incoming_connections = Counter::CreatePtr("proxy.process.http.total_incoming_connections"); + http_rsb.total_parent_marked_down_count = Counter::CreatePtr("proxy.process.http.total_parent_marked_down_count"); + http_rsb.total_parent_proxy_connections = Counter::CreatePtr("proxy.process.http.total_parent_proxy_connections"); + http_rsb.total_parent_retries = Counter::CreatePtr("proxy.process.http.total_parent_retries"); + http_rsb.total_parent_retries_exhausted = Counter::CreatePtr("proxy.process.http.total_parent_retries_exhausted"); + http_rsb.total_parent_switches = Counter::CreatePtr("proxy.process.http.total_parent_switches"); + http_rsb.total_server_connections = Counter::CreatePtr("proxy.process.http.total_server_connections"); + http_rsb.total_transactions_time = Counter::CreatePtr("proxy.process.http.total_transactions_time"); + http_rsb.total_x_redirect = Counter::CreatePtr("proxy.process.http.total_x_redirect_count"); + http_rsb.trace_requests = Counter::CreatePtr("proxy.process.http.trace_requests"); + http_rsb.tunnel_current_active_connections = Counter::CreatePtr("proxy.process.tunnel.current_active_connections"); + http_rsb.tunnels = Counter::CreatePtr("proxy.process.http.tunnels"); + http_rsb.ua_begin_time = Counter::CreatePtr("proxy.process.http.milestone.ua_begin"); + http_rsb.ua_begin_write_time = Counter::CreatePtr("proxy.process.http.milestone.ua_begin_write"); + http_rsb.ua_close_time = Counter::CreatePtr("proxy.process.http.milestone.ua_close"); + http_rsb.ua_counts_errors_aborts = Counter::CreatePtr("proxy.process.http.transaction_counts.errors.aborts"); + http_rsb.ua_counts_errors_connect_failed = Counter::CreatePtr("proxy.process.http.transaction_counts.errors.connect_failed"); + http_rsb.ua_counts_errors_other = Counter::CreatePtr("proxy.process.http.transaction_counts.errors.other"); + http_rsb.ua_counts_errors_possible_aborts = Counter::CreatePtr("proxy.process.http.transaction_counts.errors.possible_aborts"); http_rsb.ua_counts_errors_pre_accept_hangups = - metrics.createPtr("proxy.process.http.transaction_counts.errors.pre_accept_hangups"); - http_rsb.ua_counts_hit_fresh = metrics.createPtr("proxy.process.http.transaction_counts.hit_fresh"); - http_rsb.ua_counts_hit_fresh_process = metrics.createPtr("proxy.process.http.transaction_counts.hit_fresh.process"); - http_rsb.ua_counts_hit_reval = metrics.createPtr("proxy.process.http.transaction_counts.hit_revalidated"); - http_rsb.ua_counts_miss_changed = metrics.createPtr("proxy.process.http.transaction_counts.miss_changed"); - http_rsb.ua_counts_miss_client_no_cache = metrics.createPtr("proxy.process.http.transaction_counts.miss_client_no_cache"); - http_rsb.ua_counts_miss_cold = metrics.createPtr("proxy.process.http.transaction_counts.miss_cold"); - http_rsb.ua_counts_miss_uncacheable = metrics.createPtr("proxy.process.http.transaction_counts.miss_not_cacheable"); - http_rsb.ua_counts_other_unclassified = metrics.createPtr("proxy.process.http.transaction_counts.other.unclassified"); - http_rsb.ua_first_read_time = metrics.createPtr("proxy.process.http.milestone.ua_first_read"); - http_rsb.ua_msecs_errors_aborts = metrics.createPtr("proxy.process.http.transaction_totaltime.errors.aborts"); - http_rsb.ua_msecs_errors_connect_failed = metrics.createPtr("proxy.process.http.transaction_totaltime.errors.connect_failed"); - http_rsb.ua_msecs_errors_other = metrics.createPtr("proxy.process.http.transaction_totaltime.errors.other"); - http_rsb.ua_msecs_errors_possible_aborts = metrics.createPtr("proxy.process.http.transaction_totaltime.errors.possible_aborts"); + Counter::CreatePtr("proxy.process.http.transaction_counts.errors.pre_accept_hangups"); + http_rsb.ua_counts_hit_fresh = Counter::CreatePtr("proxy.process.http.transaction_counts.hit_fresh"); + http_rsb.ua_counts_hit_fresh_process = Counter::CreatePtr("proxy.process.http.transaction_counts.hit_fresh.process"); + http_rsb.ua_counts_hit_reval = Counter::CreatePtr("proxy.process.http.transaction_counts.hit_revalidated"); + http_rsb.ua_counts_miss_changed = Counter::CreatePtr("proxy.process.http.transaction_counts.miss_changed"); + http_rsb.ua_counts_miss_client_no_cache = Counter::CreatePtr("proxy.process.http.transaction_counts.miss_client_no_cache"); + http_rsb.ua_counts_miss_cold = Counter::CreatePtr("proxy.process.http.transaction_counts.miss_cold"); + http_rsb.ua_counts_miss_uncacheable = Counter::CreatePtr("proxy.process.http.transaction_counts.miss_not_cacheable"); + http_rsb.ua_counts_other_unclassified = Counter::CreatePtr("proxy.process.http.transaction_counts.other.unclassified"); + http_rsb.ua_first_read_time = Counter::CreatePtr("proxy.process.http.milestone.ua_first_read"); + http_rsb.ua_msecs_errors_aborts = Counter::CreatePtr("proxy.process.http.transaction_totaltime.errors.aborts"); + http_rsb.ua_msecs_errors_connect_failed = Counter::CreatePtr("proxy.process.http.transaction_totaltime.errors.connect_failed"); + http_rsb.ua_msecs_errors_other = Counter::CreatePtr("proxy.process.http.transaction_totaltime.errors.other"); + http_rsb.ua_msecs_errors_possible_aborts = Counter::CreatePtr("proxy.process.http.transaction_totaltime.errors.possible_aborts"); http_rsb.ua_msecs_errors_pre_accept_hangups = - metrics.createPtr("proxy.process.http.transaction_totaltime.errors.pre_accept_hangups"); - http_rsb.ua_msecs_hit_fresh = metrics.createPtr("proxy.process.http.transaction_totaltime.hit_fresh"); - http_rsb.ua_msecs_hit_fresh_process = metrics.createPtr("proxy.process.http.transaction_totaltime.hit_fresh.process"); - http_rsb.ua_msecs_hit_reval = metrics.createPtr("proxy.process.http.transaction_totaltime.hit_revalidated"); - http_rsb.ua_msecs_miss_changed = metrics.createPtr("proxy.process.http.transaction_totaltime.miss_changed"); - http_rsb.ua_msecs_miss_client_no_cache = metrics.createPtr("proxy.process.http.transaction_totaltime.miss_client_no_cache"); - http_rsb.ua_msecs_miss_cold = metrics.createPtr("proxy.process.http.transaction_totaltime.miss_cold"); - http_rsb.ua_msecs_miss_uncacheable = metrics.createPtr("proxy.process.http.transaction_totaltime.miss_not_cacheable"); - http_rsb.ua_msecs_other_unclassified = metrics.createPtr("proxy.process.http.transaction_totaltime.other.unclassified"); - http_rsb.ua_read_header_done_time = metrics.createPtr("proxy.process.http.milestone.ua_read_header_done"); - http_rsb.user_agent_request_document_total_size = metrics.createPtr("proxy.process.http.user_agent_request_document_total_size"); - http_rsb.user_agent_request_header_total_size = metrics.createPtr("proxy.process.http.user_agent_request_header_total_size"); + Counter::CreatePtr("proxy.process.http.transaction_totaltime.errors.pre_accept_hangups"); + http_rsb.ua_msecs_hit_fresh = Counter::CreatePtr("proxy.process.http.transaction_totaltime.hit_fresh"); + http_rsb.ua_msecs_hit_fresh_process = Counter::CreatePtr("proxy.process.http.transaction_totaltime.hit_fresh.process"); + http_rsb.ua_msecs_hit_reval = Counter::CreatePtr("proxy.process.http.transaction_totaltime.hit_revalidated"); + http_rsb.ua_msecs_miss_changed = Counter::CreatePtr("proxy.process.http.transaction_totaltime.miss_changed"); + http_rsb.ua_msecs_miss_client_no_cache = Counter::CreatePtr("proxy.process.http.transaction_totaltime.miss_client_no_cache"); + http_rsb.ua_msecs_miss_cold = Counter::CreatePtr("proxy.process.http.transaction_totaltime.miss_cold"); + http_rsb.ua_msecs_miss_uncacheable = Counter::CreatePtr("proxy.process.http.transaction_totaltime.miss_not_cacheable"); + http_rsb.ua_msecs_other_unclassified = Counter::CreatePtr("proxy.process.http.transaction_totaltime.other.unclassified"); + http_rsb.ua_read_header_done_time = Counter::CreatePtr("proxy.process.http.milestone.ua_read_header_done"); + http_rsb.user_agent_request_document_total_size = Counter::CreatePtr("proxy.process.http.user_agent_request_document_total_size"); + http_rsb.user_agent_request_header_total_size = Counter::CreatePtr("proxy.process.http.user_agent_request_header_total_size"); http_rsb.user_agent_response_document_total_size = - metrics.createPtr("proxy.process.http.user_agent_response_document_total_size"); - http_rsb.user_agent_response_header_total_size = metrics.createPtr("proxy.process.http.user_agent_response_header_total_size"); + Counter::CreatePtr("proxy.process.http.user_agent_response_document_total_size"); + http_rsb.user_agent_response_header_total_size = Counter::CreatePtr("proxy.process.http.user_agent_response_header_total_size"); http_rsb.websocket_current_active_client_connections = - metrics.createPtr("proxy.process.http.websocket.current_active_client_connections"); + Counter::CreatePtr("proxy.process.http.websocket.current_active_client_connections"); } static bool diff --git a/src/proxy/http/PreWarmManager.cc b/src/proxy/http/PreWarmManager.cc index f7f4022fcf8..0104de5e632 100644 --- a/src/proxy/http/PreWarmManager.cc +++ b/src/proxy/http/PreWarmManager.cc @@ -1149,7 +1149,7 @@ PreWarmManager::_register_stats(const PreWarm::ParsedSNIConf &parsed_conf) Counter::AtomicType *metric = nullptr; if (stats_id == ts::Metrics::Counter::NOT_FOUND) { - metric = metrics.createPtr(name); + metric = Counter::CreatePtr(name); if (metric == nullptr) { Error("couldn't register stat name=%s", name); diff --git a/src/proxy/http2/HTTP2.cc b/src/proxy/http2/HTTP2.cc index 5d3df2a8be6..3edc8f3f844 100644 --- a/src/proxy/http2/HTTP2.cc +++ b/src/proxy/http2/HTTP2.cc @@ -563,40 +563,38 @@ Http2::init() ink_release_assert(http2_settings_parameter_is_valid({HTTP2_SETTINGS_MAX_HEADER_LIST_SIZE, max_header_list_size})); // Setup statistics - ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); - - http2_rsb.current_client_session_count = metrics.createPtr("proxy.process.http2.current_client_connections"); - http2_rsb.current_server_session_count = metrics.createPtr("proxy.process.http2.current_server_connections"); - http2_rsb.current_active_client_connection_count = metrics.createPtr("proxy.process.http2.current_active_client_connections"); - http2_rsb.current_active_server_connection_count = metrics.createPtr("proxy.process.http2.current_active_server_connections"); - http2_rsb.current_client_stream_count = metrics.createPtr("proxy.process.http2.current_client_streams"); - http2_rsb.current_server_stream_count = metrics.createPtr("proxy.process.http2.current_server_streams"); - http2_rsb.total_client_stream_count = metrics.createPtr("proxy.process.http2.total_client_streams"); - http2_rsb.total_server_stream_count = metrics.createPtr("proxy.process.http2.total_server_streams"); - http2_rsb.total_transactions_time = metrics.createPtr("proxy.process.http2.total_transactions_time"); - http2_rsb.total_client_connection_count = metrics.createPtr("proxy.process.http2.total_client_connections"); - http2_rsb.total_server_connection_count = metrics.createPtr("proxy.process.http2.total_server_connections"); - http2_rsb.stream_errors_count = metrics.createPtr("proxy.process.http2.stream_errors"); - http2_rsb.connection_errors_count = metrics.createPtr("proxy.process.http2.connection_errors"); - http2_rsb.session_die_default = metrics.createPtr("proxy.process.http2.session_die_default"); - http2_rsb.session_die_other = metrics.createPtr("proxy.process.http2.session_die_other"); - http2_rsb.session_die_active = metrics.createPtr("proxy.process.http2.session_die_active"); - http2_rsb.session_die_inactive = metrics.createPtr("proxy.process.http2.session_die_inactive"); - http2_rsb.session_die_eos = metrics.createPtr("proxy.process.http2.session_die_eos"); - http2_rsb.session_die_error = metrics.createPtr("proxy.process.http2.session_die_error"); - http2_rsb.session_die_high_error_rate = metrics.createPtr("proxy.process.http2.session_die_high_error_rate"); - http2_rsb.max_settings_per_frame_exceeded = metrics.createPtr("proxy.process.http2.max_settings_per_frame_exceeded"); - http2_rsb.max_settings_per_minute_exceeded = metrics.createPtr("proxy.process.http2.max_settings_per_minute_exceeded"); + http2_rsb.current_client_session_count = Counter::CreatePtr("proxy.process.http2.current_client_connections"); + http2_rsb.current_server_session_count = Counter::CreatePtr("proxy.process.http2.current_server_connections"); + http2_rsb.current_active_client_connection_count = Counter::CreatePtr("proxy.process.http2.current_active_client_connections"); + http2_rsb.current_active_server_connection_count = Counter::CreatePtr("proxy.process.http2.current_active_server_connections"); + http2_rsb.current_client_stream_count = Counter::CreatePtr("proxy.process.http2.current_client_streams"); + http2_rsb.current_server_stream_count = Counter::CreatePtr("proxy.process.http2.current_server_streams"); + http2_rsb.total_client_stream_count = Counter::CreatePtr("proxy.process.http2.total_client_streams"); + http2_rsb.total_server_stream_count = Counter::CreatePtr("proxy.process.http2.total_server_streams"); + http2_rsb.total_transactions_time = Counter::CreatePtr("proxy.process.http2.total_transactions_time"); + http2_rsb.total_client_connection_count = Counter::CreatePtr("proxy.process.http2.total_client_connections"); + http2_rsb.total_server_connection_count = Counter::CreatePtr("proxy.process.http2.total_server_connections"); + http2_rsb.stream_errors_count = Counter::CreatePtr("proxy.process.http2.stream_errors"); + http2_rsb.connection_errors_count = Counter::CreatePtr("proxy.process.http2.connection_errors"); + http2_rsb.session_die_default = Counter::CreatePtr("proxy.process.http2.session_die_default"); + http2_rsb.session_die_other = Counter::CreatePtr("proxy.process.http2.session_die_other"); + http2_rsb.session_die_active = Counter::CreatePtr("proxy.process.http2.session_die_active"); + http2_rsb.session_die_inactive = Counter::CreatePtr("proxy.process.http2.session_die_inactive"); + http2_rsb.session_die_eos = Counter::CreatePtr("proxy.process.http2.session_die_eos"); + http2_rsb.session_die_error = Counter::CreatePtr("proxy.process.http2.session_die_error"); + http2_rsb.session_die_high_error_rate = Counter::CreatePtr("proxy.process.http2.session_die_high_error_rate"); + http2_rsb.max_settings_per_frame_exceeded = Counter::CreatePtr("proxy.process.http2.max_settings_per_frame_exceeded"); + http2_rsb.max_settings_per_minute_exceeded = Counter::CreatePtr("proxy.process.http2.max_settings_per_minute_exceeded"); http2_rsb.max_settings_frames_per_minute_exceeded = - metrics.createPtr("proxy.process.http2.max_settings_frames_per_minute_exceeded"); - http2_rsb.max_ping_frames_per_minute_exceeded = metrics.createPtr("proxy.process.http2.max_ping_frames_per_minute_exceeded"); + Counter::CreatePtr("proxy.process.http2.max_settings_frames_per_minute_exceeded"); + http2_rsb.max_ping_frames_per_minute_exceeded = Counter::CreatePtr("proxy.process.http2.max_ping_frames_per_minute_exceeded"); http2_rsb.max_priority_frames_per_minute_exceeded = - metrics.createPtr("proxy.process.http2.max_priority_frames_per_minute_exceeded"); + Counter::CreatePtr("proxy.process.http2.max_priority_frames_per_minute_exceeded"); http2_rsb.max_rst_stream_frames_per_minute_exceeded = - metrics.createPtr("proxy.process.http2.max_rst_stream_frames_per_minute_exceeded"); - http2_rsb.insufficient_avg_window_update = metrics.createPtr("proxy.process.http2.insufficient_avg_window_update"); - http2_rsb.max_concurrent_streams_exceeded_in = metrics.createPtr("proxy.process.http2.max_concurrent_streams_exceeded_in"); - http2_rsb.max_concurrent_streams_exceeded_out = metrics.createPtr("proxy.process.http2.max_concurrent_streams_exceeded_out"); + Counter::CreatePtr("proxy.process.http2.max_rst_stream_frames_per_minute_exceeded"); + http2_rsb.insufficient_avg_window_update = Counter::CreatePtr("proxy.process.http2.insufficient_avg_window_update"); + http2_rsb.max_concurrent_streams_exceeded_in = Counter::CreatePtr("proxy.process.http2.max_concurrent_streams_exceeded_in"); + http2_rsb.max_concurrent_streams_exceeded_out = Counter::CreatePtr("proxy.process.http2.max_concurrent_streams_exceeded_out"); http2_init(); } diff --git a/src/proxy/http3/Http3.cc b/src/proxy/http3/Http3.cc index d18dd16e536..8c55d79edf7 100644 --- a/src/proxy/http3/Http3.cc +++ b/src/proxy/http3/Http3.cc @@ -37,7 +37,5 @@ Http3::init() // Example (remove comments here when addding) // // Setup statistics - // ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); - // - // http3_rsb.current_client_session_count = metrics.createPtr("proxy.process.http3.current_client_connections"); + // http3_rsb.current_client_session_count = Counter::CreatePtr("proxy.process.http3.current_client_connections"); } diff --git a/src/proxy/logging/LogConfig.cc b/src/proxy/logging/LogConfig.cc index 91a42351bbb..9c2a42979ea 100644 --- a/src/proxy/logging/LogConfig.cc +++ b/src/proxy/logging/LogConfig.cc @@ -508,32 +508,31 @@ LogConfig::register_stat_callbacks() // // events // - ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); - log_rsb.event_log_error_skip = metrics.createPtr("proxy.process.log.event_log_error_skip"); - log_rsb.event_log_error_ok = metrics.createPtr("proxy.process.log.event_log_error_ok"); - log_rsb.event_log_error_aggr = metrics.createPtr("proxy.process.log.event_log_error_aggr"); - log_rsb.event_log_error_full = metrics.createPtr("proxy.process.log.event_log_error_full"); - log_rsb.event_log_error_fail = metrics.createPtr("proxy.process.log.event_log_error_fail"); - log_rsb.event_log_access_ok = metrics.createPtr("proxy.process.log.event_log_access_ok"); - log_rsb.event_log_access_skip = metrics.createPtr("proxy.process.log.event_log_access_skip"); - log_rsb.event_log_access_aggr = metrics.createPtr("proxy.process.log.event_log_access_aggr"); - log_rsb.event_log_access_full = metrics.createPtr("proxy.process.log.event_log_access_full"); - log_rsb.event_log_access_fail = metrics.createPtr("proxy.process.log.event_log_access_fail"); - log_rsb.num_sent_to_network = metrics.createPtr("proxy.process.log.num_sent_to_network"); - log_rsb.num_lost_before_sent_to_network = metrics.createPtr("proxy.process.log.num_lost_before_sent_to_network"); - log_rsb.num_received_from_network = metrics.createPtr("proxy.process.log.num_received_from_network"); - log_rsb.num_flush_to_disk = metrics.createPtr("proxy.process.log.num_flush_to_disk"); - log_rsb.num_lost_before_flush_to_disk = metrics.createPtr("proxy.process.log.num_lost_before_flush_to_disk"); - log_rsb.bytes_lost_before_preproc = metrics.createPtr("proxy.process.log.bytes_lost_before_preproc"); - log_rsb.bytes_sent_to_network = metrics.createPtr("proxy.process.log.bytes_sent_to_network"); - log_rsb.bytes_lost_before_sent_to_network = metrics.createPtr("proxy.process.log.bytes_lost_before_sent_to_network"); - log_rsb.bytes_received_from_network = metrics.createPtr("proxy.process.log.bytes_received_from_network"); - log_rsb.bytes_flush_to_disk = metrics.createPtr("proxy.process.log.bytes_flush_to_disk"); - log_rsb.bytes_lost_before_flush_to_disk = metrics.createPtr("proxy.process.log.bytes_lost_before_flush_to_disk"); - log_rsb.bytes_written_to_disk = metrics.createPtr("proxy.process.log.bytes_written_to_disk"); - log_rsb.bytes_lost_before_written_to_disk = metrics.createPtr("proxy.process.log.bytes_lost_before_written_to_disk"); - log_rsb.log_files_open = metrics.createPtr("proxy.process.log.log_files_open"); - log_rsb.log_files_space_used = metrics.createPtr("proxy.process.log.log_files_space_used"); + log_rsb.event_log_error_skip = Counter::CreatePtr("proxy.process.log.event_log_error_skip"); + log_rsb.event_log_error_ok = Counter::CreatePtr("proxy.process.log.event_log_error_ok"); + log_rsb.event_log_error_aggr = Counter::CreatePtr("proxy.process.log.event_log_error_aggr"); + log_rsb.event_log_error_full = Counter::CreatePtr("proxy.process.log.event_log_error_full"); + log_rsb.event_log_error_fail = Counter::CreatePtr("proxy.process.log.event_log_error_fail"); + log_rsb.event_log_access_ok = Counter::CreatePtr("proxy.process.log.event_log_access_ok"); + log_rsb.event_log_access_skip = Counter::CreatePtr("proxy.process.log.event_log_access_skip"); + log_rsb.event_log_access_aggr = Counter::CreatePtr("proxy.process.log.event_log_access_aggr"); + log_rsb.event_log_access_full = Counter::CreatePtr("proxy.process.log.event_log_access_full"); + log_rsb.event_log_access_fail = Counter::CreatePtr("proxy.process.log.event_log_access_fail"); + log_rsb.num_sent_to_network = Counter::CreatePtr("proxy.process.log.num_sent_to_network"); + log_rsb.num_lost_before_sent_to_network = Counter::CreatePtr("proxy.process.log.num_lost_before_sent_to_network"); + log_rsb.num_received_from_network = Counter::CreatePtr("proxy.process.log.num_received_from_network"); + log_rsb.num_flush_to_disk = Counter::CreatePtr("proxy.process.log.num_flush_to_disk"); + log_rsb.num_lost_before_flush_to_disk = Counter::CreatePtr("proxy.process.log.num_lost_before_flush_to_disk"); + log_rsb.bytes_lost_before_preproc = Counter::CreatePtr("proxy.process.log.bytes_lost_before_preproc"); + log_rsb.bytes_sent_to_network = Counter::CreatePtr("proxy.process.log.bytes_sent_to_network"); + log_rsb.bytes_lost_before_sent_to_network = Counter::CreatePtr("proxy.process.log.bytes_lost_before_sent_to_network"); + log_rsb.bytes_received_from_network = Counter::CreatePtr("proxy.process.log.bytes_received_from_network"); + log_rsb.bytes_flush_to_disk = Counter::CreatePtr("proxy.process.log.bytes_flush_to_disk"); + log_rsb.bytes_lost_before_flush_to_disk = Counter::CreatePtr("proxy.process.log.bytes_lost_before_flush_to_disk"); + log_rsb.bytes_written_to_disk = Counter::CreatePtr("proxy.process.log.bytes_written_to_disk"); + log_rsb.bytes_lost_before_written_to_disk = Counter::CreatePtr("proxy.process.log.bytes_lost_before_written_to_disk"); + log_rsb.log_files_open = Counter::CreatePtr("proxy.process.log.log_files_open"); + log_rsb.log_files_space_used = Counter::CreatePtr("proxy.process.log.log_files_space_used"); } /*------------------------------------------------------------------------- diff --git a/src/traffic_server/traffic_server.cc b/src/traffic_server/traffic_server.cc index fbce6aaa46e..ccade8a76c9 100644 --- a/src/traffic_server/traffic_server.cc +++ b/src/traffic_server/traffic_server.cc @@ -430,7 +430,7 @@ class MemoryLimit : public Continuation memset(&_usage, 0, sizeof(_usage)); SET_HANDLER(&MemoryLimit::periodic); - memory_rss = metrics.createPtr("proxy.process.traffic_server.memory.rss"); + memory_rss = Counter::CreatePtr("proxy.process.traffic_server.memory.rss"); } ~MemoryLimit() override { mutex = nullptr; } From 3ce5ba3b4e4baf029224df5d06d2db2817cf3327 Mon Sep 17 00:00:00 2001 From: Leif Hedstrom Date: Fri, 27 Oct 2023 13:03:59 -0600 Subject: [PATCH 3/6] Separate the metrics storage from metrics classes --- example/cripts/example1.cc | 2 +- include/api/Metrics.h | 425 +++++++++------ include/iocore/net/quic/QUICStats.h | 4 +- include/proxy/http/HttpCacheSM.h | 8 +- include/proxy/http/HttpConfig.h | 484 ++++++++--------- include/proxy/http/PreWarmManager.h | 4 +- include/proxy/http2/HTTP2.h | 60 +-- include/proxy/http2/Http2ServerSession.h | 4 +- include/proxy/http3/Http3.h | 6 +- include/proxy/logging/LogConfig.h | 52 +- src/api/InkAPI.cc | 30 +- src/api/Metrics.cc | 236 ++++---- src/api/unit_tests/test_Metrics.cc | 15 +- src/iocore/aio/AIO.cc | 24 +- src/iocore/aio/P_AIO.h | 10 +- src/iocore/aio/test_AIO.cc | 8 +- src/iocore/cache/Cache.cc | 175 +++--- src/iocore/cache/CacheDir.cc | 52 +- src/iocore/cache/CacheDisk.cc | 8 +- src/iocore/cache/CacheHttp.cc | 6 +- src/iocore/cache/CacheRead.cc | 64 +-- src/iocore/cache/CacheVC.cc | 8 +- src/iocore/cache/CacheWrite.cc | 52 +- src/iocore/cache/P_CacheInternal.h | 14 +- src/iocore/cache/P_CacheStats.h | 72 +-- src/iocore/cache/RamCacheCLFUS.cc | 48 +- src/iocore/cache/RamCacheLRU.cc | 16 +- src/iocore/dns/DNS.cc | 54 +- src/iocore/dns/P_DNSProcessor.h | 24 +- src/iocore/hostdb/HostDB.cc | 32 +- src/iocore/hostdb/P_HostDBProcessor.h | 16 +- src/iocore/hostdb/P_RefCountCache.h | 54 +- src/iocore/io_uring/io_uring.cc | 18 +- src/iocore/io_uring/unit_tests/test_diskIO.cc | 8 +- src/iocore/net/BIO_fastopen.cc | 4 +- src/iocore/net/Net.cc | 87 +-- src/iocore/net/NetHandler.cc | 8 +- src/iocore/net/OCSPStapling.cc | 8 +- src/iocore/net/P_Net.h | 86 +-- src/iocore/net/P_UnixNet.h | 2 +- src/iocore/net/QUICNetProcessor.cc | 2 +- src/iocore/net/QUICNetProcessor_quiche.cc | 2 +- src/iocore/net/QUICNetVConnection.cc | 2 +- src/iocore/net/SSLDiags.cc | 40 +- src/iocore/net/SSLNetVConnection.cc | 68 +-- src/iocore/net/SSLSessionCache.cc | 12 +- src/iocore/net/SSLStats.cc | 128 ++--- src/iocore/net/SSLStats.h | 120 ++--- src/iocore/net/SSLUtils.cc | 6 +- src/iocore/net/Socks.cc | 4 +- src/iocore/net/TLSBasicSupport.cc | 2 +- src/iocore/net/TLSSessionResumptionSupport.cc | 20 +- src/iocore/net/UnixNet.cc | 10 +- src/iocore/net/UnixNetAccept.cc | 24 +- src/iocore/net/UnixNetProcessor.cc | 2 +- src/iocore/net/UnixNetVConnection.cc | 38 +- src/iocore/net/quic/QUICGlobals.cc | 8 +- src/mgmt/rpc/handlers/config/Configuration.cc | 6 +- src/mgmt/rpc/handlers/server/Server.cc | 8 +- src/proxy/http/Http1ClientSession.cc | 18 +- src/proxy/http/Http1ClientTransaction.cc | 4 +- src/proxy/http/Http1ServerSession.cc | 12 +- src/proxy/http/Http1ServerTransaction.cc | 4 +- src/proxy/http/HttpCacheSM.cc | 4 +- src/proxy/http/HttpConfig.cc | 504 +++++++++--------- src/proxy/http/HttpSM.cc | 76 +-- src/proxy/http/HttpSessionAccept.cc | 4 +- src/proxy/http/HttpSessionManager.cc | 6 +- src/proxy/http/HttpTransact.cc | 426 +++++++-------- src/proxy/http/HttpTunnel.cc | 10 +- src/proxy/http/HttpVCTable.cc | 2 +- src/proxy/http/PreWarmManager.cc | 12 +- src/proxy/http2/HTTP2.cc | 63 ++- src/proxy/http2/Http2ClientSession.cc | 10 +- src/proxy/http2/Http2CommonSession.cc | 16 +- src/proxy/http2/Http2ConnectionState.cc | 24 +- src/proxy/http2/Http2ServerSession.cc | 6 +- src/proxy/http2/Http2SessionAccept.cc | 5 +- src/proxy/http2/Http2Stream.cc | 14 +- src/proxy/http3/Http3.cc | 2 +- src/proxy/logging/Log.cc | 24 +- src/proxy/logging/LogAccess.cc | 6 +- src/proxy/logging/LogConfig.cc | 52 +- src/proxy/logging/LogFile.cc | 18 +- src/proxy/logging/LogObject.cc | 12 +- src/records/RecCore.cc | 16 +- src/traffic_server/traffic_server.cc | 44 +- 87 files changed, 2142 insertions(+), 2042 deletions(-) diff --git a/example/cripts/example1.cc b/example/cripts/example1.cc index 202f14352c1..9e07276f571 100644 --- a/example/cripts/example1.cc +++ b/example/cripts/example1.cc @@ -230,7 +230,7 @@ do_remap() // Testing some simple metrics static auto m1 = Metrics::Sum("cript.example1`.m1"); - static auto m2 = Counter::AtomicType("cript.example1`.m2"); + static auto m2 = Metrics::Counter("cript.example1`.m2"); m1.increment(100); m2.increment(); diff --git a/include/api/Metrics.h b/include/api/Metrics.h index cba66865af0..a06ba575f75 100644 --- a/include/api/Metrics.h +++ b/include/api/Metrics.h @@ -40,132 +40,257 @@ namespace ts { -namespace Metrics +class Metrics { - class Counter +private: + using self_type = Metrics; + using AtomicType = std::atomic; // Make sure users don't use this, rather than a proper Counter/Gauge + +public: + using IdType = int32_t; // Could be a tuple, but one way or another, they have to be combined to an int32_t. + using SpanType = swoc::MemSpan; + + static constexpr uint16_t MAX_BLOBS = 8192; + static constexpr uint16_t MAX_SIZE = 1024; // For a total of 8M metrics + static constexpr IdType NOT_FOUND = std::numeric_limits::min(); // <16-bit,16-bit> = + static const auto MEMORY_ORDER = std::memory_order_relaxed; + +private: + using NameAndId = std::tuple; + using LookupTable = std::unordered_map; + using NameStorage = std::array; + using AtomicStorage = std::array; + using NamesAndAtomics = std::tuple; + using BlobStorage = std::array; + +public: + Metrics(const self_type &) = delete; + self_type &operator=(const self_type &) = delete; + Metrics &operator=(Metrics &&) = delete; + Metrics(Metrics &&) = delete; + + virtual ~Metrics() { - private: - using self_type = Counter; + for (size_t i = 0; i <= _cur_blob; ++i) { + delete _blobs[i]; + } + } - public: - using AtomicType = std::atomic; - using IdType = int32_t; // Could be a tuple, but one way or another, they have to be combined to an int32_t. - using SpanType = swoc::MemSpan; + Metrics() + { + _blobs[0] = new NamesAndAtomics(); + ink_release_assert(_blobs[0]); + ink_release_assert(0 == _create("proxy.process.api.metrics.bad_id")); // Reserve slot 0 for errors, this should always be 0 + } - static constexpr uint16_t MAX_BLOBS = 8192; - static constexpr uint16_t MAX_SIZE = 1024; // For a total of 8M metrics - static constexpr IdType NOT_FOUND = std::numeric_limits::min(); // <16-bit,16-bit> = - static const auto MEMORY_ORDER = std::memory_order_relaxed; + // The singleton instance, owned by the Metrics class + static Metrics &instance(); - private: - using NameAndId = std::tuple; - using LookupTable = std::unordered_map; - using NameStorage = std::array; - using AtomicStorage = std::array; - using NamesAndAtomics = std::tuple; - using BlobStorage = std::array; + // Yes, we don't return objects here, but rather ID's and atomic's directly. Treat + // the std::atomic as the underlying class for a single metric, and be happy. + IdType lookup(const std::string_view name) const; + AtomicType *lookup(IdType id, std::string_view *name = nullptr) const; + + std::optional + lookupPtr(const std::string_view name) const + { + IdType id = lookup(name); + if (id != NOT_FOUND) { + return lookup(id); + } + return std::nullopt; + } + + bool rename(IdType id, const std::string_view name); + + AtomicType & + operator[](IdType id) + { + return *lookup(id); + } + + IdType + operator[](const std::string_view name) const + { + return lookup(name); + } + + int64_t + increment(IdType id, uint64_t val = 1) + { + auto metric = lookup(id); + + return (metric ? metric->fetch_add(val, MEMORY_ORDER) : NOT_FOUND); + } + + int64_t + decrement(IdType id, uint64_t val = 1) + { + auto metric = lookup(id); + + return (metric ? metric->fetch_sub(val, MEMORY_ORDER) : NOT_FOUND); + } + std::string_view name(IdType id) const; + + bool + valid(IdType id) const + { + auto [blob, entry] = _splitID(id); + + return (id >= 0 && ((blob < _cur_blob && entry < MAX_SIZE) || (blob == _cur_blob && entry <= _cur_off))); + } + + // Static methods to encapsulate access to the atomic's + class iterator + { public: - Counter(const self_type &) = delete; - self_type &operator=(const self_type &) = delete; - Counter &operator=(Counter &&) = delete; - Counter(Counter &&) = delete; + using iterator_category = std::input_iterator_tag; + using value_type = std::tuple; + using difference_type = ptrdiff_t; + using pointer = value_type *; + using reference = value_type &; + + iterator(const Metrics &m, IdType pos) : _metrics(m), _it(pos) {} - virtual ~Counter() + iterator & + operator++() { - for (size_t i = 0; i <= _cur_blob; ++i) { - delete _blobs[i]; - } + next(); + + return *this; } - Counter() + iterator + operator++(int) { - _blobs[0] = new NamesAndAtomics(); - ink_release_assert(_blobs[0]); - ink_release_assert(0 == create("proxy.process.api.metrics.bad_id")); // Reserve slot 0 for errors, this should always be 0 - } + iterator result = *this; - // Yes, we don't return objects here, but rather ID's and atomic's directly. Treat - // the std::atomic as the underlying class for a single metric, and be happy. - IdType create(const std::string_view name); - SpanType createSpan(size_t size, IdType *id = nullptr); - IdType lookup(const std::string_view name) const; - AtomicType *lookup(IdType id, std::string_view *name = nullptr) const; + next(); - std::optional - lookupPtr(const std::string_view name) const - { - IdType id = lookup(name); - if (id != NOT_FOUND) { - return lookup(id); - } - return std::nullopt; + return result; } - // A bit of a convenience, since we use the ptr to the atomic frequently in the core - AtomicType * - createPtr(const std::string_view name) + value_type + operator*() const { - return lookup(create(name)); - } + std::string_view name; + auto metric = _metrics.lookup(_it, &name); - bool rename(IdType id, const std::string_view name); + return std::make_tuple(name, metric->load()); + } - AtomicType & - operator[](IdType id) + bool + operator==(const iterator &o) const { - return *lookup(id); + return _it == o._it && std::addressof(_metrics) == std::addressof(o._metrics); } - IdType - operator[](const std::string_view name) const + bool + operator!=(const iterator &o) const { - return lookup(name); + return _it != o._it || std::addressof(_metrics) != std::addressof(o._metrics); } - int64_t - increment(IdType id, uint64_t val = 1) - { - auto metric = lookup(id); + private: + void next(); - return (metric ? metric->fetch_add(val, MEMORY_ORDER) : NOT_FOUND); - } + const Metrics &_metrics; + Metrics::IdType _it; + }; - int64_t - decrement(IdType id, uint64_t val = 1) - { - auto metric = lookup(id); + iterator + begin() const + { + return iterator(*this, 0); + } - return (metric ? metric->fetch_sub(val, MEMORY_ORDER) : NOT_FOUND); - } + iterator + end() const + { + _mutex.lock(); + int16_t blob = _cur_blob; + int16_t offset = _cur_off; + _mutex.unlock(); - std::string_view name(IdType id) const; + return iterator(*this, _makeId(blob, offset)); + } - bool - valid(IdType id) const - { - auto [blob, entry] = _splitID(id); + iterator + find(const std::string_view name) const + { + auto id = lookup(name); - return (id >= 0 && ((blob < _cur_blob && entry < MAX_SIZE) || (blob == _cur_blob && entry <= _cur_off))); + if (id == NOT_FOUND) { + return end(); + } else { + return iterator(*this, id); } + } + +private: + // These are private, to assure that we don't use them by accident creating naked metrics + IdType _create(const std::string_view name); + SpanType _createSpan(size_t size, IdType *id = nullptr); + + // These are little helpers around managing the ID's + static constexpr std::tuple + _splitID(IdType value) + { + return std::make_tuple(static_cast(value >> 16), static_cast(value & 0xFFFF)); + } + + static constexpr IdType + _makeId(uint16_t blob, uint16_t offset) + { + return (blob << 16 | offset); + } + + static constexpr IdType + _makeId(std::tuple id) + { + return _makeId(std::get<0>(id), std::get<1>(id)); + } + + void _addBlob(); - // Static methods to encapsulate access to the atomic's - static Counter &getInstance(); + mutable std::mutex _mutex; + LookupTable _lookups; + BlobStorage _blobs; + uint16_t _cur_blob = 0; + uint16_t _cur_off = 0; - static IdType - Create(const std::string_view name) +public: + // These are sort of factory classes, using the Metrics singleton for all storage etc. + class Gauge + { + public: + using self_type = Gauge; + using AtomicType = Metrics::AtomicType; + using SpanType = Metrics::SpanType; + + static Metrics::IdType + create(const std::string_view name) { - auto &instance = getInstance(); + auto &instance = Metrics::instance(); - return instance.create(name); + return instance._create(name); } static AtomicType * - CreatePtr(const std::string_view name) + createPtr(const std::string_view name) { - auto &instance = getInstance(); + auto &instance = Metrics::instance(); - return instance.lookup(instance.create(name)); + return instance.lookup(instance._create(name)); + } + + static Metrics::Gauge::SpanType + createSpan(size_t size, IdType *id = nullptr) + { + auto &instance = Metrics::instance(); + + return instance._createSpan(size, id); } static void @@ -196,121 +321,69 @@ namespace Metrics return metric->store(val); } - class iterator - { - public: - using iterator_category = std::input_iterator_tag; - using value_type = std::tuple; - using difference_type = ptrdiff_t; - using pointer = value_type *; - using reference = value_type &; - - iterator(const Counter &m, IdType pos) : _counter(m), _it(pos) {} - - iterator & - operator++() - { - next(); + }; // class Gauge - return *this; - } - - iterator - operator++(int) - { - iterator result = *this; - - next(); - - return result; - } - - value_type - operator*() const - { - std::string_view name; - auto metric = _counter.lookup(_it, &name); - - return std::make_tuple(name, metric->load()); - } - - bool - operator==(const iterator &o) const - { - return _it == o._it && std::addressof(_counter) == std::addressof(o._counter); - } - - bool - operator!=(const iterator &o) const - { - return _it != o._it || std::addressof(_counter) != std::addressof(o._counter); - } - - private: - void next(); - - const Counter &_counter; - IdType _it; - }; + class Counter + { + public: + using self_type = Counter; + using AtomicType = Metrics::AtomicType; + using SpanType = Metrics::SpanType; - iterator - begin() const + static Metrics::IdType + create(const std::string_view name) { - return iterator(*this, 0); + auto &instance = Metrics::instance(); + + return instance._create(name); } - iterator - end() const + static AtomicType * + createPtr(const std::string_view name) { - _mutex.lock(); - int16_t blob = _cur_blob; - int16_t offset = _cur_off; - _mutex.unlock(); + auto &instance = Metrics::instance(); - return iterator(*this, _makeId(blob, offset)); + return instance.lookup(instance._create(name)); } - iterator - find(const std::string_view name) const + static Metrics::Counter::SpanType + createSpan(size_t size, IdType *id = nullptr) { - auto id = lookup(name); + auto &instance = Metrics::instance(); - if (id == NOT_FOUND) { - return end(); - } else { - return iterator(*this, id); - } + return instance._createSpan(size, id); } - private: - static constexpr std::tuple - _splitID(IdType value) + static void + increment(AtomicType *metric, uint64_t val = 1) { - return std::make_tuple(static_cast(value >> 16), static_cast(value & 0xFFFF)); + ink_assert(metric); + metric->fetch_add(val, MEMORY_ORDER); } - static constexpr IdType - _makeId(uint16_t blob, uint16_t offset) + static void + decrement(AtomicType *metric, uint64_t val = 1) { - return (blob << 16 | offset); + ink_assert(metric); + metric->fetch_sub(val, MEMORY_ORDER); } - static constexpr IdType - _makeId(std::tuple id) + static int64_t + read(AtomicType *metric) { - return _makeId(std::get<0>(id), std::get<1>(id)); + ink_assert(metric); + return metric->load(); } - void _addBlob(); - - mutable std::mutex _mutex; - LookupTable _lookups; - BlobStorage _blobs; - uint16_t _cur_blob = 0; - uint16_t _cur_off = 0; + static void + write(AtomicType *metric, int64_t val) + { + ink_assert(metric); + return metric->store(val); + } }; // class Counter -} // namespace Metrics +}; // class Metrics } // namespace ts diff --git a/include/iocore/net/quic/QUICStats.h b/include/iocore/net/quic/QUICStats.h index 81fbf84e694..ce48effbb1a 100644 --- a/include/iocore/net/quic/QUICStats.h +++ b/include/iocore/net/quic/QUICStats.h @@ -25,10 +25,10 @@ #include "api/Metrics.h" -using ts::Metrics::Counter; +using ts::Metrics; struct QuicStatsBlock { - Counter::AtomicType *total_packets_sent; + Metrics::Counter::AtomicType *total_packets_sent; }; extern QuicStatsBlock quic_rsb; diff --git a/include/proxy/http/HttpCacheSM.h b/include/proxy/http/HttpCacheSM.h index d51e7d4c28e..6a8b74ed547 100644 --- a/include/proxy/http/HttpCacheSM.h +++ b/include/proxy/http/HttpCacheSM.h @@ -160,7 +160,7 @@ class HttpCacheSM : public Continuation abort_read() { if (cache_read_vc) { - Counter::decrement(http_rsb.current_cache_connections); + Metrics::Counter::decrement(http_rsb.current_cache_connections); cache_read_vc->do_io_close(0); // passing zero as aborting read is not an error cache_read_vc = nullptr; } @@ -169,7 +169,7 @@ class HttpCacheSM : public Continuation abort_write() { if (cache_write_vc) { - Counter::decrement(http_rsb.current_cache_connections); + Metrics::Counter::decrement(http_rsb.current_cache_connections); cache_write_vc->do_io_close(0); // passing zero as aborting write is not an error cache_write_vc = nullptr; } @@ -178,7 +178,7 @@ class HttpCacheSM : public Continuation close_write() { if (cache_write_vc) { - Counter::decrement(http_rsb.current_cache_connections); + Metrics::Counter::decrement(http_rsb.current_cache_connections); cache_write_vc->do_io_close(); cache_write_vc = nullptr; } @@ -187,7 +187,7 @@ class HttpCacheSM : public Continuation close_read() { if (cache_read_vc) { - Counter::decrement(http_rsb.current_cache_connections); + Metrics::Counter::decrement(http_rsb.current_cache_connections); cache_read_vc->do_io_close(); cache_read_vc = nullptr; } diff --git a/include/proxy/http/HttpConfig.h b/include/proxy/http/HttpConfig.h index f149db01936..1bdff09c907 100644 --- a/include/proxy/http/HttpConfig.h +++ b/include/proxy/http/HttpConfig.h @@ -55,254 +55,254 @@ #include "tscpp/util/ts_ip.h" #include "api/Metrics.h" -using ts::Metrics::Counter; +using ts::Metrics; static const unsigned HTTP_STATUS_NUMBER = 600; using HttpStatusBitset = std::bitset; struct HttpStatsBlock { // Need two stats for these for counts and times - Counter::AtomicType *background_fill_bytes_aborted; - Counter::AtomicType *background_fill_bytes_completed; - Counter::AtomicType *background_fill_current_count; - Counter::AtomicType *background_fill_total_count; - Counter::AtomicType *broken_server_connections; - Counter::AtomicType *cache_deletes; - Counter::AtomicType *cache_hit_fresh; - Counter::AtomicType *cache_hit_ims; - Counter::AtomicType *cache_hit_mem_fresh; - Counter::AtomicType *cache_hit_reval; - Counter::AtomicType *cache_hit_rww; - Counter::AtomicType *cache_hit_stale_served; - Counter::AtomicType *cache_lookups; - Counter::AtomicType *cache_miss_changed; - Counter::AtomicType *cache_miss_client_no_cache; - Counter::AtomicType *cache_miss_cold; - Counter::AtomicType *cache_miss_ims; - Counter::AtomicType *cache_miss_uncacheable; - Counter::AtomicType *cache_open_read_begin_time; - Counter::AtomicType *cache_open_read_end_time; - Counter::AtomicType *cache_open_write_adjust_thread; - Counter::AtomicType *cache_open_write_begin_time; - Counter::AtomicType *cache_open_write_end_time; - Counter::AtomicType *cache_read_error; - Counter::AtomicType *cache_read_errors; - Counter::AtomicType *cache_updates; - Counter::AtomicType *cache_write_errors; - Counter::AtomicType *cache_writes; - Counter::AtomicType *completed_requests; - Counter::AtomicType *connect_requests; - Counter::AtomicType *current_active_client_connections; - Counter::AtomicType *current_cache_connections; - Counter::AtomicType *current_client_connections; - Counter::AtomicType *current_client_transactions; - Counter::AtomicType *current_parent_proxy_connections; - Counter::AtomicType *current_server_connections; - Counter::AtomicType *current_server_transactions; - Counter::AtomicType *delete_requests; - Counter::AtomicType *disallowed_post_100_continue; - Counter::AtomicType *dns_lookup_begin_time; - Counter::AtomicType *dns_lookup_end_time; - Counter::AtomicType *down_server_no_requests; - Counter::AtomicType *err_client_abort_count; - Counter::AtomicType *err_client_abort_origin_server_bytes; - Counter::AtomicType *err_client_abort_user_agent_bytes; - Counter::AtomicType *err_client_read_error_count; - Counter::AtomicType *err_client_read_error_origin_server_bytes; - Counter::AtomicType *err_client_read_error_user_agent_bytes; - Counter::AtomicType *err_connect_fail_count; - Counter::AtomicType *err_connect_fail_origin_server_bytes; - Counter::AtomicType *err_connect_fail_user_agent_bytes; - Counter::AtomicType *extension_method_requests; - Counter::AtomicType *get_requests; - Counter::AtomicType *head_requests; - Counter::AtomicType *https_incoming_requests; - Counter::AtomicType *https_total_client_connections; - Counter::AtomicType *incoming_requests; - Counter::AtomicType *incoming_responses; - Counter::AtomicType *invalid_client_requests; - Counter::AtomicType *misc_count; - Counter::AtomicType *misc_origin_server_bytes; - Counter::AtomicType *misc_user_agent_bytes; - Counter::AtomicType *missing_host_hdr; - Counter::AtomicType *options_requests; - Counter::AtomicType *origin_body; - Counter::AtomicType *origin_close_private; - Counter::AtomicType *origin_connect_adjust_thread; - Counter::AtomicType *origin_connections_throttled; - Counter::AtomicType *origin_make_new; - Counter::AtomicType *origin_no_sharing; - Counter::AtomicType *origin_not_found; - Counter::AtomicType *origin_private; - Counter::AtomicType *origin_raw; - Counter::AtomicType *origin_reuse; - Counter::AtomicType *origin_reuse_fail; - Counter::AtomicType *origin_server_request_document_total_size; - Counter::AtomicType *origin_server_request_header_total_size; - Counter::AtomicType *origin_server_response_document_total_size; - Counter::AtomicType *origin_server_response_header_total_size; - Counter::AtomicType *origin_shutdown_cleanup_entry; - Counter::AtomicType *origin_shutdown_migration_failure; - Counter::AtomicType *origin_shutdown_pool_lock_contention; - Counter::AtomicType *origin_shutdown_release_invalid_request; - Counter::AtomicType *origin_shutdown_release_invalid_response; - Counter::AtomicType *origin_shutdown_release_misc; - Counter::AtomicType *origin_shutdown_release_modified; - Counter::AtomicType *origin_shutdown_release_no_keep_alive; - Counter::AtomicType *origin_shutdown_release_no_server; - Counter::AtomicType *origin_shutdown_release_no_sharing; - Counter::AtomicType *origin_shutdown_tunnel_abort; - Counter::AtomicType *origin_shutdown_tunnel_client; - Counter::AtomicType *origin_shutdown_tunnel_server; - Counter::AtomicType *origin_shutdown_tunnel_server_detach; - Counter::AtomicType *origin_shutdown_tunnel_server_eos; - Counter::AtomicType *origin_shutdown_tunnel_server_no_keep_alive; - Counter::AtomicType *origin_shutdown_tunnel_server_plugin_tunnel; - Counter::AtomicType *origin_shutdown_tunnel_transform_read; - Counter::AtomicType *outgoing_requests; - Counter::AtomicType *parent_count; - Counter::AtomicType *parent_proxy_request_total_bytes; - Counter::AtomicType *parent_proxy_response_total_bytes; - Counter::AtomicType *parent_proxy_transaction_time; - Counter::AtomicType *pooled_server_connections; - Counter::AtomicType *post_body_too_large; - Counter::AtomicType *post_requests; - Counter::AtomicType *proxy_loop_detected; - Counter::AtomicType *proxy_mh_loop_detected; - Counter::AtomicType *purge_requests; - Counter::AtomicType *push_requests; - Counter::AtomicType *pushed_document_total_size; - Counter::AtomicType *pushed_response_header_total_size; - Counter::AtomicType *put_requests; - Counter::AtomicType *response_status_100_count; - Counter::AtomicType *response_status_101_count; - Counter::AtomicType *response_status_1xx_count; - Counter::AtomicType *response_status_200_count; - Counter::AtomicType *response_status_201_count; - Counter::AtomicType *response_status_202_count; - Counter::AtomicType *response_status_203_count; - Counter::AtomicType *response_status_204_count; - Counter::AtomicType *response_status_205_count; - Counter::AtomicType *response_status_206_count; - Counter::AtomicType *response_status_2xx_count; - Counter::AtomicType *response_status_300_count; - Counter::AtomicType *response_status_301_count; - Counter::AtomicType *response_status_302_count; - Counter::AtomicType *response_status_303_count; - Counter::AtomicType *response_status_304_count; - Counter::AtomicType *response_status_305_count; - Counter::AtomicType *response_status_307_count; - Counter::AtomicType *response_status_308_count; - Counter::AtomicType *response_status_3xx_count; - Counter::AtomicType *response_status_400_count; - Counter::AtomicType *response_status_401_count; - Counter::AtomicType *response_status_402_count; - Counter::AtomicType *response_status_403_count; - Counter::AtomicType *response_status_404_count; - Counter::AtomicType *response_status_405_count; - Counter::AtomicType *response_status_406_count; - Counter::AtomicType *response_status_407_count; - Counter::AtomicType *response_status_408_count; - Counter::AtomicType *response_status_409_count; - Counter::AtomicType *response_status_410_count; - Counter::AtomicType *response_status_411_count; - Counter::AtomicType *response_status_412_count; - Counter::AtomicType *response_status_413_count; - Counter::AtomicType *response_status_414_count; - Counter::AtomicType *response_status_415_count; - Counter::AtomicType *response_status_416_count; - Counter::AtomicType *response_status_4xx_count; - Counter::AtomicType *response_status_500_count; - Counter::AtomicType *response_status_501_count; - Counter::AtomicType *response_status_502_count; - Counter::AtomicType *response_status_503_count; - Counter::AtomicType *response_status_504_count; - Counter::AtomicType *response_status_505_count; - Counter::AtomicType *response_status_5xx_count; - Counter::AtomicType *server_begin_write_time; - Counter::AtomicType *server_close_time; - Counter::AtomicType *server_connect_end_time; - Counter::AtomicType *server_connect_time; - Counter::AtomicType *server_first_connect_time; - Counter::AtomicType *server_first_read_time; - Counter::AtomicType *server_read_header_done_time; - Counter::AtomicType *sm_finish_time; - Counter::AtomicType *sm_start_time; - Counter::AtomicType *tcp_client_refresh_count; - Counter::AtomicType *tcp_client_refresh_origin_server_bytes; - Counter::AtomicType *tcp_client_refresh_user_agent_bytes; - Counter::AtomicType *tcp_expired_miss_count; - Counter::AtomicType *tcp_expired_miss_origin_server_bytes; - Counter::AtomicType *tcp_expired_miss_user_agent_bytes; - Counter::AtomicType *tcp_hit_count; - Counter::AtomicType *tcp_hit_origin_server_bytes; - Counter::AtomicType *tcp_hit_user_agent_bytes; - Counter::AtomicType *tcp_ims_hit_count; - Counter::AtomicType *tcp_ims_hit_origin_server_bytes; - Counter::AtomicType *tcp_ims_hit_user_agent_bytes; - Counter::AtomicType *tcp_ims_miss_count; - Counter::AtomicType *tcp_ims_miss_origin_server_bytes; - Counter::AtomicType *tcp_ims_miss_user_agent_bytes; - Counter::AtomicType *tcp_miss_count; - Counter::AtomicType *tcp_miss_origin_server_bytes; - Counter::AtomicType *tcp_miss_user_agent_bytes; - Counter::AtomicType *tcp_refresh_hit_count; - Counter::AtomicType *tcp_refresh_hit_origin_server_bytes; - Counter::AtomicType *tcp_refresh_hit_user_agent_bytes; - Counter::AtomicType *tcp_refresh_miss_count; - Counter::AtomicType *tcp_refresh_miss_origin_server_bytes; - Counter::AtomicType *tcp_refresh_miss_user_agent_bytes; - Counter::AtomicType *total_client_connections; - Counter::AtomicType *total_client_connections_ipv4; - Counter::AtomicType *total_client_connections_ipv6; - Counter::AtomicType *total_incoming_connections; - Counter::AtomicType *total_parent_marked_down_count; - Counter::AtomicType *total_parent_proxy_connections; - Counter::AtomicType *total_parent_retries; - Counter::AtomicType *total_parent_retries_exhausted; - Counter::AtomicType *total_parent_switches; - Counter::AtomicType *total_server_connections; - Counter::AtomicType *total_transactions_time; - Counter::AtomicType *total_x_redirect; - Counter::AtomicType *trace_requests; - Counter::AtomicType *tunnel_current_active_connections; - Counter::AtomicType *tunnels; - Counter::AtomicType *ua_begin_time; - Counter::AtomicType *ua_begin_write_time; - Counter::AtomicType *ua_close_time; - Counter::AtomicType *ua_counts_errors_aborts; - Counter::AtomicType *ua_counts_errors_connect_failed; - Counter::AtomicType *ua_counts_errors_other; - Counter::AtomicType *ua_counts_errors_possible_aborts; - Counter::AtomicType *ua_counts_errors_pre_accept_hangups; - Counter::AtomicType *ua_counts_hit_fresh; - Counter::AtomicType *ua_counts_hit_fresh_process; - Counter::AtomicType *ua_counts_hit_reval; - Counter::AtomicType *ua_counts_miss_changed; - Counter::AtomicType *ua_counts_miss_client_no_cache; - Counter::AtomicType *ua_counts_miss_cold; - Counter::AtomicType *ua_counts_miss_uncacheable; - Counter::AtomicType *ua_counts_other_unclassified; - Counter::AtomicType *ua_first_read_time; - Counter::AtomicType *ua_msecs_errors_aborts; - Counter::AtomicType *ua_msecs_errors_connect_failed; - Counter::AtomicType *ua_msecs_errors_other; - Counter::AtomicType *ua_msecs_errors_possible_aborts; - Counter::AtomicType *ua_msecs_errors_pre_accept_hangups; - Counter::AtomicType *ua_msecs_hit_fresh; - Counter::AtomicType *ua_msecs_hit_fresh_process; - Counter::AtomicType *ua_msecs_hit_reval; - Counter::AtomicType *ua_msecs_miss_changed; - Counter::AtomicType *ua_msecs_miss_client_no_cache; - Counter::AtomicType *ua_msecs_miss_cold; - Counter::AtomicType *ua_msecs_miss_uncacheable; - Counter::AtomicType *ua_msecs_other_unclassified; - Counter::AtomicType *ua_read_header_done_time; - Counter::AtomicType *user_agent_request_document_total_size; - Counter::AtomicType *user_agent_request_header_total_size; - Counter::AtomicType *user_agent_response_document_total_size; - Counter::AtomicType *user_agent_response_header_total_size; - Counter::AtomicType *websocket_current_active_client_connections; + Metrics::Counter::AtomicType *background_fill_bytes_aborted; + Metrics::Counter::AtomicType *background_fill_bytes_completed; + Metrics::Counter::AtomicType *background_fill_current_count; + Metrics::Counter::AtomicType *background_fill_total_count; + Metrics::Counter::AtomicType *broken_server_connections; + Metrics::Counter::AtomicType *cache_deletes; + Metrics::Counter::AtomicType *cache_hit_fresh; + Metrics::Counter::AtomicType *cache_hit_ims; + Metrics::Counter::AtomicType *cache_hit_mem_fresh; + Metrics::Counter::AtomicType *cache_hit_reval; + Metrics::Counter::AtomicType *cache_hit_rww; + Metrics::Counter::AtomicType *cache_hit_stale_served; + Metrics::Counter::AtomicType *cache_lookups; + Metrics::Counter::AtomicType *cache_miss_changed; + Metrics::Counter::AtomicType *cache_miss_client_no_cache; + Metrics::Counter::AtomicType *cache_miss_cold; + Metrics::Counter::AtomicType *cache_miss_ims; + Metrics::Counter::AtomicType *cache_miss_uncacheable; + Metrics::Counter::AtomicType *cache_open_read_begin_time; + Metrics::Counter::AtomicType *cache_open_read_end_time; + Metrics::Counter::AtomicType *cache_open_write_adjust_thread; + Metrics::Counter::AtomicType *cache_open_write_begin_time; + Metrics::Counter::AtomicType *cache_open_write_end_time; + Metrics::Counter::AtomicType *cache_read_error; + Metrics::Counter::AtomicType *cache_read_errors; + Metrics::Counter::AtomicType *cache_updates; + Metrics::Counter::AtomicType *cache_write_errors; + Metrics::Counter::AtomicType *cache_writes; + Metrics::Counter::AtomicType *completed_requests; + Metrics::Counter::AtomicType *connect_requests; + Metrics::Counter::AtomicType *current_active_client_connections; + Metrics::Counter::AtomicType *current_cache_connections; + Metrics::Counter::AtomicType *current_client_connections; + Metrics::Counter::AtomicType *current_client_transactions; + Metrics::Counter::AtomicType *current_parent_proxy_connections; + Metrics::Counter::AtomicType *current_server_connections; + Metrics::Counter::AtomicType *current_server_transactions; + Metrics::Counter::AtomicType *delete_requests; + Metrics::Counter::AtomicType *disallowed_post_100_continue; + Metrics::Counter::AtomicType *dns_lookup_begin_time; + Metrics::Counter::AtomicType *dns_lookup_end_time; + Metrics::Counter::AtomicType *down_server_no_requests; + Metrics::Counter::AtomicType *err_client_abort_count; + Metrics::Counter::AtomicType *err_client_abort_origin_server_bytes; + Metrics::Counter::AtomicType *err_client_abort_user_agent_bytes; + Metrics::Counter::AtomicType *err_client_read_error_count; + Metrics::Counter::AtomicType *err_client_read_error_origin_server_bytes; + Metrics::Counter::AtomicType *err_client_read_error_user_agent_bytes; + Metrics::Counter::AtomicType *err_connect_fail_count; + Metrics::Counter::AtomicType *err_connect_fail_origin_server_bytes; + Metrics::Counter::AtomicType *err_connect_fail_user_agent_bytes; + Metrics::Counter::AtomicType *extension_method_requests; + Metrics::Counter::AtomicType *get_requests; + Metrics::Counter::AtomicType *head_requests; + Metrics::Counter::AtomicType *https_incoming_requests; + Metrics::Counter::AtomicType *https_total_client_connections; + Metrics::Counter::AtomicType *incoming_requests; + Metrics::Counter::AtomicType *incoming_responses; + Metrics::Counter::AtomicType *invalid_client_requests; + Metrics::Counter::AtomicType *misc_count; + Metrics::Counter::AtomicType *misc_origin_server_bytes; + Metrics::Counter::AtomicType *misc_user_agent_bytes; + Metrics::Counter::AtomicType *missing_host_hdr; + Metrics::Counter::AtomicType *options_requests; + Metrics::Counter::AtomicType *origin_body; + Metrics::Counter::AtomicType *origin_close_private; + Metrics::Counter::AtomicType *origin_connect_adjust_thread; + Metrics::Counter::AtomicType *origin_connections_throttled; + Metrics::Counter::AtomicType *origin_make_new; + Metrics::Counter::AtomicType *origin_no_sharing; + Metrics::Counter::AtomicType *origin_not_found; + Metrics::Counter::AtomicType *origin_private; + Metrics::Counter::AtomicType *origin_raw; + Metrics::Counter::AtomicType *origin_reuse; + Metrics::Counter::AtomicType *origin_reuse_fail; + Metrics::Counter::AtomicType *origin_server_request_document_total_size; + Metrics::Counter::AtomicType *origin_server_request_header_total_size; + Metrics::Counter::AtomicType *origin_server_response_document_total_size; + Metrics::Counter::AtomicType *origin_server_response_header_total_size; + Metrics::Counter::AtomicType *origin_shutdown_cleanup_entry; + Metrics::Counter::AtomicType *origin_shutdown_migration_failure; + Metrics::Counter::AtomicType *origin_shutdown_pool_lock_contention; + Metrics::Counter::AtomicType *origin_shutdown_release_invalid_request; + Metrics::Counter::AtomicType *origin_shutdown_release_invalid_response; + Metrics::Counter::AtomicType *origin_shutdown_release_misc; + Metrics::Counter::AtomicType *origin_shutdown_release_modified; + Metrics::Counter::AtomicType *origin_shutdown_release_no_keep_alive; + Metrics::Counter::AtomicType *origin_shutdown_release_no_server; + Metrics::Counter::AtomicType *origin_shutdown_release_no_sharing; + Metrics::Counter::AtomicType *origin_shutdown_tunnel_abort; + Metrics::Counter::AtomicType *origin_shutdown_tunnel_client; + Metrics::Counter::AtomicType *origin_shutdown_tunnel_server; + Metrics::Counter::AtomicType *origin_shutdown_tunnel_server_detach; + Metrics::Counter::AtomicType *origin_shutdown_tunnel_server_eos; + Metrics::Counter::AtomicType *origin_shutdown_tunnel_server_no_keep_alive; + Metrics::Counter::AtomicType *origin_shutdown_tunnel_server_plugin_tunnel; + Metrics::Counter::AtomicType *origin_shutdown_tunnel_transform_read; + Metrics::Counter::AtomicType *outgoing_requests; + Metrics::Counter::AtomicType *parent_count; + Metrics::Counter::AtomicType *parent_proxy_request_total_bytes; + Metrics::Counter::AtomicType *parent_proxy_response_total_bytes; + Metrics::Counter::AtomicType *parent_proxy_transaction_time; + Metrics::Counter::AtomicType *pooled_server_connections; + Metrics::Counter::AtomicType *post_body_too_large; + Metrics::Counter::AtomicType *post_requests; + Metrics::Counter::AtomicType *proxy_loop_detected; + Metrics::Counter::AtomicType *proxy_mh_loop_detected; + Metrics::Counter::AtomicType *purge_requests; + Metrics::Counter::AtomicType *push_requests; + Metrics::Counter::AtomicType *pushed_document_total_size; + Metrics::Counter::AtomicType *pushed_response_header_total_size; + Metrics::Counter::AtomicType *put_requests; + Metrics::Counter::AtomicType *response_status_100_count; + Metrics::Counter::AtomicType *response_status_101_count; + Metrics::Counter::AtomicType *response_status_1xx_count; + Metrics::Counter::AtomicType *response_status_200_count; + Metrics::Counter::AtomicType *response_status_201_count; + Metrics::Counter::AtomicType *response_status_202_count; + Metrics::Counter::AtomicType *response_status_203_count; + Metrics::Counter::AtomicType *response_status_204_count; + Metrics::Counter::AtomicType *response_status_205_count; + Metrics::Counter::AtomicType *response_status_206_count; + Metrics::Counter::AtomicType *response_status_2xx_count; + Metrics::Counter::AtomicType *response_status_300_count; + Metrics::Counter::AtomicType *response_status_301_count; + Metrics::Counter::AtomicType *response_status_302_count; + Metrics::Counter::AtomicType *response_status_303_count; + Metrics::Counter::AtomicType *response_status_304_count; + Metrics::Counter::AtomicType *response_status_305_count; + Metrics::Counter::AtomicType *response_status_307_count; + Metrics::Counter::AtomicType *response_status_308_count; + Metrics::Counter::AtomicType *response_status_3xx_count; + Metrics::Counter::AtomicType *response_status_400_count; + Metrics::Counter::AtomicType *response_status_401_count; + Metrics::Counter::AtomicType *response_status_402_count; + Metrics::Counter::AtomicType *response_status_403_count; + Metrics::Counter::AtomicType *response_status_404_count; + Metrics::Counter::AtomicType *response_status_405_count; + Metrics::Counter::AtomicType *response_status_406_count; + Metrics::Counter::AtomicType *response_status_407_count; + Metrics::Counter::AtomicType *response_status_408_count; + Metrics::Counter::AtomicType *response_status_409_count; + Metrics::Counter::AtomicType *response_status_410_count; + Metrics::Counter::AtomicType *response_status_411_count; + Metrics::Counter::AtomicType *response_status_412_count; + Metrics::Counter::AtomicType *response_status_413_count; + Metrics::Counter::AtomicType *response_status_414_count; + Metrics::Counter::AtomicType *response_status_415_count; + Metrics::Counter::AtomicType *response_status_416_count; + Metrics::Counter::AtomicType *response_status_4xx_count; + Metrics::Counter::AtomicType *response_status_500_count; + Metrics::Counter::AtomicType *response_status_501_count; + Metrics::Counter::AtomicType *response_status_502_count; + Metrics::Counter::AtomicType *response_status_503_count; + Metrics::Counter::AtomicType *response_status_504_count; + Metrics::Counter::AtomicType *response_status_505_count; + Metrics::Counter::AtomicType *response_status_5xx_count; + Metrics::Counter::AtomicType *server_begin_write_time; + Metrics::Counter::AtomicType *server_close_time; + Metrics::Counter::AtomicType *server_connect_end_time; + Metrics::Counter::AtomicType *server_connect_time; + Metrics::Counter::AtomicType *server_first_connect_time; + Metrics::Counter::AtomicType *server_first_read_time; + Metrics::Counter::AtomicType *server_read_header_done_time; + Metrics::Counter::AtomicType *sm_finish_time; + Metrics::Counter::AtomicType *sm_start_time; + Metrics::Counter::AtomicType *tcp_client_refresh_count; + Metrics::Counter::AtomicType *tcp_client_refresh_origin_server_bytes; + Metrics::Counter::AtomicType *tcp_client_refresh_user_agent_bytes; + Metrics::Counter::AtomicType *tcp_expired_miss_count; + Metrics::Counter::AtomicType *tcp_expired_miss_origin_server_bytes; + Metrics::Counter::AtomicType *tcp_expired_miss_user_agent_bytes; + Metrics::Counter::AtomicType *tcp_hit_count; + Metrics::Counter::AtomicType *tcp_hit_origin_server_bytes; + Metrics::Counter::AtomicType *tcp_hit_user_agent_bytes; + Metrics::Counter::AtomicType *tcp_ims_hit_count; + Metrics::Counter::AtomicType *tcp_ims_hit_origin_server_bytes; + Metrics::Counter::AtomicType *tcp_ims_hit_user_agent_bytes; + Metrics::Counter::AtomicType *tcp_ims_miss_count; + Metrics::Counter::AtomicType *tcp_ims_miss_origin_server_bytes; + Metrics::Counter::AtomicType *tcp_ims_miss_user_agent_bytes; + Metrics::Counter::AtomicType *tcp_miss_count; + Metrics::Counter::AtomicType *tcp_miss_origin_server_bytes; + Metrics::Counter::AtomicType *tcp_miss_user_agent_bytes; + Metrics::Counter::AtomicType *tcp_refresh_hit_count; + Metrics::Counter::AtomicType *tcp_refresh_hit_origin_server_bytes; + Metrics::Counter::AtomicType *tcp_refresh_hit_user_agent_bytes; + Metrics::Counter::AtomicType *tcp_refresh_miss_count; + Metrics::Counter::AtomicType *tcp_refresh_miss_origin_server_bytes; + Metrics::Counter::AtomicType *tcp_refresh_miss_user_agent_bytes; + Metrics::Counter::AtomicType *total_client_connections; + Metrics::Counter::AtomicType *total_client_connections_ipv4; + Metrics::Counter::AtomicType *total_client_connections_ipv6; + Metrics::Counter::AtomicType *total_incoming_connections; + Metrics::Counter::AtomicType *total_parent_marked_down_count; + Metrics::Counter::AtomicType *total_parent_proxy_connections; + Metrics::Counter::AtomicType *total_parent_retries; + Metrics::Counter::AtomicType *total_parent_retries_exhausted; + Metrics::Counter::AtomicType *total_parent_switches; + Metrics::Counter::AtomicType *total_server_connections; + Metrics::Counter::AtomicType *total_transactions_time; + Metrics::Counter::AtomicType *total_x_redirect; + Metrics::Counter::AtomicType *trace_requests; + Metrics::Counter::AtomicType *tunnel_current_active_connections; + Metrics::Counter::AtomicType *tunnels; + Metrics::Counter::AtomicType *ua_begin_time; + Metrics::Counter::AtomicType *ua_begin_write_time; + Metrics::Counter::AtomicType *ua_close_time; + Metrics::Counter::AtomicType *ua_counts_errors_aborts; + Metrics::Counter::AtomicType *ua_counts_errors_connect_failed; + Metrics::Counter::AtomicType *ua_counts_errors_other; + Metrics::Counter::AtomicType *ua_counts_errors_possible_aborts; + Metrics::Counter::AtomicType *ua_counts_errors_pre_accept_hangups; + Metrics::Counter::AtomicType *ua_counts_hit_fresh; + Metrics::Counter::AtomicType *ua_counts_hit_fresh_process; + Metrics::Counter::AtomicType *ua_counts_hit_reval; + Metrics::Counter::AtomicType *ua_counts_miss_changed; + Metrics::Counter::AtomicType *ua_counts_miss_client_no_cache; + Metrics::Counter::AtomicType *ua_counts_miss_cold; + Metrics::Counter::AtomicType *ua_counts_miss_uncacheable; + Metrics::Counter::AtomicType *ua_counts_other_unclassified; + Metrics::Counter::AtomicType *ua_first_read_time; + Metrics::Counter::AtomicType *ua_msecs_errors_aborts; + Metrics::Counter::AtomicType *ua_msecs_errors_connect_failed; + Metrics::Counter::AtomicType *ua_msecs_errors_other; + Metrics::Counter::AtomicType *ua_msecs_errors_possible_aborts; + Metrics::Counter::AtomicType *ua_msecs_errors_pre_accept_hangups; + Metrics::Counter::AtomicType *ua_msecs_hit_fresh; + Metrics::Counter::AtomicType *ua_msecs_hit_fresh_process; + Metrics::Counter::AtomicType *ua_msecs_hit_reval; + Metrics::Counter::AtomicType *ua_msecs_miss_changed; + Metrics::Counter::AtomicType *ua_msecs_miss_client_no_cache; + Metrics::Counter::AtomicType *ua_msecs_miss_cold; + Metrics::Counter::AtomicType *ua_msecs_miss_uncacheable; + Metrics::Counter::AtomicType *ua_msecs_other_unclassified; + Metrics::Counter::AtomicType *ua_read_header_done_time; + Metrics::Counter::AtomicType *user_agent_request_document_total_size; + Metrics::Counter::AtomicType *user_agent_request_header_total_size; + Metrics::Counter::AtomicType *user_agent_response_document_total_size; + Metrics::Counter::AtomicType *user_agent_response_header_total_size; + Metrics::Counter::AtomicType *websocket_current_active_client_connections; }; enum CacheOpenWriteFailAction_t { diff --git a/include/proxy/http/PreWarmManager.h b/include/proxy/http/PreWarmManager.h index a33dafcd7d1..dd37fc09484 100644 --- a/include/proxy/http/PreWarmManager.h +++ b/include/proxy/http/PreWarmManager.h @@ -39,7 +39,7 @@ #include "api/Metrics.h" -using ts::Metrics::Counter; +using ts::Metrics; // tscore #include "tscore/CryptoHash.h" @@ -123,7 +123,7 @@ enum class Stat { LAST_ENTRY, }; -using StatsIds = std::array(PreWarm::Stat::LAST_ENTRY)>; +using StatsIds = std::array(PreWarm::Stat::LAST_ENTRY)>; using SPtrConstStatsIds = std::shared_ptr; using StatsIdMap = std::unordered_map; } // namespace PreWarm diff --git a/include/proxy/http2/HTTP2.h b/include/proxy/http2/HTTP2.h index 59b41b5873b..18e136c1454 100644 --- a/include/proxy/http2/HTTP2.h +++ b/include/proxy/http2/HTTP2.h @@ -31,7 +31,7 @@ #include "api/Metrics.h" -using ts::Metrics::Counter; +using ts::Metrics; class HTTPHdr; @@ -77,35 +77,35 @@ const uint8_t HTTP2_PRIORITY_DEFAULT_WEIGHT = 15; // Statistics struct Http2StatsBlock { - Counter::AtomicType *current_client_session_count; - Counter::AtomicType *current_server_session_count; - Counter::AtomicType *current_active_client_connection_count; - Counter::AtomicType *current_active_server_connection_count; - Counter::AtomicType *current_client_stream_count; - Counter::AtomicType *current_server_stream_count; - Counter::AtomicType *total_client_stream_count; - Counter::AtomicType *total_server_stream_count; - Counter::AtomicType *total_transactions_time; - Counter::AtomicType *total_client_connection_count; - Counter::AtomicType *total_server_connection_count; - Counter::AtomicType *stream_errors_count; - Counter::AtomicType *connection_errors_count; - Counter::AtomicType *session_die_default; - Counter::AtomicType *session_die_other; - Counter::AtomicType *session_die_active; - Counter::AtomicType *session_die_inactive; - Counter::AtomicType *session_die_eos; - Counter::AtomicType *session_die_error; - Counter::AtomicType *session_die_high_error_rate; - Counter::AtomicType *max_settings_per_frame_exceeded; - Counter::AtomicType *max_settings_per_minute_exceeded; - Counter::AtomicType *max_settings_frames_per_minute_exceeded; - Counter::AtomicType *max_ping_frames_per_minute_exceeded; - Counter::AtomicType *max_priority_frames_per_minute_exceeded; - Counter::AtomicType *max_rst_stream_frames_per_minute_exceeded; - Counter::AtomicType *insufficient_avg_window_update; - Counter::AtomicType *max_concurrent_streams_exceeded_in; - Counter::AtomicType *max_concurrent_streams_exceeded_out; + Metrics::Counter::AtomicType *current_client_session_count; + Metrics::Counter::AtomicType *current_server_session_count; + Metrics::Counter::AtomicType *current_active_client_connection_count; + Metrics::Counter::AtomicType *current_active_server_connection_count; + Metrics::Counter::AtomicType *current_client_stream_count; + Metrics::Counter::AtomicType *current_server_stream_count; + Metrics::Counter::AtomicType *total_client_stream_count; + Metrics::Counter::AtomicType *total_server_stream_count; + Metrics::Counter::AtomicType *total_transactions_time; + Metrics::Counter::AtomicType *total_client_connection_count; + Metrics::Counter::AtomicType *total_server_connection_count; + Metrics::Counter::AtomicType *stream_errors_count; + Metrics::Counter::AtomicType *connection_errors_count; + Metrics::Counter::AtomicType *session_die_default; + Metrics::Counter::AtomicType *session_die_other; + Metrics::Counter::AtomicType *session_die_active; + Metrics::Counter::AtomicType *session_die_inactive; + Metrics::Counter::AtomicType *session_die_eos; + Metrics::Counter::AtomicType *session_die_error; + Metrics::Counter::AtomicType *session_die_high_error_rate; + Metrics::Counter::AtomicType *max_settings_per_frame_exceeded; + Metrics::Counter::AtomicType *max_settings_per_minute_exceeded; + Metrics::Counter::AtomicType *max_settings_frames_per_minute_exceeded; + Metrics::Counter::AtomicType *max_ping_frames_per_minute_exceeded; + Metrics::Counter::AtomicType *max_priority_frames_per_minute_exceeded; + Metrics::Counter::AtomicType *max_rst_stream_frames_per_minute_exceeded; + Metrics::Counter::AtomicType *insufficient_avg_window_update; + Metrics::Counter::AtomicType *max_concurrent_streams_exceeded_in; + Metrics::Counter::AtomicType *max_concurrent_streams_exceeded_out; }; extern Http2StatsBlock http2_rsb; diff --git a/include/proxy/http2/Http2ServerSession.h b/include/proxy/http2/Http2ServerSession.h index 97f80df8d2b..9500299d55c 100644 --- a/include/proxy/http2/Http2ServerSession.h +++ b/include/proxy/http2/Http2ServerSession.h @@ -72,13 +72,13 @@ class Http2ServerSession : public PoolableSession, public Http2CommonSession void increment_current_active_connections_stat() override { - Counter::increment(http2_rsb.current_active_server_connection_count); + Metrics::Counter::increment(http2_rsb.current_active_server_connection_count); } void decrement_current_active_connections_stat() override { - Counter::decrement(http2_rsb.current_active_server_connection_count); + Metrics::Counter::decrement(http2_rsb.current_active_server_connection_count); } // noncopyable diff --git a/include/proxy/http3/Http3.h b/include/proxy/http3/Http3.h index 02febc45b85..8e916418563 100644 --- a/include/proxy/http3/Http3.h +++ b/include/proxy/http3/Http3.h @@ -26,7 +26,7 @@ #include "tscore/ink_defs.h" #include "api/Metrics.h" -using ts::Metrics::Counter; +using ts::Metrics; extern const uint32_t HTTP3_DEFAULT_HEADER_TABLE_SIZE; extern const uint32_t HTTP3_DEFAULT_MAX_FIELD_SECTION_SIZE; @@ -41,9 +41,9 @@ class Http3 // Statistics struct Http3StatsBlock { - // Example: Counter::AtomicType *current_client_session_count; + // Example: Metrics::Counter::AtomicType *current_client_session_count; // Once created, e.g. - // Counter::increment(http3_rsb.current_client_session_count); + // Metrics::Counter::increment(http3_rsb.current_client_session_count); }; extern Http3StatsBlock http3_rsb; // Container for statistics. diff --git a/include/proxy/logging/LogConfig.h b/include/proxy/logging/LogConfig.h index 137fa0b4a56..ece1f3c30ca 100644 --- a/include/proxy/logging/LogConfig.h +++ b/include/proxy/logging/LogConfig.h @@ -34,34 +34,34 @@ #include "swoc/MemSpan.h" #include "api/Metrics.h" -using ts::Metrics::Counter; +using ts::Metrics; struct LogsStatsBlock { - Counter::AtomicType *event_log_error_ok; - Counter::AtomicType *event_log_error_skip; - Counter::AtomicType *event_log_error_aggr; - Counter::AtomicType *event_log_error_full; - Counter::AtomicType *event_log_error_fail; - Counter::AtomicType *event_log_access_ok; - Counter::AtomicType *event_log_access_skip; - Counter::AtomicType *event_log_access_aggr; - Counter::AtomicType *event_log_access_full; - Counter::AtomicType *event_log_access_fail; - Counter::AtomicType *num_sent_to_network; - Counter::AtomicType *num_lost_before_sent_to_network; - Counter::AtomicType *num_received_from_network; - Counter::AtomicType *num_flush_to_disk; - Counter::AtomicType *num_lost_before_flush_to_disk; - Counter::AtomicType *bytes_lost_before_preproc; - Counter::AtomicType *bytes_sent_to_network; - Counter::AtomicType *bytes_lost_before_sent_to_network; - Counter::AtomicType *bytes_received_from_network; - Counter::AtomicType *bytes_flush_to_disk; - Counter::AtomicType *bytes_lost_before_flush_to_disk; - Counter::AtomicType *bytes_written_to_disk; - Counter::AtomicType *bytes_lost_before_written_to_disk; - Counter::AtomicType *log_files_open; - Counter::AtomicType *log_files_space_used; + Metrics::Counter::AtomicType *event_log_error_ok; + Metrics::Counter::AtomicType *event_log_error_skip; + Metrics::Counter::AtomicType *event_log_error_aggr; + Metrics::Counter::AtomicType *event_log_error_full; + Metrics::Counter::AtomicType *event_log_error_fail; + Metrics::Counter::AtomicType *event_log_access_ok; + Metrics::Counter::AtomicType *event_log_access_skip; + Metrics::Counter::AtomicType *event_log_access_aggr; + Metrics::Counter::AtomicType *event_log_access_full; + Metrics::Counter::AtomicType *event_log_access_fail; + Metrics::Counter::AtomicType *num_sent_to_network; + Metrics::Counter::AtomicType *num_lost_before_sent_to_network; + Metrics::Counter::AtomicType *num_received_from_network; + Metrics::Counter::AtomicType *num_flush_to_disk; + Metrics::Counter::AtomicType *num_lost_before_flush_to_disk; + Metrics::Counter::AtomicType *bytes_lost_before_preproc; + Metrics::Counter::AtomicType *bytes_sent_to_network; + Metrics::Counter::AtomicType *bytes_lost_before_sent_to_network; + Metrics::Counter::AtomicType *bytes_received_from_network; + Metrics::Counter::AtomicType *bytes_flush_to_disk; + Metrics::Counter::AtomicType *bytes_lost_before_flush_to_disk; + Metrics::Counter::AtomicType *bytes_written_to_disk; + Metrics::Counter::AtomicType *bytes_lost_before_written_to_disk; + Metrics::Counter::AtomicType *log_files_open; + Metrics::Counter::AtomicType *log_files_space_used; }; extern LogsStatsBlock log_rsb; diff --git a/src/api/InkAPI.cc b/src/api/InkAPI.cc index 57a3a59a505..9213340547c 100644 --- a/src/api/InkAPI.cc +++ b/src/api/InkAPI.cc @@ -393,8 +393,8 @@ namespace c } // end namespace c } // end namespace tsapi -ConfigUpdateCbTable *global_config_cbs = nullptr; -static ts::Metrics::Counter &global_api_metrics = ts::Metrics::Counter::getInstance(); +ConfigUpdateCbTable *global_config_cbs = nullptr; +static ts::Metrics &global_api_metrics = ts::Metrics::instance(); static char traffic_server_version[128] = ""; static int ts_major_version = 0; @@ -4027,7 +4027,7 @@ tsapi::c::TSMgmtIntGet(const char *var_name, TSMgmtInt *result) if (res == REC_ERR_FAIL) { int id = global_api_metrics.lookup(var_name); - if (id == ts::Metrics::Counter::NOT_FOUND) { + if (id == ts::Metrics::NOT_FOUND) { return TS_ERROR; } else { *result = global_api_metrics[id].load(); @@ -4046,7 +4046,7 @@ tsapi::c::TSMgmtCounterGet(const char *var_name, TSMgmtCounter *result) if (res == REC_ERR_FAIL) { int id = global_api_metrics.lookup(var_name); - if (id == ts::Metrics::Counter::NOT_FOUND) { + if (id == ts::Metrics::NOT_FOUND) { return TS_ERROR; } else { *result = global_api_metrics[id].load(); @@ -6165,20 +6165,20 @@ tsapi::c::TSHttpTxnLookingUpTypeGet(TSHttpTxn txnp) int tsapi::c::TSHttpCurrentClientConnectionsGet() { - return Counter::read(http_rsb.current_client_connections); + return Metrics::Counter::read(http_rsb.current_client_connections); } int tsapi::c::TSHttpCurrentActiveClientConnectionsGet() { - return Counter::read(http_rsb.current_active_client_connections); + return Metrics::Counter::read(http_rsb.current_active_client_connections); } int tsapi::c::TSHttpCurrentIdleClientConnectionsGet() { - int64_t total = Counter::read(http_rsb.current_client_connections); - int64_t active = Counter::read(http_rsb.current_active_client_connections); + int64_t total = Metrics::Counter::read(http_rsb.current_client_connections); + int64_t active = Metrics::Counter::read(http_rsb.current_active_client_connections); if (total >= active) { return static_cast(total - active); @@ -6190,13 +6190,13 @@ tsapi::c::TSHttpCurrentIdleClientConnectionsGet() int tsapi::c::TSHttpCurrentCacheConnectionsGet() { - return Counter::read(http_rsb.current_cache_connections); + return Metrics::Counter::read(http_rsb.current_cache_connections); } int tsapi::c::TSHttpCurrentServerConnectionsGet() { - return Counter::read(http_rsb.current_server_connections); + return Metrics::Counter::read(http_rsb.current_server_connections); } /* HTTP alternate selection */ @@ -6999,9 +6999,9 @@ tsapi::c::TSCacheScan(TSCont contp, TSCacheKey key, int KB_per_second) int tsapi::c::TSStatCreate(const char *the_name, TSRecordDataType the_type, TSStatPersistence persist, TSStatSync sync) { - int id = global_api_metrics.create(the_name); + int id = Metrics::Gauge::create(the_name); // Gauges allows for all "int" operations - if (id == ts::Metrics::Counter::NOT_FOUND) { + if (id == ts::Metrics::NOT_FOUND) { return TS_ERROR; } @@ -7012,14 +7012,14 @@ void tsapi::c::TSStatIntIncrement(int id, TSMgmtInt amount) { sdk_assert(sdk_sanity_check_stat_id(id) == TS_SUCCESS); - global_api_metrics[id].fetch_add(amount, ts::Metrics::Counter::MEMORY_ORDER); + global_api_metrics[id].fetch_add(amount, ts::Metrics::MEMORY_ORDER); } void tsapi::c::TSStatIntDecrement(int id, TSMgmtInt amount) { sdk_assert(sdk_sanity_check_stat_id(id) == TS_SUCCESS); - global_api_metrics[id].fetch_sub(amount, ts::Metrics::Counter::MEMORY_ORDER); + global_api_metrics[id].fetch_sub(amount, ts::Metrics::MEMORY_ORDER); } tsapi::c::TSMgmtInt @@ -7044,7 +7044,7 @@ tsapi::c::TSStatFindName(const char *name, int *idp) int id = global_api_metrics.lookup(name); - if (id == ts::Metrics::Counter::NOT_FOUND) { + if (id == ts::Metrics::NOT_FOUND) { return TS_ERROR; } else { *idp = id; diff --git a/src/api/Metrics.cc b/src/api/Metrics.cc index 5d8e5ae75ee..6736bcfb750 100644 --- a/src/api/Metrics.cc +++ b/src/api/Metrics.cc @@ -1,6 +1,6 @@ /** @file - The implementations of the Counter API class. + The implementations of the Metrics::Counter API class. @section license License @@ -25,168 +25,164 @@ namespace ts { -namespace Metrics + +// This is the singleton instance of the metrics class. +Metrics & +Metrics::instance() { + static Metrics _instance; - // This is the singleton instance of the metrics class. - Counter & - Counter::getInstance() - { - static Counter _instance; + return _instance; +} - return _instance; - } +void +Metrics::_addBlob() // The mutex must be held before calling this! +{ + auto blob = new Metrics::NamesAndAtomics(); - void - Counter::_addBlob() // The mutex must be held before calling this! - { - auto blob = new Counter::NamesAndAtomics(); + ink_assert(blob); + ink_assert(_cur_blob < MAX_BLOBS); - ink_assert(blob); - ink_assert(_cur_blob < MAX_BLOBS); + _blobs[++_cur_blob] = blob; + _cur_off = 0; +} + +Metrics::IdType +Metrics::_create(std::string_view name) +{ + std::lock_guard lock(_mutex); + auto it = _lookups.find(name); - _blobs[++_cur_blob] = blob; - _cur_off = 0; + if (it != _lookups.end()) { + return it->second; } - Counter::IdType - Counter::create(std::string_view name) - { - std::lock_guard lock(_mutex); - auto it = _lookups.find(name); + Metrics::IdType id = _makeId(_cur_blob, _cur_off); + Metrics::NamesAndAtomics *blob = _blobs[_cur_blob]; + Metrics::NameStorage &names = std::get<0>(*blob); + Metrics::AtomicStorage &atomics = std::get<1>(*blob); - if (it != _lookups.end()) { - return it->second; - } + atomics[_cur_off].store(0); + names[_cur_off] = std::make_tuple(std::string(name), id); + _lookups.emplace(std::get<0>(names[_cur_off]), id); - Counter::IdType id = _makeId(_cur_blob, _cur_off); - Counter::NamesAndAtomics *blob = _blobs[_cur_blob]; - Counter::NameStorage &names = std::get<0>(*blob); - Counter::AtomicStorage &atomics = std::get<1>(*blob); + if (++_cur_off >= MAX_SIZE) { + _addBlob(); // This resets _cur_off to 0 as well + } - atomics[_cur_off].store(0); - names[_cur_off] = std::make_tuple(std::string(name), id); - _lookups.emplace(std::get<0>(names[_cur_off]), id); + return id; +} - if (++_cur_off >= MAX_SIZE) { - _addBlob(); // This resets _cur_off to 0 as well - } +Metrics::IdType +Metrics::lookup(const std::string_view name) const +{ + std::lock_guard lock(_mutex); + auto it = _lookups.find(name); - return id; + if (it != _lookups.end()) { + return it->second; } - Counter::IdType - Counter::lookup(const std::string_view name) const - { - std::lock_guard lock(_mutex); - auto it = _lookups.find(name); + return NOT_FOUND; +} - if (it != _lookups.end()) { - return it->second; - } +Metrics::Counter::AtomicType * +Metrics::lookup(Metrics::IdType id, std::string_view *name) const +{ + auto [blob_ix, offset] = _splitID(id); + Metrics::NamesAndAtomics *blob = _blobs[blob_ix]; - return NOT_FOUND; + // Do a sanity check on the ID, to make sure we don't index outside of the realm of possibility. + if (!blob || (blob_ix == _cur_blob && offset > _cur_off)) { + blob = _blobs[0]; + offset = 0; } - Counter::AtomicType * - Counter::lookup(Counter::IdType id, std::string_view *name) const - { - auto [blob_ix, offset] = _splitID(id); - Counter::NamesAndAtomics *blob = _blobs[blob_ix]; + if (name) { + *name = std::get<0>(std::get<0>(*blob)[offset]); + } - // Do a sanity check on the ID, to make sure we don't index outside of the realm of possibility. - if (!blob || (blob_ix == _cur_blob && offset > _cur_off)) { - blob = _blobs[0]; - offset = 0; - } + return &((std::get<1>(*blob)[offset])); +} - if (name) { - *name = std::get<0>(std::get<0>(*blob)[offset]); - } +std::string_view +Metrics::name(Metrics::IdType id) const +{ + auto [blob_ix, offset] = _splitID(id); + Metrics::NamesAndAtomics *blob = _blobs[blob_ix]; - return &((std::get<1>(*blob)[offset])); + // Do a sanity check on the ID, to make sure we don't index outside of the realm of possibility. + if (!blob || (blob_ix == _cur_blob && offset > _cur_off)) { + blob = _blobs[0]; + offset = 0; } - std::string_view - Counter::name(Counter::IdType id) const - { - auto [blob_ix, offset] = _splitID(id); - Counter::NamesAndAtomics *blob = _blobs[blob_ix]; + const std::string &result = std::get<0>(std::get<0>(*blob)[offset]); - // Do a sanity check on the ID, to make sure we don't index outside of the realm of possibility. - if (!blob || (blob_ix == _cur_blob && offset > _cur_off)) { - blob = _blobs[0]; - offset = 0; - } + return result; +} - const std::string &result = std::get<0>(std::get<0>(*blob)[offset]); +Metrics::SpanType +Metrics::_createSpan(size_t size, Metrics::IdType *id) +{ + ink_release_assert(size <= MAX_SIZE); + std::lock_guard lock(_mutex); - return result; + if (_cur_off + size > MAX_SIZE) { + _addBlob(); } - Counter::SpanType - Counter::createSpan(size_t size, Counter::IdType *id) - { - ink_release_assert(size <= MAX_SIZE); - std::lock_guard lock(_mutex); + Metrics::IdType span_start = _makeId(_cur_blob, _cur_off); + Metrics::NamesAndAtomics *blob = _blobs[_cur_blob]; + Metrics::AtomicStorage &atomics = std::get<1>(*blob); + Metrics::SpanType span = Metrics::SpanType(&atomics[_cur_off], size); - if (_cur_off + size > MAX_SIZE) { - _addBlob(); - } + std::fill(span.begin(), span.end(), 0); - Counter::IdType span_start = _makeId(_cur_blob, _cur_off); - Counter::NamesAndAtomics *blob = _blobs[_cur_blob]; - Counter::AtomicStorage &atomics = std::get<1>(*blob); - Counter::SpanType span = Counter::SpanType(&atomics[_cur_off], size); + if (id) { + *id = span_start; + } - std::fill(span.begin(), span.end(), 0); + _cur_off += size; - if (id) { - *id = span_start; - } + return span; +} - _cur_off += size; +bool +Metrics::rename(Metrics::IdType id, std::string_view name) +{ + auto [blob_ix, offset] = _splitID(id); + Metrics::NamesAndAtomics *blob = _blobs[blob_ix]; - return span; + // We can only rename Metrics that are already allocated + if (!blob || (blob_ix == _cur_blob && offset > _cur_off)) { + return false; } - bool - Counter::rename(Counter::IdType id, std::string_view name) - { - auto [blob_ix, offset] = _splitID(id); - Counter::NamesAndAtomics *blob = _blobs[blob_ix]; + std::string &cur = std::get<0>(std::get<0>(*blob)[offset]); + std::lock_guard lock(_mutex); - // We can only rename counter that are already allocated - if (!blob || (blob_ix == _cur_blob && offset > _cur_off)) { - return false; - } - - std::string &cur = std::get<0>(std::get<0>(*blob)[offset]); - std::lock_guard lock(_mutex); - - if (cur.length() > 0) { - _lookups.erase(cur); - } - cur = name; - _lookups.emplace(cur, id); - - return true; + if (cur.length() > 0) { + _lookups.erase(cur); } + cur = name; + _lookups.emplace(cur, id); - // Iterator implementation - void - Counter::iterator::next() - { - auto [blob, offset] = _counter._splitID(_it); + return true; +} - if (++offset == MAX_SIZE) { - ++blob; - offset = 0; - } +// Iterator implementation +void +Metrics::iterator::next() +{ + auto [blob, offset] = _metrics._splitID(_it); - _it = _makeId(blob, offset); + if (++offset == MAX_SIZE) { + ++blob; + offset = 0; } -} // namespace Metrics + _it = _makeId(blob, offset); +} } // namespace ts diff --git a/src/api/unit_tests/test_Metrics.cc b/src/api/unit_tests/test_Metrics.cc index 83061453674..946f5b7d052 100644 --- a/src/api/unit_tests/test_Metrics.cc +++ b/src/api/unit_tests/test_Metrics.cc @@ -25,10 +25,11 @@ #include "catch.hpp" #include "api/Metrics.h" +using ts::Metrics; TEST_CASE("Metrics", "[libtsapi][Metrics]") { - ts::Metrics::Counter m; + auto &m = Metrics::instance(); SECTION("iterator") { @@ -46,7 +47,7 @@ TEST_CASE("Metrics", "[libtsapi][Metrics]") SECTION("New metric") { - auto fooid = m.create("foo"); + auto fooid = Metrics::Counter::create("foo"); REQUIRE(fooid == 1); REQUIRE(m.name(fooid) == "foo"); @@ -65,9 +66,9 @@ TEST_CASE("Metrics", "[libtsapi][Metrics]") SECTION("Span allocation") { - ts::Metrics::Counter::IdType span_id; - auto fooid = m.create("foo"); // To see that span_id gets to 2 - auto span = m.createSpan(17, &span_id); + ts::Metrics::IdType span_id; + auto fooid = Metrics::Counter::create("foo"); // To see that span_id gets to 2 + auto span = Metrics::Counter::createSpan(17, &span_id); REQUIRE(span.size() == 17); REQUIRE(fooid == 1); @@ -82,7 +83,7 @@ TEST_CASE("Metrics", "[libtsapi][Metrics]") REQUIRE(m.name(span_id + 2) == "span.2"); m.rename(fooid, "foo-new"); REQUIRE(m.name(fooid) == "foo-new"); - REQUIRE(m.lookup("foo") == ts::Metrics::Counter::NOT_FOUND); + REQUIRE(m.lookup("foo") == ts::Metrics::NOT_FOUND); REQUIRE(m.lookup("foo-new") == fooid); } @@ -91,7 +92,7 @@ TEST_CASE("Metrics", "[libtsapi][Metrics]") auto nm = m.lookupPtr("notametric"); REQUIRE(!nm); - auto mid = m.create("ametric"); + auto mid = Metrics::Counter::create("ametric"); auto fm = m.lookupPtr("ametric"); REQUIRE(fm.has_value()); REQUIRE(fm.value()); diff --git a/src/iocore/aio/AIO.cc b/src/iocore/aio/AIO.cc index 5a20cd39ec7..46c9bbee068 100644 --- a/src/iocore/aio/AIO.cc +++ b/src/iocore/aio/AIO.cc @@ -107,10 +107,10 @@ ink_aio_init(ts::ModuleVersion v, AIOBackend backend) { ink_release_assert(v.check(AIO_MODULE_INTERNAL_VERSION)); - aio_rsb.read_count = Counter::CreatePtr("proxy.process.cache.aio.read_count"); - aio_rsb.write_count = Counter::CreatePtr("proxy.process.cache.aio.write_count"); - aio_rsb.kb_read = Counter::CreatePtr("proxy.process.cache.aio.KB_read"); - aio_rsb.kb_write = Counter::CreatePtr("proxy.process.cache.aio.KB_write"); + aio_rsb.read_count = Metrics::Counter::createPtr("proxy.process.cache.aio.read_count"); + aio_rsb.write_count = Metrics::Counter::createPtr("proxy.process.cache.aio.write_count"); + aio_rsb.kb_read = Metrics::Counter::createPtr("proxy.process.cache.aio.KB_read"); + aio_rsb.kb_write = Metrics::Counter::createPtr("proxy.process.cache.aio.KB_write"); memset(&aio_reqs, 0, MAX_DISKS_POSSIBLE * sizeof(AIO_Reqs *)); ink_mutex_init(&insert_mutex); @@ -440,11 +440,11 @@ AIOThreadInfo::aio_thread_main(AIOThreadInfo *thr_info) // update the stats; if (op->aiocb.aio_lio_opcode == LIO_WRITE) { - Counter::increment(aio_rsb.write_count); - Counter::increment(aio_rsb.kb_write, op->aiocb.aio_nbytes >> 10); + Metrics::Counter::increment(aio_rsb.write_count); + Metrics::Counter::increment(aio_rsb.kb_write, op->aiocb.aio_nbytes >> 10); } else { - Counter::increment(aio_rsb.read_count); - Counter::increment(aio_rsb.kb_read, op->aiocb.aio_nbytes >> 10); + Metrics::Counter::increment(aio_rsb.read_count); + Metrics::Counter::increment(aio_rsb.kb_read, op->aiocb.aio_nbytes >> 10); } cache_op(reinterpret_cast(op)); ink_atomic_increment(&my_aio_req->requests_queued, -1); @@ -576,11 +576,11 @@ AIOCallbackInternal::handle_complete(io_uring_cqe *cqe) if (op->aio_result > 0) { if (op->aiocb.aio_lio_opcode == LIO_WRITE) { - Counter::increment(aio_rsb.write_count); - Counter::increment(aio_rsb.kb_write, op->aiocb.aio_nbytes >> 10); + Metrics::Counter::increment(aio_rsb.write_count); + Metrics::Counter::increment(aio_rsb.kb_write, op->aiocb.aio_nbytes >> 10); } else { - Counter::increment(aio_rsb.read_count); - Counter::increment(aio_rsb.kb_read, op->aiocb.aio_nbytes >> 10); + Metrics::Counter::increment(aio_rsb.read_count); + Metrics::Counter::increment(aio_rsb.kb_read, op->aiocb.aio_nbytes >> 10); } } diff --git a/src/iocore/aio/P_AIO.h b/src/iocore/aio/P_AIO.h index 6f1b15bf100..1cd0556e053 100644 --- a/src/iocore/aio/P_AIO.h +++ b/src/iocore/aio/P_AIO.h @@ -39,7 +39,7 @@ #include "api/Metrics.h" -using ts::Metrics::Counter; +using ts::Metrics; // for debugging // #define AIO_STATS 1 @@ -133,10 +133,10 @@ class AIOTestData : public Continuation #endif struct AIOStatsBlock { - Counter::AtomicType *read_count; - Counter::AtomicType *kb_read; - Counter::AtomicType *write_count; - Counter::AtomicType *kb_write; + Metrics::Counter::AtomicType *read_count; + Metrics::Counter::AtomicType *kb_read; + Metrics::Counter::AtomicType *write_count; + Metrics::Counter::AtomicType *kb_write; }; extern AIOStatsBlock aio_rsb; diff --git a/src/iocore/aio/test_AIO.cc b/src/iocore/aio/test_AIO.cc index b1db80a7d97..998d8d5a64e 100644 --- a/src/iocore/aio/test_AIO.cc +++ b/src/iocore/aio/test_AIO.cc @@ -223,11 +223,11 @@ dump_summary() auto &m = Metrics::getInstance(); - Counter::AtomicType *completed = m.lookup(m.lookup("proxy.process.io_uring.completed")); - Counter::AtomicType *submitted = m.lookup(m.lookup("proxy.process.io_uring.submitted")); + Metrics::Counter::AtomicType *completed = m.lookup(m.lookup("proxy.process.io_uring.completed")); + Metrics::Counter::AtomicType *submitted = m.lookup(m.lookup("proxy.process.io_uring.submitted")); - printf("submissions: %lu\n", Counter::read(submitted)); - printf("completions: %lu\n", Counter::read(completed)); + printf("submissions: %lu\n", Metrics::Counter::read(submitted)); + printf("completions: %lu\n", Metrics::Counter::read(completed)); #endif if (delete_disks) { diff --git a/src/iocore/cache/Cache.cc b/src/iocore/cache/Cache.cc index f049ae0c31c..d7912dc251f 100644 --- a/src/iocore/cache/Cache.cc +++ b/src/iocore/cache/Cache.cc @@ -130,66 +130,66 @@ static void register_cache_stats(CacheStatsBlock *rsb, const std::string prefix) { // These are special, in that we have 7 x 3 metrics here in a structure based on cache operation done - rsb->status[static_cast(CacheOpType::Lookup)].active = Counter::CreatePtr(prefix + ".lookup.active"); - rsb->status[static_cast(CacheOpType::Lookup)].success = Counter::CreatePtr(prefix + ".lookup.success"); - rsb->status[static_cast(CacheOpType::Lookup)].failure = Counter::CreatePtr(prefix + ".lookup.failure"); - rsb->status[static_cast(CacheOpType::Read)].active = Counter::CreatePtr(prefix + ".read.active"); - rsb->status[static_cast(CacheOpType::Read)].success = Counter::CreatePtr(prefix + ".read.success"); - rsb->status[static_cast(CacheOpType::Read)].failure = Counter::CreatePtr(prefix + ".read.failure"); - rsb->status[static_cast(CacheOpType::Write)].active = Counter::CreatePtr(prefix + ".write.active"); - rsb->status[static_cast(CacheOpType::Write)].success = Counter::CreatePtr(prefix + ".write.success"); - rsb->status[static_cast(CacheOpType::Write)].failure = Counter::CreatePtr(prefix + ".write.failure"); - rsb->status[static_cast(CacheOpType::Update)].active = Counter::CreatePtr(prefix + ".update.active"); - rsb->status[static_cast(CacheOpType::Update)].success = Counter::CreatePtr(prefix + ".update.success"); - rsb->status[static_cast(CacheOpType::Update)].failure = Counter::CreatePtr(prefix + ".update.failure"); - rsb->status[static_cast(CacheOpType::Remove)].active = Counter::CreatePtr(prefix + ".remove.active"); - rsb->status[static_cast(CacheOpType::Remove)].success = Counter::CreatePtr(prefix + ".remove.success"); - rsb->status[static_cast(CacheOpType::Remove)].failure = Counter::CreatePtr(prefix + ".remove.failure"); - rsb->status[static_cast(CacheOpType::Evacuate)].active = Counter::CreatePtr(prefix + ".evacuate.active"); - rsb->status[static_cast(CacheOpType::Evacuate)].success = Counter::CreatePtr(prefix + ".evacuate.success"); - rsb->status[static_cast(CacheOpType::Evacuate)].failure = Counter::CreatePtr(prefix + ".evacuate.failure"); - rsb->status[static_cast(CacheOpType::Scan)].active = Counter::CreatePtr(prefix + ".scan.active"); - rsb->status[static_cast(CacheOpType::Scan)].success = Counter::CreatePtr(prefix + ".scan.success"); - rsb->status[static_cast(CacheOpType::Scan)].failure = Counter::CreatePtr(prefix + ".scan.failure"); + rsb->status[static_cast(CacheOpType::Lookup)].active = Metrics::Counter::createPtr(prefix + ".lookup.active"); + rsb->status[static_cast(CacheOpType::Lookup)].success = Metrics::Counter::createPtr(prefix + ".lookup.success"); + rsb->status[static_cast(CacheOpType::Lookup)].failure = Metrics::Counter::createPtr(prefix + ".lookup.failure"); + rsb->status[static_cast(CacheOpType::Read)].active = Metrics::Counter::createPtr(prefix + ".read.active"); + rsb->status[static_cast(CacheOpType::Read)].success = Metrics::Counter::createPtr(prefix + ".read.success"); + rsb->status[static_cast(CacheOpType::Read)].failure = Metrics::Counter::createPtr(prefix + ".read.failure"); + rsb->status[static_cast(CacheOpType::Write)].active = Metrics::Counter::createPtr(prefix + ".write.active"); + rsb->status[static_cast(CacheOpType::Write)].success = Metrics::Counter::createPtr(prefix + ".write.success"); + rsb->status[static_cast(CacheOpType::Write)].failure = Metrics::Counter::createPtr(prefix + ".write.failure"); + rsb->status[static_cast(CacheOpType::Update)].active = Metrics::Counter::createPtr(prefix + ".update.active"); + rsb->status[static_cast(CacheOpType::Update)].success = Metrics::Counter::createPtr(prefix + ".update.success"); + rsb->status[static_cast(CacheOpType::Update)].failure = Metrics::Counter::createPtr(prefix + ".update.failure"); + rsb->status[static_cast(CacheOpType::Remove)].active = Metrics::Counter::createPtr(prefix + ".remove.active"); + rsb->status[static_cast(CacheOpType::Remove)].success = Metrics::Counter::createPtr(prefix + ".remove.success"); + rsb->status[static_cast(CacheOpType::Remove)].failure = Metrics::Counter::createPtr(prefix + ".remove.failure"); + rsb->status[static_cast(CacheOpType::Evacuate)].active = Metrics::Counter::createPtr(prefix + ".evacuate.active"); + rsb->status[static_cast(CacheOpType::Evacuate)].success = Metrics::Counter::createPtr(prefix + ".evacuate.success"); + rsb->status[static_cast(CacheOpType::Evacuate)].failure = Metrics::Counter::createPtr(prefix + ".evacuate.failure"); + rsb->status[static_cast(CacheOpType::Scan)].active = Metrics::Counter::createPtr(prefix + ".scan.active"); + rsb->status[static_cast(CacheOpType::Scan)].success = Metrics::Counter::createPtr(prefix + ".scan.success"); + rsb->status[static_cast(CacheOpType::Scan)].failure = Metrics::Counter::createPtr(prefix + ".scan.failure"); // These are in an array of 1, 2 and 3+ fragment documents - rsb->fragment_document_count[0] = Counter::CreatePtr(prefix + ".frags_per_doc.1"); - rsb->fragment_document_count[1] = Counter::CreatePtr(prefix + ".frags_per_doc.2"); - rsb->fragment_document_count[2] = Counter::CreatePtr(prefix + ".frags_per_doc.3+"); + rsb->fragment_document_count[0] = Metrics::Counter::createPtr(prefix + ".frags_per_doc.1"); + rsb->fragment_document_count[1] = Metrics::Counter::createPtr(prefix + ".frags_per_doc.2"); + rsb->fragment_document_count[2] = Metrics::Counter::createPtr(prefix + ".frags_per_doc.3+"); // And then everything else - rsb->bytes_used = Counter::CreatePtr(prefix + ".bytes_used"); - rsb->bytes_total = Counter::CreatePtr(prefix + ".bytes_total"); - rsb->stripes = Counter::CreatePtr(prefix + ".stripes"); - rsb->ram_cache_bytes_total = Counter::CreatePtr(prefix + ".ram_cache.total_bytes"); - rsb->ram_cache_bytes = Counter::CreatePtr(prefix + ".ram_cache.bytes_used"); - rsb->ram_cache_hits = Counter::CreatePtr(prefix + ".ram_cache.hits"); - rsb->ram_cache_misses = Counter::CreatePtr(prefix + ".ram_cache.misses"); - rsb->pread_count = Counter::CreatePtr(prefix + ".pread_count"); - rsb->percent_full = Counter::CreatePtr(prefix + ".percent_full"); - rsb->read_seek_fail = Counter::CreatePtr(prefix + ".read.seek.failure"); - rsb->read_invalid = Counter::CreatePtr(prefix + ".read.invalid"); - rsb->write_backlog_failure = Counter::CreatePtr(prefix + ".write.backlog.failure"); - rsb->direntries_total = Counter::CreatePtr(prefix + ".direntries.total"); - rsb->direntries_used = Counter::CreatePtr(prefix + ".direntries.used"); - rsb->directory_collision_count = Counter::CreatePtr(prefix + ".directory_collision"); - rsb->read_busy_success = Counter::CreatePtr(prefix + ".read_busy.success"); - rsb->read_busy_failure = Counter::CreatePtr(prefix + ".read_busy.failure"); - rsb->write_bytes = Counter::CreatePtr(prefix + ".write_bytes_stat"); - rsb->hdr_vector_marshal = Counter::CreatePtr(prefix + ".vector_marshals"); - rsb->hdr_marshal = Counter::CreatePtr(prefix + ".hdr_marshals"); - rsb->hdr_marshal_bytes = Counter::CreatePtr(prefix + ".hdr_marshal_bytes"); - rsb->gc_bytes_evacuated = Counter::CreatePtr(prefix + ".gc_bytes_evacuated"); - rsb->gc_frags_evacuated = Counter::CreatePtr(prefix + ".gc_frags_evacuated"); - rsb->directory_wrap = Counter::CreatePtr(prefix + ".wrap_count"); - rsb->directory_sync_count = Counter::CreatePtr(prefix + ".sync.count"); - rsb->directory_sync_bytes = Counter::CreatePtr(prefix + ".sync.bytes"); - rsb->directory_sync_time = Counter::CreatePtr(prefix + ".sync.time"); - rsb->span_errors_read = Counter::CreatePtr(prefix + ".span.errors.read"); - rsb->span_errors_write = Counter::CreatePtr(prefix + ".span.errors.write"); - rsb->span_failing = Counter::CreatePtr(prefix + ".span.failing"); - rsb->span_offline = Counter::CreatePtr(prefix + ".span.offline"); - rsb->span_online = Counter::CreatePtr(prefix + ".span.online"); + rsb->bytes_used = Metrics::Counter::createPtr(prefix + ".bytes_used"); + rsb->bytes_total = Metrics::Counter::createPtr(prefix + ".bytes_total"); + rsb->stripes = Metrics::Counter::createPtr(prefix + ".stripes"); + rsb->ram_cache_bytes_total = Metrics::Counter::createPtr(prefix + ".ram_cache.total_bytes"); + rsb->ram_cache_bytes = Metrics::Counter::createPtr(prefix + ".ram_cache.bytes_used"); + rsb->ram_cache_hits = Metrics::Counter::createPtr(prefix + ".ram_cache.hits"); + rsb->ram_cache_misses = Metrics::Counter::createPtr(prefix + ".ram_cache.misses"); + rsb->pread_count = Metrics::Counter::createPtr(prefix + ".pread_count"); + rsb->percent_full = Metrics::Counter::createPtr(prefix + ".percent_full"); + rsb->read_seek_fail = Metrics::Counter::createPtr(prefix + ".read.seek.failure"); + rsb->read_invalid = Metrics::Counter::createPtr(prefix + ".read.invalid"); + rsb->write_backlog_failure = Metrics::Counter::createPtr(prefix + ".write.backlog.failure"); + rsb->direntries_total = Metrics::Counter::createPtr(prefix + ".direntries.total"); + rsb->direntries_used = Metrics::Counter::createPtr(prefix + ".direntries.used"); + rsb->directory_collision_count = Metrics::Counter::createPtr(prefix + ".directory_collision"); + rsb->read_busy_success = Metrics::Counter::createPtr(prefix + ".read_busy.success"); + rsb->read_busy_failure = Metrics::Counter::createPtr(prefix + ".read_busy.failure"); + rsb->write_bytes = Metrics::Counter::createPtr(prefix + ".write_bytes_stat"); + rsb->hdr_vector_marshal = Metrics::Counter::createPtr(prefix + ".vector_marshals"); + rsb->hdr_marshal = Metrics::Counter::createPtr(prefix + ".hdr_marshals"); + rsb->hdr_marshal_bytes = Metrics::Counter::createPtr(prefix + ".hdr_marshal_bytes"); + rsb->gc_bytes_evacuated = Metrics::Counter::createPtr(prefix + ".gc_bytes_evacuated"); + rsb->gc_frags_evacuated = Metrics::Counter::createPtr(prefix + ".gc_frags_evacuated"); + rsb->directory_wrap = Metrics::Counter::createPtr(prefix + ".wrap_count"); + rsb->directory_sync_count = Metrics::Counter::createPtr(prefix + ".sync.count"); + rsb->directory_sync_bytes = Metrics::Counter::createPtr(prefix + ".sync.bytes"); + rsb->directory_sync_time = Metrics::Counter::createPtr(prefix + ".sync.time"); + rsb->span_errors_read = Metrics::Counter::createPtr(prefix + ".span.errors.read"); + rsb->span_errors_write = Metrics::Counter::createPtr(prefix + ".span.errors.write"); + rsb->span_failing = Metrics::Counter::createPtr(prefix + ".span.failing"); + rsb->span_offline = Metrics::Counter::createPtr(prefix + ".span.offline"); + rsb->span_online = Metrics::Counter::createPtr(prefix + ".span.online"); } // ToDo: This gets called as part of librecords collection continuation, probably change this later. @@ -216,7 +216,7 @@ CachePeriodicMetricsUpdate() // volume metric more than once (once per disk). This happens once every sync // period (5s), and nothing else modifies these metrics. for (int vol_ix = 0; vol_ix < gnvol; ++vol_ix) { - Counter::write(gvol[vol_ix]->cache_vol->vol_rsb.bytes_used, 0); + Metrics::Counter::write(gvol[vol_ix]->cache_vol->vol_rsb.bytes_used, 0); } if (cacheProcessor.initialized == CACHE_INITIALIZED) { @@ -224,15 +224,15 @@ CachePeriodicMetricsUpdate() Stripe *v = gvol[vol_ix]; int64_t used = cache_bytes_used(vol_ix); - Counter::increment(v->cache_vol->vol_rsb.bytes_used, used); // This assumes they start at zero + Metrics::Counter::increment(v->cache_vol->vol_rsb.bytes_used, used); // This assumes they start at zero total_sum += used; } // Also update the global (not per volume) metrics - int64_t total = Counter::read(cache_rsb.bytes_total); + int64_t total = Metrics::Counter::read(cache_rsb.bytes_total); - Counter::write(cache_rsb.bytes_used, total_sum); - Counter::write(cache_rsb.percent_full, total ? (total_sum * 100) / total : 0); + Metrics::Counter::write(cache_rsb.bytes_used, total_sum); + Metrics::Counter::write(cache_rsb.percent_full, total ? (total_sum * 100) / total : 0); } } @@ -509,9 +509,9 @@ CacheProcessor::diskInitialized() /* Practically just took all bad_disks offline so update the stats. */ // ToDo: These don't get update on the per-volume metrics :-/ - Counter::write(cache_rsb.span_offline, bad_disks); - Counter::decrement(cache_rsb.span_failing, bad_disks); - Counter::write(cache_rsb.span_online, gndisks); + Metrics::Counter::write(cache_rsb.span_offline, bad_disks); + Metrics::Counter::decrement(cache_rsb.span_failing, bad_disks); + Metrics::Counter::write(cache_rsb.span_online, gndisks); /* create the cachevol list only if num volumes are greater than 0. */ if (config_volumes.num_volumes == 0) { @@ -657,21 +657,21 @@ CacheProcessor::cacheInitialized() ram_cache_bytes += gvol[i]->dirlen(); Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized - ram_cache_bytes = %" PRId64 " = %" PRId64 "Mb", ram_cache_bytes, ram_cache_bytes / (1024 * 1024)); - Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes_total, gvol[i]->dirlen()); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes_total, gvol[i]->dirlen()); } vol_total_cache_bytes = gvol[i]->len - gvol[i]->dirlen(); total_cache_bytes += vol_total_cache_bytes; Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized - total_cache_bytes = %" PRId64 " = %" PRId64 "Mb", total_cache_bytes, total_cache_bytes / (1024 * 1024)); - Counter::increment(vol->cache_vol->vol_rsb.bytes_total, vol_total_cache_bytes); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.bytes_total, vol_total_cache_bytes); vol_total_direntries = gvol[i]->buckets * gvol[i]->segments * DIR_DEPTH; total_direntries += vol_total_direntries; - Counter::increment(vol->cache_vol->vol_rsb.direntries_total, vol_total_direntries); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.direntries_total, vol_total_direntries); vol_used_direntries = dir_entries_used(gvol[i]); - Counter::increment(vol->cache_vol->vol_rsb.direntries_used, vol_used_direntries); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.direntries_used, vol_used_direntries); used_direntries += vol_used_direntries; } @@ -704,7 +704,8 @@ CacheProcessor::cacheInitialized() Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized - factor = %f", factor); gvol[i]->ram_cache->init(static_cast(http_ram_cache_size * factor), vol); ram_cache_bytes += static_cast(http_ram_cache_size * factor); - Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes_total, static_cast(http_ram_cache_size * factor)); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes_total, + static_cast(http_ram_cache_size * factor)); } else if (gvol[i]->cache_vol->ramcache_enabled) { ink_release_assert(!"Unexpected non-HTTP cache volume"); } @@ -712,17 +713,17 @@ CacheProcessor::cacheInitialized() ram_cache_bytes, ram_cache_bytes / (1024 * 1024)); vol_total_cache_bytes = gvol[i]->len - gvol[i]->dirlen(); total_cache_bytes += vol_total_cache_bytes; - Counter::increment(vol->cache_vol->vol_rsb.bytes_total, vol_total_cache_bytes); - Counter::increment(vol->cache_vol->vol_rsb.stripes); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.bytes_total, vol_total_cache_bytes); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.stripes); Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized - total_cache_bytes = %" PRId64 " = %" PRId64 "Mb", total_cache_bytes, total_cache_bytes / (1024 * 1024)); vol_total_direntries = gvol[i]->buckets * gvol[i]->segments * DIR_DEPTH; total_direntries += vol_total_direntries; - Counter::increment(vol->cache_vol->vol_rsb.direntries_total, vol_total_direntries); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.direntries_total, vol_total_direntries); vol_used_direntries = dir_entries_used(gvol[i]); - Counter::increment(vol->cache_vol->vol_rsb.direntries_used, vol_used_direntries); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.direntries_used, vol_used_direntries); used_direntries += vol_used_direntries; } } @@ -741,10 +742,10 @@ CacheProcessor::cacheInitialized() break; } - Counter::write(cache_rsb.ram_cache_bytes_total, ram_cache_bytes); - Counter::write(cache_rsb.bytes_total, total_cache_bytes); - Counter::write(cache_rsb.direntries_total, total_direntries); - Counter::write(cache_rsb.direntries_used, used_direntries); + Metrics::Counter::write(cache_rsb.ram_cache_bytes_total, ram_cache_bytes); + Metrics::Counter::write(cache_rsb.bytes_total, total_cache_bytes); + Metrics::Counter::write(cache_rsb.direntries_total, total_direntries); + Metrics::Counter::write(cache_rsb.direntries_used, used_direntries); if (!check) { dir_sync_init(); @@ -1014,14 +1015,14 @@ CacheProcessor::mark_storage_offline(CacheDisk *d, ///< Target disk } } - Counter::decrement(cache_rsb.bytes_total, total_bytes_delete); - Counter::decrement(cache_rsb.direntries_total, total_dir_delete); - Counter::decrement(cache_rsb.direntries_used, used_dir_delete); + Metrics::Counter::decrement(cache_rsb.bytes_total, total_bytes_delete); + Metrics::Counter::decrement(cache_rsb.direntries_total, total_dir_delete); + Metrics::Counter::decrement(cache_rsb.direntries_used, used_dir_delete); /* Update the span metrics, if failing then move the span from "failing" to "offline" bucket * if operator took it offline, move it from "online" to "offline" bucket */ - Counter::decrement(admin ? cache_rsb.span_online : cache_rsb.span_failing); - Counter::increment(cache_rsb.span_offline); + Metrics::Counter::decrement(admin ? cache_rsb.span_online : cache_rsb.span_failing); + Metrics::Counter::increment(cache_rsb.span_offline); if (theCache) { rebuild_host_table(theCache); @@ -1198,8 +1199,8 @@ Cache::lookup(Continuation *cont, const CacheKey *key, CacheFragType type, const SET_CONTINUATION_HANDLER(c, &CacheVC::openReadStartHead); c->vio.op = VIO::READ; c->op_type = static_cast(CacheOpType::Lookup); - Counter::increment(cache_rsb.status[c->op_type].active); - Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); + Metrics::Counter::increment(cache_rsb.status[c->op_type].active); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); c->first_key = c->key = *key; c->frag_type = type; c->f.lookup = 1; @@ -1240,8 +1241,8 @@ Cache::remove(Continuation *cont, const CacheKey *key, CacheFragType type, const c->vio.op = VIO::NONE; c->frag_type = type; c->op_type = static_cast(CacheOpType::Remove); - Counter::increment(cache_rsb.status[c->op_type].active); - Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); + Metrics::Counter::increment(cache_rsb.status[c->op_type].active); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); c->first_key = c->key = *key; c->vol = vol; c->dir = result; @@ -1689,7 +1690,7 @@ cplist_reconfigure() } } - Counter::write(cache_rsb.stripes, gnvol + assignedVol); + Metrics::Counter::write(cache_rsb.stripes, gnvol + assignedVol); return 0; } diff --git a/src/iocore/cache/CacheDir.cc b/src/iocore/cache/CacheDir.cc index 537e09a6b06..ae4baa6394e 100644 --- a/src/iocore/cache/CacheDir.cc +++ b/src/iocore/cache/CacheDir.cc @@ -367,8 +367,8 @@ dir_clean_bucket(Dir *b, int s, Stripe *vol) dir_tag(e), dir_offset(e), b, p, dir_bucket_length(b, s, vol)); } if (dir_offset(e)) { - Counter::decrement(cache_rsb.direntries_used); - Counter::decrement(vol->cache_vol->vol_rsb.direntries_used); + Metrics::Counter::decrement(cache_rsb.direntries_used); + Metrics::Counter::decrement(vol->cache_vol->vol_rsb.direntries_used); } e = dir_delete_entry(e, p, s, vol); continue; @@ -403,8 +403,8 @@ dir_clear_range(off_t start, off_t end, Stripe *vol) for (off_t i = 0; i < vol->buckets * DIR_DEPTH * vol->segments; i++) { Dir *e = dir_index(vol, i); if (dir_offset(e) >= static_cast(start) && dir_offset(e) < static_cast(end)) { - Counter::decrement(cache_rsb.direntries_used); - Counter::decrement(vol->cache_vol->vol_rsb.direntries_used); + Metrics::Counter::decrement(cache_rsb.direntries_used); + Metrics::Counter::decrement(vol->cache_vol->vol_rsb.direntries_used); dir_set_offset(e, 0); // delete } } @@ -439,8 +439,8 @@ freelist_clean(int s, Stripe *vol) for (int l = 0; l < DIR_DEPTH; l++) { Dir *e = dir_bucket_row(b, l); if (dir_head(e) && !(n++ % 10)) { - Counter::decrement(cache_rsb.direntries_used); - Counter::decrement(vol->cache_vol->vol_rsb.direntries_used); + Metrics::Counter::decrement(cache_rsb.direntries_used); + Metrics::Counter::decrement(vol->cache_vol->vol_rsb.direntries_used); dir_set_offset(e, 0); // delete } } @@ -567,8 +567,8 @@ dir_probe(const CacheKey *key, Stripe *vol, Dir *result, Dir **last_collision) // may not accurately reflect the number of documents // having the same first_key DDbg(dbg_ctl_cache_stats, "Incrementing dir collisions"); - Counter::increment(cache_rsb.directory_collision_count); - Counter::increment(vol->cache_vol->vol_rsb.directory_collision_count); + Metrics::Counter::increment(cache_rsb.directory_collision_count); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.directory_collision_count); } goto Lcont; } @@ -580,8 +580,8 @@ dir_probe(const CacheKey *key, Stripe *vol, Dir *result, Dir **last_collision) ink_assert(dir_offset(e) * CACHE_BLOCK_SIZE < vol->len); return 1; } else { // delete the invalid entry - Counter::decrement(cache_rsb.direntries_used); - Counter::decrement(vol->cache_vol->vol_rsb.direntries_used); + Metrics::Counter::decrement(cache_rsb.direntries_used); + Metrics::Counter::decrement(vol->cache_vol->vol_rsb.direntries_used); e = dir_delete_entry(e, p, s, vol); continue; } @@ -595,8 +595,8 @@ dir_probe(const CacheKey *key, Stripe *vol, Dir *result, Dir **last_collision) } if (collision) { // last collision no longer in the list, retry DDbg(dbg_ctl_cache_stats, "Incrementing dir collisions"); - Counter::increment(cache_rsb.directory_collision_count); - Counter::increment(vol->cache_vol->vol_rsb.directory_collision_count); + Metrics::Counter::increment(cache_rsb.directory_collision_count); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.directory_collision_count); collision = nullptr; goto Lagain; } @@ -667,8 +667,8 @@ dir_insert(const CacheKey *key, Stripe *vol, Dir *to_part) bi, e, key->slice32(1), dir_tag(e), dir_offset(e)); CHECK_DIR(d); vol->header->dirty = 1; - Counter::increment(cache_rsb.direntries_used); - Counter::increment(vol->cache_vol->vol_rsb.direntries_used); + Metrics::Counter::increment(cache_rsb.direntries_used); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.direntries_used); return 1; } @@ -718,8 +718,8 @@ dir_overwrite(const CacheKey *key, Stripe *vol, Dir *dir, Dir *overwrite, bool m // get from this row first e = b; if (dir_is_empty(e)) { - Counter::increment(cache_rsb.direntries_used); - Counter::increment(vol->cache_vol->vol_rsb.direntries_used); + Metrics::Counter::increment(cache_rsb.direntries_used); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.direntries_used); goto Lfill; } for (l = 1; l < DIR_DEPTH; l++) { @@ -735,8 +735,8 @@ dir_overwrite(const CacheKey *key, Stripe *vol, Dir *dir, Dir *overwrite, bool m goto Lagain; } Llink: - Counter::increment(cache_rsb.direntries_used); - Counter::increment(vol->cache_vol->vol_rsb.direntries_used); + Metrics::Counter::increment(cache_rsb.direntries_used); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.direntries_used); // as with dir_insert above, need to insert new entries at the tail of the linked list Dir *prev, *last; @@ -784,8 +784,8 @@ dir_delete(const CacheKey *key, Stripe *vol, Dir *del) } #endif if (dir_compare_tag(e, key) && dir_offset(e) == dir_offset(del)) { - Counter::decrement(cache_rsb.direntries_used); - Counter::decrement(vol->cache_vol->vol_rsb.direntries_used); + Metrics::Counter::decrement(cache_rsb.direntries_used); + Metrics::Counter::decrement(vol->cache_vol->vol_rsb.direntries_used); dir_delete_entry(e, p, s, vol); CHECK_DIR(d); return 1; @@ -1099,8 +1099,8 @@ CacheSync::mainEvent(int event, Event *e) event = EVENT_NONE; goto Ldone; } - Counter::increment(cache_rsb.directory_sync_bytes, io.aio_result); - Counter::increment(vol->cache_vol->vol_rsb.directory_sync_bytes, io.aio_result); + Metrics::Counter::increment(cache_rsb.directory_sync_bytes, io.aio_result); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.directory_sync_bytes, io.aio_result); trigger = eventProcessor.schedule_in(this, SYNC_DELAY); return EVENT_CONT; } @@ -1193,10 +1193,10 @@ CacheSync::mainEvent(int event, Event *e) writepos += headerlen; } else { vol->dir_sync_in_progress = false; - Counter::increment(cache_rsb.directory_sync_count); - Counter::increment(vol->cache_vol->vol_rsb.directory_sync_count); - Counter::increment(cache_rsb.directory_sync_time, ink_get_hrtime() - start_time); - Counter::increment(vol->cache_vol->vol_rsb.directory_sync_time, ink_get_hrtime() - start_time); + Metrics::Counter::increment(cache_rsb.directory_sync_count); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.directory_sync_count); + Metrics::Counter::increment(cache_rsb.directory_sync_time, ink_get_hrtime() - start_time); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.directory_sync_time, ink_get_hrtime() - start_time); start_time = 0; goto Ldone; } diff --git a/src/iocore/cache/CacheDisk.cc b/src/iocore/cache/CacheDisk.cc index 588be5a2824..4b47e426448 100644 --- a/src/iocore/cache/CacheDisk.cc +++ b/src/iocore/cache/CacheDisk.cc @@ -29,8 +29,8 @@ CacheDisk::incrErrors(const AIOCallback *io) if (0 == this->num_errors) { /* This it the first read/write error on this span since ATS started. * Move the newly failing span from "online" to "failing" bucket. */ - Counter::decrement(cache_rsb.span_online); - Counter::increment(cache_rsb.span_failing); + Metrics::Counter::decrement(cache_rsb.span_online); + Metrics::Counter::increment(cache_rsb.span_failing); } this->num_errors++; @@ -40,11 +40,11 @@ CacheDisk::incrErrors(const AIOCallback *io) switch (io->aiocb.aio_lio_opcode) { case LIO_READ: opname = "READ"; - Counter::increment(cache_rsb.span_errors_read); + Metrics::Counter::increment(cache_rsb.span_errors_read); break; case LIO_WRITE: opname = "WRITE"; - Counter::increment(cache_rsb.span_errors_write); + Metrics::Counter::increment(cache_rsb.span_errors_write); break; default: break; diff --git a/src/iocore/cache/CacheHttp.cc b/src/iocore/cache/CacheHttp.cc index f9384f3d057..f24b8f7ee1c 100644 --- a/src/iocore/cache/CacheHttp.cc +++ b/src/iocore/cache/CacheHttp.cc @@ -191,9 +191,9 @@ CacheHTTPInfoVector::marshal(char *buf, int length) count++; } - Counter::increment(cache_rsb.hdr_vector_marshal); - Counter::increment(cache_rsb.hdr_marshal, count); - Counter::increment(cache_rsb.hdr_marshal_bytes, buf - start); + Metrics::Counter::increment(cache_rsb.hdr_vector_marshal); + Metrics::Counter::increment(cache_rsb.hdr_marshal, count); + Metrics::Counter::increment(cache_rsb.hdr_marshal_bytes, buf - start); return buf - start; } diff --git a/src/iocore/cache/CacheRead.cc b/src/iocore/cache/CacheRead.cc index 00981956654..a12dd85816d 100644 --- a/src/iocore/cache/CacheRead.cc +++ b/src/iocore/cache/CacheRead.cc @@ -61,8 +61,8 @@ Cache::open_read(Continuation *cont, const CacheKey *key, CacheFragType type, co SET_CONTINUATION_HANDLER(c, &CacheVC::openReadStartHead); c->vio.op = VIO::READ; c->op_type = static_cast(CacheOpType::Read); - Counter::increment(cache_rsb.status[c->op_type].active); - Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); + Metrics::Counter::increment(cache_rsb.status[c->op_type].active); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); c->first_key = c->key = c->earliest_key = *key; c->vol = vol; c->frag_type = type; @@ -90,8 +90,8 @@ Cache::open_read(Continuation *cont, const CacheKey *key, CacheFragType type, co } } Lmiss: - Counter::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); - Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); + Metrics::Counter::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *)-ECACHE_NO_DOC); return ACTION_RESULT_DONE; Lwriter: @@ -131,8 +131,8 @@ Cache::open_read(Continuation *cont, const CacheKey *key, CacheHTTPHdr *request, c->vol = vol; c->vio.op = VIO::READ; c->op_type = static_cast(CacheOpType::Read); - Counter::increment(cache_rsb.status[c->op_type].active); - Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); + Metrics::Counter::increment(cache_rsb.status[c->op_type].active); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); c->request.copy_shallow(request); c->frag_type = CACHE_FRAG_TYPE_HTTP; c->params = params; @@ -163,8 +163,8 @@ Cache::open_read(Continuation *cont, const CacheKey *key, CacheHTTPHdr *request, } } Lmiss: - Counter::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); - Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); + Metrics::Counter::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *)-ECACHE_NO_DOC); return ACTION_RESULT_DONE; Lwriter: @@ -203,10 +203,10 @@ CacheVC::openReadFromWriterFailure(int event, Event *e) { od = nullptr; vector.clear(false); - Counter::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); - Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); - Counter::increment(cache_rsb.read_busy_failure); - Counter::increment(vol->cache_vol->vol_rsb.read_busy_failure); + Metrics::Counter::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); + Metrics::Counter::increment(cache_rsb.read_busy_failure); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.read_busy_failure); _action.continuation->handleEvent(event, e); free_CacheVC(this); return EVENT_DONE; @@ -454,8 +454,8 @@ CacheVC::openReadFromWriter(int event, Event *e) dir_clean(&first_dir); dir_clean(&earliest_dir); SET_HANDLER(&CacheVC::openReadFromWriterMain); - Counter::increment(cache_rsb.read_busy_success); - Counter::increment(vol->cache_vol->vol_rsb.read_busy_success); + Metrics::Counter::increment(cache_rsb.read_busy_success); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.read_busy_success); return callcont(CACHE_EVENT_OPEN_READ); } @@ -494,8 +494,8 @@ CacheVC::openReadFromWriter(int event, Event *e) DDbg(dbg_ctl_cache_read_agg, "%p: key: %X %X: single fragment read", this, first_key.slice32(1), key.slice32(0)); MUTEX_RELEASE(writer_lock); SET_HANDLER(&CacheVC::openReadFromWriterMain); - Counter::increment(cache_rsb.read_busy_success); - Counter::increment(vol->cache_vol->vol_rsb.read_busy_success); + Metrics::Counter::increment(cache_rsb.read_busy_success); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.read_busy_success); return callcont(CACHE_EVENT_OPEN_READ); } @@ -776,8 +776,8 @@ CacheVC::openReadMain(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */) doc->magic = DOC_CORRUPT; - Counter::increment(cache_rsb.read_seek_fail); - Counter::increment(vol->cache_vol->vol_rsb.read_seek_fail); + Metrics::Counter::increment(cache_rsb.read_seek_fail); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.read_seek_fail); CACHE_TRY_LOCK(lock, vol->mutex, mutex->thread_holding); if (!lock.is_locked()) { @@ -1014,16 +1014,16 @@ CacheVC::openReadStartEarliest(int /* event ATS_UNUSED */, Event * /* e ATS_UNUS vol->close_write(this); } } - Counter::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); - Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); + Metrics::Counter::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); _action.continuation->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *)-ECACHE_NO_DOC); return free_CacheVC(this); Lcallreturn: return handleEvent(AIO_EVENT_DONE, nullptr); // hopefully a tail call Lsuccess: if (write_vc) { - Counter::increment(cache_rsb.read_busy_success); - Counter::increment(vol->cache_vol->vol_rsb.read_busy_success); + Metrics::Counter::increment(cache_rsb.read_busy_success); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.read_busy_success); } SET_HANDLER(&CacheVC::openReadMain); return callcont(CACHE_EVENT_OPEN_READ); @@ -1074,8 +1074,8 @@ CacheVC::openReadVecWrite(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */ } } - Counter::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); - Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); + Metrics::Counter::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); _action.continuation->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *)-ECACHE_ALT_MISS); return free_CacheVC(this); Lrestart: @@ -1216,8 +1216,8 @@ CacheVC::openReadStartHead(int event, Event *e) if (cl != doc_len) { Warning("OpenReadHead failed for cachekey %X : alternate content length doesn't match doc_len %" PRId64 " != %" PRId64, key.slice32(0), cl, doc_len); - Counter::increment(cache_rsb.read_invalid); - Counter::increment(vol->cache_vol->vol_rsb.read_invalid); + Metrics::Counter::increment(cache_rsb.read_invalid); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.read_invalid); err = ECACHE_BAD_META_DATA; goto Ldone; } @@ -1282,12 +1282,12 @@ CacheVC::openReadStartHead(int event, Event *e) } Ldone: if (!f.lookup) { - Counter::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); - Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); + Metrics::Counter::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); _action.continuation->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *)-err); } else { - Counter::increment(cache_rsb.status[static_cast(CacheOpType::Lookup)].failure); - Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Lookup)].failure); + Metrics::Counter::increment(cache_rsb.status[static_cast(CacheOpType::Lookup)].failure); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Lookup)].failure); _action.continuation->handleEvent(CACHE_EVENT_LOOKUP_FAILED, (void *)-err); } return free_CacheVC(this); @@ -1297,8 +1297,8 @@ CacheVC::openReadStartHead(int event, Event *e) SET_HANDLER(&CacheVC::openReadMain); return callcont(CACHE_EVENT_OPEN_READ); Lookup: - Counter::increment(cache_rsb.status[static_cast(CacheOpType::Lookup)].failure); - Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Lookup)].failure); + Metrics::Counter::increment(cache_rsb.status[static_cast(CacheOpType::Lookup)].failure); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Lookup)].failure); _action.continuation->handleEvent(CACHE_EVENT_LOOKUP, nullptr); return free_CacheVC(this); Learliest: diff --git a/src/iocore/cache/CacheVC.cc b/src/iocore/cache/CacheVC.cc index 9a31893ae1d..4c24f4bd124 100644 --- a/src/iocore/cache/CacheVC.cc +++ b/src/iocore/cache/CacheVC.cc @@ -513,8 +513,8 @@ CacheVC::handleRead(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */) // ToDo: Why are these for debug only ?? #if DEBUG - Counter::increment(cache_rsb.pread_count); - Counter::increment(vol->cache_vol->vol_rsb.pread_count); + Metrics::Counter::increment(cache_rsb.pread_count); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.pread_count); #endif return EVENT_CONT; @@ -603,8 +603,8 @@ CacheVC::removeEvent(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */) return ret; } Ldone: - Counter::increment(cache_rsb.status[static_cast(CacheOpType::Remove)].failure); - Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Remove)].failure); + Metrics::Counter::increment(cache_rsb.status[static_cast(CacheOpType::Remove)].failure); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Remove)].failure); if (od) { vol->close_write(this); } diff --git a/src/iocore/cache/CacheWrite.cc b/src/iocore/cache/CacheWrite.cc index f348009eb0c..22f2e6a771d 100644 --- a/src/iocore/cache/CacheWrite.cc +++ b/src/iocore/cache/CacheWrite.cc @@ -257,10 +257,10 @@ CacheVC::handleWrite(int event, Event * /* e ATS_UNUSED */) (vio.nbytes != INT64_MAX && (cache_config_max_doc_size < vio.nbytes)))); if (agg_error || max_doc_error) { - Counter::increment(cache_rsb.write_backlog_failure); - Counter::increment(vol->cache_vol->vol_rsb.write_backlog_failure); - Counter::increment(cache_rsb.status[op_type].failure); - Counter::increment(vol->cache_vol->vol_rsb.status[op_type].failure); + Metrics::Counter::increment(cache_rsb.write_backlog_failure); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.write_backlog_failure); + Metrics::Counter::increment(cache_rsb.status[op_type].failure); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[op_type].failure); vol->agg_todo_size -= agg_len; io.aio_result = AIO_SOFT_FAILURE; if (event == EVENT_CALL) { @@ -441,8 +441,8 @@ new_DocEvacuator(int nbytes, Stripe *vol) { CacheEvacuateDocVC *c = new_CacheEvacuateDocVC(vol); c->op_type = static_cast(CacheOpType::Evacuate); - Counter::increment(cache_rsb.status[c->op_type].active); - Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); + Metrics::Counter::increment(cache_rsb.status[c->op_type].active); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); c->buf = new_IOBufferData(iobuffer_size_to_index(nbytes, MAX_BUFFER_SIZE_INDEX), MEMALIGNED); c->vol = vol; c->f.evacuator = 1; @@ -744,8 +744,8 @@ agg_copy(char *p, CacheVC *vc) // ToDo: Why are these for debug only ? #ifdef DEBUG - Counter::increment(cache_rsb.write_backlog_failure); - Counter::increment(vol->cache_vol->vol_rsb.write_backlog_failure); + Metrics::Counter::increment(cache_rsb.write_backlog_failure); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.write_backlog_failure); #endif } if (vc->f.rewrite_resident_alt) { @@ -786,8 +786,8 @@ agg_copy(char *p, CacheVC *vc) int l = vc->vol->round_to_approx_size(doc->len); #ifdef DEBUG - Counter::increment(cache_rsb.gc_frags_evacuated); - Counter::increment(vol->cache_vol->vol_rsb.gc_frags_evacuated); + Metrics::Counter::increment(cache_rsb.gc_frags_evacuated); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.gc_frags_evacuated); #endif doc->sync_serial = vc->vol->header->sync_serial; @@ -874,8 +874,8 @@ Stripe::agg_wrap() dir_clean_vol(this); { Stripe *vol = this; - Counter::increment(cache_rsb.directory_wrap); - Counter::increment(vol->cache_vol->vol_rsb.directory_wrap); + Metrics::Counter::increment(cache_rsb.directory_wrap); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.directory_wrap); Note("Cache volume %d on disk '%s' wraps around", vol->cache_vol->vol_number, vol->hash_text.get()); } periodic_scan(); @@ -1056,8 +1056,8 @@ CacheVC::openWriteCloseDir(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED * if ((closed == 1) && (total_len > 0 || f.allow_empty_doc)) { DDbg(dbg_ctl_cache_stats, "Fragment = %d", fragment); - Counter::increment(cache_rsb.fragment_document_count[std::clamp(fragment, 0, 2)]); - Counter::increment(vol->cache_vol->vol_rsb.fragment_document_count[std::clamp(fragment, 0, 2)]); + Metrics::Counter::increment(cache_rsb.fragment_document_count[std::clamp(fragment, 0, 2)]); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.fragment_document_count[std::clamp(fragment, 0, 2)]); } if (f.close_complete) { recursive++; @@ -1508,8 +1508,8 @@ CacheVC::openWriteStartDone(int event, Event *e) return callcont(CACHE_EVENT_OPEN_WRITE); Lfailure: - Counter::increment(cache_rsb.status[op_type].failure); - Counter::increment(vol->cache_vol->vol_rsb.status[op_type].failure); + Metrics::Counter::increment(cache_rsb.status[op_type].failure); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[op_type].failure); _action.continuation->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void *)-err); Lcancel: if (od) { @@ -1532,8 +1532,8 @@ CacheVC::openWriteStartBegin(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED return free_CacheVC(this); } if (((err = vol->open_write_lock(this, false, 1)) > 0)) { - Counter::increment(cache_rsb.status[op_type].failure); - Counter::increment(vol->cache_vol->vol_rsb.status[op_type].failure); + Metrics::Counter::increment(cache_rsb.status[op_type].failure); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[op_type].failure); free_CacheVC(this); _action.continuation->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void *)-err); return EVENT_DONE; @@ -1570,8 +1570,8 @@ Cache::open_write(Continuation *cont, const CacheKey *key, CacheFragType frag_ty c->op_type = static_cast(CacheOpType::Write); c->vol = key_to_vol(key, hostname, host_len); Stripe *vol = c->vol; - Counter::increment(cache_rsb.status[c->op_type].active); - Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); + Metrics::Counter::increment(cache_rsb.status[c->op_type].active); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); c->first_key = c->key = *key; c->frag_type = frag_type; /* @@ -1594,8 +1594,8 @@ Cache::open_write(Continuation *cont, const CacheKey *key, CacheFragType frag_ty if ((res = c->vol->open_write_lock(c, false, 1)) > 0) { // document currently being written, abort - Counter::increment(cache_rsb.status[c->op_type].failure); - Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].failure); + Metrics::Counter::increment(cache_rsb.status[c->op_type].failure); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].failure); cont->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void *)-res); free_CacheVC(c); return ACTION_RESULT_DONE; @@ -1690,8 +1690,8 @@ Cache::open_write(Continuation *cont, const CacheKey *key, CacheHTTPInfo *info, c->op_type = static_cast(CacheOpType::Write); } - Counter::increment(cache_rsb.status[c->op_type].active); - Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); + Metrics::Counter::increment(cache_rsb.status[c->op_type].active); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); // coverity[Y2K38_SAFETY:FALSE] c->pin_in_cache = static_cast(apin_in_cache); @@ -1742,8 +1742,8 @@ Cache::open_write(Continuation *cont, const CacheKey *key, CacheHTTPInfo *info, return ACTION_RESULT_DONE; Lfailure: - Counter::increment(cache_rsb.status[c->op_type].failure); - Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].failure); + Metrics::Counter::increment(cache_rsb.status[c->op_type].failure); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].failure); cont->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void *)-err); if (c->od) { c->openWriteCloseDir(EVENT_IMMEDIATE, nullptr); diff --git a/src/iocore/cache/P_CacheInternal.h b/src/iocore/cache/P_CacheInternal.h index 0d8699d471d..53b5d90c77a 100644 --- a/src/iocore/cache/P_CacheInternal.h +++ b/src/iocore/cache/P_CacheInternal.h @@ -34,7 +34,7 @@ #include "iocore/cache/CacheVC.h" #include "iocore/cache/CacheEvacuateDocVC.h" -using ts::Metrics::Counter; +using ts::Metrics; struct EvacuationBlock; @@ -187,11 +187,11 @@ free_CacheVC(CacheVC *cont) Stripe *vol = cont->vol; if (vol) { - Counter::decrement(cache_rsb.status[cont->op_type].active); - Counter::decrement(vol->cache_vol->vol_rsb.status[cont->op_type].active); + Metrics::Counter::decrement(cache_rsb.status[cont->op_type].active); + Metrics::Counter::decrement(vol->cache_vol->vol_rsb.status[cont->op_type].active); if (cont->closed > 0) { - Counter::increment(cache_rsb.status[cont->op_type].success); - Counter::increment(vol->cache_vol->vol_rsb.status[cont->op_type].success); + Metrics::Counter::increment(cache_rsb.status[cont->op_type].success); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[cont->op_type].success); } // else abort,cancel } ink_assert(mutex->thread_holding == this_ethread()); @@ -397,8 +397,8 @@ Stripe::open_write(CacheVC *cont, int allow_if_writers, int max_writers) } if (agg_error) { - Counter::increment(cache_rsb.write_backlog_failure); - Counter::increment(vol->cache_vol->vol_rsb.write_backlog_failure); + Metrics::Counter::increment(cache_rsb.write_backlog_failure); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.write_backlog_failure); return ECACHE_WRITE_FAIL; } diff --git a/src/iocore/cache/P_CacheStats.h b/src/iocore/cache/P_CacheStats.h index a50aed2811f..dc23047da71 100644 --- a/src/iocore/cache/P_CacheStats.h +++ b/src/iocore/cache/P_CacheStats.h @@ -28,43 +28,43 @@ enum class CacheOpType { Lookup = 0, Read, Write, Update, Remove, Evacuate, Scan struct CacheStatsBlock { struct { - Counter::AtomicType *active = nullptr; - Counter::AtomicType *success = nullptr; - Counter::AtomicType *failure = nullptr; + Metrics::Counter::AtomicType *active = nullptr; + Metrics::Counter::AtomicType *success = nullptr; + Metrics::Counter::AtomicType *failure = nullptr; } status[static_cast(CacheOpType::Last)]; - Counter::AtomicType *fragment_document_count[3] = {nullptr, nullptr, nullptr}; // For 1, 2 and 3+ fragments + Metrics::Counter::AtomicType *fragment_document_count[3] = {nullptr, nullptr, nullptr}; // For 1, 2 and 3+ fragments - Counter::AtomicType *bytes_used = nullptr; - Counter::AtomicType *bytes_total = nullptr; - Counter::AtomicType *stripes = nullptr; - Counter::AtomicType *ram_cache_bytes = nullptr; - Counter::AtomicType *ram_cache_bytes_total = nullptr; - Counter::AtomicType *direntries_total = nullptr; - Counter::AtomicType *direntries_used = nullptr; - Counter::AtomicType *ram_cache_hits = nullptr; - Counter::AtomicType *ram_cache_misses = nullptr; - Counter::AtomicType *pread_count = nullptr; - Counter::AtomicType *percent_full = nullptr; - Counter::AtomicType *read_seek_fail = nullptr; - Counter::AtomicType *read_invalid = nullptr; - Counter::AtomicType *write_backlog_failure = nullptr; - Counter::AtomicType *directory_collision_count = nullptr; - Counter::AtomicType *read_busy_success = nullptr; - Counter::AtomicType *read_busy_failure = nullptr; - Counter::AtomicType *gc_bytes_evacuated = nullptr; - Counter::AtomicType *gc_frags_evacuated = nullptr; - Counter::AtomicType *write_bytes = nullptr; - Counter::AtomicType *hdr_vector_marshal = nullptr; - Counter::AtomicType *hdr_marshal = nullptr; - Counter::AtomicType *hdr_marshal_bytes = nullptr; - Counter::AtomicType *directory_wrap = nullptr; - Counter::AtomicType *directory_sync_count = nullptr; - Counter::AtomicType *directory_sync_time = nullptr; - Counter::AtomicType *directory_sync_bytes = nullptr; - Counter::AtomicType *span_errors_read = nullptr; - Counter::AtomicType *span_errors_write = nullptr; - Counter::AtomicType *span_offline = nullptr; - Counter::AtomicType *span_online = nullptr; - Counter::AtomicType *span_failing = nullptr; + Metrics::Counter::AtomicType *bytes_used = nullptr; + Metrics::Counter::AtomicType *bytes_total = nullptr; + Metrics::Counter::AtomicType *stripes = nullptr; + Metrics::Counter::AtomicType *ram_cache_bytes = nullptr; + Metrics::Counter::AtomicType *ram_cache_bytes_total = nullptr; + Metrics::Counter::AtomicType *direntries_total = nullptr; + Metrics::Counter::AtomicType *direntries_used = nullptr; + Metrics::Counter::AtomicType *ram_cache_hits = nullptr; + Metrics::Counter::AtomicType *ram_cache_misses = nullptr; + Metrics::Counter::AtomicType *pread_count = nullptr; + Metrics::Counter::AtomicType *percent_full = nullptr; + Metrics::Counter::AtomicType *read_seek_fail = nullptr; + Metrics::Counter::AtomicType *read_invalid = nullptr; + Metrics::Counter::AtomicType *write_backlog_failure = nullptr; + Metrics::Counter::AtomicType *directory_collision_count = nullptr; + Metrics::Counter::AtomicType *read_busy_success = nullptr; + Metrics::Counter::AtomicType *read_busy_failure = nullptr; + Metrics::Counter::AtomicType *gc_bytes_evacuated = nullptr; + Metrics::Counter::AtomicType *gc_frags_evacuated = nullptr; + Metrics::Counter::AtomicType *write_bytes = nullptr; + Metrics::Counter::AtomicType *hdr_vector_marshal = nullptr; + Metrics::Counter::AtomicType *hdr_marshal = nullptr; + Metrics::Counter::AtomicType *hdr_marshal_bytes = nullptr; + Metrics::Counter::AtomicType *directory_wrap = nullptr; + Metrics::Counter::AtomicType *directory_sync_count = nullptr; + Metrics::Counter::AtomicType *directory_sync_time = nullptr; + Metrics::Counter::AtomicType *directory_sync_bytes = nullptr; + Metrics::Counter::AtomicType *span_errors_read = nullptr; + Metrics::Counter::AtomicType *span_errors_write = nullptr; + Metrics::Counter::AtomicType *span_offline = nullptr; + Metrics::Counter::AtomicType *span_online = nullptr; + Metrics::Counter::AtomicType *span_failing = nullptr; }; diff --git a/src/iocore/cache/RamCacheCLFUS.cc b/src/iocore/cache/RamCacheCLFUS.cc index 556179454fb..302b6776898 100644 --- a/src/iocore/cache/RamCacheCLFUS.cc +++ b/src/iocore/cache/RamCacheCLFUS.cc @@ -301,8 +301,8 @@ RamCacheCLFUS::get(CryptoHash *key, Ptr *ret_data, uint64_t auxkey if (!e->flag_bits.copy) { // don't bother if we have to copy anyway int64_t delta = (static_cast(e->compressed_len)) - static_cast(e->size); this->_bytes += delta; - Counter::increment(cache_rsb.ram_cache_bytes, delta); - Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); + Metrics::Counter::increment(cache_rsb.ram_cache_bytes, delta); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); e->size = e->compressed_len; check_accounting(this); e->flag_bits.compressed = 0; @@ -317,13 +317,13 @@ RamCacheCLFUS::get(CryptoHash *key, Ptr *ret_data, uint64_t auxkey } (*ret_data) = data; } - Counter::increment(cache_rsb.ram_cache_hits); - Counter::increment(vol->cache_vol->vol_rsb.ram_cache_hits); + Metrics::Counter::increment(cache_rsb.ram_cache_hits); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_hits); DDbg(dbg_ctl_ram_cache, "get %X %" PRId64 " size %d HIT", key->slice32(3), auxkey, e->size); return ram_hit_state; } else { - Counter::increment(cache_rsb.ram_cache_misses); - Counter::increment(vol->cache_vol->vol_rsb.ram_cache_misses); + Metrics::Counter::increment(cache_rsb.ram_cache_misses); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_misses); DDbg(dbg_ctl_ram_cache, "get %X %" PRId64 " HISTORY", key->slice32(3), auxkey); return 0; } @@ -333,8 +333,8 @@ RamCacheCLFUS::get(CryptoHash *key, Ptr *ret_data, uint64_t auxkey } DDbg(dbg_ctl_ram_cache, "get %X %" PRId64 " MISS", key->slice32(3), auxkey); Lerror: - Counter::increment(cache_rsb.ram_cache_misses); - Counter::increment(vol->cache_vol->vol_rsb.ram_cache_misses); + Metrics::Counter::increment(cache_rsb.ram_cache_misses); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_misses); return 0; Lfailed: @@ -407,8 +407,8 @@ RamCacheCLFUS::_destroy(RamCacheCLFUSEntry *e) if (!e->flag_bits.lru) { this->_objects--; this->_bytes -= e->size + ENTRY_OVERHEAD; - Counter::decrement(cache_rsb.ram_cache_bytes, e->size); - Counter::decrement(vol->cache_vol->vol_rsb.ram_cache_bytes, e->size); + Metrics::Counter::decrement(cache_rsb.ram_cache_bytes, e->size); + Metrics::Counter::decrement(vol->cache_vol->vol_rsb.ram_cache_bytes, e->size); e->data = nullptr; } else { this->_history--; @@ -536,8 +536,8 @@ RamCacheCLFUS::compress_entries(EThread *thread, int do_at_most) e->compressed_len = l; int64_t delta = (static_cast(l)) - static_cast(e->size); this->_bytes += delta; - Counter::increment(cache_rsb.ram_cache_bytes, delta); - Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); + Metrics::Counter::increment(cache_rsb.ram_cache_bytes, delta); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); e->size = l; } else { ats_free(b); @@ -546,8 +546,8 @@ RamCacheCLFUS::compress_entries(EThread *thread, int do_at_most) memcpy(bb, e->data->data(), e->len); int64_t delta = (static_cast(e->len)) - static_cast(e->size); this->_bytes += delta; - Counter::increment(cache_rsb.ram_cache_bytes, delta); - Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); + Metrics::Counter::increment(cache_rsb.ram_cache_bytes, delta); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); e->size = e->len; l = e->len; } @@ -578,8 +578,8 @@ RamCacheCLFUS::_requeue_victims(Que(RamCacheCLFUSEntry, lru_link) & victims) RamCacheCLFUSEntry *victim = nullptr; while ((victim = victims.dequeue())) { this->_bytes += victim->size + ENTRY_OVERHEAD; - Counter::increment(cache_rsb.ram_cache_bytes, victim->size); - Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, victim->size); + Metrics::Counter::increment(cache_rsb.ram_cache_bytes, victim->size); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, victim->size); victim->hits = REQUEUE_HITS(victim->hits); this->_lru[0].enqueue(victim); } @@ -614,8 +614,8 @@ RamCacheCLFUS::put(CryptoHash *key, IOBufferData *data, uint32_t len, bool copy, this->_lru[e->flag_bits.lru].enqueue(e); int64_t delta = (static_cast(size)) - static_cast(e->size); this->_bytes += delta; - Counter::increment(cache_rsb.ram_cache_bytes, delta); - Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); + Metrics::Counter::increment(cache_rsb.ram_cache_bytes, delta); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); if (!copy) { e->size = size; e->data = data; @@ -676,8 +676,8 @@ RamCacheCLFUS::put(CryptoHash *key, IOBufferData *data, uint32_t len, bool copy, continue; } this->_bytes -= victim->size + ENTRY_OVERHEAD; - Counter::decrement(cache_rsb.ram_cache_bytes, victim->size); - Counter::decrement(vol->cache_vol->vol_rsb.ram_cache_bytes, victim->size); + Metrics::Counter::decrement(cache_rsb.ram_cache_bytes, victim->size); + Metrics::Counter::decrement(vol->cache_vol->vol_rsb.ram_cache_bytes, victim->size); victims.enqueue(victim); if (victim == this->_compressed) { this->_compressed = nullptr; @@ -705,8 +705,8 @@ RamCacheCLFUS::put(CryptoHash *key, IOBufferData *data, uint32_t len, bool copy, while ((victim = victims.dequeue())) { if (this->_bytes + size + victim->size <= this->_max_bytes) { this->_bytes += victim->size + ENTRY_OVERHEAD; - Counter::increment(cache_rsb.ram_cache_bytes, victim->size); - Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, victim->size); + Metrics::Counter::increment(cache_rsb.ram_cache_bytes, victim->size); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, victim->size); victim->hits = REQUEUE_HITS(victim->hits); this->_lru[0].enqueue(victim); } else { @@ -738,8 +738,8 @@ RamCacheCLFUS::put(CryptoHash *key, IOBufferData *data, uint32_t len, bool copy, } e->flag_bits.copy = copy; this->_bytes += size + ENTRY_OVERHEAD; - Counter::increment(cache_rsb.ram_cache_bytes, size); - Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, size); + Metrics::Counter::increment(cache_rsb.ram_cache_bytes, size); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, size); e->size = size; this->_objects++; this->_lru[0].enqueue(e); diff --git a/src/iocore/cache/RamCacheLRU.cc b/src/iocore/cache/RamCacheLRU.cc index 1fdc1eba30f..2b055a030e0 100644 --- a/src/iocore/cache/RamCacheLRU.cc +++ b/src/iocore/cache/RamCacheLRU.cc @@ -141,16 +141,16 @@ RamCacheLRU::get(CryptoHash *key, Ptr *ret_data, uint64_t auxkey) lru.enqueue(e); (*ret_data) = e->data; DDbg(dbg_ctl_ram_cache, "get %X %" PRIu64 " HIT", key->slice32(3), auxkey); - Counter::increment(cache_rsb.ram_cache_hits); - Counter::increment(vol->cache_vol->vol_rsb.ram_cache_hits); + Metrics::Counter::increment(cache_rsb.ram_cache_hits); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_hits); return 1; } e = e->hash_link.next; } DDbg(dbg_ctl_ram_cache, "get %X %" PRIu64 " MISS", key->slice32(3), auxkey); - Counter::increment(cache_rsb.ram_cache_misses); - Counter::increment(vol->cache_vol->vol_rsb.ram_cache_misses); + Metrics::Counter::increment(cache_rsb.ram_cache_misses); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_misses); return 0; } @@ -163,8 +163,8 @@ RamCacheLRU::remove(RamCacheLRUEntry *e) bucket[b].remove(e); lru.remove(e); bytes -= ENTRY_OVERHEAD + e->data->block_size(); - Counter::decrement(cache_rsb.ram_cache_bytes, ENTRY_OVERHEAD + e->data->block_size()); - Counter::decrement(vol->cache_vol->vol_rsb.ram_cache_bytes, ENTRY_OVERHEAD + e->data->block_size()); + Metrics::Counter::decrement(cache_rsb.ram_cache_bytes, ENTRY_OVERHEAD + e->data->block_size()); + Metrics::Counter::decrement(vol->cache_vol->vol_rsb.ram_cache_bytes, ENTRY_OVERHEAD + e->data->block_size()); DDbg(dbg_ctl_ram_cache, "put %X %" PRIu64 " FREED", e->key.slice32(3), e->auxkey); e->data = nullptr; @@ -212,8 +212,8 @@ RamCacheLRU::put(CryptoHash *key, IOBufferData *data, uint32_t len, bool, uint64 lru.enqueue(e); bytes += ENTRY_OVERHEAD + data->block_size(); objects++; - Counter::increment(cache_rsb.ram_cache_bytes, ENTRY_OVERHEAD + data->block_size()); - Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, ENTRY_OVERHEAD + data->block_size()); + Metrics::Counter::increment(cache_rsb.ram_cache_bytes, ENTRY_OVERHEAD + data->block_size()); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, ENTRY_OVERHEAD + data->block_size()); while (bytes > max_bytes) { RamCacheLRUEntry *ee = lru.dequeue(); if (ee) { diff --git a/src/iocore/dns/DNS.cc b/src/iocore/dns/DNS.cc index 8db24aba743..73de5bcbea3 100644 --- a/src/iocore/dns/DNS.cc +++ b/src/iocore/dns/DNS.cc @@ -470,7 +470,7 @@ DNSHandler::open_cons(sockaddr const *target, bool failed, int icon) bool DNSHandler::reset_tcp_conn(int ndx) { - Counter::increment(dns_rsb.tcp_reset); + Metrics::Counter::increment(dns_rsb.tcp_reset); tcpcon[ndx].close(); return open_con(&m_res->nsaddr_list[ndx].sa, true, ndx, true); } @@ -824,7 +824,7 @@ DNSHandler::rr_failure(int ndx) ++(e->retries); // give them another chance } --in_flight; - Counter::decrement(dns_rsb.in_flight); + Metrics::Counter::decrement(dns_rsb.in_flight); } } else { // move outstanding requests that were sent to this nameserver to another @@ -835,7 +835,7 @@ DNSHandler::rr_failure(int ndx) ++(e->retries); // give them another chance } --in_flight; - Counter::decrement(dns_rsb.in_flight); + Metrics::Counter::decrement(dns_rsb.in_flight); } } } @@ -1079,7 +1079,7 @@ get_entry(DNSHandler *h, char *qname, int qtype) static void write_dns(DNSHandler *h, bool tcp_retry) { - Counter::increment(dns_rsb.total_lookups); + Metrics::Counter::increment(dns_rsb.total_lookups); int max_nscount = h->m_res->nscount; if (max_nscount > MAX_NAMED) { max_nscount = MAX_NAMED; @@ -1217,7 +1217,7 @@ write_dns_event(DNSHandler *h, DNSEntry *e, bool over_tcp) e->which_ns = h->name_server; e->once_written_flag = true; ++h->in_flight; - Counter::increment(dns_rsb.in_flight); + Metrics::Counter::increment(dns_rsb.in_flight); e->send_time = ink_get_hrtime(); @@ -1302,7 +1302,7 @@ DNSEntry::mainEvent(int event, Event *e) Dbg(dbg_ctl_dns, "marking %s as not-written", qname); written_flag = false; --(dnsH->in_flight); - Counter::decrement(dns_rsb.in_flight); + Metrics::Counter::decrement(dns_rsb.in_flight); } timeout = nullptr; dns_result(dnsH, this, result_ent.get(), true); @@ -1349,7 +1349,7 @@ dns_result(DNSHandler *h, DNSEntry *e, HostEnt *ent, bool retry, bool tcp_retry) if (retry && e->retries) { Dbg(dbg_ctl_dns, "doing retry for %s", e->qname); - Counter::increment(dns_rsb.tcp_retries); + Metrics::Counter::increment(dns_rsb.tcp_retries); --(e->retries); write_dns(h, tcp_retry); @@ -1385,7 +1385,7 @@ dns_result(DNSHandler *h, DNSEntry *e, HostEnt *ent, bool retry, bool tcp_retry) } } if (retry) { - Counter::increment(dns_rsb.max_retries_exceeded); + Metrics::Counter::increment(dns_rsb.max_retries_exceeded); } } if (ent == BAD_DNS_RESULT) { @@ -1397,12 +1397,12 @@ dns_result(DNSHandler *h, DNSEntry *e, HostEnt *ent, bool retry, bool tcp_retry) // These are rolling averages, this requires that the lookup_fail/success counters are incremented later if (!ent || !ent->good) { - Counter::increment(dns_rsb.fail_time, diff); - Counter::increment(dns_rsb.lookup_fail); + Metrics::Counter::increment(dns_rsb.fail_time, diff); + Metrics::Counter::increment(dns_rsb.lookup_fail); } else { - Counter::increment(dns_rsb.success_time, diff); + Metrics::Counter::increment(dns_rsb.success_time, diff); - Counter::increment(dns_rsb.lookup_success); + Metrics::Counter::increment(dns_rsb.lookup_success); } } @@ -1559,17 +1559,17 @@ dns_process(DNSHandler *handler, HostEnt *buf, int len) // e->written_flag = false; --(handler->in_flight); - Counter::decrement(dns_rsb.in_flight); + Metrics::Counter::decrement(dns_rsb.in_flight); // These are rolling averages ink_hrtime diff = (ink_get_hrtime() - e->send_time) / HRTIME_MSECOND; - Counter::increment(dns_rsb.response_time, diff); + Metrics::Counter::increment(dns_rsb.response_time, diff); // retrying over TCP when truncated is set if (dns_conn_mode == DNS_CONN_MODE::TCP_RETRY && h->tc == 1) { Dbg(dbg_ctl_dns, "Retrying DNS query over TCP for [%s]", e->qname); tcp_retry = true; - Counter::increment(dns_rsb.tcp_retries); + Metrics::Counter::increment(dns_rsb.tcp_retries); goto Lerror; } @@ -1882,7 +1882,7 @@ dns_process(DNSHandler *handler, HostEnt *buf, int len) } } Lerror:; - Counter::increment(dns_rsb.lookup_fail); + Metrics::Counter::increment(dns_rsb.lookup_fail); buf->good = false; dns_result(handler, e, buf, retry, tcp_retry); return server_ok; @@ -1907,17 +1907,17 @@ ink_dns_init(ts::ModuleVersion v) // // Register statistics callbacks // - dns_rsb.fail_time = Counter::CreatePtr("proxy.process.dns.fail_time"); - dns_rsb.in_flight = Counter::CreatePtr("proxy.process.dns.in_flight"); - dns_rsb.lookup_fail = Counter::CreatePtr("proxy.process.dns.lookup_failures"); - dns_rsb.lookup_success = Counter::CreatePtr("proxy.process.dns.lookup_successes"); - dns_rsb.max_retries_exceeded = Counter::CreatePtr("proxy.process.dns.max_retries_exceeded"); - dns_rsb.response_time = Counter::CreatePtr("proxy.process.dns.lookup_time"); - dns_rsb.retries = Counter::CreatePtr("proxy.process.dns.retries"); - dns_rsb.success_time = Counter::CreatePtr("proxy.process.dns.success_time"); - dns_rsb.tcp_reset = Counter::CreatePtr("proxy.process.dns.tcp_reset"); - dns_rsb.tcp_retries = Counter::CreatePtr("proxy.process.dns.tcp_retries"); - dns_rsb.total_lookups = Counter::CreatePtr("proxy.process.dns.total_dns_lookups"); + dns_rsb.fail_time = Metrics::Counter::createPtr("proxy.process.dns.fail_time"); + dns_rsb.in_flight = Metrics::Counter::createPtr("proxy.process.dns.in_flight"); + dns_rsb.lookup_fail = Metrics::Counter::createPtr("proxy.process.dns.lookup_failures"); + dns_rsb.lookup_success = Metrics::Counter::createPtr("proxy.process.dns.lookup_successes"); + dns_rsb.max_retries_exceeded = Metrics::Counter::createPtr("proxy.process.dns.max_retries_exceeded"); + dns_rsb.response_time = Metrics::Counter::createPtr("proxy.process.dns.lookup_time"); + dns_rsb.retries = Metrics::Counter::createPtr("proxy.process.dns.retries"); + dns_rsb.success_time = Metrics::Counter::createPtr("proxy.process.dns.success_time"); + dns_rsb.tcp_reset = Metrics::Counter::createPtr("proxy.process.dns.tcp_reset"); + dns_rsb.tcp_retries = Metrics::Counter::createPtr("proxy.process.dns.tcp_retries"); + dns_rsb.total_lookups = Metrics::Counter::createPtr("proxy.process.dns.total_dns_lookups"); } #if TS_HAS_TESTS diff --git a/src/iocore/dns/P_DNSProcessor.h b/src/iocore/dns/P_DNSProcessor.h index 8218e59984c..a14c44fecfa 100644 --- a/src/iocore/dns/P_DNSProcessor.h +++ b/src/iocore/dns/P_DNSProcessor.h @@ -45,7 +45,7 @@ #include "api/Metrics.h" -using ts::Metrics::Counter; +using ts::Metrics; #define MAX_NAMED 32 #define DEFAULT_DNS_RETRIES 5 @@ -97,17 +97,17 @@ extern unsigned int dns_sequence_number; // Stats struct DNSStatsBlock { - Counter::AtomicType *fail_time; - Counter::AtomicType *in_flight; - Counter::AtomicType *lookup_fail; - Counter::AtomicType *lookup_success; - Counter::AtomicType *max_retries_exceeded; - Counter::AtomicType *response_time; - Counter::AtomicType *retries; - Counter::AtomicType *success_time; - Counter::AtomicType *tcp_reset; - Counter::AtomicType *tcp_retries; - Counter::AtomicType *total_lookups; + Metrics::Counter::AtomicType *fail_time; + Metrics::Counter::AtomicType *in_flight; + Metrics::Counter::AtomicType *lookup_fail; + Metrics::Counter::AtomicType *lookup_success; + Metrics::Counter::AtomicType *max_retries_exceeded; + Metrics::Counter::AtomicType *response_time; + Metrics::Counter::AtomicType *retries; + Metrics::Counter::AtomicType *success_time; + Metrics::Counter::AtomicType *tcp_reset; + Metrics::Counter::AtomicType *tcp_retries; + Metrics::Counter::AtomicType *total_lookups; }; struct HostEnt; diff --git a/src/iocore/hostdb/HostDB.cc b/src/iocore/hostdb/HostDB.cc index 471d6836181..52e93d2cbdd 100644 --- a/src/iocore/hostdb/HostDB.cc +++ b/src/iocore/hostdb/HostDB.cc @@ -510,7 +510,7 @@ probe(HostDBHash const &hash, bool ignore_timeout) return NO_RECORD; // if we aren't ignoring timeouts, and we are past it-- then remove the record } else if (!ignore_timeout && record->is_ip_timeout() && !record->serve_stale_but_revalidate()) { - Counter::increment(hostdb_rsb.ttl_expires); + Metrics::Counter::increment(hostdb_rsb.ttl_expires); return NO_RECORD; } } @@ -518,7 +518,7 @@ probe(HostDBHash const &hash, bool ignore_timeout) // If the record is stale, but we want to revalidate-- lets start that up if ((!ignore_timeout && record->is_ip_configured_stale() && record->record_type != HostDBType::HOST) || (record->is_ip_timeout() && record->serve_stale_but_revalidate())) { - Counter::increment(hostdb_rsb.total_serve_stale); + Metrics::Counter::increment(hostdb_rsb.total_serve_stale); if (hostDB.is_pending_dns_for_hash(hash.hash)) { Dbg(dbg_ctl_hostdb, "%s", swoc::bwprint(ts::bw_dbg, "stale {} {} {}, using with pending refresh", record->ip_age(), @@ -556,11 +556,11 @@ HostDBProcessor::getby(Continuation *cont, cb_process_result_pfn cb_process_resu } else if (opt.flags & HOSTDB_FORCE_DNS_RELOAD) { force_dns = hostdb_re_dns_on_reload; if (force_dns) { - Counter::increment(hostdb_rsb.re_dns_on_reload); + Metrics::Counter::increment(hostdb_rsb.re_dns_on_reload); } } - Counter::increment(hostdb_rsb.total_lookups); + Metrics::Counter::increment(hostdb_rsb.total_lookups); if (!hostdb_enable || // if the HostDB is disabled, (hash.host_name && !*hash.host_name) || // or host_name is empty string @@ -604,7 +604,7 @@ HostDBProcessor::getby(Continuation *cont, cb_process_result_pfn cb_process_resu } else { Dbg(dbg_ctl_hostdb, "immediate answer for %s", hash.ip.isValid() ? hash.ip.toString(ipb, sizeof ipb) : ""); } - Counter::increment(hostdb_rsb.total_hits); + Metrics::Counter::increment(hostdb_rsb.total_hits); if (cb_process_result) { (cont->*cb_process_result)(r.get()); } else { @@ -749,7 +749,7 @@ HostDBProcessor::iterate(Continuation *cont) ink_assert(cont->mutex->thread_holding == this_ethread()); EThread *thread = cont->mutex->thread_holding; - Counter::increment(hostdb_rsb.total_lookups); + Metrics::Counter::increment(hostdb_rsb.total_lookups); HostDBContinuation *c = hostDBContAllocator.alloc(); HostDBContinuation::Options copt; @@ -814,7 +814,7 @@ HostDBContinuation::lookup_done(TextView query_name, ts_seconds answer_ttl, SRVH } break; } - Counter::increment(hostdb_rsb.ttl, answer_ttl.count()); + Metrics::Counter::increment(hostdb_rsb.ttl, answer_ttl.count()); // update the TTL record->ip_timestamp = hostdb_current_timestamp; @@ -1184,7 +1184,7 @@ HostDBContinuation::probeEvent(int /* event ATS_UNUSED */, Event *e) Ptr r = probe(hash, false); if (r) { - Counter::increment(hostdb_rsb.total_hits); + Metrics::Counter::increment(hostdb_rsb.total_hits); } if (action.continuation && r) { @@ -1212,7 +1212,7 @@ HostDBContinuation::set_check_pending_dns() Queue &q = hostDB.pending_dns_for_hash(hash.hash); this->setThreadAffinity(this_ethread()); if (q.in(this)) { - Counter::increment(hostdb_rsb.insert_duplicate_to_pending_dns); + Metrics::Counter::increment(hostdb_rsb.insert_duplicate_to_pending_dns); Dbg(dbg_ctl_hostdb, "Skip the insertion of the same continuation to pending dns"); return false; } @@ -1790,13 +1790,13 @@ ink_hostdb_init(ts::ModuleVersion v) // // Register stats // - hostdb_rsb.total_lookups = Counter::CreatePtr("proxy.process.hostdb.total_lookups"); - hostdb_rsb.total_hits = Counter::CreatePtr("proxy.process.hostdb.total_hits"); - hostdb_rsb.total_serve_stale = Counter::CreatePtr("proxy.process.hostdb.total_serve_stale"); - hostdb_rsb.ttl = Counter::CreatePtr("proxy.process.hostdb.ttl"); - hostdb_rsb.ttl_expires = Counter::CreatePtr("proxy.process.hostdb.ttl_expires"); - hostdb_rsb.re_dns_on_reload = Counter::CreatePtr("proxy.process.hostdb.re_dns_on_reload"); - hostdb_rsb.insert_duplicate_to_pending_dns = Counter::CreatePtr("proxy.process.hostdb.insert_duplicate_to_pending_dns"); + hostdb_rsb.total_lookups = Metrics::Counter::createPtr("proxy.process.hostdb.total_lookups"); + hostdb_rsb.total_hits = Metrics::Counter::createPtr("proxy.process.hostdb.total_hits"); + hostdb_rsb.total_serve_stale = Metrics::Counter::createPtr("proxy.process.hostdb.total_serve_stale"); + hostdb_rsb.ttl = Metrics::Counter::createPtr("proxy.process.hostdb.ttl"); + hostdb_rsb.ttl_expires = Metrics::Counter::createPtr("proxy.process.hostdb.ttl_expires"); + hostdb_rsb.re_dns_on_reload = Metrics::Counter::createPtr("proxy.process.hostdb.re_dns_on_reload"); + hostdb_rsb.insert_duplicate_to_pending_dns = Metrics::Counter::createPtr("proxy.process.hostdb.insert_duplicate_to_pending_dns"); ts_host_res_global_init(); } diff --git a/src/iocore/hostdb/P_HostDBProcessor.h b/src/iocore/hostdb/P_HostDBProcessor.h index 1d7604f4651..bdfeb1d26f6 100644 --- a/src/iocore/hostdb/P_HostDBProcessor.h +++ b/src/iocore/hostdb/P_HostDBProcessor.h @@ -37,7 +37,7 @@ #include "tscore/PendingAction.h" #include "api/Metrics.h" -using ts::Metrics::Counter; +using ts::Metrics; // // Data @@ -120,13 +120,13 @@ struct HostEnt; // Stats struct HostDBStatsBlock { - Counter::AtomicType *total_lookups; - Counter::AtomicType *total_hits; - Counter::AtomicType *total_serve_stale; - Counter::AtomicType *ttl; - Counter::AtomicType *ttl_expires; - Counter::AtomicType *re_dns_on_reload; - Counter::AtomicType *insert_duplicate_to_pending_dns; + Metrics::Counter::AtomicType *total_lookups; + Metrics::Counter::AtomicType *total_hits; + Metrics::Counter::AtomicType *total_serve_stale; + Metrics::Counter::AtomicType *ttl; + Metrics::Counter::AtomicType *ttl_expires; + Metrics::Counter::AtomicType *re_dns_on_reload; + Metrics::Counter::AtomicType *insert_duplicate_to_pending_dns; }; extern HostDBStatsBlock hostdb_rsb; diff --git a/src/iocore/hostdb/P_RefCountCache.h b/src/iocore/hostdb/P_RefCountCache.h index 90fafa427b4..cf18cc6449a 100644 --- a/src/iocore/hostdb/P_RefCountCache.h +++ b/src/iocore/hostdb/P_RefCountCache.h @@ -39,7 +39,7 @@ #include #include -using ts::Metrics::Counter; +using ts::Metrics; #define REFCOUNT_CACHE_EVENT_SYNC REFCOUNT_CACHE_EVENT_EVENTS_START @@ -51,15 +51,15 @@ static constexpr ts::VersionNumber REFCOUNTCACHE_VERSION(1, 0); // Stats struct RefCountCacheBlock { - Counter::AtomicType *refcountcache_current_items; - Counter::AtomicType *refcountcache_current_size; - Counter::AtomicType *refcountcache_total_inserts; - Counter::AtomicType *refcountcache_total_failed_inserts; - Counter::AtomicType *refcountcache_total_lookups; - Counter::AtomicType *refcountcache_total_hits; - Counter::AtomicType *refcountcache_last_sync_time; - Counter::AtomicType *refcountcache_last_total_items; - Counter::AtomicType *refcountcache_last_total_size; + Metrics::Counter::AtomicType *refcountcache_current_items; + Metrics::Counter::AtomicType *refcountcache_current_size; + Metrics::Counter::AtomicType *refcountcache_total_inserts; + Metrics::Counter::AtomicType *refcountcache_total_failed_inserts; + Metrics::Counter::AtomicType *refcountcache_total_lookups; + Metrics::Counter::AtomicType *refcountcache_total_hits; + Metrics::Counter::AtomicType *refcountcache_last_sync_time; + Metrics::Counter::AtomicType *refcountcache_last_total_items; + Metrics::Counter::AtomicType *refcountcache_last_total_size; }; struct RefCountCacheItemMeta { @@ -204,10 +204,10 @@ template Ptr RefCountCachePartition::get(uint64_t key) { - Counter::increment(this->rsb->refcountcache_total_lookups); + Metrics::Counter::increment(this->rsb->refcountcache_total_lookups); if (auto it = this->item_map.find(key); it != this->item_map.end()) { // found - Counter::increment(this->rsb->refcountcache_total_hits); + Metrics::Counter::increment(this->rsb->refcountcache_total_hits); return make_ptr(static_cast(it->item.get())); } else { return Ptr(); @@ -218,7 +218,7 @@ template void RefCountCachePartition::put(uint64_t key, C *item, int size, int expire_time) { - Counter::increment(this->rsb->refcountcache_total_inserts); + Metrics::Counter::increment(this->rsb->refcountcache_total_inserts); size += sizeof(C); // Remove any colliding entries this->erase(key); @@ -226,7 +226,7 @@ RefCountCachePartition::put(uint64_t key, C *item, int size, int expire_time) // if we are full, and can't make space-- then don't store the item if (this->is_full() && !this->make_space_for(size)) { Dbg(dbg_ctl, "partition %d is full-- not storing item key=%" PRIu64, this->part_num, key); - Counter::increment(this->rsb->refcountcache_total_failed_inserts); + Metrics::Counter::increment(this->rsb->refcountcache_total_failed_inserts); return; } @@ -247,8 +247,8 @@ RefCountCachePartition::put(uint64_t key, C *item, int size, int expire_time) this->item_map.insert(val); this->size += val->meta.size; this->items++; - Counter::increment(this->rsb->refcountcache_current_size, (int64_t)val->meta.size); - Counter::increment(this->rsb->refcountcache_current_items); + Metrics::Counter::increment(this->rsb->refcountcache_current_size, (int64_t)val->meta.size); + Metrics::Counter::increment(this->rsb->refcountcache_current_items); } template @@ -273,8 +273,8 @@ RefCountCachePartition::dealloc_entry(hash_type::iterator ptr) this->size -= ptr->meta.size; this->items--; - Counter::decrement(this->rsb->refcountcache_current_size, ptr->meta.size); - Counter::decrement(this->rsb->refcountcache_current_items); + Metrics::Counter::decrement(this->rsb->refcountcache_current_size, ptr->meta.size); + Metrics::Counter::decrement(this->rsb->refcountcache_current_items); // remove from expiry queue if (ptr->expiry_entry != nullptr) { @@ -432,15 +432,15 @@ RefCountCache::RefCountCache(unsigned int num_partitions, int size, int items this->max_items = items; this->num_partitions = num_partitions; - this->rsb.refcountcache_current_items = Counter::CreatePtr((metrics_prefix + "current_items").c_str()); - this->rsb.refcountcache_current_size = Counter::CreatePtr((metrics_prefix + "current_size").c_str()); - this->rsb.refcountcache_total_inserts = Counter::CreatePtr((metrics_prefix + "total_inserts").c_str()); - this->rsb.refcountcache_total_failed_inserts = Counter::CreatePtr((metrics_prefix + "total_failed_inserts").c_str()); - this->rsb.refcountcache_total_lookups = Counter::CreatePtr((metrics_prefix + "total_lookups").c_str()); - this->rsb.refcountcache_total_hits = Counter::CreatePtr((metrics_prefix + "total_hits").c_str()); - this->rsb.refcountcache_last_sync_time = Counter::CreatePtr((metrics_prefix + "last_sync.time").c_str()); - this->rsb.refcountcache_last_total_items = Counter::CreatePtr((metrics_prefix + "last_sync.total_items").c_str()); - this->rsb.refcountcache_last_total_size = Counter::CreatePtr((metrics_prefix + "last_sync.total_size").c_str()); + this->rsb.refcountcache_current_items = Metrics::Counter::createPtr((metrics_prefix + "current_items").c_str()); + this->rsb.refcountcache_current_size = Metrics::Counter::createPtr((metrics_prefix + "current_size").c_str()); + this->rsb.refcountcache_total_inserts = Metrics::Counter::createPtr((metrics_prefix + "total_inserts").c_str()); + this->rsb.refcountcache_total_failed_inserts = Metrics::Counter::createPtr((metrics_prefix + "total_failed_inserts").c_str()); + this->rsb.refcountcache_total_lookups = Metrics::Counter::createPtr((metrics_prefix + "total_lookups").c_str()); + this->rsb.refcountcache_total_hits = Metrics::Counter::createPtr((metrics_prefix + "total_hits").c_str()); + this->rsb.refcountcache_last_sync_time = Metrics::Counter::createPtr((metrics_prefix + "last_sync.time").c_str()); + this->rsb.refcountcache_last_total_items = Metrics::Counter::createPtr((metrics_prefix + "last_sync.total_items").c_str()); + this->rsb.refcountcache_last_total_size = Metrics::Counter::createPtr((metrics_prefix + "last_sync.total_size").c_str()); // Now lets create all the partitions this->partitions.reserve(num_partitions); diff --git a/src/iocore/io_uring/io_uring.cc b/src/iocore/io_uring/io_uring.cc index 19bac433627..d80d2341656 100644 --- a/src/iocore/io_uring/io_uring.cc +++ b/src/iocore/io_uring/io_uring.cc @@ -33,21 +33,21 @@ Linux io_uring helper library #include "tscore/Diags.h" #include -using ts::Metrics::Counter; +using ts::Metrics; std::atomic main_wq_fd; IOUringConfig IOUringContext::config; struct IOUringStatsBlock { - Counter::AtomicType *io_uring_submitted; - Counter::AtomicType *io_uring_completed; + Metrics::Counter::AtomicType *io_uring_submitted; + Metrics::Counter::AtomicType *io_uring_completed; }; static IOUringStatsBlock io_uring_rsb = []() { auto &intm = Metrics::getInstance(); - return IOUringStatsBlock{Counter::CreatePtr("proxy.process.io_uring.submitted"), - Counter::CreatePtr("proxy.process.io_uring.completed")}; + return IOUringStatsBlock{Metrics::Counter::createPtr("proxy.process.io_uring.submitted"), + Metrics::Counter::createPtr("proxy.process.io_uring.completed")}; }(); void @@ -142,7 +142,7 @@ IOUringContext::get_wq_max_workers() void IOUringContext::submit() { - Counter::increment(io_uring_rsb.io_uring_submitted, io_uring_submit(&ring)); + Metrics::Counter::increment(io_uring_rsb.io_uring_submitted, io_uring_submit(&ring)); } void @@ -160,7 +160,7 @@ IOUringContext::service() io_uring_peek_cqe(&ring, &cqe); while (cqe) { handle_cqe(cqe); - Counter::increment(io_uring_rsb.io_uring_completed); + Metrics::Counter::increment(io_uring_rsb.io_uring_completed); io_uring_cqe_seen(&ring, cqe); cqe = nullptr; @@ -182,10 +182,10 @@ IOUringContext::submit_and_wait(ink_hrtime t) int count = io_uring_submit_and_wait_timeout(&ring, &cqe, 1, &timeout, nullptr); - Counter::increment(io_uring_rsb.io_uring_submitted, count); + Metrics::Counter::increment(io_uring_rsb.io_uring_submitted, count); while (cqe) { handle_cqe(cqe); - Counter::increment(io_uring_rsb.io_uring_completed); + Metrics::Counter::increment(io_uring_rsb.io_uring_completed); io_uring_cqe_seen(&ring, cqe); cqe = nullptr; diff --git a/src/iocore/io_uring/unit_tests/test_diskIO.cc b/src/iocore/io_uring/unit_tests/test_diskIO.cc index 3cdbeb03cc9..b9e06031fdf 100644 --- a/src/iocore/io_uring/unit_tests/test_diskIO.cc +++ b/src/iocore/io_uring/unit_tests/test_diskIO.cc @@ -36,7 +36,7 @@ #include "tscore/ink_hrtime.h" #include "api/Metrics.h" -using ts::Metrics::Counter; +using ts::Metrics; swoc::file::path temp_prefix(const char *basename) @@ -267,12 +267,12 @@ TEST_CASE("net_io", "[io_uring]") auto &m = Metrics::getInstance(); - Counter::AtomicType *completed = m.lookup(m.lookup("proxy.process.io_uring.completed")); + Metrics::Counter::AtomicType *completed = m.lookup(m.lookup("proxy.process.io_uring.completed")); - uint64_t completions_before = Counter::read(completed); + uint64_t completions_before = Metrics::Counter::read(completed); uint64_t needed = 2; - while ((Counter::read(completed) - completions_before) < needed) { + while ((Metrics::Counter::read(completed) - completions_before) < needed) { ctx.submit_and_wait(1 * HRTIME_SECOND); } diff --git a/src/iocore/net/BIO_fastopen.cc b/src/iocore/net/BIO_fastopen.cc index c836e8517e4..ac2a9e38b79 100644 --- a/src/iocore/net/BIO_fastopen.cc +++ b/src/iocore/net/BIO_fastopen.cc @@ -120,10 +120,10 @@ fastopen_bwrite(BIO *bio, const char *in, int insz) // sent without data and we should retry. const sockaddr *dst = reinterpret_cast(BIO_get_data(bio)); - Counter::increment(net_rsb.fastopen_attempts); + Metrics::Counter::increment(net_rsb.fastopen_attempts); err = SocketManager::sendto(fd, (void *)in, insz, MSG_FASTOPEN, dst, ats_ip_size(dst)); if (err >= 0) { - Counter::increment(net_rsb.fastopen_successes); + Metrics::Counter::increment(net_rsb.fastopen_successes); } BIO_set_data(bio, nullptr); diff --git a/src/iocore/net/Net.cc b/src/iocore/net/Net.cc index 0a2665650b1..41a402932bf 100644 --- a/src/iocore/net/Net.cc +++ b/src/iocore/net/Net.cc @@ -80,56 +80,61 @@ configure_net() static inline void register_net_stats() { - net_rsb.accepts_currently_open = Counter::CreatePtr("proxy.process.net.accepts_currently_open"); - net_rsb.calls_to_read = Counter::CreatePtr("proxy.process.net.calls_to_read"); - net_rsb.calls_to_read_nodata = Counter::CreatePtr("proxy.process.net.calls_to_read_nodata"); - net_rsb.calls_to_readfromnet = Counter::CreatePtr("proxy.process.net.calls_to_readfromnet"); - net_rsb.calls_to_write = Counter::CreatePtr("proxy.process.net.calls_to_write"); - net_rsb.calls_to_write_nodata = Counter::CreatePtr("proxy.process.net.calls_to_write_nodata"); - net_rsb.calls_to_writetonet = Counter::CreatePtr("proxy.process.net.calls_to_writetonet"); - net_rsb.connections_currently_open = Counter::CreatePtr("proxy.process.net.connections_currently_open"); - net_rsb.connections_throttled_in = Counter::CreatePtr("proxy.process.net.connections_throttled_in"); - net_rsb.connections_throttled_out = Counter::CreatePtr("proxy.process.net.connections_throttled_out"); - net_rsb.tunnel_total_client_connections_blind_tcp = Counter::CreatePtr("proxy.process.tunnel.total_client_connections_blind_tcp"); + net_rsb.accepts_currently_open = Metrics::Counter::createPtr("proxy.process.net.accepts_currently_open"); + net_rsb.calls_to_read = Metrics::Counter::createPtr("proxy.process.net.calls_to_read"); + net_rsb.calls_to_read_nodata = Metrics::Counter::createPtr("proxy.process.net.calls_to_read_nodata"); + net_rsb.calls_to_readfromnet = Metrics::Counter::createPtr("proxy.process.net.calls_to_readfromnet"); + net_rsb.calls_to_write = Metrics::Counter::createPtr("proxy.process.net.calls_to_write"); + net_rsb.calls_to_write_nodata = Metrics::Counter::createPtr("proxy.process.net.calls_to_write_nodata"); + net_rsb.calls_to_writetonet = Metrics::Counter::createPtr("proxy.process.net.calls_to_writetonet"); + net_rsb.connections_currently_open = Metrics::Counter::createPtr("proxy.process.net.connections_currently_open"); + net_rsb.connections_throttled_in = Metrics::Counter::createPtr("proxy.process.net.connections_throttled_in"); + net_rsb.connections_throttled_out = Metrics::Counter::createPtr("proxy.process.net.connections_throttled_out"); + net_rsb.tunnel_total_client_connections_blind_tcp = + Metrics::Counter::createPtr("proxy.process.tunnel.total_client_connections_blind_tcp"); net_rsb.tunnel_current_client_connections_blind_tcp = - Counter::CreatePtr("proxy.process.tunnel.current_client_connections_blind_tcp"); - net_rsb.tunnel_total_server_connections_blind_tcp = Counter::CreatePtr("proxy.process.tunnel.total_server_connections_blind_tcp"); + Metrics::Counter::createPtr("proxy.process.tunnel.current_client_connections_blind_tcp"); + net_rsb.tunnel_total_server_connections_blind_tcp = + Metrics::Counter::createPtr("proxy.process.tunnel.total_server_connections_blind_tcp"); net_rsb.tunnel_current_server_connections_blind_tcp = - Counter::CreatePtr("proxy.process.tunnel.current_server_connections_blind_tcp"); + Metrics::Counter::createPtr("proxy.process.tunnel.current_server_connections_blind_tcp"); net_rsb.tunnel_total_client_connections_tls_tunnel = - Counter::CreatePtr("proxy.process.tunnel.total_client_connections_tls_tunnel"); + Metrics::Counter::createPtr("proxy.process.tunnel.total_client_connections_tls_tunnel"); net_rsb.tunnel_current_client_connections_tls_tunnel = - Counter::CreatePtr("proxy.process.tunnel.current_client_connections_tls_tunnel"); + Metrics::Counter::createPtr("proxy.process.tunnel.current_client_connections_tls_tunnel"); net_rsb.tunnel_total_client_connections_tls_forward = - Counter::CreatePtr("proxy.process.tunnel.total_client_connections_tls_forward"); + Metrics::Counter::createPtr("proxy.process.tunnel.total_client_connections_tls_forward"); net_rsb.tunnel_current_client_connections_tls_forward = - Counter::CreatePtr("proxy.process.tunnel.current_client_connections_tls_forward"); + Metrics::Counter::createPtr("proxy.process.tunnel.current_client_connections_tls_forward"); net_rsb.tunnel_total_client_connections_tls_partial_blind = - Counter::CreatePtr("proxy.process.tunnel.total_client_connections_tls_partial_blind"); + Metrics::Counter::createPtr("proxy.process.tunnel.total_client_connections_tls_partial_blind"); net_rsb.tunnel_current_client_connections_tls_partial_blind = - Counter::CreatePtr("proxy.process.tunnel.current_client_connections_tls_partial_blind"); - net_rsb.tunnel_total_client_connections_tls_http = Counter::CreatePtr("proxy.process.tunnel.total_client_connections_tls_http"); + Metrics::Counter::createPtr("proxy.process.tunnel.current_client_connections_tls_partial_blind"); + net_rsb.tunnel_total_client_connections_tls_http = + Metrics::Counter::createPtr("proxy.process.tunnel.total_client_connections_tls_http"); net_rsb.tunnel_current_client_connections_tls_http = - Counter::CreatePtr("proxy.process.tunnel.current_client_connections_tls_http"); - net_rsb.tunnel_total_server_connections_tls = Counter::CreatePtr("proxy.process.tunnel.total_server_connections_tls"); - net_rsb.tunnel_current_server_connections_tls = Counter::CreatePtr("proxy.process.tunnel.current_server_connections_tls"); - net_rsb.default_inactivity_timeout_applied = Counter::CreatePtr("proxy.process.net.default_inactivity_timeout_applied"); - net_rsb.default_inactivity_timeout_count = Counter::CreatePtr("proxy.process.net.default_inactivity_timeout_count"); - net_rsb.fastopen_attempts = Counter::CreatePtr("proxy.process.net.fastopen_out.attempts"); - net_rsb.fastopen_successes = Counter::CreatePtr("proxy.process.net.fastopen_out.successes"); - net_rsb.handler_run = Counter::CreatePtr("proxy.process.net.net_handler_run"); - net_rsb.inactivity_cop_lock_acquire_failure = Counter::CreatePtr("proxy.process.net.inactivity_cop_lock_acquire_failure"); - net_rsb.keep_alive_queue_timeout_count = Counter::CreatePtr("proxy.process.net.dynamic_keep_alive_timeout_in_count"); - net_rsb.keep_alive_queue_timeout_total = Counter::CreatePtr("proxy.process.net.dynamic_keep_alive_timeout_in_total"); - net_rsb.read_bytes = Counter::CreatePtr("proxy.process.net.read_bytes"); - net_rsb.read_bytes_count = Counter::CreatePtr("proxy.process.net.read_bytes_count"); - net_rsb.requests_max_throttled_in = Counter::CreatePtr("proxy.process.net.max.requests_throttled_in"); - net_rsb.socks_connections_currently_open = Counter::CreatePtr("proxy.process.socks.connections_currently_open"); - net_rsb.socks_connections_successful = Counter::CreatePtr("proxy.process.socks.connections_successful"); - net_rsb.socks_connections_unsuccessful = Counter::CreatePtr("proxy.process.socks.connections_unsuccessful"); - net_rsb.tcp_accept = Counter::CreatePtr("proxy.process.tcp.total_accepts"); - net_rsb.write_bytes = Counter::CreatePtr("proxy.process.net.write_bytes"); - net_rsb.write_bytes_count = Counter::CreatePtr("proxy.process.net.write_bytes_count"); + Metrics::Counter::createPtr("proxy.process.tunnel.current_client_connections_tls_http"); + net_rsb.tunnel_total_server_connections_tls = Metrics::Counter::createPtr("proxy.process.tunnel.total_server_connections_tls"); + net_rsb.tunnel_current_server_connections_tls = + Metrics::Counter::createPtr("proxy.process.tunnel.current_server_connections_tls"); + net_rsb.default_inactivity_timeout_applied = Metrics::Counter::createPtr("proxy.process.net.default_inactivity_timeout_applied"); + net_rsb.default_inactivity_timeout_count = Metrics::Counter::createPtr("proxy.process.net.default_inactivity_timeout_count"); + net_rsb.fastopen_attempts = Metrics::Counter::createPtr("proxy.process.net.fastopen_out.attempts"); + net_rsb.fastopen_successes = Metrics::Counter::createPtr("proxy.process.net.fastopen_out.successes"); + net_rsb.handler_run = Metrics::Counter::createPtr("proxy.process.net.net_handler_run"); + net_rsb.inactivity_cop_lock_acquire_failure = + Metrics::Counter::createPtr("proxy.process.net.inactivity_cop_lock_acquire_failure"); + net_rsb.keep_alive_queue_timeout_count = Metrics::Counter::createPtr("proxy.process.net.dynamic_keep_alive_timeout_in_count"); + net_rsb.keep_alive_queue_timeout_total = Metrics::Counter::createPtr("proxy.process.net.dynamic_keep_alive_timeout_in_total"); + net_rsb.read_bytes = Metrics::Counter::createPtr("proxy.process.net.read_bytes"); + net_rsb.read_bytes_count = Metrics::Counter::createPtr("proxy.process.net.read_bytes_count"); + net_rsb.requests_max_throttled_in = Metrics::Counter::createPtr("proxy.process.net.max.requests_throttled_in"); + net_rsb.socks_connections_currently_open = Metrics::Counter::createPtr("proxy.process.socks.connections_currently_open"); + net_rsb.socks_connections_successful = Metrics::Counter::createPtr("proxy.process.socks.connections_successful"); + net_rsb.socks_connections_unsuccessful = Metrics::Counter::createPtr("proxy.process.socks.connections_unsuccessful"); + net_rsb.tcp_accept = Metrics::Counter::createPtr("proxy.process.tcp.total_accepts"); + net_rsb.write_bytes = Metrics::Counter::createPtr("proxy.process.net.write_bytes"); + net_rsb.write_bytes_count = Metrics::Counter::createPtr("proxy.process.net.write_bytes_count"); } void diff --git a/src/iocore/net/NetHandler.cc b/src/iocore/net/NetHandler.cc index 397ee71858d..d823c0b3b1d 100644 --- a/src/iocore/net/NetHandler.cc +++ b/src/iocore/net/NetHandler.cc @@ -326,7 +326,7 @@ NetHandler::waitForActivity(ink_hrtime timeout) IOUringContext *ur = IOUringContext::local_context(); #endif - Counter::increment(net_rsb.handler_run); + Metrics::Counter::increment(net_rsb.handler_run); SCOPED_MUTEX_LOCK(lock, mutex, this->thread); process_enabled_list(); @@ -481,8 +481,8 @@ NetHandler::_close_ne(NetEvent *ne, ink_hrtime now, int &handle_event, int &clos if (diff > 0) { total_idle_time += diff; ++total_idle_count; - Counter::increment(net_rsb.keep_alive_queue_timeout_total, diff); - Counter::increment(net_rsb.keep_alive_queue_timeout_count); + Metrics::Counter::increment(net_rsb.keep_alive_queue_timeout_total, diff); + Metrics::Counter::increment(net_rsb.keep_alive_queue_timeout_count); } Debug("net_queue", "closing connection NetEvent=%p idle: %u now: %" PRId64 " at: %" PRId64 " in: %" PRId64 " diff: %" PRId64, ne, keep_alive_queue_size, ink_hrtime_to_sec(now), ink_hrtime_to_sec(ne->next_inactivity_timeout_at), @@ -560,7 +560,7 @@ NetHandler::add_to_active_queue(NetEvent *ne) } else { if (active_queue_full) { // there is no room left in the queue - Counter::increment(net_rsb.requests_max_throttled_in); + Metrics::Counter::increment(net_rsb.requests_max_throttled_in); return false; } // in the keep-alive queue or no queue, new to this queue diff --git a/src/iocore/net/OCSPStapling.cc b/src/iocore/net/OCSPStapling.cc index f56da3b51e2..3dec8601130 100644 --- a/src/iocore/net/OCSPStapling.cc +++ b/src/iocore/net/OCSPStapling.cc @@ -985,10 +985,10 @@ stapling_check_response(certinfo *cinf, TS_OCSP_RESPONSE *rsp) case TS_OCSP_CERTSTATUS_GOOD: break; case TS_OCSP_CERTSTATUS_REVOKED: - Counter::increment(ssl_rsb.ocsp_revoked_cert); + Metrics::Counter::increment(ssl_rsb.ocsp_revoked_cert); break; case TS_OCSP_CERTSTATUS_UNKNOWN: - Counter::increment(ssl_rsb.ocsp_unknown_cert); + Metrics::Counter::increment(ssl_rsb.ocsp_unknown_cert); break; default: break; @@ -1281,10 +1281,10 @@ ocsp_update() ink_mutex_release(&cinf->stapling_mutex); if (stapling_refresh_response(cinf, &resp)) { Debug("ssl_ocsp", "Successfully refreshed OCSP for %s certificate. url=%s", cinf->certname, cinf->uri); - Counter::increment(ssl_rsb.ocsp_refreshed_cert); + Metrics::Counter::increment(ssl_rsb.ocsp_refreshed_cert); } else { Error("Failed to refresh OCSP for %s certificate. url=%s", cinf->certname, cinf->uri); - Counter::increment(ssl_rsb.ocsp_refresh_cert_failure); + Metrics::Counter::increment(ssl_rsb.ocsp_refresh_cert_failure); } } else { ink_mutex_release(&cinf->stapling_mutex); diff --git a/src/iocore/net/P_Net.h b/src/iocore/net/P_Net.h index 65f9c09c84c..4d3a5db89ad 100644 --- a/src/iocore/net/P_Net.h +++ b/src/iocore/net/P_Net.h @@ -32,51 +32,51 @@ #include "api/Metrics.h" // Net Stats -using ts::Metrics::Counter; +using ts::Metrics; struct NetStatsBlock { - Counter::AtomicType *accepts_currently_open; - Counter::AtomicType *calls_to_read_nodata; - Counter::AtomicType *calls_to_read; - Counter::AtomicType *calls_to_readfromnet; - Counter::AtomicType *calls_to_write_nodata; - Counter::AtomicType *calls_to_write; - Counter::AtomicType *calls_to_writetonet; - Counter::AtomicType *connections_currently_open; - Counter::AtomicType *connections_throttled_in; - Counter::AtomicType *connections_throttled_out; - Counter::AtomicType *default_inactivity_timeout_applied; - Counter::AtomicType *default_inactivity_timeout_count; - Counter::AtomicType *fastopen_attempts; - Counter::AtomicType *fastopen_successes; - Counter::AtomicType *handler_run; - Counter::AtomicType *handler_run_count; - Counter::AtomicType *inactivity_cop_lock_acquire_failure; - Counter::AtomicType *keep_alive_queue_timeout_count; - Counter::AtomicType *keep_alive_queue_timeout_total; - Counter::AtomicType *read_bytes; - Counter::AtomicType *read_bytes_count; - Counter::AtomicType *requests_max_throttled_in; - Counter::AtomicType *tunnel_total_client_connections_blind_tcp; - Counter::AtomicType *tunnel_current_client_connections_blind_tcp; - Counter::AtomicType *tunnel_total_server_connections_blind_tcp; - Counter::AtomicType *tunnel_current_server_connections_blind_tcp; - Counter::AtomicType *tunnel_total_client_connections_tls_tunnel; - Counter::AtomicType *tunnel_current_client_connections_tls_tunnel; - Counter::AtomicType *tunnel_total_server_connections_tls; - Counter::AtomicType *tunnel_current_server_connections_tls; - Counter::AtomicType *tunnel_total_client_connections_tls_forward; - Counter::AtomicType *tunnel_current_client_connections_tls_forward; - Counter::AtomicType *tunnel_total_client_connections_tls_partial_blind; - Counter::AtomicType *tunnel_current_client_connections_tls_partial_blind; - Counter::AtomicType *tunnel_total_client_connections_tls_http; - Counter::AtomicType *tunnel_current_client_connections_tls_http; - Counter::AtomicType *socks_connections_currently_open; - Counter::AtomicType *socks_connections_successful; - Counter::AtomicType *socks_connections_unsuccessful; - Counter::AtomicType *tcp_accept; - Counter::AtomicType *write_bytes; - Counter::AtomicType *write_bytes_count; + Metrics::Counter::AtomicType *accepts_currently_open; + Metrics::Counter::AtomicType *calls_to_read_nodata; + Metrics::Counter::AtomicType *calls_to_read; + Metrics::Counter::AtomicType *calls_to_readfromnet; + Metrics::Counter::AtomicType *calls_to_write_nodata; + Metrics::Counter::AtomicType *calls_to_write; + Metrics::Counter::AtomicType *calls_to_writetonet; + Metrics::Counter::AtomicType *connections_currently_open; + Metrics::Counter::AtomicType *connections_throttled_in; + Metrics::Counter::AtomicType *connections_throttled_out; + Metrics::Counter::AtomicType *default_inactivity_timeout_applied; + Metrics::Counter::AtomicType *default_inactivity_timeout_count; + Metrics::Counter::AtomicType *fastopen_attempts; + Metrics::Counter::AtomicType *fastopen_successes; + Metrics::Counter::AtomicType *handler_run; + Metrics::Counter::AtomicType *handler_run_count; + Metrics::Counter::AtomicType *inactivity_cop_lock_acquire_failure; + Metrics::Counter::AtomicType *keep_alive_queue_timeout_count; + Metrics::Counter::AtomicType *keep_alive_queue_timeout_total; + Metrics::Counter::AtomicType *read_bytes; + Metrics::Counter::AtomicType *read_bytes_count; + Metrics::Counter::AtomicType *requests_max_throttled_in; + Metrics::Counter::AtomicType *tunnel_total_client_connections_blind_tcp; + Metrics::Counter::AtomicType *tunnel_current_client_connections_blind_tcp; + Metrics::Counter::AtomicType *tunnel_total_server_connections_blind_tcp; + Metrics::Counter::AtomicType *tunnel_current_server_connections_blind_tcp; + Metrics::Counter::AtomicType *tunnel_total_client_connections_tls_tunnel; + Metrics::Counter::AtomicType *tunnel_current_client_connections_tls_tunnel; + Metrics::Counter::AtomicType *tunnel_total_server_connections_tls; + Metrics::Counter::AtomicType *tunnel_current_server_connections_tls; + Metrics::Counter::AtomicType *tunnel_total_client_connections_tls_forward; + Metrics::Counter::AtomicType *tunnel_current_client_connections_tls_forward; + Metrics::Counter::AtomicType *tunnel_total_client_connections_tls_partial_blind; + Metrics::Counter::AtomicType *tunnel_current_client_connections_tls_partial_blind; + Metrics::Counter::AtomicType *tunnel_total_client_connections_tls_http; + Metrics::Counter::AtomicType *tunnel_current_client_connections_tls_http; + Metrics::Counter::AtomicType *socks_connections_currently_open; + Metrics::Counter::AtomicType *socks_connections_successful; + Metrics::Counter::AtomicType *socks_connections_unsuccessful; + Metrics::Counter::AtomicType *tcp_accept; + Metrics::Counter::AtomicType *write_bytes; + Metrics::Counter::AtomicType *write_bytes_count; }; extern NetStatsBlock net_rsb; diff --git a/src/iocore/net/P_UnixNet.h b/src/iocore/net/P_UnixNet.h index 7d6399f53f3..1a2ec3d12e2 100644 --- a/src/iocore/net/P_UnixNet.h +++ b/src/iocore/net/P_UnixNet.h @@ -93,7 +93,7 @@ TS_INLINE int net_connections_to_throttle(ThrottleType t) { double headroom = t == ACCEPT ? NET_THROTTLE_ACCEPT_HEADROOM : NET_THROTTLE_CONNECT_HEADROOM; - int currently_open = static_cast(Counter::read(net_rsb.connections_currently_open)); + int currently_open = static_cast(Metrics::Counter::read(net_rsb.connections_currently_open)); // deal with race if we got to multiple net threads if (currently_open < 0) { diff --git a/src/iocore/net/QUICNetProcessor.cc b/src/iocore/net/QUICNetProcessor.cc index 52ad0f5f9be..dcd86c3aeed 100644 --- a/src/iocore/net/QUICNetProcessor.cc +++ b/src/iocore/net/QUICNetProcessor.cc @@ -204,7 +204,7 @@ QUICNetProcessor::main_accept(Continuation *cont, SOCKET fd, AcceptOptions const if (accept_threads < 0) { REC_ReadConfigInteger(accept_threads, "proxy.config.accept_threads"); } - Counter::increment(net_rsb.accepts_currently_open); + Metrics::Counter::increment(net_rsb.accepts_currently_open); if (opt.localhost_only) { accept_ip.setToLoopback(opt.ip_family); diff --git a/src/iocore/net/QUICNetProcessor_quiche.cc b/src/iocore/net/QUICNetProcessor_quiche.cc index 1ddb087d405..7dd820014f3 100644 --- a/src/iocore/net/QUICNetProcessor_quiche.cc +++ b/src/iocore/net/QUICNetProcessor_quiche.cc @@ -227,7 +227,7 @@ QUICNetProcessor::main_accept(Continuation *cont, SOCKET fd, AcceptOptions const if (accept_threads < 0) { REC_ReadConfigInteger(accept_threads, "proxy.config.accept_threads"); } - Counter::increment(net_rsb.accepts_currently_open); + Metrics::Counter::increment(net_rsb.accepts_currently_open); if (opt.localhost_only) { accept_ip.setToLoopback(opt.ip_family); diff --git a/src/iocore/net/QUICNetVConnection.cc b/src/iocore/net/QUICNetVConnection.cc index 61f791f5bb4..a40aec7c8d1 100644 --- a/src/iocore/net/QUICNetVConnection.cc +++ b/src/iocore/net/QUICNetVConnection.cc @@ -1570,7 +1570,7 @@ QUICNetVConnection::_state_common_send_packet() this->_context->trigger(QUICContext::CallbackEvent::METRICS_UPDATE, this->_congestion_controller->congestion_window(), this->_congestion_controller->bytes_in_flight(), this->_congestion_controller->current_ssthresh()); - Counter::increment(quic_rsb.total_packets_sent_stat, packet_count); + Metrics::Counter::increment(quic_rsb.total_packets_sent_stat, packet_count); net_activity(this, this_ethread()); } diff --git a/src/iocore/net/SSLDiags.cc b/src/iocore/net/SSLDiags.cc index 9fc039f93d1..dae89530fb6 100644 --- a/src/iocore/net/SSLDiags.cc +++ b/src/iocore/net/SSLDiags.cc @@ -37,7 +37,7 @@ increment_ssl_client_error(unsigned long err) { // we only look for LIB_SSL errors atm if (ERR_LIB_SSL != ERR_GET_LIB(err)) { - Counter::increment(ssl_rsb.user_agent_other_errors); + Metrics::Counter::increment(ssl_rsb.user_agent_other_errors); return false; } @@ -46,31 +46,31 @@ increment_ssl_client_error(unsigned long err) // the error came from, hope that's ok?) switch (ERR_GET_REASON(err)) { case SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED: - Counter::increment(ssl_rsb.user_agent_expired_cert); + Metrics::Counter::increment(ssl_rsb.user_agent_expired_cert); break; case SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED: - Counter::increment(ssl_rsb.user_agent_revoked_cert); + Metrics::Counter::increment(ssl_rsb.user_agent_revoked_cert); break; case SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN: - Counter::increment(ssl_rsb.user_agent_unknown_cert); + Metrics::Counter::increment(ssl_rsb.user_agent_unknown_cert); break; case SSL_R_CERTIFICATE_VERIFY_FAILED: - Counter::increment(ssl_rsb.user_agent_cert_verify_failed); + Metrics::Counter::increment(ssl_rsb.user_agent_cert_verify_failed); break; case SSL_R_SSLV3_ALERT_BAD_CERTIFICATE: - Counter::increment(ssl_rsb.user_agent_bad_cert); + Metrics::Counter::increment(ssl_rsb.user_agent_bad_cert); break; case SSL_R_TLSV1_ALERT_DECRYPTION_FAILED: - Counter::increment(ssl_rsb.user_agent_decryption_failed); + Metrics::Counter::increment(ssl_rsb.user_agent_decryption_failed); break; case SSL_R_WRONG_VERSION_NUMBER: - Counter::increment(ssl_rsb.user_agent_wrong_version); + Metrics::Counter::increment(ssl_rsb.user_agent_wrong_version); break; case SSL_R_TLSV1_ALERT_UNKNOWN_CA: - Counter::increment(ssl_rsb.user_agent_unknown_ca); + Metrics::Counter::increment(ssl_rsb.user_agent_unknown_ca); break; default: - Counter::increment(ssl_rsb.user_agent_other_errors); + Metrics::Counter::increment(ssl_rsb.user_agent_other_errors); return false; } @@ -84,7 +84,7 @@ increment_ssl_server_error(unsigned long err) { // we only look for LIB_SSL errors atm if (ERR_LIB_SSL != ERR_GET_LIB(err)) { - Counter::increment(ssl_rsb.origin_server_other_errors); + Metrics::Counter::increment(ssl_rsb.origin_server_other_errors); return false; } @@ -93,31 +93,31 @@ increment_ssl_server_error(unsigned long err) // the error came from, hope that's ok?) switch (ERR_GET_REASON(err)) { case SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED: - Counter::increment(ssl_rsb.origin_server_expired_cert); + Metrics::Counter::increment(ssl_rsb.origin_server_expired_cert); break; case SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED: - Counter::increment(ssl_rsb.origin_server_revoked_cert); + Metrics::Counter::increment(ssl_rsb.origin_server_revoked_cert); break; case SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN: - Counter::increment(ssl_rsb.origin_server_unknown_cert); + Metrics::Counter::increment(ssl_rsb.origin_server_unknown_cert); break; case SSL_R_CERTIFICATE_VERIFY_FAILED: - Counter::increment(ssl_rsb.origin_server_cert_verify_failed); + Metrics::Counter::increment(ssl_rsb.origin_server_cert_verify_failed); break; case SSL_R_SSLV3_ALERT_BAD_CERTIFICATE: - Counter::increment(ssl_rsb.origin_server_bad_cert); + Metrics::Counter::increment(ssl_rsb.origin_server_bad_cert); break; case SSL_R_TLSV1_ALERT_DECRYPTION_FAILED: - Counter::increment(ssl_rsb.origin_server_decryption_failed); + Metrics::Counter::increment(ssl_rsb.origin_server_decryption_failed); break; case SSL_R_WRONG_VERSION_NUMBER: - Counter::increment(ssl_rsb.origin_server_wrong_version); + Metrics::Counter::increment(ssl_rsb.origin_server_wrong_version); break; case SSL_R_TLSV1_ALERT_UNKNOWN_CA: - Counter::increment(ssl_rsb.origin_server_unknown_ca); + Metrics::Counter::increment(ssl_rsb.origin_server_unknown_ca); break; default: - Counter::increment(ssl_rsb.origin_server_other_errors); + Metrics::Counter::increment(ssl_rsb.origin_server_other_errors); return false; } diff --git a/src/iocore/net/SSLNetVConnection.cc b/src/iocore/net/SSLNetVConnection.cc index 91b96d7e52c..04c34b11e08 100644 --- a/src/iocore/net/SSLNetVConnection.cc +++ b/src/iocore/net/SSLNetVConnection.cc @@ -349,7 +349,7 @@ SSLNetVConnection::_ssl_read_from_net(EThread *lthread, int64_t &ret) case SSL_ERROR_SYSCALL: if (nread != 0) { // not EOF - Counter::increment(ssl_rsb.error_syscall); + Metrics::Counter::increment(ssl_rsb.error_syscall); event = SSL_READ_ERROR; ret = errno; Dbg(dbg_ctl_ssl_error, "SSL_ERROR_SYSCALL, underlying IO error: %s", strerror(errno)); @@ -370,7 +370,7 @@ SSLNetVConnection::_ssl_read_from_net(EThread *lthread, int64_t &ret) event = SSL_READ_ERROR; ret = errno; SSLVCDebug(this, "errno=%d", errno); - Counter::increment(ssl_rsb.error_ssl); + Metrics::Counter::increment(ssl_rsb.error_ssl); } break; } // switch } // while @@ -421,7 +421,7 @@ SSLNetVConnection::read_raw_data() b = b->next.get(); r = SocketManager::read(this->con.fd, buffer, buf_len); - Counter::increment(net_rsb.calls_to_read); + Metrics::Counter::increment(net_rsb.calls_to_read); total_read += rattempted; Dbg(dbg_ctl_ssl, "read_raw_data r=%" PRId64 " rattempted=%" PRId64 " total_read=%" PRId64 " fd=%d", r, rattempted, total_read, @@ -443,8 +443,8 @@ SSLNetVConnection::read_raw_data() r = total_read - rattempted + r; } } - Counter::increment(net_rsb.read_bytes, r); - Counter::increment(net_rsb.read_bytes_count); + Metrics::Counter::increment(net_rsb.read_bytes, r); + Metrics::Counter::increment(net_rsb.read_bytes_count); swoc::IPRangeSet *pp_ipmap; pp_ipmap = SSLConfigParams::proxy_protocol_ip_addrs; @@ -514,7 +514,7 @@ SSLNetVConnection::read_raw_data() // check for errors if (r <= 0) { if (r == -EAGAIN || r == -ENOTCONN) { - Counter::increment(net_rsb.calls_to_read_nodata); + Metrics::Counter::increment(net_rsb.calls_to_read_nodata); } } @@ -838,10 +838,10 @@ SSLNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor &buf } else if (SSLConfigParams::ssl_maxrecord == -1) { if (sslTotalBytesSent < SSL_DEF_TLS_RECORD_BYTE_THRESHOLD) { dynamic_tls_record_size = SSL_DEF_TLS_RECORD_SIZE; - Counter::increment(ssl_rsb.total_dyn_def_tls_record_count); + Metrics::Counter::increment(ssl_rsb.total_dyn_def_tls_record_count); } else { dynamic_tls_record_size = SSL_MAX_TLS_RECORD_SIZE; - Counter::increment(ssl_rsb.total_dyn_max_tls_record_count); + Metrics::Counter::increment(ssl_rsb.total_dyn_max_tls_record_count); } if (l > dynamic_tls_record_size) { l = dynamic_tls_record_size; @@ -866,7 +866,7 @@ SSLNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor &buf Dbg(dbg_ctl_ssl, "try_to_write=%" PRId64 " written=%" PRId64 " total_written=%" PRId64, try_to_write, num_really_written, total_written); - Counter::increment(net_rsb.calls_to_write); + Metrics::Counter::increment(net_rsb.calls_to_write); } while (num_really_written == try_to_write && total_written < towrite); if (total_written > 0) { @@ -903,7 +903,7 @@ SSLNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor &buf // SSL_ERROR_SYSCALL is an IO error. errno is likely 0, so set EPIPE, as // we do with SSL_ERROR_SSL below, to indicate a connection error. num_really_written = -EPIPE; - Counter::increment(ssl_rsb.error_syscall); + Metrics::Counter::increment(ssl_rsb.error_syscall); Dbg(dbg_ctl_ssl_error, "SSL_write-SSL_ERROR_SYSCALL"); break; // end of stream @@ -916,7 +916,7 @@ SSLNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor &buf // Treat SSL_ERROR_SSL as EPIPE error. num_really_written = -EPIPE; SSLVCDebug(this, "SSL_write-SSL_ERROR_SSL errno=%d", errno); - Counter::increment(ssl_rsb.error_ssl); + Metrics::Counter::increment(ssl_rsb.error_ssl); } break; } } @@ -1031,14 +1031,14 @@ SSLNetVConnection::free_thread(EThread *t) // close socket fd if (con.fd != NO_FD) { - Counter::decrement(net_rsb.connections_currently_open); + Metrics::Counter::decrement(net_rsb.connections_currently_open); } con.close(); if (is_tunnel_endpoint()) { ink_assert(get_context() != NET_VCONNECTION_UNSET); - Counter::decrement(([&]() -> Counter::AtomicType * { + Metrics::Counter::decrement(([&]() -> Metrics::Counter::AtomicType * { if (get_context() == NET_VCONNECTION_IN) { switch (get_tunnel_type()) { case SNIRoutingType::BLIND: @@ -1251,7 +1251,7 @@ SSLNetVConnection::sslStartHandShake(int event, int &err) Dbg(dbg_ctl_ssl, "using SNI name '%s' for client handshake", tlsext_host_name.get()); } else { Dbg(dbg_ctl_ssl_error, "failed to set SNI name '%s' for client handshake", tlsext_host_name.get()); - Counter::increment(ssl_rsb.sni_name_set_failure); + Metrics::Counter::increment(ssl_rsb.sni_name_set_failure); } } @@ -1285,7 +1285,7 @@ SSLNetVConnection::sslServerHandShakeEvent(int &err) // Go do the preaccept hooks if (sslHandshakeHookState == HANDSHAKE_HOOKS_PRE) { - Counter::increment(ssl_rsb.total_attempts_handshake_count_in); + Metrics::Counter::increment(ssl_rsb.total_attempts_handshake_count_in); if (!curHook) { Dbg(dbg_ctl_ssl, "Initialize preaccept curHook from NULL"); curHook = g_ssl_hooks->get(TSSslHookInternalID(TS_VCONN_START_HOOK)); @@ -1435,7 +1435,7 @@ SSLNetVConnection::sslServerHandShakeEvent(int &err) if (this->get_tls_handshake_begin_time()) { this->_record_tls_handshake_end_time(); - Counter::increment(ssl_rsb.total_success_handshake_count_in); + Metrics::Counter::increment(ssl_rsb.total_success_handshake_count_in); } if (this->get_tunnel_type() != SNIRoutingType::NONE) { @@ -1517,7 +1517,7 @@ SSLNetVConnection::sslServerHandShakeEvent(int &err) #if TS_USE_TLS_ASYNC case SSL_ERROR_WANT_ASYNC: - Counter::increment(ssl_rsb.error_async); + Metrics::Counter::increment(ssl_rsb.error_async); return SSL_WAIT_FOR_ASYNC; #endif @@ -1587,7 +1587,7 @@ SSLNetVConnection::sslClientHandShakeEvent(int &err) // Go do the preaccept hooks if (sslHandshakeHookState == HANDSHAKE_HOOKS_OUTBOUND_PRE) { - Counter::increment(ssl_rsb.total_attempts_handshake_count_out); + Metrics::Counter::increment(ssl_rsb.total_attempts_handshake_count_out); if (!curHook) { Dbg(dbg_ctl_ssl, "Initialize outbound connect curHook from NULL"); curHook = g_ssl_hooks->get(TSSslHookInternalID(TS_VCONN_OUTBOUND_START_HOOK)); @@ -1637,7 +1637,7 @@ SSLNetVConnection::sslClientHandShakeEvent(int &err) writeReschedule(nh); } - Counter::increment(ssl_rsb.total_success_handshake_count_out); + Metrics::Counter::increment(ssl_rsb.total_success_handshake_count_out); sslHandshakeStatus = SSLHandshakeStatus::SSL_HANDSHAKE_DONE; return EVENT_DONE; @@ -1670,7 +1670,7 @@ SSLNetVConnection::sslClientHandShakeEvent(int &err) case SSL_ERROR_SYSCALL: err = errno; - Counter::increment(ssl_rsb.error_syscall); + Metrics::Counter::increment(ssl_rsb.error_syscall); Dbg(dbg_ctl_ssl_error, "syscall"); return EVENT_ERROR; break; @@ -1683,7 +1683,7 @@ SSLNetVConnection::sslClientHandShakeEvent(int &err) ERR_error_string_n(e, buf, sizeof(buf)); // FIXME -- This triggers a retry on cases of cert validation errors... SSLVCDebug(this, "SSL_ERROR_SSL errno=%d", errno); - Counter::increment(ssl_rsb.error_ssl); + Metrics::Counter::increment(ssl_rsb.error_ssl); Dbg(dbg_ctl_ssl_error, "SSL_ERROR_SSL"); if (e) { if (this->options.sni_servername) { @@ -1986,7 +1986,7 @@ SSLNetVConnection::_in_context_tunnel() { ink_assert(get_context() == NET_VCONNECTION_IN); - Counter::AtomicType *t, *c; + Metrics::Counter::AtomicType *t, *c; switch (get_tunnel_type()) { case SNIRoutingType::BLIND: @@ -2006,8 +2006,8 @@ SSLNetVConnection::_in_context_tunnel() c = net_rsb.tunnel_current_client_connections_tls_http; break; } - Counter::increment(t); - Counter::increment(c); + Metrics::Counter::increment(t); + Metrics::Counter::increment(c); } void @@ -2018,8 +2018,8 @@ SSLNetVConnection::_out_context_tunnel() // Never a tunnel type for out (to server) context. ink_assert(get_tunnel_type() == SNIRoutingType::NONE); - Counter::increment(net_rsb.tunnel_total_server_connections_tls); - Counter::increment(net_rsb.tunnel_current_server_connections_tls); + Metrics::Counter::increment(net_rsb.tunnel_total_server_connections_tls); + Metrics::Counter::increment(net_rsb.tunnel_current_server_connections_tls); } void @@ -2027,20 +2027,20 @@ SSLNetVConnection::increment_ssl_version_metric(int version) const { switch (version) { case SSL3_VERSION: - Counter::increment(ssl_rsb.total_sslv3); + Metrics::Counter::increment(ssl_rsb.total_sslv3); break; case TLS1_VERSION: - Counter::increment(ssl_rsb.total_tlsv1); + Metrics::Counter::increment(ssl_rsb.total_tlsv1); break; case TLS1_1_VERSION: - Counter::increment(ssl_rsb.total_tlsv11); + Metrics::Counter::increment(ssl_rsb.total_tlsv11); break; case TLS1_2_VERSION: - Counter::increment(ssl_rsb.total_tlsv12); + Metrics::Counter::increment(ssl_rsb.total_tlsv12); break; #ifdef TLS1_3_VERSION case TLS1_3_VERSION: - Counter::increment(ssl_rsb.total_tlsv13); + Metrics::Counter::increment(ssl_rsb.total_tlsv13); break; #endif default: @@ -2384,7 +2384,7 @@ SSLNetVConnection::_ssl_accept() } block->fill(nread); this->_early_data_buf->append_block(block); - Counter::increment(ssl_rsb.early_data_received_count); + Metrics::Counter::increment(ssl_rsb.early_data_received_count); if (dbg_ctl_ssl_early_data_show_received.on()) { std::string early_data_str(reinterpret_cast(block->buf()), nread); @@ -2459,7 +2459,7 @@ SSLNetVConnection::_ssl_connect() if (ret > 0) { if (SSL_session_reused(ssl)) { - Counter::increment(ssl_rsb.origin_session_reused_count); + Metrics::Counter::increment(ssl_rsb.origin_session_reused_count); Dbg(dbg_ctl_ssl_origin_session_cache, "reused session to origin server"); } else { Dbg(dbg_ctl_ssl_origin_session_cache, "new session to origin server"); @@ -2611,7 +2611,7 @@ SSLNetVConnection::_ssl_read_buffer(void *buf, int64_t nbytes, int64_t &nread) } else { if ((nread = read_bytes) > 0) { this->_increment_early_data_len(read_bytes); - Counter::increment(ssl_rsb.early_data_received_count); + Metrics::Counter::increment(ssl_rsb.early_data_received_count); if (dbg_ctl_ssl_early_data_show_received.on()) { std::string early_data_str(reinterpret_cast(buf), nread); DbgPrint(dbg_ctl_ssl_early_data_show_received, "Early data buffer: \n%s", early_data_str.c_str()); diff --git a/src/iocore/net/SSLSessionCache.cc b/src/iocore/net/SSLSessionCache.cc index 1f8ef388dcd..81931f781df 100644 --- a/src/iocore/net/SSLSessionCache.cc +++ b/src/iocore/net/SSLSessionCache.cc @@ -91,7 +91,7 @@ SSLSessionCache::removeSession(const SSLSessionID &sid) Debug("ssl.session_cache.remove", "SessionCache using bucket %" PRId64 " (%p): Removing session '%s' (hash: %" PRIX64 ").", target_bucket, bucket, buf, hash); } - Counter::increment(ssl_rsb.session_cache_eviction); + Metrics::Counter::increment(ssl_rsb.session_cache_eviction); bucket->removeSession(sid); } @@ -118,7 +118,7 @@ SSLSessionBucket::insertSession(const SSLSessionID &id, SSL_SESSION *sess, SSL * { std::shared_lock r_lock(mutex, std::try_to_lock); if (!r_lock.owns_lock()) { - Counter::increment(ssl_rsb.session_cache_lock_contention); + Metrics::Counter::increment(ssl_rsb.session_cache_lock_contention); if (SSLConfigParams::session_cache_skip_on_lock_contention) { return; } @@ -162,7 +162,7 @@ SSLSessionBucket::insertSession(const SSLSessionID &id, SSL_SESSION *sess, SSL * std::unique_lock w_lock(mutex, std::try_to_lock); if (!w_lock.owns_lock()) { - Counter::increment(ssl_rsb.session_cache_lock_contention); + Metrics::Counter::increment(ssl_rsb.session_cache_lock_contention); if (SSLConfigParams::session_cache_skip_on_lock_contention) { return; } @@ -171,7 +171,7 @@ SSLSessionBucket::insertSession(const SSLSessionID &id, SSL_SESSION *sess, SSL * PRINT_BUCKET("insertSession before") if (bucket_map.size() >= SSLConfigParams::session_cache_max_bucket_size) { - Counter::increment(ssl_rsb.session_cache_eviction); + Metrics::Counter::increment(ssl_rsb.session_cache_eviction); removeOldestSession(w_lock); } @@ -189,7 +189,7 @@ SSLSessionBucket::getSessionBuffer(const SSLSessionID &id, char *buffer, int &le int true_len = 0; std::shared_lock lock(mutex, std::try_to_lock); if (!lock.owns_lock()) { - Counter::increment(ssl_rsb.session_cache_lock_contention); + Metrics::Counter::increment(ssl_rsb.session_cache_lock_contention); if (SSLConfigParams::session_cache_skip_on_lock_contention) { return true_len; } @@ -222,7 +222,7 @@ SSLSessionBucket::getSession(const SSLSessionID &id, SSL_SESSION **sess, ssl_ses std::shared_lock lock(mutex, std::try_to_lock); if (!lock.owns_lock()) { - Counter::increment(ssl_rsb.session_cache_lock_contention); + Metrics::Counter::increment(ssl_rsb.session_cache_lock_contention); if (SSLConfigParams::session_cache_skip_on_lock_contention) { return false; } diff --git a/src/iocore/net/SSLStats.cc b/src/iocore/net/SSLStats.cc index 1cecef4338b..8dcd631900c 100644 --- a/src/iocore/net/SSLStats.cc +++ b/src/iocore/net/SSLStats.cc @@ -30,7 +30,7 @@ #include "../../records/P_RecProcess.h" SSLStatsBlock ssl_rsb; -std::unordered_map cipher_map; +std::unordered_map cipher_map; // ToDo: This gets called once per global sync, for now at least. void @@ -60,10 +60,10 @@ SSLPeriodicMetricsUpdate() } } - Counter::write(ssl_rsb.user_agent_sessions, sessions); - Counter::write(ssl_rsb.user_agent_session_hit, hits); - Counter::write(ssl_rsb.user_agent_session_miss, misses); - Counter::write(ssl_rsb.user_agent_session_timeout, timeouts); + Metrics::Counter::write(ssl_rsb.user_agent_sessions, sessions); + Metrics::Counter::write(ssl_rsb.user_agent_session_hit, hits); + Metrics::Counter::write(ssl_rsb.user_agent_session_miss, misses); + Metrics::Counter::write(ssl_rsb.user_agent_session_timeout, timeouts); } static void @@ -71,7 +71,7 @@ add_cipher_stat(const char *cipherName, const std::string &statName) { // If not already registered ... if (cipherName && cipher_map.find(cipherName) == cipher_map.end()) { - Counter::AtomicType *metric = Counter::CreatePtr(statName); + Metrics::Counter::AtomicType *metric = Metrics::Counter::createPtr(statName); cipher_map.emplace(cipherName, metric); Debug("ssl", "registering SSL cipher metric '%s'", statName.c_str()); @@ -88,64 +88,64 @@ SSLInitializeStatistics() // For now, register with the librecords global sync. RecRegNewSyncStatSync(SSLPeriodicMetricsUpdate); - ssl_rsb.early_data_received_count = Counter::CreatePtr("proxy.process.ssl.early_data_received"); - ssl_rsb.error_async = Counter::CreatePtr("proxy.process.ssl.ssl_error_async"); - ssl_rsb.error_ssl = Counter::CreatePtr("proxy.process.ssl.ssl_error_ssl"); - ssl_rsb.error_syscall = Counter::CreatePtr("proxy.process.ssl.ssl_error_syscall"); - ssl_rsb.ocsp_refresh_cert_failure = Counter::CreatePtr("proxy.process.ssl.ssl_ocsp_refresh_cert_failure"); - ssl_rsb.ocsp_refreshed_cert = Counter::CreatePtr("proxy.process.ssl.ssl_ocsp_refreshed_cert"); - ssl_rsb.ocsp_revoked_cert = Counter::CreatePtr("proxy.process.ssl.ssl_ocsp_revoked_cert"); - ssl_rsb.ocsp_unknown_cert = Counter::CreatePtr("proxy.process.ssl.ssl_ocsp_unknown_cert"); - ssl_rsb.origin_server_bad_cert = Counter::CreatePtr("proxy.process.ssl.origin_server_bad_cert"); - ssl_rsb.origin_server_cert_verify_failed = Counter::CreatePtr("proxy.process.ssl.origin_server_cert_verify_failed"); - ssl_rsb.origin_server_decryption_failed = Counter::CreatePtr("proxy.process.ssl.origin_server_decryption_failed"); - ssl_rsb.origin_server_expired_cert = Counter::CreatePtr("proxy.process.ssl.origin_server_expired_cert"); - ssl_rsb.origin_server_other_errors = Counter::CreatePtr("proxy.process.ssl.origin_server_other_errors"); - ssl_rsb.origin_server_revoked_cert = Counter::CreatePtr("proxy.process.ssl.origin_server_revoked_cert"); - ssl_rsb.origin_server_unknown_ca = Counter::CreatePtr("proxy.process.ssl.origin_server_unknown_ca"); - ssl_rsb.origin_server_unknown_cert = Counter::CreatePtr("proxy.process.ssl.origin_server_unknown_cert"); - ssl_rsb.origin_server_wrong_version = Counter::CreatePtr("proxy.process.ssl.origin_server_wrong_version"); - ssl_rsb.origin_session_reused_count = Counter::CreatePtr("proxy.process.ssl.origin_session_reused"); - ssl_rsb.sni_name_set_failure = Counter::CreatePtr("proxy.process.ssl.ssl_sni_name_set_failure"); - ssl_rsb.origin_session_cache_hit = Counter::CreatePtr("proxy.process.ssl.ssl_origin_session_cache_hit"); - ssl_rsb.origin_session_cache_miss = Counter::CreatePtr("proxy.process.ssl.ssl_origin_session_cache_miss"); - ssl_rsb.session_cache_eviction = Counter::CreatePtr("proxy.process.ssl.ssl_session_cache_eviction"); - ssl_rsb.session_cache_hit = Counter::CreatePtr("proxy.process.ssl.ssl_session_cache_hit"); - ssl_rsb.session_cache_lock_contention = Counter::CreatePtr("proxy.process.ssl.ssl_session_cache_lock_contention"); - ssl_rsb.session_cache_miss = Counter::CreatePtr("proxy.process.ssl.ssl_session_cache_miss"); - ssl_rsb.session_cache_new_session = Counter::CreatePtr("proxy.process.ssl.ssl_session_cache_new_session"); - ssl_rsb.total_attempts_handshake_count_in = Counter::CreatePtr("proxy.process.ssl.total_attempts_handshake_count_in"); - ssl_rsb.total_attempts_handshake_count_out = Counter::CreatePtr("proxy.process.ssl.total_attempts_handshake_count_out"); - ssl_rsb.total_dyn_def_tls_record_count = Counter::CreatePtr("proxy.process.ssl.default_record_size_count"); - ssl_rsb.total_dyn_max_tls_record_count = Counter::CreatePtr("proxy.process.ssl.max_record_size_count"); - ssl_rsb.total_dyn_redo_tls_record_count = Counter::CreatePtr("proxy.process.ssl.redo_record_size_count"); - ssl_rsb.total_handshake_time = Counter::CreatePtr("proxy.process.ssl.total_handshake_time"); - ssl_rsb.total_sslv3 = Counter::CreatePtr("proxy.process.ssl.ssl_total_sslv3"); - ssl_rsb.total_success_handshake_count_in = Counter::CreatePtr("proxy.process.ssl.total_success_handshake_count_in"); - ssl_rsb.total_success_handshake_count_out = Counter::CreatePtr("proxy.process.ssl.total_success_handshake_count_out"); - ssl_rsb.total_ticket_keys_renewed = Counter::CreatePtr("proxy.process.ssl.total_ticket_keys_renewed"); - ssl_rsb.total_tickets_created = Counter::CreatePtr("proxy.process.ssl.total_tickets_created"); - ssl_rsb.total_tickets_not_found = Counter::CreatePtr("proxy.process.ssl.total_tickets_not_found"); - ssl_rsb.total_tickets_renewed = Counter::CreatePtr("proxy.process.ssl.total_tickets_renewed"); // ToDo: Not used? - ssl_rsb.total_tickets_verified = Counter::CreatePtr("proxy.process.ssl.total_tickets_verified"); - ssl_rsb.total_tickets_verified_old_key = Counter::CreatePtr("proxy.process.ssl.total_tickets_verified_old_key"); - ssl_rsb.total_tlsv1 = Counter::CreatePtr("proxy.process.ssl.ssl_total_tlsv1"); - ssl_rsb.total_tlsv11 = Counter::CreatePtr("proxy.process.ssl.ssl_total_tlsv11"); - ssl_rsb.total_tlsv12 = Counter::CreatePtr("proxy.process.ssl.ssl_total_tlsv12"); - ssl_rsb.total_tlsv13 = Counter::CreatePtr("proxy.process.ssl.ssl_total_tlsv13"); - ssl_rsb.user_agent_bad_cert = Counter::CreatePtr("proxy.process.ssl.user_agent_bad_cert"); - ssl_rsb.user_agent_cert_verify_failed = Counter::CreatePtr("proxy.process.ssl.user_agent_cert_verify_failed"); - ssl_rsb.user_agent_decryption_failed = Counter::CreatePtr("proxy.process.ssl.user_agent_decryption_failed"); - ssl_rsb.user_agent_expired_cert = Counter::CreatePtr("proxy.process.ssl.user_agent_expired_cert"); - ssl_rsb.user_agent_other_errors = Counter::CreatePtr("proxy.process.ssl.user_agent_other_errors"); - ssl_rsb.user_agent_revoked_cert = Counter::CreatePtr("proxy.process.ssl.user_agent_revoked_cert"); - ssl_rsb.user_agent_session_hit = Counter::CreatePtr("proxy.process.ssl.user_agent_session_hit"); - ssl_rsb.user_agent_session_miss = Counter::CreatePtr("proxy.process.ssl.user_agent_session_miss"); - ssl_rsb.user_agent_session_timeout = Counter::CreatePtr("proxy.process.ssl.user_agent_session_timeout"); - ssl_rsb.user_agent_sessions = Counter::CreatePtr("proxy.process.ssl.user_agent_sessions"); - ssl_rsb.user_agent_unknown_ca = Counter::CreatePtr("proxy.process.ssl.user_agent_unknown_ca"); - ssl_rsb.user_agent_unknown_cert = Counter::CreatePtr("proxy.process.ssl.user_agent_unknown_cert"); - ssl_rsb.user_agent_wrong_version = Counter::CreatePtr("proxy.process.ssl.user_agent_wrong_version"); + ssl_rsb.early_data_received_count = Metrics::Counter::createPtr("proxy.process.ssl.early_data_received"); + ssl_rsb.error_async = Metrics::Counter::createPtr("proxy.process.ssl.ssl_error_async"); + ssl_rsb.error_ssl = Metrics::Counter::createPtr("proxy.process.ssl.ssl_error_ssl"); + ssl_rsb.error_syscall = Metrics::Counter::createPtr("proxy.process.ssl.ssl_error_syscall"); + ssl_rsb.ocsp_refresh_cert_failure = Metrics::Counter::createPtr("proxy.process.ssl.ssl_ocsp_refresh_cert_failure"); + ssl_rsb.ocsp_refreshed_cert = Metrics::Counter::createPtr("proxy.process.ssl.ssl_ocsp_refreshed_cert"); + ssl_rsb.ocsp_revoked_cert = Metrics::Counter::createPtr("proxy.process.ssl.ssl_ocsp_revoked_cert"); + ssl_rsb.ocsp_unknown_cert = Metrics::Counter::createPtr("proxy.process.ssl.ssl_ocsp_unknown_cert"); + ssl_rsb.origin_server_bad_cert = Metrics::Counter::createPtr("proxy.process.ssl.origin_server_bad_cert"); + ssl_rsb.origin_server_cert_verify_failed = Metrics::Counter::createPtr("proxy.process.ssl.origin_server_cert_verify_failed"); + ssl_rsb.origin_server_decryption_failed = Metrics::Counter::createPtr("proxy.process.ssl.origin_server_decryption_failed"); + ssl_rsb.origin_server_expired_cert = Metrics::Counter::createPtr("proxy.process.ssl.origin_server_expired_cert"); + ssl_rsb.origin_server_other_errors = Metrics::Counter::createPtr("proxy.process.ssl.origin_server_other_errors"); + ssl_rsb.origin_server_revoked_cert = Metrics::Counter::createPtr("proxy.process.ssl.origin_server_revoked_cert"); + ssl_rsb.origin_server_unknown_ca = Metrics::Counter::createPtr("proxy.process.ssl.origin_server_unknown_ca"); + ssl_rsb.origin_server_unknown_cert = Metrics::Counter::createPtr("proxy.process.ssl.origin_server_unknown_cert"); + ssl_rsb.origin_server_wrong_version = Metrics::Counter::createPtr("proxy.process.ssl.origin_server_wrong_version"); + ssl_rsb.origin_session_reused_count = Metrics::Counter::createPtr("proxy.process.ssl.origin_session_reused"); + ssl_rsb.sni_name_set_failure = Metrics::Counter::createPtr("proxy.process.ssl.ssl_sni_name_set_failure"); + ssl_rsb.origin_session_cache_hit = Metrics::Counter::createPtr("proxy.process.ssl.ssl_origin_session_cache_hit"); + ssl_rsb.origin_session_cache_miss = Metrics::Counter::createPtr("proxy.process.ssl.ssl_origin_session_cache_miss"); + ssl_rsb.session_cache_eviction = Metrics::Counter::createPtr("proxy.process.ssl.ssl_session_cache_eviction"); + ssl_rsb.session_cache_hit = Metrics::Counter::createPtr("proxy.process.ssl.ssl_session_cache_hit"); + ssl_rsb.session_cache_lock_contention = Metrics::Counter::createPtr("proxy.process.ssl.ssl_session_cache_lock_contention"); + ssl_rsb.session_cache_miss = Metrics::Counter::createPtr("proxy.process.ssl.ssl_session_cache_miss"); + ssl_rsb.session_cache_new_session = Metrics::Counter::createPtr("proxy.process.ssl.ssl_session_cache_new_session"); + ssl_rsb.total_attempts_handshake_count_in = Metrics::Counter::createPtr("proxy.process.ssl.total_attempts_handshake_count_in"); + ssl_rsb.total_attempts_handshake_count_out = Metrics::Counter::createPtr("proxy.process.ssl.total_attempts_handshake_count_out"); + ssl_rsb.total_dyn_def_tls_record_count = Metrics::Counter::createPtr("proxy.process.ssl.default_record_size_count"); + ssl_rsb.total_dyn_max_tls_record_count = Metrics::Counter::createPtr("proxy.process.ssl.max_record_size_count"); + ssl_rsb.total_dyn_redo_tls_record_count = Metrics::Counter::createPtr("proxy.process.ssl.redo_record_size_count"); + ssl_rsb.total_handshake_time = Metrics::Counter::createPtr("proxy.process.ssl.total_handshake_time"); + ssl_rsb.total_sslv3 = Metrics::Counter::createPtr("proxy.process.ssl.ssl_total_sslv3"); + ssl_rsb.total_success_handshake_count_in = Metrics::Counter::createPtr("proxy.process.ssl.total_success_handshake_count_in"); + ssl_rsb.total_success_handshake_count_out = Metrics::Counter::createPtr("proxy.process.ssl.total_success_handshake_count_out"); + ssl_rsb.total_ticket_keys_renewed = Metrics::Counter::createPtr("proxy.process.ssl.total_ticket_keys_renewed"); + ssl_rsb.total_tickets_created = Metrics::Counter::createPtr("proxy.process.ssl.total_tickets_created"); + ssl_rsb.total_tickets_not_found = Metrics::Counter::createPtr("proxy.process.ssl.total_tickets_not_found"); + ssl_rsb.total_tickets_renewed = Metrics::Counter::createPtr("proxy.process.ssl.total_tickets_renewed"); // ToDo: Not used? + ssl_rsb.total_tickets_verified = Metrics::Counter::createPtr("proxy.process.ssl.total_tickets_verified"); + ssl_rsb.total_tickets_verified_old_key = Metrics::Counter::createPtr("proxy.process.ssl.total_tickets_verified_old_key"); + ssl_rsb.total_tlsv1 = Metrics::Counter::createPtr("proxy.process.ssl.ssl_total_tlsv1"); + ssl_rsb.total_tlsv11 = Metrics::Counter::createPtr("proxy.process.ssl.ssl_total_tlsv11"); + ssl_rsb.total_tlsv12 = Metrics::Counter::createPtr("proxy.process.ssl.ssl_total_tlsv12"); + ssl_rsb.total_tlsv13 = Metrics::Counter::createPtr("proxy.process.ssl.ssl_total_tlsv13"); + ssl_rsb.user_agent_bad_cert = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_bad_cert"); + ssl_rsb.user_agent_cert_verify_failed = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_cert_verify_failed"); + ssl_rsb.user_agent_decryption_failed = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_decryption_failed"); + ssl_rsb.user_agent_expired_cert = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_expired_cert"); + ssl_rsb.user_agent_other_errors = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_other_errors"); + ssl_rsb.user_agent_revoked_cert = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_revoked_cert"); + ssl_rsb.user_agent_session_hit = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_session_hit"); + ssl_rsb.user_agent_session_miss = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_session_miss"); + ssl_rsb.user_agent_session_timeout = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_session_timeout"); + ssl_rsb.user_agent_sessions = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_sessions"); + ssl_rsb.user_agent_unknown_ca = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_unknown_ca"); + ssl_rsb.user_agent_unknown_cert = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_unknown_cert"); + ssl_rsb.user_agent_wrong_version = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_wrong_version"); // Get and register the SSL cipher stats. Note that we are using the default SSL context to obtain // the cipher list. This means that the set of ciphers is fixed by the build configuration and not diff --git a/src/iocore/net/SSLStats.h b/src/iocore/net/SSLStats.h index a3d0c267ab9..39da1b9b2c1 100644 --- a/src/iocore/net/SSLStats.h +++ b/src/iocore/net/SSLStats.h @@ -30,75 +30,75 @@ #include "api/Metrics.h" -using ts::Metrics::Counter; +using ts::Metrics; // For some odd reason, these have to be initialized with nullptr, because the order // of initialization and how we load certs is weird... In reality only the metric // for ssl_rsb.total_ticket_keys_renewed needs this initialization, but lets be // consistent at least. struct SSLStatsBlock { - Counter::AtomicType *early_data_received_count = nullptr; - Counter::AtomicType *error_async = nullptr; - Counter::AtomicType *error_ssl = nullptr; - Counter::AtomicType *error_syscall = nullptr; - Counter::AtomicType *ocsp_refresh_cert_failure = nullptr; - Counter::AtomicType *ocsp_refreshed_cert = nullptr; - Counter::AtomicType *ocsp_revoked_cert = nullptr; - Counter::AtomicType *ocsp_unknown_cert = nullptr; - Counter::AtomicType *origin_server_bad_cert = nullptr; - Counter::AtomicType *origin_server_cert_verify_failed = nullptr; - Counter::AtomicType *origin_server_decryption_failed = nullptr; - Counter::AtomicType *origin_server_expired_cert = nullptr; - Counter::AtomicType *origin_server_other_errors = nullptr; - Counter::AtomicType *origin_server_revoked_cert = nullptr; - Counter::AtomicType *origin_server_unknown_ca = nullptr; - Counter::AtomicType *origin_server_unknown_cert = nullptr; - Counter::AtomicType *origin_server_wrong_version = nullptr; - Counter::AtomicType *origin_session_cache_hit = nullptr; - Counter::AtomicType *origin_session_cache_miss = nullptr; - Counter::AtomicType *origin_session_reused_count = nullptr; - Counter::AtomicType *session_cache_eviction = nullptr; - Counter::AtomicType *session_cache_hit = nullptr; - Counter::AtomicType *session_cache_lock_contention = nullptr; - Counter::AtomicType *session_cache_miss = nullptr; - Counter::AtomicType *session_cache_new_session = nullptr; - Counter::AtomicType *sni_name_set_failure = nullptr; - Counter::AtomicType *total_attempts_handshake_count_in = nullptr; - Counter::AtomicType *total_attempts_handshake_count_out = nullptr; - Counter::AtomicType *total_dyn_def_tls_record_count = nullptr; - Counter::AtomicType *total_dyn_max_tls_record_count = nullptr; - Counter::AtomicType *total_dyn_redo_tls_record_count = nullptr; - Counter::AtomicType *total_handshake_time = nullptr; - Counter::AtomicType *total_sslv3 = nullptr; - Counter::AtomicType *total_success_handshake_count_in = nullptr; - Counter::AtomicType *total_success_handshake_count_out = nullptr; - Counter::AtomicType *total_ticket_keys_renewed = nullptr; - Counter::AtomicType *total_tickets_created = nullptr; - Counter::AtomicType *total_tickets_not_found = nullptr; - Counter::AtomicType *total_tickets_renewed = nullptr; - Counter::AtomicType *total_tickets_verified_old_key = nullptr; - Counter::AtomicType *total_tickets_verified = nullptr; - Counter::AtomicType *total_tlsv1 = nullptr; - Counter::AtomicType *total_tlsv11 = nullptr; - Counter::AtomicType *total_tlsv12 = nullptr; - Counter::AtomicType *total_tlsv13 = nullptr; - Counter::AtomicType *user_agent_bad_cert = nullptr; - Counter::AtomicType *user_agent_cert_verify_failed = nullptr; - Counter::AtomicType *user_agent_decryption_failed = nullptr; - Counter::AtomicType *user_agent_expired_cert = nullptr; - Counter::AtomicType *user_agent_other_errors = nullptr; - Counter::AtomicType *user_agent_revoked_cert = nullptr; - Counter::AtomicType *user_agent_session_hit = nullptr; - Counter::AtomicType *user_agent_session_miss = nullptr; - Counter::AtomicType *user_agent_session_timeout = nullptr; - Counter::AtomicType *user_agent_sessions = nullptr; - Counter::AtomicType *user_agent_unknown_ca = nullptr; - Counter::AtomicType *user_agent_unknown_cert = nullptr; - Counter::AtomicType *user_agent_wrong_version = nullptr; + Metrics::Counter::AtomicType *early_data_received_count = nullptr; + Metrics::Counter::AtomicType *error_async = nullptr; + Metrics::Counter::AtomicType *error_ssl = nullptr; + Metrics::Counter::AtomicType *error_syscall = nullptr; + Metrics::Counter::AtomicType *ocsp_refresh_cert_failure = nullptr; + Metrics::Counter::AtomicType *ocsp_refreshed_cert = nullptr; + Metrics::Counter::AtomicType *ocsp_revoked_cert = nullptr; + Metrics::Counter::AtomicType *ocsp_unknown_cert = nullptr; + Metrics::Counter::AtomicType *origin_server_bad_cert = nullptr; + Metrics::Counter::AtomicType *origin_server_cert_verify_failed = nullptr; + Metrics::Counter::AtomicType *origin_server_decryption_failed = nullptr; + Metrics::Counter::AtomicType *origin_server_expired_cert = nullptr; + Metrics::Counter::AtomicType *origin_server_other_errors = nullptr; + Metrics::Counter::AtomicType *origin_server_revoked_cert = nullptr; + Metrics::Counter::AtomicType *origin_server_unknown_ca = nullptr; + Metrics::Counter::AtomicType *origin_server_unknown_cert = nullptr; + Metrics::Counter::AtomicType *origin_server_wrong_version = nullptr; + Metrics::Counter::AtomicType *origin_session_cache_hit = nullptr; + Metrics::Counter::AtomicType *origin_session_cache_miss = nullptr; + Metrics::Counter::AtomicType *origin_session_reused_count = nullptr; + Metrics::Counter::AtomicType *session_cache_eviction = nullptr; + Metrics::Counter::AtomicType *session_cache_hit = nullptr; + Metrics::Counter::AtomicType *session_cache_lock_contention = nullptr; + Metrics::Counter::AtomicType *session_cache_miss = nullptr; + Metrics::Counter::AtomicType *session_cache_new_session = nullptr; + Metrics::Counter::AtomicType *sni_name_set_failure = nullptr; + Metrics::Counter::AtomicType *total_attempts_handshake_count_in = nullptr; + Metrics::Counter::AtomicType *total_attempts_handshake_count_out = nullptr; + Metrics::Counter::AtomicType *total_dyn_def_tls_record_count = nullptr; + Metrics::Counter::AtomicType *total_dyn_max_tls_record_count = nullptr; + Metrics::Counter::AtomicType *total_dyn_redo_tls_record_count = nullptr; + Metrics::Counter::AtomicType *total_handshake_time = nullptr; + Metrics::Counter::AtomicType *total_sslv3 = nullptr; + Metrics::Counter::AtomicType *total_success_handshake_count_in = nullptr; + Metrics::Counter::AtomicType *total_success_handshake_count_out = nullptr; + Metrics::Counter::AtomicType *total_ticket_keys_renewed = nullptr; + Metrics::Counter::AtomicType *total_tickets_created = nullptr; + Metrics::Counter::AtomicType *total_tickets_not_found = nullptr; + Metrics::Counter::AtomicType *total_tickets_renewed = nullptr; + Metrics::Counter::AtomicType *total_tickets_verified_old_key = nullptr; + Metrics::Counter::AtomicType *total_tickets_verified = nullptr; + Metrics::Counter::AtomicType *total_tlsv1 = nullptr; + Metrics::Counter::AtomicType *total_tlsv11 = nullptr; + Metrics::Counter::AtomicType *total_tlsv12 = nullptr; + Metrics::Counter::AtomicType *total_tlsv13 = nullptr; + Metrics::Counter::AtomicType *user_agent_bad_cert = nullptr; + Metrics::Counter::AtomicType *user_agent_cert_verify_failed = nullptr; + Metrics::Counter::AtomicType *user_agent_decryption_failed = nullptr; + Metrics::Counter::AtomicType *user_agent_expired_cert = nullptr; + Metrics::Counter::AtomicType *user_agent_other_errors = nullptr; + Metrics::Counter::AtomicType *user_agent_revoked_cert = nullptr; + Metrics::Counter::AtomicType *user_agent_session_hit = nullptr; + Metrics::Counter::AtomicType *user_agent_session_miss = nullptr; + Metrics::Counter::AtomicType *user_agent_session_timeout = nullptr; + Metrics::Counter::AtomicType *user_agent_sessions = nullptr; + Metrics::Counter::AtomicType *user_agent_unknown_ca = nullptr; + Metrics::Counter::AtomicType *user_agent_unknown_cert = nullptr; + Metrics::Counter::AtomicType *user_agent_wrong_version = nullptr; }; extern SSLStatsBlock ssl_rsb; -extern std::unordered_map cipher_map; +extern std::unordered_map cipher_map; // Initialize SSL statistics. void SSLInitializeStatistics(); diff --git a/src/iocore/net/SSLUtils.cc b/src/iocore/net/SSLUtils.cc index 46f17b26aad..8c7edd33295 100644 --- a/src/iocore/net/SSLUtils.cc +++ b/src/iocore/net/SSLUtils.cc @@ -228,7 +228,7 @@ ssl_new_cached_session(SSL *ssl, SSL_SESSION *sess) } } - Counter::increment(ssl_rsb.session_cache_new_session); + Metrics::Counter::increment(ssl_rsb.session_cache_new_session); session_cache->insertSession(sid, sess, ssl); // Call hook after new session is created @@ -651,7 +651,7 @@ ssl_context_enable_tickets(SSL_CTX *ctx, const char *ticket_key_path) // On the "first run" the metrics have not been initialized, so this has to check it. if (ssl_rsb.total_ticket_keys_renewed) { - Counter::increment(ssl_rsb.total_ticket_keys_renewed); + Metrics::Counter::increment(ssl_rsb.total_ticket_keys_renewed); } // Setting the callback can only fail if OpenSSL does not recognize the @@ -1136,7 +1136,7 @@ ssl_callback_info(const SSL *ssl, int where, int ret) it = cipher_map.find(SSL_CIPHER_STAT_OTHER); ink_assert(it != cipher_map.end()); } - Counter::increment(it->second); + Metrics::Counter::increment(it->second); } } } diff --git a/src/iocore/net/Socks.cc b/src/iocore/net/Socks.cc index cb3273adfd0..e5905f9fabf 100644 --- a/src/iocore/net/Socks.cc +++ b/src/iocore/net/Socks.cc @@ -164,7 +164,7 @@ SocksEntry::free() if (!action_.cancelled) { if (lerrno || !netVConnection) { Dbg(dbg_ctl_Socks, "retryevent: Sent errno %d to HTTP", lerrno); - Counter::increment(net_rsb.socks_connections_unsuccessful); + Metrics::Counter::increment(net_rsb.socks_connections_unsuccessful); action_.continuation->handleEvent(NET_EVENT_OPEN_FAILED, (void *)static_cast(-lerrno)); } else { netVConnection->do_io_read(this, 0, nullptr); @@ -172,7 +172,7 @@ SocksEntry::free() netVConnection->action_ = action_; // assign the original continuation netVConnection->con.setRemote(&server_addr.sa); Dbg(dbg_ctl_Socks, "Sent success to HTTP"); - Counter::increment(net_rsb.socks_connections_successful); + Metrics::Counter::increment(net_rsb.socks_connections_successful); action_.continuation->handleEvent(NET_EVENT_OPEN, netVConnection); } } diff --git a/src/iocore/net/TLSBasicSupport.cc b/src/iocore/net/TLSBasicSupport.cc index 1644130e264..d3fdcca6193 100644 --- a/src/iocore/net/TLSBasicSupport.cc +++ b/src/iocore/net/TLSBasicSupport.cc @@ -167,5 +167,5 @@ TLSBasicSupport::_record_tls_handshake_end_time() const ink_hrtime ssl_handshake_time = this->_tls_handshake_end_time - this->_tls_handshake_begin_time; Debug("ssl", "ssl handshake time:%" PRId64, ssl_handshake_time); - Counter::increment(ssl_rsb.total_handshake_time, ssl_handshake_time); + Metrics::Counter::increment(ssl_rsb.total_handshake_time, ssl_handshake_time); } diff --git a/src/iocore/net/TLSSessionResumptionSupport.cc b/src/iocore/net/TLSSessionResumptionSupport.cc index 3e7b260af5d..90394d63dc6 100644 --- a/src/iocore/net/TLSSessionResumptionSupport.cc +++ b/src/iocore/net/TLSSessionResumptionSupport.cc @@ -165,7 +165,7 @@ TLSSessionResumptionSupport::getSession(SSL *ssl, const unsigned char *id, int l // Double check the timeout if (is_ssl_session_timed_out(session)) { - Counter::increment(ssl_rsb.session_cache_miss); + Metrics::Counter::increment(ssl_rsb.session_cache_miss); // Due to bug in openssl, the timeout is checked, but only removed // from the openssl built-in hash table. The external remove cb is not called #if 0 // This is currently eliminated, since it breaks things in odd ways (see TS-3710) @@ -174,12 +174,12 @@ TLSSessionResumptionSupport::getSession(SSL *ssl, const unsigned char *id, int l SSL_SESSION_free(session); session = nullptr; } else { - Counter::increment(ssl_rsb.session_cache_hit); + Metrics::Counter::increment(ssl_rsb.session_cache_hit); this->_setSSLSessionCacheHit(true); this->_setSSLCurveNID(exdata->curve); } } else { - Counter::increment(ssl_rsb.session_cache_miss); + Metrics::Counter::increment(ssl_rsb.session_cache_miss); } return session; } @@ -193,16 +193,16 @@ TLSSessionResumptionSupport::getOriginSession(SSL *ssl, const std::string &looku if (shared_sess != nullptr) { // Double check the timeout if (is_ssl_session_timed_out(shared_sess.get())) { - Counter::increment(ssl_rsb.origin_session_cache_miss); + Metrics::Counter::increment(ssl_rsb.origin_session_cache_miss); origin_sess_cache->remove_session(lookup_key); shared_sess.reset(); } else { - Counter::increment(ssl_rsb.origin_session_cache_hit); + Metrics::Counter::increment(ssl_rsb.origin_session_cache_hit); this->_setSSLOriginSessionCacheHit(true); this->_setSSLCurveNID(curve); } } else { - Counter::increment(ssl_rsb.origin_session_cache_miss); + Metrics::Counter::increment(ssl_rsb.origin_session_cache_miss); } return shared_sess; } @@ -248,7 +248,7 @@ TLSSessionResumptionSupport::_setSessionInformation(ssl_ticket_key_block *keyblo #endif Debug("ssl_session_ticket", "create ticket for a new session."); - Counter::increment(ssl_rsb.total_tickets_created); + Metrics::Counter::increment(ssl_rsb.total_tickets_created); return 1; } @@ -284,10 +284,10 @@ TLSSessionResumptionSupport::_getSessionInformation(ssl_ticket_key_block *keyblo Debug("ssl_session_ticket", "verify the ticket for an existing session."); // Increase the total number of decrypted tickets. - Counter::increment(ssl_rsb.total_tickets_verified); + Metrics::Counter::increment(ssl_rsb.total_tickets_verified); if (i != 0) { // The number of tickets decrypted with "older" keys. - Counter::increment(ssl_rsb.total_tickets_verified_old_key); + Metrics::Counter::increment(ssl_rsb.total_tickets_verified_old_key); } this->_setSSLSessionCacheHit(true); @@ -305,7 +305,7 @@ TLSSessionResumptionSupport::_getSessionInformation(ssl_ticket_key_block *keyblo } Debug("ssl_session_ticket", "keyname is not consistent."); - Counter::increment(ssl_rsb.total_tickets_not_found); + Metrics::Counter::increment(ssl_rsb.total_tickets_not_found); return 0; } diff --git a/src/iocore/net/UnixNet.cc b/src/iocore/net/UnixNet.cc index dd065d23bfb..0202bb45378 100644 --- a/src/iocore/net/UnixNet.cc +++ b/src/iocore/net/UnixNet.cc @@ -90,7 +90,7 @@ class InactivityCop : public Continuation // If we cannot get the lock don't stop just keep cleaning MUTEX_TRY_LOCK(lock, ne->get_mutex(), this_ethread()); if (!lock.is_locked()) { - Counter::increment(net_rsb.inactivity_cop_lock_acquire_failure); + Metrics::Counter::increment(net_rsb.inactivity_cop_lock_acquire_failure); continue; } @@ -117,20 +117,20 @@ class InactivityCop : public Continuation ne->use_default_inactivity_timeout = true; ne->next_inactivity_timeout_at = ink_get_hrtime() + ne->default_inactivity_timeout_in; ne->inactivity_timeout_in = 0; - Counter::increment(net_rsb.default_inactivity_timeout_applied); + Metrics::Counter::increment(net_rsb.default_inactivity_timeout_applied); } if (ne->next_inactivity_timeout_at && ne->next_inactivity_timeout_at < now) { if (ne->is_default_inactivity_timeout()) { // track the connections that timed out due to default inactivity Dbg(dbg_ctl_inactivity_cop, "vc: %p timed out due to default inactivity timeout", ne); - Counter::increment(net_rsb.default_inactivity_timeout_count); + Metrics::Counter::increment(net_rsb.default_inactivity_timeout_count); } if (nh.keep_alive_queue.in(ne)) { // only stat if the connection is in keep-alive, there can be other inactivity timeouts ink_hrtime diff = (now - (ne->next_inactivity_timeout_at - ne->inactivity_timeout_in)) / HRTIME_SECOND; - Counter::increment(net_rsb.keep_alive_queue_timeout_total, diff); - Counter::increment(net_rsb.keep_alive_queue_timeout_count); + Metrics::Counter::increment(net_rsb.keep_alive_queue_timeout_total, diff); + Metrics::Counter::increment(net_rsb.keep_alive_queue_timeout_count); } Dbg(dbg_ctl_inactivity_cop_verbose, "ne: %p now: %" PRId64 " timeout at: %" PRId64 " timeout in: %" PRId64, ne, ink_hrtime_to_sec(now), ne->next_inactivity_timeout_at, ne->inactivity_timeout_in); diff --git a/src/iocore/net/UnixNetAccept.cc b/src/iocore/net/UnixNetAccept.cc index 7a1d42fbdc8..76aa8ed5703 100644 --- a/src/iocore/net/UnixNetAccept.cc +++ b/src/iocore/net/UnixNetAccept.cc @@ -80,7 +80,7 @@ net_accept(NetAccept *na, void *ep, bool blockable) count = res; goto Ldone; } - Counter::increment(net_rsb.tcp_accept); + Metrics::Counter::increment(net_rsb.tcp_accept); vc = static_cast(na->getNetProcessor()->allocate_vc(e->ethread)); if (!vc) { @@ -88,7 +88,7 @@ net_accept(NetAccept *na, void *ep, bool blockable) } count++; - Counter::increment(net_rsb.connections_currently_open); + Metrics::Counter::increment(net_rsb.connections_currently_open); vc->id = net_next_connection_number(); vc->con.move(con); vc->set_remote_addr(con.addr); @@ -338,7 +338,7 @@ NetAccept::do_blocking_accept(EThread *t) check_throttle_warning(ACCEPT); // close the connection as we are in throttle state con.close(); - Counter::increment(net_rsb.connections_throttled_in); + Metrics::Counter::increment(net_rsb.connections_throttled_in); continue; } @@ -346,7 +346,7 @@ NetAccept::do_blocking_accept(EThread *t) return -1; } - Counter::increment(net_rsb.tcp_accept); + Metrics::Counter::increment(net_rsb.tcp_accept); // Use 'nullptr' to Bypass thread allocator vc = (UnixNetVConnection *)this->getNetProcessor()->allocate_vc(nullptr); @@ -355,7 +355,7 @@ NetAccept::do_blocking_accept(EThread *t) } count++; - Counter::increment(net_rsb.connections_currently_open); + Metrics::Counter::increment(net_rsb.connections_currently_open); vc->id = net_next_connection_number(); vc->con.move(con); vc->set_remote_addr(con.addr); @@ -410,14 +410,14 @@ NetAccept::acceptEvent(int event, void *ep) if (lock.is_locked()) { if (action_->cancelled) { e->cancel(); - Counter::decrement(net_rsb.accepts_currently_open); + Metrics::Counter::decrement(net_rsb.accepts_currently_open); delete this; return EVENT_DONE; } int res; if ((res = accept_fn(this, e, false)) < 0) { - Counter::decrement(net_rsb.accepts_currently_open); + Metrics::Counter::decrement(net_rsb.accepts_currently_open); /* INKqa11179 */ Warning("Accept on port %d failed with error no %d", ats_ip_port_host_order(&server.addr), res); Warning("Traffic Server may be unable to accept more network" @@ -458,11 +458,11 @@ NetAccept::acceptFastEvent(int event, void *ep) if (check_net_throttle(ACCEPT)) { // close the connection as we are in throttle state con.close(); - Counter::increment(net_rsb.connections_throttled_in); + Metrics::Counter::increment(net_rsb.connections_throttled_in); continue; } Dbg(dbg_ctl_iocore_net, "accepted a new socket: %d", fd); - Counter::increment(net_rsb.tcp_accept); + Metrics::Counter::increment(net_rsb.tcp_accept); if (opt.send_bufsize > 0) { if (unlikely(SocketManager::set_sndbuf_size(fd, opt.send_bufsize))) { bufsz = ROUNDUP(opt.send_bufsize, 1024); @@ -512,7 +512,7 @@ NetAccept::acceptFastEvent(int event, void *ep) ink_release_assert(vc); count++; - Counter::increment(net_rsb.connections_currently_open); + Metrics::Counter::increment(net_rsb.connections_currently_open); vc->id = net_next_connection_number(); vc->con.move(con); vc->set_remote_addr(con.addr); @@ -560,7 +560,7 @@ NetAccept::acceptFastEvent(int event, void *ep) Lerror: server.close(); e->cancel(); - Counter::decrement(net_rsb.accepts_currently_open); + Metrics::Counter::decrement(net_rsb.accepts_currently_open); delete this; return EVENT_DONE; } @@ -577,7 +577,7 @@ NetAccept::acceptLoopEvent(int event, Event *e) } // Don't think this ever happens ... - Counter::decrement(net_rsb.accepts_currently_open); + Metrics::Counter::decrement(net_rsb.accepts_currently_open); delete this; return EVENT_DONE; } diff --git a/src/iocore/net/UnixNetProcessor.cc b/src/iocore/net/UnixNetProcessor.cc index 3c4dcee744d..a5b0158f7f8 100644 --- a/src/iocore/net/UnixNetProcessor.cc +++ b/src/iocore/net/UnixNetProcessor.cc @@ -97,7 +97,7 @@ UnixNetProcessor::accept_internal(Continuation *cont, int fd, AcceptOptions cons Fatal("Please disable accept_threads or exec_thread.listen"); } - Counter::increment(net_rsb.accepts_currently_open); + Metrics::Counter::increment(net_rsb.accepts_currently_open); // We've handled the config stuff at start up, but there are a few cases // we must handle at this point. diff --git a/src/iocore/net/UnixNetVConnection.cc b/src/iocore/net/UnixNetVConnection.cc index 0e866a0ebac..e91ff9dceed 100644 --- a/src/iocore/net/UnixNetVConnection.cc +++ b/src/iocore/net/UnixNetVConnection.cc @@ -262,7 +262,7 @@ read_from_net(NetHandler *nh, UnixNetVConnection *vc, EThread *thread) msg.msg_iovlen = niov; r = SocketManager::recvmsg(vc->con.fd, &msg, 0); - Counter::increment(net_rsb.calls_to_read); + Metrics::Counter::increment(net_rsb.calls_to_read); total_read += rattempted; } while (rattempted && r == rattempted && total_read < toread); @@ -278,7 +278,7 @@ read_from_net(NetHandler *nh, UnixNetVConnection *vc, EThread *thread) // check for errors if (r <= 0) { if (r == -EAGAIN || r == -ENOTCONN) { - Counter::increment(net_rsb.calls_to_read_nodata); + Metrics::Counter::increment(net_rsb.calls_to_read_nodata); vc->read.triggered = 0; nh->read_ready_list.remove(vc); return; @@ -294,8 +294,8 @@ read_from_net(NetHandler *nh, UnixNetVConnection *vc, EThread *thread) read_signal_error(nh, vc, static_cast(-r)); return; } - Counter::increment(net_rsb.read_bytes, r); - Counter::increment(net_rsb.read_bytes_count); + Metrics::Counter::increment(net_rsb.read_bytes, r); + Metrics::Counter::increment(net_rsb.read_bytes_count); // Add data to buffer and signal continuation. buf.writer()->fill(r); @@ -347,7 +347,7 @@ read_from_net(NetHandler *nh, UnixNetVConnection *vc, EThread *thread) void write_to_net(NetHandler *nh, UnixNetVConnection *vc, EThread *thread) { - Counter::increment(net_rsb.calls_to_writetonet); + Metrics::Counter::increment(net_rsb.calls_to_writetonet); write_to_net_io(nh, vc, thread); } @@ -472,8 +472,8 @@ write_to_net_io(NetHandler *nh, UnixNetVConnection *vc, EThread *thread) int64_t r = vc->load_buffer_and_write(towrite, buf, total_written, needs); if (total_written > 0) { - Counter::increment(net_rsb.write_bytes, total_written); - Counter::increment(net_rsb.write_bytes_count); + Metrics::Counter::increment(net_rsb.write_bytes, total_written); + Metrics::Counter::increment(net_rsb.write_bytes_count); s->vio.ndone += total_written; net_activity(vc, thread); } @@ -484,7 +484,7 @@ write_to_net_io(NetHandler *nh, UnixNetVConnection *vc, EThread *thread) // check for errors if (r < 0) { // if the socket was not ready, add to WaitList if (r == -EAGAIN || r == -ENOTCONN || -r == EINPROGRESS) { - Counter::increment(net_rsb.calls_to_write_nodata); + Metrics::Counter::increment(net_rsb.calls_to_write_nodata); if ((needs & EVENTIO_WRITE) == EVENTIO_WRITE) { vc->write.triggered = 0; nh->write_ready_list.remove(vc); @@ -916,7 +916,7 @@ UnixNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor &bu int flags = 0; if (!this->con.is_connected && this->options.f_tcp_fastopen) { - Counter::increment(net_rsb.fastopen_attempts); + Metrics::Counter::increment(net_rsb.fastopen_attempts); flags = MSG_FASTOPEN; } r = SocketManager::sendmsg(con.fd, &msg, flags); @@ -926,7 +926,7 @@ UnixNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor &bu this->con.is_connected = true; } } else { - Counter::increment(net_rsb.fastopen_successes); + Metrics::Counter::increment(net_rsb.fastopen_successes); this->con.is_connected = true; } } @@ -936,7 +936,7 @@ UnixNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor &bu total_written += r; } - Counter::increment(net_rsb.calls_to_write); + Metrics::Counter::increment(net_rsb.calls_to_write); } while (r == try_to_write && total_written < towrite); tmp_reader->dealloc(); @@ -1159,7 +1159,7 @@ UnixNetVConnection::connectUp(EThread *t, int fd) if (check_net_throttle(CONNECT)) { check_throttle_warning(CONNECT); res = -ENET_THROTTLING; - Counter::increment(net_rsb.connections_throttled_out); + Metrics::Counter::increment(net_rsb.connections_throttled_out); goto fail; } @@ -1212,7 +1212,7 @@ UnixNetVConnection::connectUp(EThread *t, int fd) } // Did not fail, increment connection count - Counter::increment(net_rsb.connections_currently_open); + Metrics::Counter::increment(net_rsb.connections_currently_open); ink_release_assert(con.fd != NO_FD); // Setup a timeout callback handler. @@ -1290,14 +1290,14 @@ UnixNetVConnection::free_thread(EThread *t) // close socket fd if (con.fd != NO_FD) { - Counter::decrement(net_rsb.connections_currently_open); + Metrics::Counter::decrement(net_rsb.connections_currently_open); } con.close(); if (is_tunnel_endpoint()) { Debug("iocore_net", "Freeing UnixNetVConnection that is tunnel endpoint"); - Counter::decrement(([&]() -> Counter::AtomicType * { + Metrics::Counter::decrement(([&]() -> Metrics::Counter::AtomicType * { switch (get_context()) { case NET_VCONNECTION_IN: return net_rsb.tunnel_current_client_connections_blind_tcp; @@ -1533,13 +1533,13 @@ UnixNetVConnection::mark_as_tunnel_endpoint() void UnixNetVConnection::_in_context_tunnel() { - Counter::increment(net_rsb.tunnel_total_client_connections_blind_tcp); - Counter::increment(net_rsb.tunnel_current_client_connections_blind_tcp); + Metrics::Counter::increment(net_rsb.tunnel_total_client_connections_blind_tcp); + Metrics::Counter::increment(net_rsb.tunnel_current_client_connections_blind_tcp); } void UnixNetVConnection::_out_context_tunnel() { - Counter::increment(net_rsb.tunnel_total_server_connections_blind_tcp); - Counter::increment(net_rsb.tunnel_current_server_connections_blind_tcp); + Metrics::Counter::increment(net_rsb.tunnel_total_server_connections_blind_tcp); + Metrics::Counter::increment(net_rsb.tunnel_current_server_connections_blind_tcp); } diff --git a/src/iocore/net/quic/QUICGlobals.cc b/src/iocore/net/quic/QUICGlobals.cc index 409566006c0..2d93df5f441 100644 --- a/src/iocore/net/quic/QUICGlobals.cc +++ b/src/iocore/net/quic/QUICGlobals.cc @@ -73,10 +73,10 @@ QUIC::ssl_client_new_session(SSL *ssl, SSL_SESSION *session) void QUIC::_register_stats() { - ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); + ts::Metrics::Counter &metrics = ts::Metrics::instance(); // Transferred packet counts - quic_rsb.total_packets_sent = Counter::CreatePtr("proxy.process.quic.total_packets_sent"); + quic_rsb.total_packets_sent = Metrics::Counter::createPtr("proxy.process.quic.total_packets_sent"); - // quic_rsb.total_packets_retransmitted = Counter::CreatePtr("proxy.process.quic.total_packets_retransmitted"); - // quic_rsb.total_packets_received = Counter::CreatePtr("proxy.process.quic.total_packets_received"); + // quic_rsb.total_packets_retransmitted = Metrics::Counter::createPtr("proxy.process.quic.total_packets_retransmitted"); + // quic_rsb.total_packets_received = Metrics::Counter::createPtr("proxy.process.quic.total_packets_received"); } diff --git a/src/mgmt/rpc/handlers/config/Configuration.cc b/src/mgmt/rpc/handlers/config/Configuration.cc index 846593d9d25..7f0877a46ef 100644 --- a/src/mgmt/rpc/handlers/config/Configuration.cc +++ b/src/mgmt/rpc/handlers/config/Configuration.cc @@ -184,9 +184,9 @@ set_config_records(std::string_view const &id, YAML::Node const ¶ms) ts::Rv reload_config(std::string_view const &id, YAML::Node const ¶ms) { - ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); - static auto reconf_time = metrics.lookup("proxy.process.proxy.reconfigure_time"); - static auto reconf_req = metrics.lookup("proxy.process.proxy.reconfigure_required"); + ts::Metrics &metrics = ts::Metrics::instance(); + static auto reconf_time = metrics.lookup("proxy.process.proxy.reconfigure_time"); + static auto reconf_req = metrics.lookup("proxy.process.proxy.reconfigure_required"); ts::Rv resp; Debug("RPC", "invoke plugin callbacks"); // if there is any error, report it back. diff --git a/src/mgmt/rpc/handlers/server/Server.cc b/src/mgmt/rpc/handlers/server/Server.cc index 8b457b09e50..3a927deb093 100644 --- a/src/mgmt/rpc/handlers/server/Server.cc +++ b/src/mgmt/rpc/handlers/server/Server.cc @@ -63,8 +63,8 @@ namespace err = rpc::handlers::errors; static bool is_server_draining() { - ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); - static auto drain_id = metrics.lookup("proxy.process.proxy.draining"); + ts::Metrics &metrics = ts::Metrics::instance(); + static auto drain_id = metrics.lookup("proxy.process.proxy.draining"); return (metrics[drain_id] != 0); } @@ -72,8 +72,8 @@ is_server_draining() static void set_server_drain(bool drain) { - ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); - static auto drain_id = metrics.lookup("proxy.process.proxy.draining"); + ts::Metrics &metrics = ts::Metrics::instance(); + static auto drain_id = metrics.lookup("proxy.process.proxy.draining"); TSSystemState::drain(drain); metrics[drain_id] = TSSystemState::is_draining() ? 1 : 0; diff --git a/src/proxy/http/Http1ClientSession.cc b/src/proxy/http/Http1ClientSession.cc index 746f83497b5..a36e942bc40 100644 --- a/src/proxy/http/Http1ClientSession.cc +++ b/src/proxy/http/Http1ClientSession.cc @@ -118,7 +118,7 @@ Http1ClientSession::free() #endif if (conn_decrease) { - Counter::decrement(http_rsb.current_client_connections); + Metrics::Counter::decrement(http_rsb.current_client_connections); conn_decrease = false; } @@ -154,26 +154,26 @@ Http1ClientSession::new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOB schedule_event = nullptr; - Counter::increment(http_rsb.current_client_connections); + Metrics::Counter::increment(http_rsb.current_client_connections); conn_decrease = true; - Counter::increment(http_rsb.total_client_connections); + Metrics::Counter::increment(http_rsb.total_client_connections); if (static_cast(new_vc->attributes) == HttpProxyPort::TRANSPORT_SSL) { - Counter::increment(http_rsb.https_total_client_connections); + Metrics::Counter::increment(http_rsb.https_total_client_connections); } /* inbound requests stat should be incremented here, not after the * header has been read */ - Counter::increment(http_rsb.total_incoming_connections); + Metrics::Counter::increment(http_rsb.total_incoming_connections); // check what type of socket address we just accepted // by looking at the address family value of sockaddr_storage // and logging to stat system switch (new_vc->get_remote_addr()->sa_family) { case AF_INET: - Counter::increment(http_rsb.total_client_connections_ipv4); + Metrics::Counter::increment(http_rsb.total_client_connections_ipv4); break; case AF_INET6: - Counter::increment(http_rsb.total_client_connections_ipv6); + Metrics::Counter::increment(http_rsb.total_client_connections_ipv6); break; default: // don't do anything if the address family is not ipv4 or ipv6 @@ -513,12 +513,12 @@ Http1ClientSession::attach_server_session(PoolableSession *ssession, bool transa void Http1ClientSession::increment_current_active_connections_stat() { - Counter::increment(http_rsb.current_active_client_connections); + Metrics::Counter::increment(http_rsb.current_active_client_connections); } void Http1ClientSession::decrement_current_active_connections_stat() { - Counter::decrement(http_rsb.current_active_client_connections); + Metrics::Counter::decrement(http_rsb.current_active_client_connections); } void diff --git a/src/proxy/http/Http1ClientTransaction.cc b/src/proxy/http/Http1ClientTransaction.cc index dcde861aae2..b02448944f3 100644 --- a/src/proxy/http/Http1ClientTransaction.cc +++ b/src/proxy/http/Http1ClientTransaction.cc @@ -59,11 +59,11 @@ Http1ClientTransaction::allow_half_open() const void Http1ClientTransaction::increment_transactions_stat() { - Counter::increment(http_rsb.current_client_transactions); + Metrics::Counter::increment(http_rsb.current_client_transactions); } void Http1ClientTransaction::decrement_transactions_stat() { - Counter::decrement(http_rsb.current_client_transactions); + Metrics::Counter::decrement(http_rsb.current_client_transactions); } diff --git a/src/proxy/http/Http1ServerSession.cc b/src/proxy/http/Http1ServerSession.cc index 0102abfd82c..808c93a9254 100644 --- a/src/proxy/http/Http1ServerSession.cc +++ b/src/proxy/http/Http1ServerSession.cc @@ -80,8 +80,8 @@ Http1ServerSession::new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOB con_id = ProxySession::next_connection_id(); magic = HTTP_SS_MAGIC_ALIVE; - Counter::increment(http_rsb.current_server_connections); - Counter::increment(http_rsb.total_server_connections); + Metrics::Counter::increment(http_rsb.current_server_connections); + Metrics::Counter::increment(http_rsb.total_server_connections); if (iobuf == nullptr) { read_buffer = new_MIOBuffer(HTTP_SERVER_RESP_HDR_BUFFER_INDEX); @@ -110,7 +110,7 @@ Http1ServerSession::do_io_close(int alerrno) w.print("[{}] session close: nevtc {:x}", con_id, _vc); } - Counter::decrement(http_rsb.current_server_connections); + Metrics::Counter::decrement(http_rsb.current_server_connections); // Update upstream connection tracking data if present. this->release_outbound_connection_tracking(); @@ -125,7 +125,7 @@ Http1ServerSession::do_io_close(int alerrno) _vc = nullptr; if (to_parent_proxy) { - Counter::decrement(http_rsb.current_parent_proxy_connections); + Metrics::Counter::decrement(http_rsb.current_parent_proxy_connections); } } @@ -207,7 +207,7 @@ Http1ServerSession ::release_transaction() // Private sessions are never released back to the shared pool if (this->is_private() || sharing_match == 0) { if (this->is_private()) { - Counter::increment(http_rsb.origin_close_private); + Metrics::Counter::increment(http_rsb.origin_close_private); } this->do_io_close(); } else if (state == SSN_TO_RELEASE) { @@ -225,7 +225,7 @@ Http1ServerSession ::release_transaction() // due to lock contention // FIX: should retry instead of closing do_io_close(HTTP_ERRNO); - Counter::increment(http_rsb.origin_shutdown_pool_lock_contention); + Metrics::Counter::increment(http_rsb.origin_shutdown_pool_lock_contention); } else { // The session was successfully put into the session // manager and it will manage it diff --git a/src/proxy/http/Http1ServerTransaction.cc b/src/proxy/http/Http1ServerTransaction.cc index 3207da850f8..e51918179d0 100644 --- a/src/proxy/http/Http1ServerTransaction.cc +++ b/src/proxy/http/Http1ServerTransaction.cc @@ -33,13 +33,13 @@ Http1ServerTransaction::release() void Http1ServerTransaction::increment_transactions_stat() { - Counter::increment(http_rsb.current_server_transactions); + Metrics::Counter::increment(http_rsb.current_server_transactions); } void Http1ServerTransaction::decrement_transactions_stat() { - Counter::decrement(http_rsb.current_server_transactions); + Metrics::Counter::decrement(http_rsb.current_server_transactions); } void diff --git a/src/proxy/http/HttpCacheSM.cc b/src/proxy/http/HttpCacheSM.cc index 7db70a81494..c6ef0cf3d4a 100644 --- a/src/proxy/http/HttpCacheSM.cc +++ b/src/proxy/http/HttpCacheSM.cc @@ -107,7 +107,7 @@ HttpCacheSM::state_cache_open_read(int event, void *data) switch (event) { case CACHE_EVENT_OPEN_READ: - Counter::increment(http_rsb.current_cache_connections); + Metrics::Counter::increment(http_rsb.current_cache_connections); ink_assert((cache_read_vc == nullptr) || master_sm->t_state.redirect_info.redirect_in_process); if (cache_read_vc) { // redirect follow in progress, close the previous cache_read_vc @@ -186,7 +186,7 @@ HttpCacheSM::state_cache_open_write(int event, void *data) switch (event) { case CACHE_EVENT_OPEN_WRITE: - Counter::increment(http_rsb.current_cache_connections); + Metrics::Counter::increment(http_rsb.current_cache_connections); ink_assert(cache_write_vc == nullptr); cache_write_vc = static_cast(data); open_write_cb = true; diff --git a/src/proxy/http/HttpConfig.cc b/src/proxy/http/HttpConfig.cc index c227eae7b3d..ce90af072da 100644 --- a/src/proxy/http/HttpConfig.cc +++ b/src/proxy/http/HttpConfig.cc @@ -259,260 +259,282 @@ http_insert_forwarded_cb(const char *name, RecDataT dtype, RecData data, void *c void register_stat_callbacks() { - http_rsb.background_fill_bytes_aborted = Counter::CreatePtr("proxy.process.http.background_fill_bytes_aborted"); - http_rsb.background_fill_bytes_completed = Counter::CreatePtr("proxy.process.http.background_fill_bytes_completed"); - http_rsb.background_fill_current_count = Counter::CreatePtr("proxy.process.http.background_fill_current_count"); - http_rsb.background_fill_total_count = Counter::CreatePtr("proxy.process.http.background_fill_total_count"); - http_rsb.broken_server_connections = Counter::CreatePtr("proxy.process.http.broken_server_connections"); - http_rsb.cache_deletes = Counter::CreatePtr("proxy.process.http.cache_deletes"); - http_rsb.cache_hit_fresh = Counter::CreatePtr("proxy.process.http.cache_hit_fresh"); - http_rsb.cache_hit_ims = Counter::CreatePtr("proxy.process.http.cache_hit_ims"); - http_rsb.cache_hit_mem_fresh = Counter::CreatePtr("proxy.process.http.cache_hit_mem_fresh"); - http_rsb.cache_hit_reval = Counter::CreatePtr("proxy.process.http.cache_hit_revalidated"); - http_rsb.cache_hit_rww = Counter::CreatePtr("proxy.process.http.cache_hit_rww"); - http_rsb.cache_hit_stale_served = Counter::CreatePtr("proxy.process.http.cache_hit_stale_served"); - http_rsb.cache_lookups = Counter::CreatePtr("proxy.process.http.cache_lookups"); - http_rsb.cache_miss_changed = Counter::CreatePtr("proxy.process.http.cache_miss_changed"); - http_rsb.cache_miss_client_no_cache = Counter::CreatePtr("proxy.process.http.cache_miss_client_no_cache"); - http_rsb.cache_miss_cold = Counter::CreatePtr("proxy.process.http.cache_miss_cold"); - http_rsb.cache_miss_ims = Counter::CreatePtr("proxy.process.http.cache_miss_ims"); - http_rsb.cache_miss_uncacheable = Counter::CreatePtr("proxy.process.http.cache_miss_client_not_cacheable"); - http_rsb.cache_open_read_begin_time = Counter::CreatePtr("proxy.process.http.milestone.cache_open_read_begin"); - http_rsb.cache_open_read_end_time = Counter::CreatePtr("proxy.process.http.milestone.cache_open_read_end"); - http_rsb.cache_open_write_adjust_thread = Counter::CreatePtr("proxy.process.http.cache.open_write.adjust_thread"); - http_rsb.cache_open_write_begin_time = Counter::CreatePtr("proxy.process.http.milestone.cache_open_write_begin"); - http_rsb.cache_open_write_end_time = Counter::CreatePtr("proxy.process.http.milestone.cache_open_write_end"); - http_rsb.cache_read_error = Counter::CreatePtr("proxy.process.http.cache_read_error"); - http_rsb.cache_read_errors = Counter::CreatePtr("proxy.process.http.cache_read_errors"); - http_rsb.cache_updates = Counter::CreatePtr("proxy.process.http.cache_updates"); - http_rsb.cache_write_errors = Counter::CreatePtr("proxy.process.http.cache_write_errors"); - http_rsb.cache_writes = Counter::CreatePtr("proxy.process.http.cache_writes"); - http_rsb.completed_requests = Counter::CreatePtr("proxy.process.http.completed_requests"); - http_rsb.connect_requests = Counter::CreatePtr("proxy.process.http.connect_requests"); - http_rsb.current_active_client_connections = Counter::CreatePtr("proxy.process.http.current_active_client_connections"); - http_rsb.current_cache_connections = Counter::CreatePtr("proxy.process.http.current_cache_connections"); - http_rsb.current_client_connections = Counter::CreatePtr("proxy.process.http.current_client_connections"); - http_rsb.current_client_transactions = Counter::CreatePtr("proxy.process.http.current_client_transactions"); - http_rsb.current_parent_proxy_connections = Counter::CreatePtr("proxy.process.http.current_parent_proxy_connections"); - http_rsb.current_server_connections = Counter::CreatePtr("proxy.process.http.current_server_connections"); - http_rsb.current_server_transactions = Counter::CreatePtr("proxy.process.http.current_server_transactions"); - http_rsb.delete_requests = Counter::CreatePtr("proxy.process.http.delete_requests"); - http_rsb.disallowed_post_100_continue = Counter::CreatePtr("proxy.process.http.disallowed_post_100_continue"); - http_rsb.dns_lookup_begin_time = Counter::CreatePtr("proxy.process.http.milestone.dns_lookup_begin"); - http_rsb.dns_lookup_end_time = Counter::CreatePtr("proxy.process.http.milestone.dns_lookup_end"); - http_rsb.down_server_no_requests = Counter::CreatePtr("proxy.process.http.down_server.no_requests"); - http_rsb.err_client_abort_count = Counter::CreatePtr("proxy.process.http.err_client_abort_count"); - http_rsb.err_client_abort_origin_server_bytes = Counter::CreatePtr("proxy.process.http.err_client_abort_origin_server_bytes"); - http_rsb.err_client_abort_user_agent_bytes = Counter::CreatePtr("proxy.process.http.err_client_abort_user_agent_bytes"); - http_rsb.err_client_read_error_count = Counter::CreatePtr("proxy.process.http.err_client_read_error_count"); + http_rsb.background_fill_bytes_aborted = Metrics::Counter::createPtr("proxy.process.http.background_fill_bytes_aborted"); + http_rsb.background_fill_bytes_completed = Metrics::Counter::createPtr("proxy.process.http.background_fill_bytes_completed"); + http_rsb.background_fill_current_count = Metrics::Counter::createPtr("proxy.process.http.background_fill_current_count"); + http_rsb.background_fill_total_count = Metrics::Counter::createPtr("proxy.process.http.background_fill_total_count"); + http_rsb.broken_server_connections = Metrics::Counter::createPtr("proxy.process.http.broken_server_connections"); + http_rsb.cache_deletes = Metrics::Counter::createPtr("proxy.process.http.cache_deletes"); + http_rsb.cache_hit_fresh = Metrics::Counter::createPtr("proxy.process.http.cache_hit_fresh"); + http_rsb.cache_hit_ims = Metrics::Counter::createPtr("proxy.process.http.cache_hit_ims"); + http_rsb.cache_hit_mem_fresh = Metrics::Counter::createPtr("proxy.process.http.cache_hit_mem_fresh"); + http_rsb.cache_hit_reval = Metrics::Counter::createPtr("proxy.process.http.cache_hit_revalidated"); + http_rsb.cache_hit_rww = Metrics::Counter::createPtr("proxy.process.http.cache_hit_rww"); + http_rsb.cache_hit_stale_served = Metrics::Counter::createPtr("proxy.process.http.cache_hit_stale_served"); + http_rsb.cache_lookups = Metrics::Counter::createPtr("proxy.process.http.cache_lookups"); + http_rsb.cache_miss_changed = Metrics::Counter::createPtr("proxy.process.http.cache_miss_changed"); + http_rsb.cache_miss_client_no_cache = Metrics::Counter::createPtr("proxy.process.http.cache_miss_client_no_cache"); + http_rsb.cache_miss_cold = Metrics::Counter::createPtr("proxy.process.http.cache_miss_cold"); + http_rsb.cache_miss_ims = Metrics::Counter::createPtr("proxy.process.http.cache_miss_ims"); + http_rsb.cache_miss_uncacheable = Metrics::Counter::createPtr("proxy.process.http.cache_miss_client_not_cacheable"); + http_rsb.cache_open_read_begin_time = Metrics::Counter::createPtr("proxy.process.http.milestone.cache_open_read_begin"); + http_rsb.cache_open_read_end_time = Metrics::Counter::createPtr("proxy.process.http.milestone.cache_open_read_end"); + http_rsb.cache_open_write_adjust_thread = Metrics::Counter::createPtr("proxy.process.http.cache.open_write.adjust_thread"); + http_rsb.cache_open_write_begin_time = Metrics::Counter::createPtr("proxy.process.http.milestone.cache_open_write_begin"); + http_rsb.cache_open_write_end_time = Metrics::Counter::createPtr("proxy.process.http.milestone.cache_open_write_end"); + http_rsb.cache_read_error = Metrics::Counter::createPtr("proxy.process.http.cache_read_error"); + http_rsb.cache_read_errors = Metrics::Counter::createPtr("proxy.process.http.cache_read_errors"); + http_rsb.cache_updates = Metrics::Counter::createPtr("proxy.process.http.cache_updates"); + http_rsb.cache_write_errors = Metrics::Counter::createPtr("proxy.process.http.cache_write_errors"); + http_rsb.cache_writes = Metrics::Counter::createPtr("proxy.process.http.cache_writes"); + http_rsb.completed_requests = Metrics::Counter::createPtr("proxy.process.http.completed_requests"); + http_rsb.connect_requests = Metrics::Counter::createPtr("proxy.process.http.connect_requests"); + http_rsb.current_active_client_connections = Metrics::Counter::createPtr("proxy.process.http.current_active_client_connections"); + http_rsb.current_cache_connections = Metrics::Counter::createPtr("proxy.process.http.current_cache_connections"); + http_rsb.current_client_connections = Metrics::Counter::createPtr("proxy.process.http.current_client_connections"); + http_rsb.current_client_transactions = Metrics::Counter::createPtr("proxy.process.http.current_client_transactions"); + http_rsb.current_parent_proxy_connections = Metrics::Counter::createPtr("proxy.process.http.current_parent_proxy_connections"); + http_rsb.current_server_connections = Metrics::Counter::createPtr("proxy.process.http.current_server_connections"); + http_rsb.current_server_transactions = Metrics::Counter::createPtr("proxy.process.http.current_server_transactions"); + http_rsb.delete_requests = Metrics::Counter::createPtr("proxy.process.http.delete_requests"); + http_rsb.disallowed_post_100_continue = Metrics::Counter::createPtr("proxy.process.http.disallowed_post_100_continue"); + http_rsb.dns_lookup_begin_time = Metrics::Counter::createPtr("proxy.process.http.milestone.dns_lookup_begin"); + http_rsb.dns_lookup_end_time = Metrics::Counter::createPtr("proxy.process.http.milestone.dns_lookup_end"); + http_rsb.down_server_no_requests = Metrics::Counter::createPtr("proxy.process.http.down_server.no_requests"); + http_rsb.err_client_abort_count = Metrics::Counter::createPtr("proxy.process.http.err_client_abort_count"); + http_rsb.err_client_abort_origin_server_bytes = + Metrics::Counter::createPtr("proxy.process.http.err_client_abort_origin_server_bytes"); + http_rsb.err_client_abort_user_agent_bytes = Metrics::Counter::createPtr("proxy.process.http.err_client_abort_user_agent_bytes"); + http_rsb.err_client_read_error_count = Metrics::Counter::createPtr("proxy.process.http.err_client_read_error_count"); http_rsb.err_client_read_error_origin_server_bytes = - Counter::CreatePtr("proxy.process.http.err_client_read_error_origin_server_bytes"); - http_rsb.err_client_read_error_user_agent_bytes = Counter::CreatePtr("proxy.process.http.err_client_read_error_user_agent_bytes"); - http_rsb.err_connect_fail_count = Counter::CreatePtr("proxy.process.http.err_connect_fail_count"); - http_rsb.err_connect_fail_origin_server_bytes = Counter::CreatePtr("proxy.process.http.err_connect_fail_origin_server_bytes"); - http_rsb.err_connect_fail_user_agent_bytes = Counter::CreatePtr("proxy.process.http.err_connect_fail_user_agent_bytes"); - http_rsb.extension_method_requests = Counter::CreatePtr("proxy.process.http.extension_method_requests"); - http_rsb.get_requests = Counter::CreatePtr("proxy.process.http.get_requests"); - http_rsb.head_requests = Counter::CreatePtr("proxy.process.http.head_requests"); - http_rsb.https_incoming_requests = Counter::CreatePtr("proxy.process.https.incoming_requests"); - http_rsb.https_total_client_connections = Counter::CreatePtr("proxy.process.https.total_client_connections"); - http_rsb.incoming_requests = Counter::CreatePtr("proxy.process.http.incoming_requests"); - http_rsb.incoming_responses = Counter::CreatePtr("proxy.process.http.incoming_responses"); - http_rsb.invalid_client_requests = Counter::CreatePtr("proxy.process.http.invalid_client_requests"); - http_rsb.misc_count = Counter::CreatePtr("proxy.process.http.misc_count"); - http_rsb.misc_origin_server_bytes = Counter::CreatePtr("proxy.process.http.http_misc_origin_server_bytes"); - http_rsb.misc_user_agent_bytes = Counter::CreatePtr("proxy.process.http.misc_user_agent_bytes"); - http_rsb.missing_host_hdr = Counter::CreatePtr("proxy.process.http.missing_host_hdr"); - http_rsb.options_requests = Counter::CreatePtr("proxy.process.http.options_requests"); - http_rsb.origin_body = Counter::CreatePtr("proxy.process.http.origin.body"); - http_rsb.origin_close_private = Counter::CreatePtr("proxy.process.http.origin.close_private"); - http_rsb.origin_connect_adjust_thread = Counter::CreatePtr("proxy.process.http.origin.connect.adjust_thread"); - http_rsb.origin_connections_throttled = Counter::CreatePtr("proxy.process.http.origin_connections_throttled_out"); - http_rsb.origin_make_new = Counter::CreatePtr("proxy.process.http.origin.make_new"); - http_rsb.origin_no_sharing = Counter::CreatePtr("proxy.process.http.origin.no_sharing"); - http_rsb.origin_not_found = Counter::CreatePtr("proxy.process.http.origin.not_found"); - http_rsb.origin_private = Counter::CreatePtr("proxy.process.http.origin.private"); - http_rsb.origin_raw = Counter::CreatePtr("proxy.process.http.origin.raw"); - http_rsb.origin_reuse = Counter::CreatePtr("proxy.process.http.origin.reuse"); - http_rsb.origin_reuse_fail = Counter::CreatePtr("proxy.process.http.origin.reuse_fail"); + Metrics::Counter::createPtr("proxy.process.http.err_client_read_error_origin_server_bytes"); + http_rsb.err_client_read_error_user_agent_bytes = + Metrics::Counter::createPtr("proxy.process.http.err_client_read_error_user_agent_bytes"); + http_rsb.err_connect_fail_count = Metrics::Counter::createPtr("proxy.process.http.err_connect_fail_count"); + http_rsb.err_connect_fail_origin_server_bytes = + Metrics::Counter::createPtr("proxy.process.http.err_connect_fail_origin_server_bytes"); + http_rsb.err_connect_fail_user_agent_bytes = Metrics::Counter::createPtr("proxy.process.http.err_connect_fail_user_agent_bytes"); + http_rsb.extension_method_requests = Metrics::Counter::createPtr("proxy.process.http.extension_method_requests"); + http_rsb.get_requests = Metrics::Counter::createPtr("proxy.process.http.get_requests"); + http_rsb.head_requests = Metrics::Counter::createPtr("proxy.process.http.head_requests"); + http_rsb.https_incoming_requests = Metrics::Counter::createPtr("proxy.process.https.incoming_requests"); + http_rsb.https_total_client_connections = Metrics::Counter::createPtr("proxy.process.https.total_client_connections"); + http_rsb.incoming_requests = Metrics::Counter::createPtr("proxy.process.http.incoming_requests"); + http_rsb.incoming_responses = Metrics::Counter::createPtr("proxy.process.http.incoming_responses"); + http_rsb.invalid_client_requests = Metrics::Counter::createPtr("proxy.process.http.invalid_client_requests"); + http_rsb.misc_count = Metrics::Counter::createPtr("proxy.process.http.misc_count"); + http_rsb.misc_origin_server_bytes = Metrics::Counter::createPtr("proxy.process.http.http_misc_origin_server_bytes"); + http_rsb.misc_user_agent_bytes = Metrics::Counter::createPtr("proxy.process.http.misc_user_agent_bytes"); + http_rsb.missing_host_hdr = Metrics::Counter::createPtr("proxy.process.http.missing_host_hdr"); + http_rsb.options_requests = Metrics::Counter::createPtr("proxy.process.http.options_requests"); + http_rsb.origin_body = Metrics::Counter::createPtr("proxy.process.http.origin.body"); + http_rsb.origin_close_private = Metrics::Counter::createPtr("proxy.process.http.origin.close_private"); + http_rsb.origin_connect_adjust_thread = Metrics::Counter::createPtr("proxy.process.http.origin.connect.adjust_thread"); + http_rsb.origin_connections_throttled = Metrics::Counter::createPtr("proxy.process.http.origin_connections_throttled_out"); + http_rsb.origin_make_new = Metrics::Counter::createPtr("proxy.process.http.origin.make_new"); + http_rsb.origin_no_sharing = Metrics::Counter::createPtr("proxy.process.http.origin.no_sharing"); + http_rsb.origin_not_found = Metrics::Counter::createPtr("proxy.process.http.origin.not_found"); + http_rsb.origin_private = Metrics::Counter::createPtr("proxy.process.http.origin.private"); + http_rsb.origin_raw = Metrics::Counter::createPtr("proxy.process.http.origin.raw"); + http_rsb.origin_reuse = Metrics::Counter::createPtr("proxy.process.http.origin.reuse"); + http_rsb.origin_reuse_fail = Metrics::Counter::createPtr("proxy.process.http.origin.reuse_fail"); http_rsb.origin_server_request_document_total_size = - Counter::CreatePtr("proxy.process.http.origin_server_request_document_total_size"); + Metrics::Counter::createPtr("proxy.process.http.origin_server_request_document_total_size"); http_rsb.origin_server_request_header_total_size = - Counter::CreatePtr("proxy.process.http.origin_server_request_header_total_size"); + Metrics::Counter::createPtr("proxy.process.http.origin_server_request_header_total_size"); http_rsb.origin_server_response_document_total_size = - Counter::CreatePtr("proxy.process.http.origin_server_response_document_total_size"); + Metrics::Counter::createPtr("proxy.process.http.origin_server_response_document_total_size"); http_rsb.origin_server_response_header_total_size = - Counter::CreatePtr("proxy.process.http.origin_server_response_header_total_size"); - http_rsb.origin_shutdown_cleanup_entry = Counter::CreatePtr("proxy.process.http.origin_shutdown.cleanup_entry"); - http_rsb.origin_shutdown_migration_failure = Counter::CreatePtr("proxy.process.http.origin_shutdown.migration_failure"); - http_rsb.origin_shutdown_pool_lock_contention = Counter::CreatePtr("proxy.process.http.origin_shutdown.pool_lock_contention"); + Metrics::Counter::createPtr("proxy.process.http.origin_server_response_header_total_size"); + http_rsb.origin_shutdown_cleanup_entry = Metrics::Counter::createPtr("proxy.process.http.origin_shutdown.cleanup_entry"); + http_rsb.origin_shutdown_migration_failure = Metrics::Counter::createPtr("proxy.process.http.origin_shutdown.migration_failure"); + http_rsb.origin_shutdown_pool_lock_contention = + Metrics::Counter::createPtr("proxy.process.http.origin_shutdown.pool_lock_contention"); http_rsb.origin_shutdown_release_invalid_request = - Counter::CreatePtr("proxy.process.http.origin_shutdown.release_invalid_request"); + Metrics::Counter::createPtr("proxy.process.http.origin_shutdown.release_invalid_request"); http_rsb.origin_shutdown_release_invalid_response = - Counter::CreatePtr("proxy.process.http.origin_shutdown.release_invalid_response"); - http_rsb.origin_shutdown_release_misc = Counter::CreatePtr("proxy.process.http.origin_shutdown.release_misc"); - http_rsb.origin_shutdown_release_modified = Counter::CreatePtr("proxy.process.http.origin_shutdown.release_modified"); - http_rsb.origin_shutdown_release_no_keep_alive = Counter::CreatePtr("proxy.process.http.origin_shutdown.release_no_keep_alive"); - http_rsb.origin_shutdown_release_no_server = Counter::CreatePtr("proxy.process.http.origin_shutdown.release_no_server"); - http_rsb.origin_shutdown_release_no_sharing = Counter::CreatePtr("proxy.process.http.origin_shutdown.release_no_sharing"); - http_rsb.origin_shutdown_tunnel_abort = Counter::CreatePtr("proxy.process.http.origin_shutdown.tunnel_abort"); - http_rsb.origin_shutdown_tunnel_client = Counter::CreatePtr("proxy.process.http.origin_shutdown.tunnel_client"); - http_rsb.origin_shutdown_tunnel_server = Counter::CreatePtr("proxy.process.http.origin_shutdown.tunnel_server"); - http_rsb.origin_shutdown_tunnel_server_detach = Counter::CreatePtr("proxy.process.http.origin_shutdown.tunnel_server_detach"); - http_rsb.origin_shutdown_tunnel_server_eos = Counter::CreatePtr("proxy.process.http.origin_shutdown.tunnel_server_eos"); + Metrics::Counter::createPtr("proxy.process.http.origin_shutdown.release_invalid_response"); + http_rsb.origin_shutdown_release_misc = Metrics::Counter::createPtr("proxy.process.http.origin_shutdown.release_misc"); + http_rsb.origin_shutdown_release_modified = Metrics::Counter::createPtr("proxy.process.http.origin_shutdown.release_modified"); + http_rsb.origin_shutdown_release_no_keep_alive = + Metrics::Counter::createPtr("proxy.process.http.origin_shutdown.release_no_keep_alive"); + http_rsb.origin_shutdown_release_no_server = Metrics::Counter::createPtr("proxy.process.http.origin_shutdown.release_no_server"); + http_rsb.origin_shutdown_release_no_sharing = + Metrics::Counter::createPtr("proxy.process.http.origin_shutdown.release_no_sharing"); + http_rsb.origin_shutdown_tunnel_abort = Metrics::Counter::createPtr("proxy.process.http.origin_shutdown.tunnel_abort"); + http_rsb.origin_shutdown_tunnel_client = Metrics::Counter::createPtr("proxy.process.http.origin_shutdown.tunnel_client"); + http_rsb.origin_shutdown_tunnel_server = Metrics::Counter::createPtr("proxy.process.http.origin_shutdown.tunnel_server"); + http_rsb.origin_shutdown_tunnel_server_detach = + Metrics::Counter::createPtr("proxy.process.http.origin_shutdown.tunnel_server_detach"); + http_rsb.origin_shutdown_tunnel_server_eos = Metrics::Counter::createPtr("proxy.process.http.origin_shutdown.tunnel_server_eos"); http_rsb.origin_shutdown_tunnel_server_no_keep_alive = - Counter::CreatePtr("proxy.process.http.origin_shutdown.tunnel_server_no_keep_alive"); + Metrics::Counter::createPtr("proxy.process.http.origin_shutdown.tunnel_server_no_keep_alive"); http_rsb.origin_shutdown_tunnel_server_plugin_tunnel = - Counter::CreatePtr("proxy.process.http.origin_shutdown.tunnel_server_plugin_tunnel"); - http_rsb.origin_shutdown_tunnel_transform_read = Counter::CreatePtr("proxy.process.http.origin_shutdown.tunnel_transform_read"); - http_rsb.outgoing_requests = Counter::CreatePtr("proxy.process.http.outgoing_requests"); - http_rsb.parent_count = Counter::CreatePtr("proxy.process.http_parent_count"); - http_rsb.parent_proxy_request_total_bytes = Counter::CreatePtr("proxy.process.http.parent_proxy_request_total_bytes"); - http_rsb.parent_proxy_response_total_bytes = Counter::CreatePtr("proxy.process.http.parent_proxy_response_total_bytes"); - http_rsb.parent_proxy_transaction_time = Counter::CreatePtr("proxy.process.http.parent_proxy_transaction_time"); - http_rsb.pooled_server_connections = Counter::CreatePtr("proxy.process.http.pooled_server_connections"); - http_rsb.post_body_too_large = Counter::CreatePtr("proxy.process.http.post_body_too_large"); - http_rsb.post_requests = Counter::CreatePtr("proxy.process.http.post_requests"); - http_rsb.proxy_loop_detected = Counter::CreatePtr("proxy.process.http.http_proxy_loop_detected"); - http_rsb.proxy_mh_loop_detected = Counter::CreatePtr("proxy.process.http.http_proxy_mh_loop_detected"); - http_rsb.purge_requests = Counter::CreatePtr("proxy.process.http.purge_requests"); - http_rsb.push_requests = Counter::CreatePtr("proxy.process.http.push_requests"); - http_rsb.pushed_document_total_size = Counter::CreatePtr("proxy.process.http.pushed_document_total_size"); - http_rsb.pushed_response_header_total_size = Counter::CreatePtr("proxy.process.http.pushed_response_header_total_size"); - http_rsb.put_requests = Counter::CreatePtr("proxy.process.http.put_requests"); - http_rsb.response_status_100_count = Counter::CreatePtr("proxy.process.http.100_responses"); - http_rsb.response_status_101_count = Counter::CreatePtr("proxy.process.http.101_responses"); - http_rsb.response_status_1xx_count = Counter::CreatePtr("proxy.process.http.1xx_responses"); - http_rsb.response_status_200_count = Counter::CreatePtr("proxy.process.http.200_responses"); - http_rsb.response_status_201_count = Counter::CreatePtr("proxy.process.http.201_responses"); - http_rsb.response_status_202_count = Counter::CreatePtr("proxy.process.http.202_responses"); - http_rsb.response_status_203_count = Counter::CreatePtr("proxy.process.http.203_responses"); - http_rsb.response_status_204_count = Counter::CreatePtr("proxy.process.http.204_responses"); - http_rsb.response_status_205_count = Counter::CreatePtr("proxy.process.http.205_responses"); - http_rsb.response_status_206_count = Counter::CreatePtr("proxy.process.http.206_responses"); - http_rsb.response_status_2xx_count = Counter::CreatePtr("proxy.process.http.2xx_responses"); - http_rsb.response_status_300_count = Counter::CreatePtr("proxy.process.http.300_responses"); - http_rsb.response_status_301_count = Counter::CreatePtr("proxy.process.http.301_responses"); - http_rsb.response_status_302_count = Counter::CreatePtr("proxy.process.http.302_responses"); - http_rsb.response_status_303_count = Counter::CreatePtr("proxy.process.http.303_responses"); - http_rsb.response_status_304_count = Counter::CreatePtr("proxy.process.http.304_responses"); - http_rsb.response_status_305_count = Counter::CreatePtr("proxy.process.http.305_responses"); - http_rsb.response_status_307_count = Counter::CreatePtr("proxy.process.http.307_responses"); - http_rsb.response_status_308_count = Counter::CreatePtr("proxy.process.http.308_responses"); - http_rsb.response_status_3xx_count = Counter::CreatePtr("proxy.process.http.3xx_responses"); - http_rsb.response_status_400_count = Counter::CreatePtr("proxy.process.http.400_responses"); - http_rsb.response_status_401_count = Counter::CreatePtr("proxy.process.http.401_responses"); - http_rsb.response_status_402_count = Counter::CreatePtr("proxy.process.http.402_responses"); - http_rsb.response_status_403_count = Counter::CreatePtr("proxy.process.http.403_responses"); - http_rsb.response_status_404_count = Counter::CreatePtr("proxy.process.http.404_responses"); - http_rsb.response_status_405_count = Counter::CreatePtr("proxy.process.http.405_responses"); - http_rsb.response_status_406_count = Counter::CreatePtr("proxy.process.http.406_responses"); - http_rsb.response_status_407_count = Counter::CreatePtr("proxy.process.http.407_responses"); - http_rsb.response_status_408_count = Counter::CreatePtr("proxy.process.http.408_responses"); - http_rsb.response_status_409_count = Counter::CreatePtr("proxy.process.http.409_responses"); - http_rsb.response_status_410_count = Counter::CreatePtr("proxy.process.http.410_responses"); - http_rsb.response_status_411_count = Counter::CreatePtr("proxy.process.http.411_responses"); - http_rsb.response_status_412_count = Counter::CreatePtr("proxy.process.http.412_responses"); - http_rsb.response_status_413_count = Counter::CreatePtr("proxy.process.http.413_responses"); - http_rsb.response_status_414_count = Counter::CreatePtr("proxy.process.http.414_responses"); - http_rsb.response_status_415_count = Counter::CreatePtr("proxy.process.http.415_responses"); - http_rsb.response_status_416_count = Counter::CreatePtr("proxy.process.http.416_responses"); - http_rsb.response_status_4xx_count = Counter::CreatePtr("proxy.process.http.4xx_responses"); - http_rsb.response_status_500_count = Counter::CreatePtr("proxy.process.http.500_responses"); - http_rsb.response_status_501_count = Counter::CreatePtr("proxy.process.http.501_responses"); - http_rsb.response_status_502_count = Counter::CreatePtr("proxy.process.http.502_responses"); - http_rsb.response_status_503_count = Counter::CreatePtr("proxy.process.http.503_responses"); - http_rsb.response_status_504_count = Counter::CreatePtr("proxy.process.http.504_responses"); - http_rsb.response_status_505_count = Counter::CreatePtr("proxy.process.http.505_responses"); - http_rsb.response_status_5xx_count = Counter::CreatePtr("proxy.process.http.5xx_responses"); - http_rsb.server_begin_write_time = Counter::CreatePtr("proxy.process.http.milestone.server_begin_write"); - http_rsb.server_close_time = Counter::CreatePtr("proxy.process.http.milestone.server_close"); - http_rsb.server_connect_end_time = Counter::CreatePtr("proxy.process.http.milestone.server_connect_end"); - http_rsb.server_connect_time = Counter::CreatePtr("proxy.process.http.milestone.server_connect"); - http_rsb.server_first_connect_time = Counter::CreatePtr("proxy.process.http.milestone.server_first_connect"); - http_rsb.server_first_read_time = Counter::CreatePtr("proxy.process.http.milestone.server_first_read"); - http_rsb.server_read_header_done_time = Counter::CreatePtr("proxy.process.http.milestone.server_read_header_done"); - http_rsb.sm_finish_time = Counter::CreatePtr("proxy.process.http.milestone.sm_finish"); - http_rsb.sm_start_time = Counter::CreatePtr("proxy.process.http.milestone.sm_start"); - http_rsb.tcp_client_refresh_count = Counter::CreatePtr("proxy.process.http.tcp_client_refresh_count"); - http_rsb.tcp_client_refresh_origin_server_bytes = Counter::CreatePtr("proxy.process.http.tcp_client_refresh_origin_server_bytes"); - http_rsb.tcp_client_refresh_user_agent_bytes = Counter::CreatePtr("proxy.process.http.tcp_client_refresh_user_agent_bytes"); - http_rsb.tcp_expired_miss_count = Counter::CreatePtr("proxy.process.http.tcp_expired_miss_count"); - http_rsb.tcp_expired_miss_origin_server_bytes = Counter::CreatePtr("proxy.process.http.tcp_expired_miss_origin_server_bytes"); - http_rsb.tcp_expired_miss_user_agent_bytes = Counter::CreatePtr("proxy.process.http.tcp_expired_miss_user_agent_bytes"); - http_rsb.tcp_hit_count = Counter::CreatePtr("proxy.process.http.tcp_hit_count"); - http_rsb.tcp_hit_origin_server_bytes = Counter::CreatePtr("proxy.process.http.tcp_hit_origin_server_bytes"); - http_rsb.tcp_hit_user_agent_bytes = Counter::CreatePtr("proxy.process.http.tcp_hit_user_agent_bytes"); - http_rsb.tcp_ims_hit_count = Counter::CreatePtr("proxy.process.http.tcp_ims_hit_count"); - http_rsb.tcp_ims_hit_origin_server_bytes = Counter::CreatePtr("proxy.process.http.tcp_ims_hit_origin_server_bytes"); - http_rsb.tcp_ims_hit_user_agent_bytes = Counter::CreatePtr("proxy.process.http.tcp_ims_hit_user_agent_bytes"); - http_rsb.tcp_ims_miss_count = Counter::CreatePtr("proxy.process.http.tcp_ims_miss_count"); - http_rsb.tcp_ims_miss_origin_server_bytes = Counter::CreatePtr("proxy.process.http.tcp_ims_miss_origin_server_bytes"); - http_rsb.tcp_ims_miss_user_agent_bytes = Counter::CreatePtr("proxy.process.http.tcp_ims_miss_user_agent_bytes"); - http_rsb.tcp_miss_count = Counter::CreatePtr("proxy.process.http.tcp_miss_count"); - http_rsb.tcp_miss_origin_server_bytes = Counter::CreatePtr("proxy.process.http.tcp_miss_origin_server_bytes"); - http_rsb.tcp_miss_user_agent_bytes = Counter::CreatePtr("proxy.process.http.tcp_miss_user_agent_bytes"); - http_rsb.tcp_refresh_hit_count = Counter::CreatePtr("proxy.process.http.tcp_refresh_hit_count"); - http_rsb.tcp_refresh_hit_origin_server_bytes = Counter::CreatePtr("proxy.process.http.tcp_refresh_hit_origin_server_bytes"); - http_rsb.tcp_refresh_hit_user_agent_bytes = Counter::CreatePtr("proxy.process.http.tcp_refresh_hit_user_agent_bytes"); - http_rsb.tcp_refresh_miss_count = Counter::CreatePtr("proxy.process.http.tcp_refresh_miss_count"); - http_rsb.tcp_refresh_miss_origin_server_bytes = Counter::CreatePtr("proxy.process.http.tcp_refresh_miss_origin_server_bytes"); - http_rsb.tcp_refresh_miss_user_agent_bytes = Counter::CreatePtr("proxy.process.http.tcp_refresh_miss_user_agent_bytes"); - http_rsb.total_client_connections = Counter::CreatePtr("proxy.process.http.total_client_connections"); - http_rsb.total_client_connections_ipv4 = Counter::CreatePtr("proxy.process.http.total_client_connections_ipv4"); - http_rsb.total_client_connections_ipv6 = Counter::CreatePtr("proxy.process.http.total_client_connections_ipv6"); - http_rsb.total_incoming_connections = Counter::CreatePtr("proxy.process.http.total_incoming_connections"); - http_rsb.total_parent_marked_down_count = Counter::CreatePtr("proxy.process.http.total_parent_marked_down_count"); - http_rsb.total_parent_proxy_connections = Counter::CreatePtr("proxy.process.http.total_parent_proxy_connections"); - http_rsb.total_parent_retries = Counter::CreatePtr("proxy.process.http.total_parent_retries"); - http_rsb.total_parent_retries_exhausted = Counter::CreatePtr("proxy.process.http.total_parent_retries_exhausted"); - http_rsb.total_parent_switches = Counter::CreatePtr("proxy.process.http.total_parent_switches"); - http_rsb.total_server_connections = Counter::CreatePtr("proxy.process.http.total_server_connections"); - http_rsb.total_transactions_time = Counter::CreatePtr("proxy.process.http.total_transactions_time"); - http_rsb.total_x_redirect = Counter::CreatePtr("proxy.process.http.total_x_redirect_count"); - http_rsb.trace_requests = Counter::CreatePtr("proxy.process.http.trace_requests"); - http_rsb.tunnel_current_active_connections = Counter::CreatePtr("proxy.process.tunnel.current_active_connections"); - http_rsb.tunnels = Counter::CreatePtr("proxy.process.http.tunnels"); - http_rsb.ua_begin_time = Counter::CreatePtr("proxy.process.http.milestone.ua_begin"); - http_rsb.ua_begin_write_time = Counter::CreatePtr("proxy.process.http.milestone.ua_begin_write"); - http_rsb.ua_close_time = Counter::CreatePtr("proxy.process.http.milestone.ua_close"); - http_rsb.ua_counts_errors_aborts = Counter::CreatePtr("proxy.process.http.transaction_counts.errors.aborts"); - http_rsb.ua_counts_errors_connect_failed = Counter::CreatePtr("proxy.process.http.transaction_counts.errors.connect_failed"); - http_rsb.ua_counts_errors_other = Counter::CreatePtr("proxy.process.http.transaction_counts.errors.other"); - http_rsb.ua_counts_errors_possible_aborts = Counter::CreatePtr("proxy.process.http.transaction_counts.errors.possible_aborts"); + Metrics::Counter::createPtr("proxy.process.http.origin_shutdown.tunnel_server_plugin_tunnel"); + http_rsb.origin_shutdown_tunnel_transform_read = + Metrics::Counter::createPtr("proxy.process.http.origin_shutdown.tunnel_transform_read"); + http_rsb.outgoing_requests = Metrics::Counter::createPtr("proxy.process.http.outgoing_requests"); + http_rsb.parent_count = Metrics::Counter::createPtr("proxy.process.http_parent_count"); + http_rsb.parent_proxy_request_total_bytes = Metrics::Counter::createPtr("proxy.process.http.parent_proxy_request_total_bytes"); + http_rsb.parent_proxy_response_total_bytes = Metrics::Counter::createPtr("proxy.process.http.parent_proxy_response_total_bytes"); + http_rsb.parent_proxy_transaction_time = Metrics::Counter::createPtr("proxy.process.http.parent_proxy_transaction_time"); + http_rsb.pooled_server_connections = Metrics::Counter::createPtr("proxy.process.http.pooled_server_connections"); + http_rsb.post_body_too_large = Metrics::Counter::createPtr("proxy.process.http.post_body_too_large"); + http_rsb.post_requests = Metrics::Counter::createPtr("proxy.process.http.post_requests"); + http_rsb.proxy_loop_detected = Metrics::Counter::createPtr("proxy.process.http.http_proxy_loop_detected"); + http_rsb.proxy_mh_loop_detected = Metrics::Counter::createPtr("proxy.process.http.http_proxy_mh_loop_detected"); + http_rsb.purge_requests = Metrics::Counter::createPtr("proxy.process.http.purge_requests"); + http_rsb.push_requests = Metrics::Counter::createPtr("proxy.process.http.push_requests"); + http_rsb.pushed_document_total_size = Metrics::Counter::createPtr("proxy.process.http.pushed_document_total_size"); + http_rsb.pushed_response_header_total_size = Metrics::Counter::createPtr("proxy.process.http.pushed_response_header_total_size"); + http_rsb.put_requests = Metrics::Counter::createPtr("proxy.process.http.put_requests"); + http_rsb.response_status_100_count = Metrics::Counter::createPtr("proxy.process.http.100_responses"); + http_rsb.response_status_101_count = Metrics::Counter::createPtr("proxy.process.http.101_responses"); + http_rsb.response_status_1xx_count = Metrics::Counter::createPtr("proxy.process.http.1xx_responses"); + http_rsb.response_status_200_count = Metrics::Counter::createPtr("proxy.process.http.200_responses"); + http_rsb.response_status_201_count = Metrics::Counter::createPtr("proxy.process.http.201_responses"); + http_rsb.response_status_202_count = Metrics::Counter::createPtr("proxy.process.http.202_responses"); + http_rsb.response_status_203_count = Metrics::Counter::createPtr("proxy.process.http.203_responses"); + http_rsb.response_status_204_count = Metrics::Counter::createPtr("proxy.process.http.204_responses"); + http_rsb.response_status_205_count = Metrics::Counter::createPtr("proxy.process.http.205_responses"); + http_rsb.response_status_206_count = Metrics::Counter::createPtr("proxy.process.http.206_responses"); + http_rsb.response_status_2xx_count = Metrics::Counter::createPtr("proxy.process.http.2xx_responses"); + http_rsb.response_status_300_count = Metrics::Counter::createPtr("proxy.process.http.300_responses"); + http_rsb.response_status_301_count = Metrics::Counter::createPtr("proxy.process.http.301_responses"); + http_rsb.response_status_302_count = Metrics::Counter::createPtr("proxy.process.http.302_responses"); + http_rsb.response_status_303_count = Metrics::Counter::createPtr("proxy.process.http.303_responses"); + http_rsb.response_status_304_count = Metrics::Counter::createPtr("proxy.process.http.304_responses"); + http_rsb.response_status_305_count = Metrics::Counter::createPtr("proxy.process.http.305_responses"); + http_rsb.response_status_307_count = Metrics::Counter::createPtr("proxy.process.http.307_responses"); + http_rsb.response_status_308_count = Metrics::Counter::createPtr("proxy.process.http.308_responses"); + http_rsb.response_status_3xx_count = Metrics::Counter::createPtr("proxy.process.http.3xx_responses"); + http_rsb.response_status_400_count = Metrics::Counter::createPtr("proxy.process.http.400_responses"); + http_rsb.response_status_401_count = Metrics::Counter::createPtr("proxy.process.http.401_responses"); + http_rsb.response_status_402_count = Metrics::Counter::createPtr("proxy.process.http.402_responses"); + http_rsb.response_status_403_count = Metrics::Counter::createPtr("proxy.process.http.403_responses"); + http_rsb.response_status_404_count = Metrics::Counter::createPtr("proxy.process.http.404_responses"); + http_rsb.response_status_405_count = Metrics::Counter::createPtr("proxy.process.http.405_responses"); + http_rsb.response_status_406_count = Metrics::Counter::createPtr("proxy.process.http.406_responses"); + http_rsb.response_status_407_count = Metrics::Counter::createPtr("proxy.process.http.407_responses"); + http_rsb.response_status_408_count = Metrics::Counter::createPtr("proxy.process.http.408_responses"); + http_rsb.response_status_409_count = Metrics::Counter::createPtr("proxy.process.http.409_responses"); + http_rsb.response_status_410_count = Metrics::Counter::createPtr("proxy.process.http.410_responses"); + http_rsb.response_status_411_count = Metrics::Counter::createPtr("proxy.process.http.411_responses"); + http_rsb.response_status_412_count = Metrics::Counter::createPtr("proxy.process.http.412_responses"); + http_rsb.response_status_413_count = Metrics::Counter::createPtr("proxy.process.http.413_responses"); + http_rsb.response_status_414_count = Metrics::Counter::createPtr("proxy.process.http.414_responses"); + http_rsb.response_status_415_count = Metrics::Counter::createPtr("proxy.process.http.415_responses"); + http_rsb.response_status_416_count = Metrics::Counter::createPtr("proxy.process.http.416_responses"); + http_rsb.response_status_4xx_count = Metrics::Counter::createPtr("proxy.process.http.4xx_responses"); + http_rsb.response_status_500_count = Metrics::Counter::createPtr("proxy.process.http.500_responses"); + http_rsb.response_status_501_count = Metrics::Counter::createPtr("proxy.process.http.501_responses"); + http_rsb.response_status_502_count = Metrics::Counter::createPtr("proxy.process.http.502_responses"); + http_rsb.response_status_503_count = Metrics::Counter::createPtr("proxy.process.http.503_responses"); + http_rsb.response_status_504_count = Metrics::Counter::createPtr("proxy.process.http.504_responses"); + http_rsb.response_status_505_count = Metrics::Counter::createPtr("proxy.process.http.505_responses"); + http_rsb.response_status_5xx_count = Metrics::Counter::createPtr("proxy.process.http.5xx_responses"); + http_rsb.server_begin_write_time = Metrics::Counter::createPtr("proxy.process.http.milestone.server_begin_write"); + http_rsb.server_close_time = Metrics::Counter::createPtr("proxy.process.http.milestone.server_close"); + http_rsb.server_connect_end_time = Metrics::Counter::createPtr("proxy.process.http.milestone.server_connect_end"); + http_rsb.server_connect_time = Metrics::Counter::createPtr("proxy.process.http.milestone.server_connect"); + http_rsb.server_first_connect_time = Metrics::Counter::createPtr("proxy.process.http.milestone.server_first_connect"); + http_rsb.server_first_read_time = Metrics::Counter::createPtr("proxy.process.http.milestone.server_first_read"); + http_rsb.server_read_header_done_time = Metrics::Counter::createPtr("proxy.process.http.milestone.server_read_header_done"); + http_rsb.sm_finish_time = Metrics::Counter::createPtr("proxy.process.http.milestone.sm_finish"); + http_rsb.sm_start_time = Metrics::Counter::createPtr("proxy.process.http.milestone.sm_start"); + http_rsb.tcp_client_refresh_count = Metrics::Counter::createPtr("proxy.process.http.tcp_client_refresh_count"); + http_rsb.tcp_client_refresh_origin_server_bytes = + Metrics::Counter::createPtr("proxy.process.http.tcp_client_refresh_origin_server_bytes"); + http_rsb.tcp_client_refresh_user_agent_bytes = + Metrics::Counter::createPtr("proxy.process.http.tcp_client_refresh_user_agent_bytes"); + http_rsb.tcp_expired_miss_count = Metrics::Counter::createPtr("proxy.process.http.tcp_expired_miss_count"); + http_rsb.tcp_expired_miss_origin_server_bytes = + Metrics::Counter::createPtr("proxy.process.http.tcp_expired_miss_origin_server_bytes"); + http_rsb.tcp_expired_miss_user_agent_bytes = Metrics::Counter::createPtr("proxy.process.http.tcp_expired_miss_user_agent_bytes"); + http_rsb.tcp_hit_count = Metrics::Counter::createPtr("proxy.process.http.tcp_hit_count"); + http_rsb.tcp_hit_origin_server_bytes = Metrics::Counter::createPtr("proxy.process.http.tcp_hit_origin_server_bytes"); + http_rsb.tcp_hit_user_agent_bytes = Metrics::Counter::createPtr("proxy.process.http.tcp_hit_user_agent_bytes"); + http_rsb.tcp_ims_hit_count = Metrics::Counter::createPtr("proxy.process.http.tcp_ims_hit_count"); + http_rsb.tcp_ims_hit_origin_server_bytes = Metrics::Counter::createPtr("proxy.process.http.tcp_ims_hit_origin_server_bytes"); + http_rsb.tcp_ims_hit_user_agent_bytes = Metrics::Counter::createPtr("proxy.process.http.tcp_ims_hit_user_agent_bytes"); + http_rsb.tcp_ims_miss_count = Metrics::Counter::createPtr("proxy.process.http.tcp_ims_miss_count"); + http_rsb.tcp_ims_miss_origin_server_bytes = Metrics::Counter::createPtr("proxy.process.http.tcp_ims_miss_origin_server_bytes"); + http_rsb.tcp_ims_miss_user_agent_bytes = Metrics::Counter::createPtr("proxy.process.http.tcp_ims_miss_user_agent_bytes"); + http_rsb.tcp_miss_count = Metrics::Counter::createPtr("proxy.process.http.tcp_miss_count"); + http_rsb.tcp_miss_origin_server_bytes = Metrics::Counter::createPtr("proxy.process.http.tcp_miss_origin_server_bytes"); + http_rsb.tcp_miss_user_agent_bytes = Metrics::Counter::createPtr("proxy.process.http.tcp_miss_user_agent_bytes"); + http_rsb.tcp_refresh_hit_count = Metrics::Counter::createPtr("proxy.process.http.tcp_refresh_hit_count"); + http_rsb.tcp_refresh_hit_origin_server_bytes = + Metrics::Counter::createPtr("proxy.process.http.tcp_refresh_hit_origin_server_bytes"); + http_rsb.tcp_refresh_hit_user_agent_bytes = Metrics::Counter::createPtr("proxy.process.http.tcp_refresh_hit_user_agent_bytes"); + http_rsb.tcp_refresh_miss_count = Metrics::Counter::createPtr("proxy.process.http.tcp_refresh_miss_count"); + http_rsb.tcp_refresh_miss_origin_server_bytes = + Metrics::Counter::createPtr("proxy.process.http.tcp_refresh_miss_origin_server_bytes"); + http_rsb.tcp_refresh_miss_user_agent_bytes = Metrics::Counter::createPtr("proxy.process.http.tcp_refresh_miss_user_agent_bytes"); + http_rsb.total_client_connections = Metrics::Counter::createPtr("proxy.process.http.total_client_connections"); + http_rsb.total_client_connections_ipv4 = Metrics::Counter::createPtr("proxy.process.http.total_client_connections_ipv4"); + http_rsb.total_client_connections_ipv6 = Metrics::Counter::createPtr("proxy.process.http.total_client_connections_ipv6"); + http_rsb.total_incoming_connections = Metrics::Counter::createPtr("proxy.process.http.total_incoming_connections"); + http_rsb.total_parent_marked_down_count = Metrics::Counter::createPtr("proxy.process.http.total_parent_marked_down_count"); + http_rsb.total_parent_proxy_connections = Metrics::Counter::createPtr("proxy.process.http.total_parent_proxy_connections"); + http_rsb.total_parent_retries = Metrics::Counter::createPtr("proxy.process.http.total_parent_retries"); + http_rsb.total_parent_retries_exhausted = Metrics::Counter::createPtr("proxy.process.http.total_parent_retries_exhausted"); + http_rsb.total_parent_switches = Metrics::Counter::createPtr("proxy.process.http.total_parent_switches"); + http_rsb.total_server_connections = Metrics::Counter::createPtr("proxy.process.http.total_server_connections"); + http_rsb.total_transactions_time = Metrics::Counter::createPtr("proxy.process.http.total_transactions_time"); + http_rsb.total_x_redirect = Metrics::Counter::createPtr("proxy.process.http.total_x_redirect_count"); + http_rsb.trace_requests = Metrics::Counter::createPtr("proxy.process.http.trace_requests"); + http_rsb.tunnel_current_active_connections = Metrics::Counter::createPtr("proxy.process.tunnel.current_active_connections"); + http_rsb.tunnels = Metrics::Counter::createPtr("proxy.process.http.tunnels"); + http_rsb.ua_begin_time = Metrics::Counter::createPtr("proxy.process.http.milestone.ua_begin"); + http_rsb.ua_begin_write_time = Metrics::Counter::createPtr("proxy.process.http.milestone.ua_begin_write"); + http_rsb.ua_close_time = Metrics::Counter::createPtr("proxy.process.http.milestone.ua_close"); + http_rsb.ua_counts_errors_aborts = Metrics::Counter::createPtr("proxy.process.http.transaction_counts.errors.aborts"); + http_rsb.ua_counts_errors_connect_failed = + Metrics::Counter::createPtr("proxy.process.http.transaction_counts.errors.connect_failed"); + http_rsb.ua_counts_errors_other = Metrics::Counter::createPtr("proxy.process.http.transaction_counts.errors.other"); + http_rsb.ua_counts_errors_possible_aborts = + Metrics::Counter::createPtr("proxy.process.http.transaction_counts.errors.possible_aborts"); http_rsb.ua_counts_errors_pre_accept_hangups = - Counter::CreatePtr("proxy.process.http.transaction_counts.errors.pre_accept_hangups"); - http_rsb.ua_counts_hit_fresh = Counter::CreatePtr("proxy.process.http.transaction_counts.hit_fresh"); - http_rsb.ua_counts_hit_fresh_process = Counter::CreatePtr("proxy.process.http.transaction_counts.hit_fresh.process"); - http_rsb.ua_counts_hit_reval = Counter::CreatePtr("proxy.process.http.transaction_counts.hit_revalidated"); - http_rsb.ua_counts_miss_changed = Counter::CreatePtr("proxy.process.http.transaction_counts.miss_changed"); - http_rsb.ua_counts_miss_client_no_cache = Counter::CreatePtr("proxy.process.http.transaction_counts.miss_client_no_cache"); - http_rsb.ua_counts_miss_cold = Counter::CreatePtr("proxy.process.http.transaction_counts.miss_cold"); - http_rsb.ua_counts_miss_uncacheable = Counter::CreatePtr("proxy.process.http.transaction_counts.miss_not_cacheable"); - http_rsb.ua_counts_other_unclassified = Counter::CreatePtr("proxy.process.http.transaction_counts.other.unclassified"); - http_rsb.ua_first_read_time = Counter::CreatePtr("proxy.process.http.milestone.ua_first_read"); - http_rsb.ua_msecs_errors_aborts = Counter::CreatePtr("proxy.process.http.transaction_totaltime.errors.aborts"); - http_rsb.ua_msecs_errors_connect_failed = Counter::CreatePtr("proxy.process.http.transaction_totaltime.errors.connect_failed"); - http_rsb.ua_msecs_errors_other = Counter::CreatePtr("proxy.process.http.transaction_totaltime.errors.other"); - http_rsb.ua_msecs_errors_possible_aborts = Counter::CreatePtr("proxy.process.http.transaction_totaltime.errors.possible_aborts"); + Metrics::Counter::createPtr("proxy.process.http.transaction_counts.errors.pre_accept_hangups"); + http_rsb.ua_counts_hit_fresh = Metrics::Counter::createPtr("proxy.process.http.transaction_counts.hit_fresh"); + http_rsb.ua_counts_hit_fresh_process = Metrics::Counter::createPtr("proxy.process.http.transaction_counts.hit_fresh.process"); + http_rsb.ua_counts_hit_reval = Metrics::Counter::createPtr("proxy.process.http.transaction_counts.hit_revalidated"); + http_rsb.ua_counts_miss_changed = Metrics::Counter::createPtr("proxy.process.http.transaction_counts.miss_changed"); + http_rsb.ua_counts_miss_client_no_cache = + Metrics::Counter::createPtr("proxy.process.http.transaction_counts.miss_client_no_cache"); + http_rsb.ua_counts_miss_cold = Metrics::Counter::createPtr("proxy.process.http.transaction_counts.miss_cold"); + http_rsb.ua_counts_miss_uncacheable = Metrics::Counter::createPtr("proxy.process.http.transaction_counts.miss_not_cacheable"); + http_rsb.ua_counts_other_unclassified = Metrics::Counter::createPtr("proxy.process.http.transaction_counts.other.unclassified"); + http_rsb.ua_first_read_time = Metrics::Counter::createPtr("proxy.process.http.milestone.ua_first_read"); + http_rsb.ua_msecs_errors_aborts = Metrics::Counter::createPtr("proxy.process.http.transaction_totaltime.errors.aborts"); + http_rsb.ua_msecs_errors_connect_failed = + Metrics::Counter::createPtr("proxy.process.http.transaction_totaltime.errors.connect_failed"); + http_rsb.ua_msecs_errors_other = Metrics::Counter::createPtr("proxy.process.http.transaction_totaltime.errors.other"); + http_rsb.ua_msecs_errors_possible_aborts = + Metrics::Counter::createPtr("proxy.process.http.transaction_totaltime.errors.possible_aborts"); http_rsb.ua_msecs_errors_pre_accept_hangups = - Counter::CreatePtr("proxy.process.http.transaction_totaltime.errors.pre_accept_hangups"); - http_rsb.ua_msecs_hit_fresh = Counter::CreatePtr("proxy.process.http.transaction_totaltime.hit_fresh"); - http_rsb.ua_msecs_hit_fresh_process = Counter::CreatePtr("proxy.process.http.transaction_totaltime.hit_fresh.process"); - http_rsb.ua_msecs_hit_reval = Counter::CreatePtr("proxy.process.http.transaction_totaltime.hit_revalidated"); - http_rsb.ua_msecs_miss_changed = Counter::CreatePtr("proxy.process.http.transaction_totaltime.miss_changed"); - http_rsb.ua_msecs_miss_client_no_cache = Counter::CreatePtr("proxy.process.http.transaction_totaltime.miss_client_no_cache"); - http_rsb.ua_msecs_miss_cold = Counter::CreatePtr("proxy.process.http.transaction_totaltime.miss_cold"); - http_rsb.ua_msecs_miss_uncacheable = Counter::CreatePtr("proxy.process.http.transaction_totaltime.miss_not_cacheable"); - http_rsb.ua_msecs_other_unclassified = Counter::CreatePtr("proxy.process.http.transaction_totaltime.other.unclassified"); - http_rsb.ua_read_header_done_time = Counter::CreatePtr("proxy.process.http.milestone.ua_read_header_done"); - http_rsb.user_agent_request_document_total_size = Counter::CreatePtr("proxy.process.http.user_agent_request_document_total_size"); - http_rsb.user_agent_request_header_total_size = Counter::CreatePtr("proxy.process.http.user_agent_request_header_total_size"); + Metrics::Counter::createPtr("proxy.process.http.transaction_totaltime.errors.pre_accept_hangups"); + http_rsb.ua_msecs_hit_fresh = Metrics::Counter::createPtr("proxy.process.http.transaction_totaltime.hit_fresh"); + http_rsb.ua_msecs_hit_fresh_process = Metrics::Counter::createPtr("proxy.process.http.transaction_totaltime.hit_fresh.process"); + http_rsb.ua_msecs_hit_reval = Metrics::Counter::createPtr("proxy.process.http.transaction_totaltime.hit_revalidated"); + http_rsb.ua_msecs_miss_changed = Metrics::Counter::createPtr("proxy.process.http.transaction_totaltime.miss_changed"); + http_rsb.ua_msecs_miss_client_no_cache = + Metrics::Counter::createPtr("proxy.process.http.transaction_totaltime.miss_client_no_cache"); + http_rsb.ua_msecs_miss_cold = Metrics::Counter::createPtr("proxy.process.http.transaction_totaltime.miss_cold"); + http_rsb.ua_msecs_miss_uncacheable = Metrics::Counter::createPtr("proxy.process.http.transaction_totaltime.miss_not_cacheable"); + http_rsb.ua_msecs_other_unclassified = Metrics::Counter::createPtr("proxy.process.http.transaction_totaltime.other.unclassified"); + http_rsb.ua_read_header_done_time = Metrics::Counter::createPtr("proxy.process.http.milestone.ua_read_header_done"); + http_rsb.user_agent_request_document_total_size = + Metrics::Counter::createPtr("proxy.process.http.user_agent_request_document_total_size"); + http_rsb.user_agent_request_header_total_size = + Metrics::Counter::createPtr("proxy.process.http.user_agent_request_header_total_size"); http_rsb.user_agent_response_document_total_size = - Counter::CreatePtr("proxy.process.http.user_agent_response_document_total_size"); - http_rsb.user_agent_response_header_total_size = Counter::CreatePtr("proxy.process.http.user_agent_response_header_total_size"); + Metrics::Counter::createPtr("proxy.process.http.user_agent_response_document_total_size"); + http_rsb.user_agent_response_header_total_size = + Metrics::Counter::createPtr("proxy.process.http.user_agent_response_header_total_size"); http_rsb.websocket_current_active_client_connections = - Counter::CreatePtr("proxy.process.http.websocket.current_active_client_connections"); + Metrics::Counter::createPtr("proxy.process.http.websocket.current_active_client_connections"); } static bool diff --git a/src/proxy/http/HttpSM.cc b/src/proxy/http/HttpSM.cc index eb4d5f39ffe..5c3e240fd64 100644 --- a/src/proxy/http/HttpSM.cc +++ b/src/proxy/http/HttpSM.cc @@ -1609,7 +1609,7 @@ HttpSM::handle_api_return() // a blind tunnel. IOBufferReader *initial_data = nullptr; if (t_state.is_websocket) { - Counter::increment(http_rsb.websocket_current_active_client_connections); + Metrics::Counter::increment(http_rsb.websocket_current_active_client_connections); if (server_txn) { initial_data = server_txn->get_remote_reader(); } @@ -1726,8 +1726,8 @@ HttpSM::create_server_txn(PoolableSession *new_session) server_txn->attach_transaction(this); if (t_state.current.request_to == ResolveInfo::PARENT_PROXY) { new_session->to_parent_proxy = true; - Counter::increment(http_rsb.current_parent_proxy_connections); - Counter::increment(http_rsb.total_parent_proxy_connections); + Metrics::Counter::increment(http_rsb.current_parent_proxy_connections); + Metrics::Counter::increment(http_rsb.total_parent_proxy_connections); } else { new_session->to_parent_proxy = false; } @@ -1847,7 +1847,7 @@ HttpSM::state_http_server_open(int event, void *data) t_state.client_info.keep_alive = HTTP_NO_KEEPALIVE; // part of the problem, clear it. terminate_sm = true; } else if (ENET_THROTTLING == t_state.current.server->connect_result) { - Counter::increment(http_rsb.origin_connections_throttled); + Metrics::Counter::increment(http_rsb.origin_connections_throttled); send_origin_throttled_response(); } else { // Go ahead and release the failed server session. Since it didn't receive a response, the release logic will @@ -2457,7 +2457,7 @@ HttpSM::state_cache_open_write(int event, void *data) if (_ua.get_txn()) { pending_action = _ua.get_txn()->adjust_thread(this, event, data); if (!pending_action.empty()) { - Counter::increment(http_rsb.cache_open_write_adjust_thread); + Metrics::Counter::increment(http_rsb.cache_open_write_adjust_thread); return 0; // Go away if we reschedule } NetVConnection *vc = _ua.get_txn()->get_netvc(); @@ -3009,7 +3009,7 @@ HttpSM::tunnel_handler(int event, void *data) terminate_sm = true; if (unlikely(t_state.is_websocket)) { - Counter::decrement(http_rsb.websocket_current_active_client_connections); + Metrics::Counter::decrement(http_rsb.websocket_current_active_client_connections); } return 0; @@ -3070,11 +3070,11 @@ HttpSM::tunnel_handler_server(int event, HttpTunnelProducer *p) close_connection = false; } else { if (t_state.current.server->keep_alive != HTTP_KEEPALIVE) { - Counter::increment(http_rsb.origin_shutdown_tunnel_server_no_keep_alive); + Metrics::Counter::increment(http_rsb.origin_shutdown_tunnel_server_no_keep_alive); } else if (server_entry->eos == true) { - Counter::increment(http_rsb.origin_shutdown_tunnel_server_eos); + Metrics::Counter::increment(http_rsb.origin_shutdown_tunnel_server_eos); } else { - Counter::increment(http_rsb.origin_shutdown_tunnel_server_plugin_tunnel); + Metrics::Counter::increment(http_rsb.origin_shutdown_tunnel_server_plugin_tunnel); } close_connection = true; } @@ -3103,7 +3103,7 @@ HttpSM::tunnel_handler_server(int event, HttpTunnelProducer *p) t_state.current.server->state = HttpTransact::TRANSACTION_COMPLETE; break; } - Counter::increment(http_rsb.origin_shutdown_tunnel_server); + Metrics::Counter::increment(http_rsb.origin_shutdown_tunnel_server); close_connection = true; ink_assert(p->vc_type == HT_HTTP_SERVER); @@ -3181,7 +3181,7 @@ HttpSM::tunnel_handler_server(int event, HttpTunnelProducer *p) p->read_success = true; t_state.current.server->state = HttpTransact::TRANSACTION_COMPLETE; t_state.current.server->abort = HttpTransact::DIDNOT_ABORT; - Counter::increment(http_rsb.origin_shutdown_tunnel_server_detach); + Metrics::Counter::increment(http_rsb.origin_shutdown_tunnel_server_detach); close_connection = true; break; @@ -3202,7 +3202,7 @@ HttpSM::tunnel_handler_server(int event, HttpTunnelProducer *p) // If we had a ground fill, check update our status if (background_fill == BACKGROUND_FILL_STARTED) { background_fill = p->read_success ? BACKGROUND_FILL_COMPLETED : BACKGROUND_FILL_ABORTED; - Counter::decrement(http_rsb.background_fill_current_count); + Metrics::Counter::decrement(http_rsb.background_fill_current_count); } // We handled the event. Now either shutdown the connection or // setup it up for keep-alive @@ -3449,8 +3449,8 @@ HttpSM::tunnel_handler_ua(int event, HttpTunnelConsumer *c) // There is another consumer (cache write) so // detach the user agent if (background_fill == BACKGROUND_FILL_STARTED) { - Counter::increment(http_rsb.background_fill_current_count); - Counter::increment(http_rsb.background_fill_total_count); + Metrics::Counter::increment(http_rsb.background_fill_current_count); + Metrics::Counter::increment(http_rsb.background_fill_total_count); ink_assert(c->is_downstream_from(server_txn)); server_txn->set_active_timeout(HRTIME_SECONDS(t_state.txn_conf->background_fill_active_timeout)); @@ -3667,7 +3667,7 @@ HttpSM::tunnel_handler_cache_read(int event, HttpTunnelProducer *p) p->vc->do_io_close(EHTTP_ERROR); p->read_vio = nullptr; tunnel.chain_abort_all(p); - Counter::increment(http_rsb.cache_read_errors); + Metrics::Counter::increment(http_rsb.cache_read_errors); break; } else { tunnel.local_finish_all(p); @@ -3688,7 +3688,7 @@ HttpSM::tunnel_handler_cache_read(int event, HttpTunnelProducer *p) break; } - Counter::decrement(http_rsb.current_cache_connections); + Metrics::Counter::decrement(http_rsb.current_cache_connections); return 0; } @@ -3709,7 +3709,7 @@ HttpSM::tunnel_handler_cache_write(int event, HttpTunnelConsumer *c) c->write_vio = nullptr; c->vc->do_io_close(EHTTP_ERROR); - Counter::increment(http_rsb.cache_write_errors); + Metrics::Counter::increment(http_rsb.cache_write_errors); SMDebug("http", "aborting cache write due %s event from cache", HttpDebugNames::get_event_name(event)); // abort the producer if the cache_writevc is the only consumer. if (c->producer->alive && c->producer->num_consumers == 1) { @@ -3743,7 +3743,7 @@ HttpSM::tunnel_handler_cache_write(int event, HttpTunnelConsumer *c) server_response_body_bytes = c->bytes_written; } - Counter::decrement(http_rsb.current_cache_connections); + Metrics::Counter::decrement(http_rsb.current_cache_connections); return 0; } @@ -4233,7 +4233,7 @@ HttpSM::tunnel_handler_transform_read(int event, HttpTunnelProducer *p) // transform hasn't detached yet. If it is still alive, // don't close the transform vc if (p->self_consumer->alive == false) { - Counter::increment(http_rsb.origin_shutdown_tunnel_transform_read); + Metrics::Counter::increment(http_rsb.origin_shutdown_tunnel_transform_read); p->vc->do_io_close(); } p->handler_state = HTTP_SM_TRANSFORM_CLOSED; @@ -4936,7 +4936,7 @@ HttpSM::do_cache_lookup_and_read() t_state.request_sent_time = UNDEFINED_TIME; t_state.response_received_time = UNDEFINED_TIME; - Counter::increment(http_rsb.cache_lookups); + Metrics::Counter::increment(http_rsb.cache_lookups); milestones[TS_MILESTONE_CACHE_OPEN_READ_BEGIN] = ink_get_hrtime(); t_state.cache_lookup_result = HttpTransact::CACHE_LOOKUP_NONE; @@ -5386,16 +5386,16 @@ HttpSM::do_http_server_open(bool raw, bool only_direct) switch (shared_result) { case HSM_DONE: - Counter::increment(http_rsb.origin_reuse); + Metrics::Counter::increment(http_rsb.origin_reuse); hsm_release_assert(server_txn != nullptr); handle_http_server_open(); return; case HSM_NOT_FOUND: - Counter::increment(http_rsb.origin_not_found); + Metrics::Counter::increment(http_rsb.origin_not_found); hsm_release_assert(server_txn == nullptr); break; case HSM_RETRY: - Counter::increment(http_rsb.origin_reuse_fail); + Metrics::Counter::increment(http_rsb.origin_reuse_fail); // Could not get shared pool lock // FIX: should retry lock break; @@ -5443,15 +5443,15 @@ HttpSM::do_http_server_open(bool raw, bool only_direct) } if (!try_reuse) { - Counter::increment(http_rsb.origin_make_new); + Metrics::Counter::increment(http_rsb.origin_make_new); if (TS_SERVER_SESSION_SHARING_MATCH_NONE == t_state.txn_conf->server_session_sharing_match) { - Counter::increment(http_rsb.origin_no_sharing); + Metrics::Counter::increment(http_rsb.origin_no_sharing); } else if ((t_state.txn_conf->keep_alive_post_out != 1 && t_state.hdr_info.request_content_length > 0)) { - Counter::increment(http_rsb.origin_body); + Metrics::Counter::increment(http_rsb.origin_body); } else if (is_private()) { - Counter::increment(http_rsb.origin_private); + Metrics::Counter::increment(http_rsb.origin_private); } else if (raw) { - Counter::increment(http_rsb.origin_raw); + Metrics::Counter::increment(http_rsb.origin_raw); } else { ink_release_assert(_ua.get_txn() == nullptr); } @@ -5472,7 +5472,7 @@ HttpSM::do_http_server_open(bool raw, bool only_direct) // Atomically read the current number of connections and check to see // if we have gone above the max allowed. if (t_state.http_config_param->server_max_connections > 0) { - if (Counter::read(http_rsb.current_server_connections) >= t_state.http_config_param->server_max_connections) { + if (Metrics::Counter::read(http_rsb.current_server_connections) >= t_state.http_config_param->server_max_connections) { httpSessionManager.purge_keepalives(); // Eventually may want to have a queue as the origin_max_connection does to allow for a combination // of retries and errors. But at this point, we are just going to allow the error case. @@ -5500,7 +5500,7 @@ HttpSM::do_http_server_open(bool raw, bool only_direct) ink_assert(pending_action.empty()); // in case of reschedule must not have already pending. ct_state.blocked(); - Counter::increment(http_rsb.origin_connections_throttled); + Metrics::Counter::increment(http_rsb.origin_connections_throttled); ct_state.Warn_Blocked(server_max, sm_id, ccount - 1, &t_state.current.server->dst_addr.sa, debug_on && is_debug_tag_set("http") ? "http" : nullptr); send_origin_throttled_response(); @@ -5882,21 +5882,21 @@ HttpSM::release_server_session(bool serve_from_cache) } else { server_txn->do_io_close(); if (TS_SERVER_SESSION_SHARING_MATCH_NONE == t_state.txn_conf->server_session_sharing_match) { - Counter::increment(http_rsb.origin_shutdown_release_no_sharing); + Metrics::Counter::increment(http_rsb.origin_shutdown_release_no_sharing); } else if (t_state.current.server == nullptr) { - Counter::increment(http_rsb.origin_shutdown_release_no_server); + Metrics::Counter::increment(http_rsb.origin_shutdown_release_no_server); } else if (t_state.current.server->keep_alive != HTTP_KEEPALIVE) { - Counter::increment(http_rsb.origin_shutdown_release_no_keep_alive); + Metrics::Counter::increment(http_rsb.origin_shutdown_release_no_keep_alive); } else if (!t_state.hdr_info.server_response.valid()) { - Counter::increment(http_rsb.origin_shutdown_release_invalid_response); + Metrics::Counter::increment(http_rsb.origin_shutdown_release_invalid_response); } else if (!t_state.hdr_info.server_request.valid()) { - Counter::increment(http_rsb.origin_shutdown_release_invalid_request); + Metrics::Counter::increment(http_rsb.origin_shutdown_release_invalid_request); } else if (t_state.hdr_info.server_response.status_get() != HTTP_STATUS_NOT_MODIFIED && (t_state.hdr_info.server_request.method_get_wksidx() != HTTP_WKSIDX_HEAD || t_state.www_auth_content == HttpTransact::CACHE_AUTH_NONE)) { - Counter::increment(http_rsb.origin_shutdown_release_modified); + Metrics::Counter::increment(http_rsb.origin_shutdown_release_modified); } else { - Counter::increment(http_rsb.origin_shutdown_release_misc); + Metrics::Counter::increment(http_rsb.origin_shutdown_release_misc); } } @@ -8271,7 +8271,7 @@ HttpSM::do_redirect() ats_free((void *)redirect_url); redirect_url = nullptr; redirect_url_len = 0; - Counter::increment(http_rsb.total_x_redirect); + Metrics::Counter::increment(http_rsb.total_x_redirect); } else { // get the location header and setup the redirect int redir_len = 0; diff --git a/src/proxy/http/HttpSessionAccept.cc b/src/proxy/http/HttpSessionAccept.cc index ab93610e268..7351cacb2ea 100644 --- a/src/proxy/http/HttpSessionAccept.cc +++ b/src/proxy/http/HttpSessionAccept.cc @@ -81,8 +81,8 @@ HttpSessionAccept::mainEvent(int event, void *data) ///////////////// if (((long)data) == -ECONNABORTED) { // FIX: add time to user_agent_hangup - Counter::increment(http_rsb.ua_counts_errors_pre_accept_hangups); - // Counter::increment(http_rsb.ua_msecs_errors_pre_accept_hangups, 0); // ToDo: Weird, but we added 0 here before + Metrics::Counter::increment(http_rsb.ua_counts_errors_pre_accept_hangups); + // Metrics::Counter::increment(http_rsb.ua_msecs_errors_pre_accept_hangups, 0); // ToDo: Weird, but we added 0 here before } ink_abort("HTTP accept received fatal error: errno = %d", -(static_cast((intptr_t)data))); diff --git a/src/proxy/http/HttpSessionManager.cc b/src/proxy/http/HttpSessionManager.cc index 923d4dbcb72..07a621372ee 100644 --- a/src/proxy/http/HttpSessionManager.cc +++ b/src/proxy/http/HttpSessionManager.cc @@ -455,7 +455,7 @@ HttpSessionManager::_acquire_session(sockaddr const *ip, CryptoHash const &hostn ink_assert(new_vc == nullptr || new_vc->nh != nullptr); if (!new_vc) { // Close out to_return, we were't able to get a connection - Counter::increment(http_rsb.origin_shutdown_migration_failure); + Metrics::Counter::increment(http_rsb.origin_shutdown_migration_failure); to_return->do_io_close(); to_return = nullptr; retval = HSM_NOT_FOUND; @@ -536,7 +536,7 @@ ServerSessionPool::removeSession(PoolableSession *to_remove) } m_fqdn_pool.erase(to_remove); if (m_ip_pool.erase(to_remove)) { - Counter::decrement(http_rsb.pooled_server_connections); + Metrics::Counter::decrement(http_rsb.pooled_server_connections); } if (is_debug_tag_set("http_ss")) { Debug("http_ss", "After Remove session %p m_fqdn_pool size=%zu m_ip_pool_size=%zu", to_remove, m_fqdn_pool.count(), @@ -552,7 +552,7 @@ ServerSessionPool::addSession(PoolableSession *ss) // put it in the pools. m_ip_pool.insert(ss); m_fqdn_pool.insert(ss); - Counter::increment(http_rsb.pooled_server_connections); + Metrics::Counter::increment(http_rsb.pooled_server_connections); if (is_debug_tag_set("http_ss")) { char peer_ip[INET6_ADDRPORTSTRLEN]; diff --git a/src/proxy/http/HttpTransact.cc b/src/proxy/http/HttpTransact.cc index ecd70f61a6a..c4d716b6b64 100644 --- a/src/proxy/http/HttpTransact.cc +++ b/src/proxy/http/HttpTransact.cc @@ -189,7 +189,7 @@ inline static void findParent(HttpTransact::State *s) { url_mapping *mp = s->url_map.getMapping(); - Counter::increment(http_rsb.parent_count); + Metrics::Counter::increment(http_rsb.parent_count); if (s->response_action.handled) { s->parent_result.hostname = s->response_action.action.hostname; s->parent_result.port = s->response_action.action.port; @@ -214,7 +214,7 @@ findParent(HttpTransact::State *s) inline static void markParentDown(HttpTransact::State *s) { - Counter::increment(http_rsb.total_parent_marked_down_count); + Metrics::Counter::increment(http_rsb.total_parent_marked_down_count); url_mapping *mp = s->url_map.getMapping(); TxnDebug("http_trans", "enable_parent_timeout_markdowns: %d, disable_parent_markdowns: %d", @@ -280,7 +280,7 @@ nextParent(HttpTransact::State *s) TxnDebug("parent_down", "connection to parent %s failed, conn_state: %s, request to origin: %s", s->parent_result.hostname, HttpDebugNames::get_server_state_name(s->current.state), s->request_data.get_host()); url_mapping *mp = s->url_map.getMapping(); - Counter::increment(http_rsb.parent_count); + Metrics::Counter::increment(http_rsb.parent_count); if (s->response_action.handled) { s->parent_result.hostname = s->response_action.action.hostname; s->parent_result.port = s->response_action.action.port; @@ -909,7 +909,7 @@ HttpTransact::OriginDown(State *s) TxnDebug("http_trans", "origin server is marked down"); bootstrap_state_variables_from_request(s, &s->hdr_info.client_request); build_error_response(s, HTTP_STATUS_BAD_GATEWAY, "Origin Server Marked Down", "connect#failed_connect"); - Counter::increment(http_rsb.down_server_no_requests); + Metrics::Counter::increment(http_rsb.down_server_no_requests); char *url_str = s->hdr_info.client_request.url_string_get(&s->arena); int host_len; const char *host_name_ptr = s->unmapped_url.host_get(&host_len); @@ -1194,7 +1194,7 @@ HttpTransact::EndRemapRequest(State *s) */ if (!s->reverse_proxy && s->state_machine->plugin_tunnel_type == HTTP_NO_PLUGIN_TUNNEL) { TxnDebug("http_trans", "END HttpTransact::EndRemapRequest"); - Counter::increment(http_rsb.invalid_client_requests); + Metrics::Counter::increment(http_rsb.invalid_client_requests); TRANSACT_RETURN(SM_ACTION_SEND_ERROR_CACHE_NOOP, nullptr); } else { s->hdr_info.client_response.destroy(); // release the underlying memory. @@ -1489,10 +1489,10 @@ HttpTransact::HandleRequest(State *s) if (!s->state_machine->is_waiting_for_full_body && !s->state_machine->is_using_post_buffer) { ink_assert(!s->hdr_info.server_request.valid()); - Counter::increment(http_rsb.incoming_requests); + Metrics::Counter::increment(http_rsb.incoming_requests); if (s->client_info.port_attribute == HttpProxyPort::TRANSPORT_SSL) { - Counter::increment(http_rsb.https_incoming_requests); + Metrics::Counter::increment(http_rsb.https_incoming_requests); } /////////////////////////////////////////////// @@ -1500,7 +1500,7 @@ HttpTransact::HandleRequest(State *s) /////////////////////////////////////////////// if (!(is_request_valid(s, &s->hdr_info.client_request))) { - Counter::increment(http_rsb.invalid_client_requests); + Metrics::Counter::increment(http_rsb.invalid_client_requests); TxnDebug("http_seq", "request invalid."); s->next_action = SM_ACTION_SEND_ERROR_CACHE_NOOP; // s->next_action = HttpTransact::PROXY_INTERNAL_CACHE_NOOP; @@ -1517,7 +1517,8 @@ HttpTransact::HandleRequest(State *s) initialize_state_variables_from_request(s, &s->hdr_info.client_request); // The following chunk of code will limit the maximum number of websocket connections (TS-3659) if (s->is_upgrade_request && s->is_websocket && s->http_config_param->max_websocket_connections >= 0) { - if (Counter::read(http_rsb.websocket_current_active_client_connections) >= s->http_config_param->max_websocket_connections) { + if (Metrics::Counter::read(http_rsb.websocket_current_active_client_connections) >= + s->http_config_param->max_websocket_connections) { s->is_websocket = false; // unset to avoid screwing up stats. TxnDebug("http_trans", "Rejecting websocket connection because the limit has been exceeded"); bootstrap_state_variables_from_request(s, &s->hdr_info.client_request); @@ -1531,7 +1532,7 @@ HttpTransact::HandleRequest(State *s) s->hdr_info.request_content_length > s->http_config_param->max_post_size) { TxnDebug("http_trans", "Max post size %" PRId64 " Client tried to post a body that was too large.", s->http_config_param->max_post_size); - Counter::increment(http_rsb.post_body_too_large); + Metrics::Counter::increment(http_rsb.post_body_too_large); bootstrap_state_variables_from_request(s, &s->hdr_info.client_request); build_error_response(s, HTTP_STATUS_REQUEST_ENTITY_TOO_LARGE, "Request Entity Too Large", "request#entity_too_large"); s->squid_codes.log_code = SQUID_LOG_ERR_POST_ENTITY_TOO_LARGE; @@ -1549,7 +1550,7 @@ HttpTransact::HandleRequest(State *s) if (ptr_len_casecmp(expect_hdr_val, expect_hdr_val_len, HTTP_VALUE_100_CONTINUE, HTTP_LEN_100_CONTINUE) == 0) { // Let's error out this request. TxnDebug("http_trans", "Client sent a post expect: 100-continue, sending 405."); - Counter::increment(http_rsb.disallowed_post_100_continue); + Metrics::Counter::increment(http_rsb.disallowed_post_100_continue); build_error_response(s, HTTP_STATUS_METHOD_NOT_ALLOWED, "Method Not Allowed", "request#method_unsupported"); TRANSACT_RETURN(SM_ACTION_SEND_ERROR_CACHE_NOOP, nullptr); } @@ -1674,7 +1675,7 @@ HttpTransact::setup_plugin_request_intercept(State *s) if (s->cache_info.action != HttpTransact::CACHE_DO_NO_ACTION) { s->cache_info.action = HttpTransact::CACHE_DO_NO_ACTION; s->current.mode = TUNNELLING_PROXY; - Counter::increment(http_rsb.tunnels); + Metrics::Counter::increment(http_rsb.tunnels); } // Regardless of the protocol we're gatewaying to // we see the scheme as http @@ -2088,7 +2089,7 @@ HttpTransact::DecideCacheLookup(State *s) } else { s->cache_info.action = CACHE_DO_NO_ACTION; s->current.mode = TUNNELLING_PROXY; - Counter::increment(http_rsb.tunnels); + Metrics::Counter::increment(http_rsb.tunnels); } } @@ -3419,7 +3420,7 @@ HttpTransact::HandleResponse(State *s) TxnDebug("http_trans", "response_received_time: %" PRId64, (int64_t)s->response_received_time); DUMP_HEADER("http_hdrs", &s->hdr_info.server_response, s->state_machine_id(), "Incoming O.S. Response"); - Counter::increment(http_rsb.incoming_responses); + Metrics::Counter::increment(http_rsb.incoming_responses); ink_release_assert(s->current.request_to != ResolveInfo::UNDEFINED_LOOKUP); if (s->cache_info.action != CACHE_DO_WRITE) { @@ -3639,13 +3640,13 @@ HttpTransact::handle_response_from_parent(State *s) } if (s->current.retry_attempts.get() < (s->txn_conf->parent_connect_attempts - 1)) { - Counter::increment(http_rsb.total_parent_retries); + Metrics::Counter::increment(http_rsb.total_parent_retries); s->current.retry_attempts.increment(); // Are we done with this particular parent? if (s->current.retry_attempts.get() % s->txn_conf->per_parent_connect_attempts != 0) { // No we are not done with this parent so retry - Counter::increment(http_rsb.total_parent_switches); + Metrics::Counter::increment(http_rsb.total_parent_switches); s->next_action = how_to_open_connection(s); TxnDebug("http_trans", "%s Retrying parent for attempt %d, max %" PRId64, "[handle_response_from_parent]", s->current.retry_attempts.get(), s->txn_conf->per_parent_connect_attempts); @@ -3653,7 +3654,7 @@ HttpTransact::handle_response_from_parent(State *s) } else { TxnDebug("http_trans", "%s %d per parent attempts exhausted", "[handle_response_from_parent]", s->current.retry_attempts.get()); - Counter::increment(http_rsb.total_parent_retries_exhausted); + Metrics::Counter::increment(http_rsb.total_parent_retries_exhausted); // Only mark the parent down if we failed to connect // to the parent otherwise slow origin servers cause @@ -3667,7 +3668,7 @@ HttpTransact::handle_response_from_parent(State *s) } else { // Done trying parents... fail over to origin server if that is // appropriate - Counter::increment(http_rsb.total_parent_retries_exhausted); + Metrics::Counter::increment(http_rsb.total_parent_retries_exhausted); TxnDebug("http_trans", "Error. No more retries."); if (s->current.state == CONNECTION_ERROR || s->current.state == INACTIVE_TIMEOUT) { markParentDown(s); @@ -3888,7 +3889,7 @@ HttpTransact::handle_server_connection_not_open(State *s) ink_assert(s->current.state != CONNECTION_ALIVE); SET_VIA_STRING(VIA_SERVER_RESULT, VIA_SERVER_ERROR); - Counter::increment(http_rsb.broken_server_connections); + Metrics::Counter::increment(http_rsb.broken_server_connections); // Fire off a hostdb update to mark the server as down s->state_machine->do_hostdb_update_if_necessary(); @@ -4349,7 +4350,7 @@ HttpTransact::handle_cache_operation_on_forward_server_response(State *s) base_response->set_expires(exp_time); SET_VIA_STRING(VIA_CACHE_FILL_ACTION, VIA_CACHE_UPDATED); - Counter::increment(http_rsb.cache_updates); + Metrics::Counter::increment(http_rsb.cache_updates); // unset Cache-control: "need-revalidate-once" (if it's set) // This directive is used internally by T.S. to invalidate @@ -4552,12 +4553,12 @@ HttpTransact::handle_cache_operation_on_forward_server_response(State *s) case CACHE_DO_DELETE: TxnDebug("http_trans", "[hcoofsr] delete cached copy"); SET_VIA_STRING(VIA_CACHE_FILL_ACTION, VIA_CACHE_DELETED); - Counter::increment(http_rsb.cache_deletes); + Metrics::Counter::increment(http_rsb.cache_deletes); break; case CACHE_DO_WRITE: TxnDebug("http_trans", "[hcoofsr] cache write"); SET_VIA_STRING(VIA_CACHE_FILL_ACTION, VIA_CACHE_WRITTEN); - Counter::increment(http_rsb.cache_writes); + Metrics::Counter::increment(http_rsb.cache_writes); break; case CACHE_DO_SERVE_AND_UPDATE: // fall through @@ -4566,7 +4567,7 @@ HttpTransact::handle_cache_operation_on_forward_server_response(State *s) case CACHE_DO_REPLACE: TxnDebug("http_trans", "[hcoofsr] cache update/replace"); SET_VIA_STRING(VIA_CACHE_FILL_ACTION, VIA_CACHE_UPDATED); - Counter::increment(http_rsb.cache_updates); + Metrics::Counter::increment(http_rsb.cache_updates); break; default: break; @@ -5410,7 +5411,7 @@ HttpTransact::check_request_validity(State *s, HTTPHdr *incoming_hdr) if (!incoming_hdr->presence(MIME_PRESENCE_HOST) && incoming_hdr->version_get() != HTTP_0_9) { // Update the number of incoming 1.0 or 1.1 requests that do // not contain Host header fields. - Counter::increment(http_rsb.missing_host_hdr); + Metrics::Counter::increment(http_rsb.missing_host_hdr); } // Did the client send a "TE: identity;q=0"? We have to respond // with an error message because we only support identity @@ -5567,7 +5568,7 @@ HttpTransact::handle_trace_and_options_requests(State *s, HTTPHdr *incoming_hdr) // Trace and Options requests should not be looked up in cache. // s->cache_info.action = CACHE_DO_NO_ACTION; s->current.mode = TUNNELLING_PROXY; - Counter::increment(http_rsb.tunnels); + Metrics::Counter::increment(http_rsb.tunnels); return false; } @@ -5633,7 +5634,7 @@ HttpTransact::handle_trace_and_options_requests(State *s, HTTPHdr *incoming_hdr) // Trace and Options requests should not be looked up in cache. // s->cache_info.action = CACHE_DO_NO_ACTION; s->current.mode = TUNNELLING_PROXY; - Counter::increment(http_rsb.tunnels); + Metrics::Counter::increment(http_rsb.tunnels); } return false; @@ -5780,27 +5781,27 @@ void HttpTransact::update_method_stat(int method) { if (method == HTTP_WKSIDX_GET) { - Counter::increment(http_rsb.get_requests); + Metrics::Counter::increment(http_rsb.get_requests); } else if (method == HTTP_WKSIDX_HEAD) { - Counter::increment(http_rsb.head_requests); + Metrics::Counter::increment(http_rsb.head_requests); } else if (method == HTTP_WKSIDX_POST) { - Counter::increment(http_rsb.post_requests); + Metrics::Counter::increment(http_rsb.post_requests); } else if (method == HTTP_WKSIDX_PUT) { - Counter::increment(http_rsb.put_requests); + Metrics::Counter::increment(http_rsb.put_requests); } else if (method == HTTP_WKSIDX_CONNECT) { - Counter::increment(http_rsb.connect_requests); + Metrics::Counter::increment(http_rsb.connect_requests); } else if (method == HTTP_WKSIDX_DELETE) { - Counter::increment(http_rsb.delete_requests); + Metrics::Counter::increment(http_rsb.delete_requests); } else if (method == HTTP_WKSIDX_PURGE) { - Counter::increment(http_rsb.purge_requests); + Metrics::Counter::increment(http_rsb.purge_requests); } else if (method == HTTP_WKSIDX_TRACE) { - Counter::increment(http_rsb.trace_requests); + Metrics::Counter::increment(http_rsb.trace_requests); } else if (method == HTTP_WKSIDX_PUSH) { - Counter::increment(http_rsb.push_requests); + Metrics::Counter::increment(http_rsb.push_requests); } else if (method == HTTP_WKSIDX_OPTIONS) { - Counter::increment(http_rsb.options_requests); + Metrics::Counter::increment(http_rsb.options_requests); } else { - Counter::increment(http_rsb.extension_method_requests); + Metrics::Counter::increment(http_rsb.extension_method_requests); } } @@ -6622,7 +6623,7 @@ HttpTransact::will_this_request_self_loop(State *s) break; } SET_VIA_STRING(VIA_ERROR_TYPE, VIA_ERROR_LOOP_DETECTED); - Counter::increment(http_rsb.proxy_loop_detected); + Metrics::Counter::increment(http_rsb.proxy_loop_detected); build_error_response(s, HTTP_STATUS_BAD_REQUEST, "Cycle Detected", "request#cycle_detected"); return true; } @@ -6656,7 +6657,7 @@ HttpTransact::will_this_request_self_loop(State *s) if (count > max_proxy_cycles) { TxnDebug("http_transact", "count = %d > max_proxy_cycles = %d : detected loop", count, max_proxy_cycles); SET_VIA_STRING(VIA_ERROR_TYPE, VIA_ERROR_LOOP_DETECTED); - Counter::increment(http_rsb.proxy_mh_loop_detected); + Metrics::Counter::increment(http_rsb.proxy_mh_loop_detected); build_error_response(s, HTTP_STATUS_BAD_REQUEST, "Multi-Hop Cycle Detected", "request#cycle_detected"); return true; } else { @@ -7832,7 +7833,7 @@ HttpTransact::build_request(State *s, HTTPHdr *base_request, HTTPHdr *outgoing_r TxnDebug("http_trans", "request_sent_time: %" PRId64, (int64_t)s->request_sent_time); DUMP_HEADER("http_hdrs", outgoing_request, s->state_machine_id(), "Proxy's Request"); - Counter::increment(http_rsb.outgoing_requests); + Metrics::Counter::increment(http_rsb.outgoing_requests); } // build a (status_code) response based upon the given info @@ -8332,68 +8333,68 @@ HttpTransact::client_result_stat(State *s, ink_hrtime total_time, ink_hrtime req switch (s->squid_codes.log_code) { case SQUID_LOG_ERR_CONNECT_FAIL: - Counter::increment(http_rsb.cache_miss_cold); + Metrics::Counter::increment(http_rsb.cache_miss_cold); client_transaction_result = CLIENT_TRANSACTION_RESULT_ERROR_CONNECT_FAIL; break; case SQUID_LOG_TCP_CF_HIT: - Counter::increment(http_rsb.cache_hit_rww); + Metrics::Counter::increment(http_rsb.cache_hit_rww); client_transaction_result = CLIENT_TRANSACTION_RESULT_HIT_FRESH; break; case SQUID_LOG_TCP_MEM_HIT: - Counter::increment(http_rsb.cache_hit_mem_fresh); + Metrics::Counter::increment(http_rsb.cache_hit_mem_fresh); // fallthrough case SQUID_LOG_TCP_HIT: // It's possible to have two stat's instead of one, if needed. - Counter::increment(http_rsb.cache_hit_fresh); + Metrics::Counter::increment(http_rsb.cache_hit_fresh); client_transaction_result = CLIENT_TRANSACTION_RESULT_HIT_FRESH; break; case SQUID_LOG_TCP_REFRESH_HIT: - Counter::increment(http_rsb.cache_hit_reval); + Metrics::Counter::increment(http_rsb.cache_hit_reval); client_transaction_result = CLIENT_TRANSACTION_RESULT_HIT_REVALIDATED; break; case SQUID_LOG_TCP_IMS_HIT: - Counter::increment(http_rsb.cache_hit_ims); + Metrics::Counter::increment(http_rsb.cache_hit_ims); client_transaction_result = CLIENT_TRANSACTION_RESULT_HIT_FRESH; break; case SQUID_LOG_TCP_REF_FAIL_HIT: - Counter::increment(http_rsb.cache_hit_stale_served); + Metrics::Counter::increment(http_rsb.cache_hit_stale_served); client_transaction_result = CLIENT_TRANSACTION_RESULT_HIT_FRESH; break; case SQUID_LOG_TCP_MISS: if ((GET_VIA_STRING(VIA_CACHE_RESULT) == VIA_IN_CACHE_NOT_ACCEPTABLE) || (GET_VIA_STRING(VIA_CACHE_RESULT) == VIA_CACHE_MISS)) { - Counter::increment(http_rsb.cache_miss_cold); + Metrics::Counter::increment(http_rsb.cache_miss_cold); client_transaction_result = CLIENT_TRANSACTION_RESULT_MISS_COLD; } else { // FIX: what case is this for? can it ever happen? - Counter::increment(http_rsb.cache_miss_uncacheable); + Metrics::Counter::increment(http_rsb.cache_miss_uncacheable); client_transaction_result = CLIENT_TRANSACTION_RESULT_MISS_UNCACHABLE; } break; case SQUID_LOG_TCP_REFRESH_MISS: - Counter::increment(http_rsb.cache_miss_changed); + Metrics::Counter::increment(http_rsb.cache_miss_changed); client_transaction_result = CLIENT_TRANSACTION_RESULT_MISS_CHANGED; break; case SQUID_LOG_TCP_CLIENT_REFRESH: - Counter::increment(http_rsb.cache_miss_client_no_cache); + Metrics::Counter::increment(http_rsb.cache_miss_client_no_cache); client_transaction_result = CLIENT_TRANSACTION_RESULT_MISS_CLIENT_NO_CACHE; break; case SQUID_LOG_TCP_IMS_MISS: - Counter::increment(http_rsb.cache_miss_ims); + Metrics::Counter::increment(http_rsb.cache_miss_ims); client_transaction_result = CLIENT_TRANSACTION_RESULT_MISS_COLD; break; case SQUID_LOG_TCP_SWAPFAIL: - Counter::increment(http_rsb.cache_read_error); + Metrics::Counter::increment(http_rsb.cache_read_error); client_transaction_result = CLIENT_TRANSACTION_RESULT_HIT_FRESH; break; @@ -8426,143 +8427,143 @@ HttpTransact::client_result_stat(State *s, ink_hrtime total_time, ink_hrtime req if ((s->source != SOURCE_NONE) && (s->client_info.abort == DIDNOT_ABORT)) { switch (client_response_status) { case 100: - Counter::increment(http_rsb.response_status_100_count); + Metrics::Counter::increment(http_rsb.response_status_100_count); break; case 101: - Counter::increment(http_rsb.response_status_101_count); + Metrics::Counter::increment(http_rsb.response_status_101_count); break; case 200: - Counter::increment(http_rsb.response_status_200_count); + Metrics::Counter::increment(http_rsb.response_status_200_count); break; case 201: - Counter::increment(http_rsb.response_status_201_count); + Metrics::Counter::increment(http_rsb.response_status_201_count); break; case 202: - Counter::increment(http_rsb.response_status_202_count); + Metrics::Counter::increment(http_rsb.response_status_202_count); break; case 203: - Counter::increment(http_rsb.response_status_203_count); + Metrics::Counter::increment(http_rsb.response_status_203_count); break; case 204: - Counter::increment(http_rsb.response_status_204_count); + Metrics::Counter::increment(http_rsb.response_status_204_count); break; case 205: - Counter::increment(http_rsb.response_status_205_count); + Metrics::Counter::increment(http_rsb.response_status_205_count); break; case 206: - Counter::increment(http_rsb.response_status_206_count); + Metrics::Counter::increment(http_rsb.response_status_206_count); break; case 300: - Counter::increment(http_rsb.response_status_300_count); + Metrics::Counter::increment(http_rsb.response_status_300_count); break; case 301: - Counter::increment(http_rsb.response_status_301_count); + Metrics::Counter::increment(http_rsb.response_status_301_count); break; case 302: - Counter::increment(http_rsb.response_status_302_count); + Metrics::Counter::increment(http_rsb.response_status_302_count); break; case 303: - Counter::increment(http_rsb.response_status_303_count); + Metrics::Counter::increment(http_rsb.response_status_303_count); break; case 304: - Counter::increment(http_rsb.response_status_304_count); + Metrics::Counter::increment(http_rsb.response_status_304_count); break; case 305: - Counter::increment(http_rsb.response_status_305_count); + Metrics::Counter::increment(http_rsb.response_status_305_count); break; case 307: - Counter::increment(http_rsb.response_status_307_count); + Metrics::Counter::increment(http_rsb.response_status_307_count); break; case 308: - Counter::increment(http_rsb.response_status_308_count); + Metrics::Counter::increment(http_rsb.response_status_308_count); break; case 400: - Counter::increment(http_rsb.response_status_400_count); + Metrics::Counter::increment(http_rsb.response_status_400_count); break; case 401: - Counter::increment(http_rsb.response_status_401_count); + Metrics::Counter::increment(http_rsb.response_status_401_count); break; case 402: - Counter::increment(http_rsb.response_status_402_count); + Metrics::Counter::increment(http_rsb.response_status_402_count); break; case 403: - Counter::increment(http_rsb.response_status_403_count); + Metrics::Counter::increment(http_rsb.response_status_403_count); break; case 404: - Counter::increment(http_rsb.response_status_404_count); + Metrics::Counter::increment(http_rsb.response_status_404_count); break; case 405: - Counter::increment(http_rsb.response_status_405_count); + Metrics::Counter::increment(http_rsb.response_status_405_count); break; case 406: - Counter::increment(http_rsb.response_status_406_count); + Metrics::Counter::increment(http_rsb.response_status_406_count); break; case 407: - Counter::increment(http_rsb.response_status_407_count); + Metrics::Counter::increment(http_rsb.response_status_407_count); break; case 408: - Counter::increment(http_rsb.response_status_408_count); + Metrics::Counter::increment(http_rsb.response_status_408_count); break; case 409: - Counter::increment(http_rsb.response_status_409_count); + Metrics::Counter::increment(http_rsb.response_status_409_count); break; case 410: - Counter::increment(http_rsb.response_status_410_count); + Metrics::Counter::increment(http_rsb.response_status_410_count); break; case 411: - Counter::increment(http_rsb.response_status_411_count); + Metrics::Counter::increment(http_rsb.response_status_411_count); break; case 412: - Counter::increment(http_rsb.response_status_412_count); + Metrics::Counter::increment(http_rsb.response_status_412_count); break; case 413: - Counter::increment(http_rsb.response_status_413_count); + Metrics::Counter::increment(http_rsb.response_status_413_count); break; case 414: - Counter::increment(http_rsb.response_status_414_count); + Metrics::Counter::increment(http_rsb.response_status_414_count); break; case 415: - Counter::increment(http_rsb.response_status_415_count); + Metrics::Counter::increment(http_rsb.response_status_415_count); break; case 416: - Counter::increment(http_rsb.response_status_416_count); + Metrics::Counter::increment(http_rsb.response_status_416_count); break; case 500: - Counter::increment(http_rsb.response_status_500_count); + Metrics::Counter::increment(http_rsb.response_status_500_count); break; case 501: - Counter::increment(http_rsb.response_status_501_count); + Metrics::Counter::increment(http_rsb.response_status_501_count); break; case 502: - Counter::increment(http_rsb.response_status_502_count); + Metrics::Counter::increment(http_rsb.response_status_502_count); break; case 503: - Counter::increment(http_rsb.response_status_503_count); + Metrics::Counter::increment(http_rsb.response_status_503_count); break; case 504: - Counter::increment(http_rsb.response_status_504_count); + Metrics::Counter::increment(http_rsb.response_status_504_count); break; case 505: - Counter::increment(http_rsb.response_status_505_count); + Metrics::Counter::increment(http_rsb.response_status_505_count); break; default: break; } switch (client_response_status / 100) { case 1: - Counter::increment(http_rsb.response_status_1xx_count); + Metrics::Counter::increment(http_rsb.response_status_1xx_count); break; case 2: - Counter::increment(http_rsb.response_status_2xx_count); + Metrics::Counter::increment(http_rsb.response_status_2xx_count); break; case 3: - Counter::increment(http_rsb.response_status_3xx_count); + Metrics::Counter::increment(http_rsb.response_status_3xx_count); break; case 4: - Counter::increment(http_rsb.response_status_4xx_count); + Metrics::Counter::increment(http_rsb.response_status_4xx_count); break; case 5: - Counter::increment(http_rsb.response_status_5xx_count); + Metrics::Counter::increment(http_rsb.response_status_5xx_count); break; default: break; @@ -8570,57 +8571,57 @@ HttpTransact::client_result_stat(State *s, ink_hrtime total_time, ink_hrtime req } // Increment the completed connection count - Counter::increment(http_rsb.completed_requests); + Metrics::Counter::increment(http_rsb.completed_requests); // Set the stat now that we know what happend ink_hrtime total_msec = ink_hrtime_to_msec(total_time); ink_hrtime process_msec = ink_hrtime_to_msec(request_process_time); switch (client_transaction_result) { case CLIENT_TRANSACTION_RESULT_HIT_FRESH: - Counter::increment(http_rsb.ua_counts_hit_fresh); - Counter::increment(http_rsb.ua_msecs_hit_fresh, total_msec); - Counter::increment(http_rsb.ua_counts_hit_fresh_process); - Counter::increment(http_rsb.ua_msecs_hit_fresh_process, process_msec); + Metrics::Counter::increment(http_rsb.ua_counts_hit_fresh); + Metrics::Counter::increment(http_rsb.ua_msecs_hit_fresh, total_msec); + Metrics::Counter::increment(http_rsb.ua_counts_hit_fresh_process); + Metrics::Counter::increment(http_rsb.ua_msecs_hit_fresh_process, process_msec); break; case CLIENT_TRANSACTION_RESULT_HIT_REVALIDATED: - Counter::increment(http_rsb.ua_counts_hit_reval); - Counter::increment(http_rsb.ua_msecs_hit_reval, total_msec); + Metrics::Counter::increment(http_rsb.ua_counts_hit_reval); + Metrics::Counter::increment(http_rsb.ua_msecs_hit_reval, total_msec); break; case CLIENT_TRANSACTION_RESULT_MISS_COLD: - Counter::increment(http_rsb.ua_counts_miss_cold); - Counter::increment(http_rsb.ua_msecs_miss_cold, total_msec); + Metrics::Counter::increment(http_rsb.ua_counts_miss_cold); + Metrics::Counter::increment(http_rsb.ua_msecs_miss_cold, total_msec); break; case CLIENT_TRANSACTION_RESULT_MISS_CHANGED: - Counter::increment(http_rsb.ua_counts_miss_changed); - Counter::increment(http_rsb.ua_msecs_miss_changed, total_msec); + Metrics::Counter::increment(http_rsb.ua_counts_miss_changed); + Metrics::Counter::increment(http_rsb.ua_msecs_miss_changed, total_msec); break; case CLIENT_TRANSACTION_RESULT_MISS_CLIENT_NO_CACHE: - Counter::increment(http_rsb.ua_counts_miss_client_no_cache); - Counter::increment(http_rsb.ua_msecs_miss_client_no_cache, total_msec); + Metrics::Counter::increment(http_rsb.ua_counts_miss_client_no_cache); + Metrics::Counter::increment(http_rsb.ua_msecs_miss_client_no_cache, total_msec); break; case CLIENT_TRANSACTION_RESULT_MISS_UNCACHABLE: - Counter::increment(http_rsb.ua_counts_miss_uncacheable); - Counter::increment(http_rsb.ua_msecs_miss_uncacheable, total_msec); + Metrics::Counter::increment(http_rsb.ua_counts_miss_uncacheable); + Metrics::Counter::increment(http_rsb.ua_msecs_miss_uncacheable, total_msec); break; case CLIENT_TRANSACTION_RESULT_ERROR_ABORT: - Counter::increment(http_rsb.ua_counts_errors_aborts); - Counter::increment(http_rsb.ua_msecs_errors_aborts, total_msec); + Metrics::Counter::increment(http_rsb.ua_counts_errors_aborts); + Metrics::Counter::increment(http_rsb.ua_msecs_errors_aborts, total_msec); break; case CLIENT_TRANSACTION_RESULT_ERROR_POSSIBLE_ABORT: - Counter::increment(http_rsb.ua_counts_errors_possible_aborts); - Counter::increment(http_rsb.ua_msecs_errors_possible_aborts, total_msec); + Metrics::Counter::increment(http_rsb.ua_counts_errors_possible_aborts); + Metrics::Counter::increment(http_rsb.ua_msecs_errors_possible_aborts, total_msec); break; case CLIENT_TRANSACTION_RESULT_ERROR_CONNECT_FAIL: - Counter::increment(http_rsb.ua_counts_errors_connect_failed); - Counter::increment(http_rsb.ua_msecs_errors_connect_failed, total_msec); + Metrics::Counter::increment(http_rsb.ua_counts_errors_connect_failed); + Metrics::Counter::increment(http_rsb.ua_msecs_errors_connect_failed, total_msec); break; case CLIENT_TRANSACTION_RESULT_ERROR_OTHER: - Counter::increment(http_rsb.ua_counts_errors_other); - Counter::increment(http_rsb.ua_msecs_errors_other, total_msec); + Metrics::Counter::increment(http_rsb.ua_counts_errors_other); + Metrics::Counter::increment(http_rsb.ua_msecs_errors_other, total_msec); break; default: - Counter::increment(http_rsb.ua_counts_other_unclassified); - Counter::increment(http_rsb.ua_msecs_other_unclassified, total_msec); + Metrics::Counter::increment(http_rsb.ua_counts_other_unclassified); + Metrics::Counter::increment(http_rsb.ua_msecs_other_unclassified, total_msec); // This can happen if a plugin manually sets the status code after an error. TxnDebug("http", "Unclassified statistic"); break; @@ -8649,7 +8650,7 @@ HttpTransact::update_size_and_time_stats(State *s, ink_hrtime total_time, ink_hr case BACKGROUND_FILL_COMPLETED: { int64_t bg_size = origin_server_response_body_size - user_agent_response_body_size; bg_size = std::max(static_cast(0), bg_size); - Counter::increment(http_rsb.background_fill_bytes_completed, bg_size); + Metrics::Counter::increment(http_rsb.background_fill_bytes_completed, bg_size); break; } case BACKGROUND_FILL_ABORTED: { @@ -8658,7 +8659,7 @@ HttpTransact::update_size_and_time_stats(State *s, ink_hrtime total_time, ink_hr if (bg_size < 0) { bg_size = 0; } - Counter::increment(http_rsb.background_fill_bytes_aborted, bg_size); + Metrics::Counter::increment(http_rsb.background_fill_bytes_aborted, bg_size); break; } case BACKGROUND_FILL_NONE: @@ -8674,133 +8675,136 @@ HttpTransact::update_size_and_time_stats(State *s, ink_hrtime total_time, ink_hr case SQUID_LOG_TCP_MEM_HIT: case SQUID_LOG_TCP_CF_HIT: // It's possible to have two stat's instead of one, if needed. - Counter::increment(http_rsb.tcp_hit_count); - Counter::increment(http_rsb.tcp_hit_user_agent_bytes, user_agent_bytes); - Counter::increment(http_rsb.tcp_hit_origin_server_bytes, origin_server_bytes); + Metrics::Counter::increment(http_rsb.tcp_hit_count); + Metrics::Counter::increment(http_rsb.tcp_hit_user_agent_bytes, user_agent_bytes); + Metrics::Counter::increment(http_rsb.tcp_hit_origin_server_bytes, origin_server_bytes); break; case SQUID_LOG_TCP_MISS: - Counter::increment(http_rsb.tcp_miss_count); - Counter::increment(http_rsb.tcp_miss_user_agent_bytes, user_agent_bytes); - Counter::increment(http_rsb.tcp_miss_origin_server_bytes, origin_server_bytes); + Metrics::Counter::increment(http_rsb.tcp_miss_count); + Metrics::Counter::increment(http_rsb.tcp_miss_user_agent_bytes, user_agent_bytes); + Metrics::Counter::increment(http_rsb.tcp_miss_origin_server_bytes, origin_server_bytes); break; case SQUID_LOG_TCP_EXPIRED_MISS: - Counter::increment(http_rsb.tcp_expired_miss_count); - Counter::increment(http_rsb.tcp_expired_miss_user_agent_bytes, user_agent_bytes); - Counter::increment(http_rsb.tcp_expired_miss_origin_server_bytes, origin_server_bytes); + Metrics::Counter::increment(http_rsb.tcp_expired_miss_count); + Metrics::Counter::increment(http_rsb.tcp_expired_miss_user_agent_bytes, user_agent_bytes); + Metrics::Counter::increment(http_rsb.tcp_expired_miss_origin_server_bytes, origin_server_bytes); break; case SQUID_LOG_TCP_REFRESH_HIT: - Counter::increment(http_rsb.tcp_refresh_hit_count); - Counter::increment(http_rsb.tcp_refresh_hit_user_agent_bytes, user_agent_bytes); - Counter::increment(http_rsb.tcp_refresh_hit_origin_server_bytes, origin_server_bytes); + Metrics::Counter::increment(http_rsb.tcp_refresh_hit_count); + Metrics::Counter::increment(http_rsb.tcp_refresh_hit_user_agent_bytes, user_agent_bytes); + Metrics::Counter::increment(http_rsb.tcp_refresh_hit_origin_server_bytes, origin_server_bytes); break; case SQUID_LOG_TCP_REFRESH_MISS: - Counter::increment(http_rsb.tcp_refresh_miss_count); - Counter::increment(http_rsb.tcp_refresh_miss_user_agent_bytes, user_agent_bytes); - Counter::increment(http_rsb.tcp_refresh_miss_origin_server_bytes, origin_server_bytes); + Metrics::Counter::increment(http_rsb.tcp_refresh_miss_count); + Metrics::Counter::increment(http_rsb.tcp_refresh_miss_user_agent_bytes, user_agent_bytes); + Metrics::Counter::increment(http_rsb.tcp_refresh_miss_origin_server_bytes, origin_server_bytes); break; case SQUID_LOG_TCP_CLIENT_REFRESH: - Counter::increment(http_rsb.tcp_client_refresh_count); - Counter::increment(http_rsb.tcp_client_refresh_user_agent_bytes, user_agent_bytes); - Counter::increment(http_rsb.tcp_client_refresh_origin_server_bytes, origin_server_bytes); + Metrics::Counter::increment(http_rsb.tcp_client_refresh_count); + Metrics::Counter::increment(http_rsb.tcp_client_refresh_user_agent_bytes, user_agent_bytes); + Metrics::Counter::increment(http_rsb.tcp_client_refresh_origin_server_bytes, origin_server_bytes); break; case SQUID_LOG_TCP_IMS_HIT: - Counter::increment(http_rsb.tcp_ims_hit_count); - Counter::increment(http_rsb.tcp_ims_hit_user_agent_bytes, user_agent_bytes); - Counter::increment(http_rsb.tcp_ims_hit_origin_server_bytes, origin_server_bytes); + Metrics::Counter::increment(http_rsb.tcp_ims_hit_count); + Metrics::Counter::increment(http_rsb.tcp_ims_hit_user_agent_bytes, user_agent_bytes); + Metrics::Counter::increment(http_rsb.tcp_ims_hit_origin_server_bytes, origin_server_bytes); break; case SQUID_LOG_TCP_IMS_MISS: - Counter::increment(http_rsb.tcp_ims_miss_count); - Counter::increment(http_rsb.tcp_ims_miss_user_agent_bytes, user_agent_bytes); - Counter::increment(http_rsb.tcp_ims_miss_origin_server_bytes, origin_server_bytes); + Metrics::Counter::increment(http_rsb.tcp_ims_miss_count); + Metrics::Counter::increment(http_rsb.tcp_ims_miss_user_agent_bytes, user_agent_bytes); + Metrics::Counter::increment(http_rsb.tcp_ims_miss_origin_server_bytes, origin_server_bytes); break; case SQUID_LOG_ERR_CLIENT_ABORT: - Counter::increment(http_rsb.err_client_abort_count); - Counter::increment(http_rsb.err_client_abort_user_agent_bytes, user_agent_bytes); - Counter::increment(http_rsb.err_client_abort_origin_server_bytes, origin_server_bytes); + Metrics::Counter::increment(http_rsb.err_client_abort_count); + Metrics::Counter::increment(http_rsb.err_client_abort_user_agent_bytes, user_agent_bytes); + Metrics::Counter::increment(http_rsb.err_client_abort_origin_server_bytes, origin_server_bytes); break; case SQUID_LOG_ERR_CLIENT_READ_ERROR: - Counter::increment(http_rsb.err_client_read_error_count); - Counter::increment(http_rsb.err_client_read_error_user_agent_bytes, user_agent_bytes); - Counter::increment(http_rsb.err_client_read_error_origin_server_bytes, origin_server_bytes); + Metrics::Counter::increment(http_rsb.err_client_read_error_count); + Metrics::Counter::increment(http_rsb.err_client_read_error_user_agent_bytes, user_agent_bytes); + Metrics::Counter::increment(http_rsb.err_client_read_error_origin_server_bytes, origin_server_bytes); break; case SQUID_LOG_ERR_CONNECT_FAIL: - Counter::increment(http_rsb.err_connect_fail_count); - Counter::increment(http_rsb.err_connect_fail_user_agent_bytes, user_agent_bytes); - Counter::increment(http_rsb.err_connect_fail_origin_server_bytes, origin_server_bytes); + Metrics::Counter::increment(http_rsb.err_connect_fail_count); + Metrics::Counter::increment(http_rsb.err_connect_fail_user_agent_bytes, user_agent_bytes); + Metrics::Counter::increment(http_rsb.err_connect_fail_origin_server_bytes, origin_server_bytes); break; default: - Counter::increment(http_rsb.misc_count); - Counter::increment(http_rsb.misc_user_agent_bytes, user_agent_bytes); - Counter::increment(http_rsb.misc_origin_server_bytes, origin_server_bytes); + Metrics::Counter::increment(http_rsb.misc_count); + Metrics::Counter::increment(http_rsb.misc_user_agent_bytes, user_agent_bytes); + Metrics::Counter::increment(http_rsb.misc_origin_server_bytes, origin_server_bytes); break; } // times - Counter::increment(http_rsb.total_transactions_time, total_time); + Metrics::Counter::increment(http_rsb.total_transactions_time, total_time); // sizes - Counter::increment(http_rsb.user_agent_request_header_total_size, user_agent_request_header_size); - Counter::increment(http_rsb.user_agent_response_header_total_size, user_agent_response_header_size); - Counter::increment(http_rsb.user_agent_request_document_total_size, user_agent_request_body_size); - Counter::increment(http_rsb.user_agent_response_document_total_size, user_agent_response_body_size); + Metrics::Counter::increment(http_rsb.user_agent_request_header_total_size, user_agent_request_header_size); + Metrics::Counter::increment(http_rsb.user_agent_response_header_total_size, user_agent_response_header_size); + Metrics::Counter::increment(http_rsb.user_agent_request_document_total_size, user_agent_request_body_size); + Metrics::Counter::increment(http_rsb.user_agent_response_document_total_size, user_agent_response_body_size); // proxy stats if (s->current.request_to == ResolveInfo::PARENT_PROXY) { - Counter::increment(http_rsb.parent_proxy_request_total_bytes, - origin_server_request_header_size + origin_server_request_body_size); - Counter::increment(http_rsb.parent_proxy_response_total_bytes, - origin_server_response_header_size + origin_server_response_body_size); - Counter::increment(http_rsb.parent_proxy_transaction_time, total_time); + Metrics::Counter::increment(http_rsb.parent_proxy_request_total_bytes, + origin_server_request_header_size + origin_server_request_body_size); + Metrics::Counter::increment(http_rsb.parent_proxy_response_total_bytes, + origin_server_response_header_size + origin_server_response_body_size); + Metrics::Counter::increment(http_rsb.parent_proxy_transaction_time, total_time); } // request header zero means the document was cached. // do not add to stats. if (origin_server_request_header_size > 0) { - Counter::increment(http_rsb.origin_server_request_header_total_size, origin_server_request_header_size); - Counter::increment(http_rsb.origin_server_response_header_total_size, origin_server_response_header_size); - Counter::increment(http_rsb.origin_server_request_document_total_size, origin_server_request_body_size); - Counter::increment(http_rsb.origin_server_response_document_total_size, origin_server_response_body_size); + Metrics::Counter::increment(http_rsb.origin_server_request_header_total_size, origin_server_request_header_size); + Metrics::Counter::increment(http_rsb.origin_server_response_header_total_size, origin_server_response_header_size); + Metrics::Counter::increment(http_rsb.origin_server_request_document_total_size, origin_server_request_body_size); + Metrics::Counter::increment(http_rsb.origin_server_response_document_total_size, origin_server_response_body_size); } if (s->method == HTTP_WKSIDX_PUSH) { - Counter::increment(http_rsb.pushed_response_header_total_size, pushed_response_header_size); - Counter::increment(http_rsb.pushed_document_total_size, pushed_response_body_size); + Metrics::Counter::increment(http_rsb.pushed_response_header_total_size, pushed_response_header_size); + Metrics::Counter::increment(http_rsb.pushed_document_total_size, pushed_response_body_size); } // update milestones stats - Counter::increment(http_rsb.ua_begin_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_BEGIN, 0)); - Counter::increment(http_rsb.ua_first_read_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_FIRST_READ, 0)); - Counter::increment(http_rsb.ua_read_header_done_time, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_READ_HEADER_DONE, 0)); - Counter::increment(http_rsb.ua_begin_write_time, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_BEGIN_WRITE, 0)); - Counter::increment(http_rsb.ua_close_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_CLOSE, 0)); - Counter::increment(http_rsb.server_first_connect_time, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_FIRST_CONNECT, 0)); - Counter::increment(http_rsb.server_connect_time, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_CONNECT, 0)); - Counter::increment(http_rsb.server_connect_end_time, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_CONNECT_END, 0)); - Counter::increment(http_rsb.server_begin_write_time, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_BEGIN_WRITE, 0)); - Counter::increment(http_rsb.server_first_read_time, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_FIRST_READ, 0)); - Counter::increment(http_rsb.server_read_header_done_time, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_READ_HEADER_DONE, 0)); - Counter::increment(http_rsb.server_close_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_CLOSE, 0)); - Counter::increment(http_rsb.cache_open_read_begin_time, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_CACHE_OPEN_READ_BEGIN, 0)); - Counter::increment(http_rsb.cache_open_read_end_time, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_CACHE_OPEN_READ_END, 0)); - Counter::increment(http_rsb.cache_open_write_begin_time, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_CACHE_OPEN_WRITE_BEGIN, 0)); - Counter::increment(http_rsb.cache_open_write_end_time, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_CACHE_OPEN_WRITE_END, 0)); - Counter::increment(http_rsb.dns_lookup_begin_time, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_DNS_LOOKUP_BEGIN, 0)); - Counter::increment(http_rsb.dns_lookup_end_time, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_DNS_LOOKUP_END, 0)); - Counter::increment(http_rsb.sm_start_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SM_START, 0)); - Counter::increment(http_rsb.sm_finish_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SM_FINISH, 0)); + Metrics::Counter::increment(http_rsb.ua_begin_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_BEGIN, 0)); + Metrics::Counter::increment(http_rsb.ua_first_read_time, + milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_FIRST_READ, 0)); + Metrics::Counter::increment(http_rsb.ua_read_header_done_time, + milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_READ_HEADER_DONE, 0)); + Metrics::Counter::increment(http_rsb.ua_begin_write_time, + milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_BEGIN_WRITE, 0)); + Metrics::Counter::increment(http_rsb.ua_close_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_CLOSE, 0)); + Metrics::Counter::increment(http_rsb.server_first_connect_time, + milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_FIRST_CONNECT, 0)); + Metrics::Counter::increment(http_rsb.server_connect_time, + milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_CONNECT, 0)); + Metrics::Counter::increment(http_rsb.server_connect_end_time, + milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_CONNECT_END, 0)); + Metrics::Counter::increment(http_rsb.server_begin_write_time, + milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_BEGIN_WRITE, 0)); + Metrics::Counter::increment(http_rsb.server_first_read_time, + milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_FIRST_READ, 0)); + Metrics::Counter::increment(http_rsb.server_read_header_done_time, + milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_READ_HEADER_DONE, 0)); + Metrics::Counter::increment(http_rsb.server_close_time, + milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_CLOSE, 0)); + Metrics::Counter::increment(http_rsb.cache_open_read_begin_time, + milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_CACHE_OPEN_READ_BEGIN, 0)); + Metrics::Counter::increment(http_rsb.cache_open_read_end_time, + milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_CACHE_OPEN_READ_END, 0)); + Metrics::Counter::increment(http_rsb.cache_open_write_begin_time, + milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_CACHE_OPEN_WRITE_BEGIN, 0)); + Metrics::Counter::increment(http_rsb.cache_open_write_end_time, + milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_CACHE_OPEN_WRITE_END, 0)); + Metrics::Counter::increment(http_rsb.dns_lookup_begin_time, + milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_DNS_LOOKUP_BEGIN, 0)); + Metrics::Counter::increment(http_rsb.dns_lookup_end_time, + milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_DNS_LOOKUP_END, 0)); + Metrics::Counter::increment(http_rsb.sm_start_time, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SM_START, 0)); + Metrics::Counter::increment(http_rsb.sm_finish_time, + milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SM_FINISH, 0)); } void diff --git a/src/proxy/http/HttpTunnel.cc b/src/proxy/http/HttpTunnel.cc index 03a88484d9c..dcfd0293bf9 100644 --- a/src/proxy/http/HttpTunnel.cc +++ b/src/proxy/http/HttpTunnel.cc @@ -1484,7 +1484,7 @@ HttpTunnel::chain_abort_all(HttpTunnelProducer *p) } p->read_vio = nullptr; p->vc->do_io_close(EHTTP_ERROR); - Counter::increment(http_rsb.origin_shutdown_tunnel_abort); + Metrics::Counter::increment(http_rsb.origin_shutdown_tunnel_abort); update_stats_after_abort(p->vc_type); } } @@ -1601,7 +1601,7 @@ HttpTunnel::chain_abort_cache_write(HttpTunnelProducer *p) c->write_vio = nullptr; c->vc->do_io_close(EHTTP_ERROR); c->alive = false; - Counter::decrement(http_rsb.current_cache_connections); + Metrics::Counter::decrement(http_rsb.current_cache_connections); } else if (c->self_producer) { chain_abort_cache_write(c->self_producer); } @@ -1715,7 +1715,7 @@ HttpTunnel::update_stats_after_abort(HttpTunnelType_t t) switch (t) { case HT_CACHE_READ: case HT_CACHE_WRITE: - Counter::decrement(http_rsb.current_cache_connections); + Metrics::Counter::decrement(http_rsb.current_cache_connections); break; default: // Handled here: @@ -1740,7 +1740,7 @@ HttpTunnel::mark_tls_tunnel_active() } _tls_tunnel_active = true; - Counter::increment(http_rsb.tunnel_current_active_connections); + Metrics::Counter::increment(http_rsb.tunnel_current_active_connections); _schedule_tls_tunnel_activity_check_event(); } @@ -1753,7 +1753,7 @@ HttpTunnel::mark_tls_tunnel_inactive() } _tls_tunnel_active = false; - Counter::decrement(http_rsb.tunnel_current_active_connections); + Metrics::Counter::decrement(http_rsb.tunnel_current_active_connections); if (_tls_tunnel_activity_check_event) { _tls_tunnel_activity_check_event->cancel(); diff --git a/src/proxy/http/HttpVCTable.cc b/src/proxy/http/HttpVCTable.cc index 46a1b871afe..f8e9524959b 100644 --- a/src/proxy/http/HttpVCTable.cc +++ b/src/proxy/http/HttpVCTable.cc @@ -117,7 +117,7 @@ HttpVCTable::cleanup_entry(HttpVCTableEntry *e) ink_assert(e->vc); if (e->in_tunnel == false) { if (e->vc_type == HTTP_SERVER_VC) { - Counter::increment(http_rsb.origin_shutdown_cleanup_entry); + Metrics::Counter::increment(http_rsb.origin_shutdown_cleanup_entry); } e->vc->do_io_close(); e->vc = nullptr; diff --git a/src/proxy/http/PreWarmManager.cc b/src/proxy/http/PreWarmManager.cc index 0104de5e632..99c3e8a8215 100644 --- a/src/proxy/http/PreWarmManager.cc +++ b/src/proxy/http/PreWarmManager.cc @@ -1125,8 +1125,8 @@ PreWarmManager::_parse_sni_conf(PreWarm::ParsedSNIConf &parsed_conf, const SNICo void PreWarmManager::_register_stats(const PreWarm::ParsedSNIConf &parsed_conf) { - int stats_counter = 0; - ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); + int stats_counter = 0; + ts::Metrics &metrics = ts::Metrics::instance(); for (auto &entry : parsed_conf) { const PreWarm::SPtrConstDst &dst = entry.first; @@ -1145,11 +1145,11 @@ PreWarmManager::_register_stats(const PreWarm::ParsedSNIConf &parsed_conf) dst->host.data(), dst->port, (dst->type == SNIRoutingType::PARTIAL_BLIND) ? "tls" : "tcp", STAT_ENTRIES[j].data()); } - ts::Metrics::Counter::IdType stats_id = metrics.lookup(name); - Counter::AtomicType *metric = nullptr; + ts::Metrics::IdType stats_id = metrics.lookup(name); + Metrics::Counter::AtomicType *metric = nullptr; - if (stats_id == ts::Metrics::Counter::NOT_FOUND) { - metric = Counter::CreatePtr(name); + if (stats_id == ts::Metrics::NOT_FOUND) { + metric = Metrics::Counter::createPtr(name); if (metric == nullptr) { Error("couldn't register stat name=%s", name); diff --git a/src/proxy/http2/HTTP2.cc b/src/proxy/http2/HTTP2.cc index 3edc8f3f844..bbf0837c7e3 100644 --- a/src/proxy/http2/HTTP2.cc +++ b/src/proxy/http2/HTTP2.cc @@ -563,38 +563,43 @@ Http2::init() ink_release_assert(http2_settings_parameter_is_valid({HTTP2_SETTINGS_MAX_HEADER_LIST_SIZE, max_header_list_size})); // Setup statistics - http2_rsb.current_client_session_count = Counter::CreatePtr("proxy.process.http2.current_client_connections"); - http2_rsb.current_server_session_count = Counter::CreatePtr("proxy.process.http2.current_server_connections"); - http2_rsb.current_active_client_connection_count = Counter::CreatePtr("proxy.process.http2.current_active_client_connections"); - http2_rsb.current_active_server_connection_count = Counter::CreatePtr("proxy.process.http2.current_active_server_connections"); - http2_rsb.current_client_stream_count = Counter::CreatePtr("proxy.process.http2.current_client_streams"); - http2_rsb.current_server_stream_count = Counter::CreatePtr("proxy.process.http2.current_server_streams"); - http2_rsb.total_client_stream_count = Counter::CreatePtr("proxy.process.http2.total_client_streams"); - http2_rsb.total_server_stream_count = Counter::CreatePtr("proxy.process.http2.total_server_streams"); - http2_rsb.total_transactions_time = Counter::CreatePtr("proxy.process.http2.total_transactions_time"); - http2_rsb.total_client_connection_count = Counter::CreatePtr("proxy.process.http2.total_client_connections"); - http2_rsb.total_server_connection_count = Counter::CreatePtr("proxy.process.http2.total_server_connections"); - http2_rsb.stream_errors_count = Counter::CreatePtr("proxy.process.http2.stream_errors"); - http2_rsb.connection_errors_count = Counter::CreatePtr("proxy.process.http2.connection_errors"); - http2_rsb.session_die_default = Counter::CreatePtr("proxy.process.http2.session_die_default"); - http2_rsb.session_die_other = Counter::CreatePtr("proxy.process.http2.session_die_other"); - http2_rsb.session_die_active = Counter::CreatePtr("proxy.process.http2.session_die_active"); - http2_rsb.session_die_inactive = Counter::CreatePtr("proxy.process.http2.session_die_inactive"); - http2_rsb.session_die_eos = Counter::CreatePtr("proxy.process.http2.session_die_eos"); - http2_rsb.session_die_error = Counter::CreatePtr("proxy.process.http2.session_die_error"); - http2_rsb.session_die_high_error_rate = Counter::CreatePtr("proxy.process.http2.session_die_high_error_rate"); - http2_rsb.max_settings_per_frame_exceeded = Counter::CreatePtr("proxy.process.http2.max_settings_per_frame_exceeded"); - http2_rsb.max_settings_per_minute_exceeded = Counter::CreatePtr("proxy.process.http2.max_settings_per_minute_exceeded"); + http2_rsb.current_client_session_count = Metrics::Counter::createPtr("proxy.process.http2.current_client_connections"); + http2_rsb.current_server_session_count = Metrics::Counter::createPtr("proxy.process.http2.current_server_connections"); + http2_rsb.current_active_client_connection_count = + Metrics::Counter::createPtr("proxy.process.http2.current_active_client_connections"); + http2_rsb.current_active_server_connection_count = + Metrics::Counter::createPtr("proxy.process.http2.current_active_server_connections"); + http2_rsb.current_client_stream_count = Metrics::Counter::createPtr("proxy.process.http2.current_client_streams"); + http2_rsb.current_server_stream_count = Metrics::Counter::createPtr("proxy.process.http2.current_server_streams"); + http2_rsb.total_client_stream_count = Metrics::Counter::createPtr("proxy.process.http2.total_client_streams"); + http2_rsb.total_server_stream_count = Metrics::Counter::createPtr("proxy.process.http2.total_server_streams"); + http2_rsb.total_transactions_time = Metrics::Counter::createPtr("proxy.process.http2.total_transactions_time"); + http2_rsb.total_client_connection_count = Metrics::Counter::createPtr("proxy.process.http2.total_client_connections"); + http2_rsb.total_server_connection_count = Metrics::Counter::createPtr("proxy.process.http2.total_server_connections"); + http2_rsb.stream_errors_count = Metrics::Counter::createPtr("proxy.process.http2.stream_errors"); + http2_rsb.connection_errors_count = Metrics::Counter::createPtr("proxy.process.http2.connection_errors"); + http2_rsb.session_die_default = Metrics::Counter::createPtr("proxy.process.http2.session_die_default"); + http2_rsb.session_die_other = Metrics::Counter::createPtr("proxy.process.http2.session_die_other"); + http2_rsb.session_die_active = Metrics::Counter::createPtr("proxy.process.http2.session_die_active"); + http2_rsb.session_die_inactive = Metrics::Counter::createPtr("proxy.process.http2.session_die_inactive"); + http2_rsb.session_die_eos = Metrics::Counter::createPtr("proxy.process.http2.session_die_eos"); + http2_rsb.session_die_error = Metrics::Counter::createPtr("proxy.process.http2.session_die_error"); + http2_rsb.session_die_high_error_rate = Metrics::Counter::createPtr("proxy.process.http2.session_die_high_error_rate"); + http2_rsb.max_settings_per_frame_exceeded = Metrics::Counter::createPtr("proxy.process.http2.max_settings_per_frame_exceeded"); + http2_rsb.max_settings_per_minute_exceeded = Metrics::Counter::createPtr("proxy.process.http2.max_settings_per_minute_exceeded"); http2_rsb.max_settings_frames_per_minute_exceeded = - Counter::CreatePtr("proxy.process.http2.max_settings_frames_per_minute_exceeded"); - http2_rsb.max_ping_frames_per_minute_exceeded = Counter::CreatePtr("proxy.process.http2.max_ping_frames_per_minute_exceeded"); + Metrics::Counter::createPtr("proxy.process.http2.max_settings_frames_per_minute_exceeded"); + http2_rsb.max_ping_frames_per_minute_exceeded = + Metrics::Counter::createPtr("proxy.process.http2.max_ping_frames_per_minute_exceeded"); http2_rsb.max_priority_frames_per_minute_exceeded = - Counter::CreatePtr("proxy.process.http2.max_priority_frames_per_minute_exceeded"); + Metrics::Counter::createPtr("proxy.process.http2.max_priority_frames_per_minute_exceeded"); http2_rsb.max_rst_stream_frames_per_minute_exceeded = - Counter::CreatePtr("proxy.process.http2.max_rst_stream_frames_per_minute_exceeded"); - http2_rsb.insufficient_avg_window_update = Counter::CreatePtr("proxy.process.http2.insufficient_avg_window_update"); - http2_rsb.max_concurrent_streams_exceeded_in = Counter::CreatePtr("proxy.process.http2.max_concurrent_streams_exceeded_in"); - http2_rsb.max_concurrent_streams_exceeded_out = Counter::CreatePtr("proxy.process.http2.max_concurrent_streams_exceeded_out"); + Metrics::Counter::createPtr("proxy.process.http2.max_rst_stream_frames_per_minute_exceeded"); + http2_rsb.insufficient_avg_window_update = Metrics::Counter::createPtr("proxy.process.http2.insufficient_avg_window_update"); + http2_rsb.max_concurrent_streams_exceeded_in = + Metrics::Counter::createPtr("proxy.process.http2.max_concurrent_streams_exceeded_in"); + http2_rsb.max_concurrent_streams_exceeded_out = + Metrics::Counter::createPtr("proxy.process.http2.max_concurrent_streams_exceeded_out"); http2_init(); } diff --git a/src/proxy/http2/Http2ClientSession.cc b/src/proxy/http2/Http2ClientSession.cc index b7d97c0a8a2..a044618e5b3 100644 --- a/src/proxy/http2/Http2ClientSession.cc +++ b/src/proxy/http2/Http2ClientSession.cc @@ -60,7 +60,7 @@ Http2ClientSession::free() { auto mutex_thread = this->mutex->thread_holding; if (Http2CommonSession::common_free(this)) { - Counter::decrement(http2_rsb.current_client_session_count); + Metrics::Counter::decrement(http2_rsb.current_client_session_count); THREAD_FREE(this, http2ClientSessionAllocator, mutex_thread); } } @@ -88,8 +88,8 @@ void Http2ClientSession::new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOBufferReader *reader) { ink_assert(new_vc->mutex->thread_holding == this_ethread()); - Counter::increment(http2_rsb.current_client_session_count); - Counter::increment(http2_rsb.total_client_connection_count); + Metrics::Counter::increment(http2_rsb.current_client_session_count); + Metrics::Counter::increment(http2_rsb.total_client_connection_count); this->_milestones.mark(Http2SsnMilestone::OPEN); // Unique client session identifier. @@ -254,13 +254,13 @@ Http2ClientSession::main_event_handler(int event, void *edata) void Http2ClientSession::increment_current_active_connections_stat() { - Counter::increment(http2_rsb.current_active_client_connection_count); + Metrics::Counter::increment(http2_rsb.current_active_client_connection_count); } void Http2ClientSession::decrement_current_active_connections_stat() { - Counter::decrement(http2_rsb.current_active_client_connection_count); + Metrics::Counter::decrement(http2_rsb.current_active_client_connection_count); } sockaddr const * diff --git a/src/proxy/http2/Http2CommonSession.cc b/src/proxy/http2/Http2CommonSession.cc index 4de93584ace..cc4a357523c 100644 --- a/src/proxy/http2/Http2CommonSession.cc +++ b/src/proxy/http2/Http2CommonSession.cc @@ -98,32 +98,32 @@ Http2CommonSession::common_free(ProxySession *ssn) if (cause_of_death != Http2SessionCod::NOT_PROVIDED) { switch (cause_of_death) { case Http2SessionCod::HIGH_ERROR_RATE: - Counter::increment(http2_rsb.session_die_high_error_rate); + Metrics::Counter::increment(http2_rsb.session_die_high_error_rate); break; case Http2SessionCod::NOT_PROVIDED: // Can't happen but this case is here to not have default case. - Counter::increment(http2_rsb.session_die_other); + Metrics::Counter::increment(http2_rsb.session_die_other); break; } } else { switch (dying_event) { case VC_EVENT_NONE: - Counter::increment(http2_rsb.session_die_default); + Metrics::Counter::increment(http2_rsb.session_die_default); break; case VC_EVENT_ACTIVE_TIMEOUT: - Counter::increment(http2_rsb.session_die_active); + Metrics::Counter::increment(http2_rsb.session_die_active); break; case VC_EVENT_INACTIVITY_TIMEOUT: - Counter::increment(http2_rsb.session_die_inactive); + Metrics::Counter::increment(http2_rsb.session_die_inactive); break; case VC_EVENT_ERROR: - Counter::increment(http2_rsb.session_die_error); + Metrics::Counter::increment(http2_rsb.session_die_error); break; case VC_EVENT_EOS: - Counter::increment(http2_rsb.session_die_eos); + Metrics::Counter::increment(http2_rsb.session_die_eos); break; default: - Counter::increment(http2_rsb.session_die_other); + Metrics::Counter::increment(http2_rsb.session_die_other); break; } } diff --git a/src/proxy/http2/Http2ConnectionState.cc b/src/proxy/http2/Http2ConnectionState.cc index 4a28a240d9e..f244a3c817b 100644 --- a/src/proxy/http2/Http2ConnectionState.cc +++ b/src/proxy/http2/Http2ConnectionState.cc @@ -553,7 +553,7 @@ Http2ConnectionState::rcv_priority_frame(const Http2Frame &frame) // Close this connection if its priority frame count received exceeds a limit if (configured_max_priority_frames_per_minute != 0 && this->get_received_priority_frame_count() > configured_max_priority_frames_per_minute) { - Counter::increment(http2_rsb.max_priority_frames_per_minute_exceeded); + Metrics::Counter::increment(http2_rsb.max_priority_frames_per_minute_exceeded); Http2StreamDebug(this->session, stream_id, "Observed too frequent priority changes: %u priority changes within a last minute", this->get_received_priority_frame_count()); return Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_CONNECTION, Http2ErrorCode::HTTP2_ERROR_ENHANCE_YOUR_CALM, @@ -628,7 +628,7 @@ Http2ConnectionState::rcv_rst_stream_frame(const Http2Frame &frame) // Close this connection if its RST_STREAM frame count exceeds a limit if (configured_max_rst_stream_frames_per_minute != 0 && this->get_received_rst_stream_frame_count() > configured_max_rst_stream_frames_per_minute) { - Counter::increment(http2_rsb.max_rst_stream_frames_per_minute_exceeded); + Metrics::Counter::increment(http2_rsb.max_rst_stream_frames_per_minute_exceeded); Http2StreamDebug(this->session, stream_id, "Observed too frequent RST_STREAM frames: %u frames within a last minute", this->get_received_rst_stream_frame_count()); return Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_CONNECTION, Http2ErrorCode::HTTP2_ERROR_ENHANCE_YOUR_CALM, @@ -677,7 +677,7 @@ Http2ConnectionState::rcv_settings_frame(const Http2Frame &frame) // Close this connection if its SETTINGS frame count exceeds a limit if (configured_max_settings_frames_per_minute != 0 && this->get_received_settings_frame_count() > configured_max_settings_frames_per_minute) { - Counter::increment(http2_rsb.max_settings_frames_per_minute_exceeded); + Metrics::Counter::increment(http2_rsb.max_settings_frames_per_minute_exceeded); Http2StreamDebug(this->session, stream_id, "Observed too frequent SETTINGS frames: %u frames within a last minute", this->get_received_settings_frame_count()); return Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_CONNECTION, Http2ErrorCode::HTTP2_ERROR_ENHANCE_YOUR_CALM, @@ -717,7 +717,7 @@ Http2ConnectionState::rcv_settings_frame(const Http2Frame &frame) uint32_t n_settings = 0; while (nbytes < frame.header().length) { if (n_settings >= Http2::max_settings_per_frame) { - Counter::increment(http2_rsb.max_settings_per_frame_exceeded); + Metrics::Counter::increment(http2_rsb.max_settings_per_frame_exceeded); Http2StreamDebug(this->session, stream_id, "Observed too many settings in a frame"); return Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_CONNECTION, Http2ErrorCode::HTTP2_ERROR_ENHANCE_YOUR_CALM, "recv settings too many settings in a frame"); @@ -758,7 +758,7 @@ Http2ConnectionState::rcv_settings_frame(const Http2Frame &frame) this->increment_received_settings_count(n_settings); // Close this connection if its settings count received exceeds a limit if (this->get_received_settings_count() > Http2::max_settings_per_minute) { - Counter::increment(http2_rsb.max_settings_per_minute_exceeded); + Metrics::Counter::increment(http2_rsb.max_settings_per_minute_exceeded); Http2StreamDebug(this->session, stream_id, "Observed too frequent setting changes: %u settings within a last minute", this->get_received_settings_count()); return Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_CONNECTION, Http2ErrorCode::HTTP2_ERROR_ENHANCE_YOUR_CALM, @@ -812,7 +812,7 @@ Http2ConnectionState::rcv_ping_frame(const Http2Frame &frame) this->increment_received_ping_frame_count(); // Close this connection if its ping count received exceeds a limit if (configured_max_ping_frames_per_minute != 0 && this->get_received_ping_frame_count() > configured_max_ping_frames_per_minute) { - Counter::increment(http2_rsb.max_ping_frames_per_minute_exceeded); + Metrics::Counter::increment(http2_rsb.max_ping_frames_per_minute_exceeded); Http2StreamDebug(this->session, stream_id, "Observed too frequent PING frames: %u PING frames within a last minute", this->get_received_ping_frame_count()); return Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_CONNECTION, Http2ErrorCode::HTTP2_ERROR_ENHANCE_YOUR_CALM, @@ -1683,8 +1683,8 @@ Http2ConnectionState::create_stream(Http2StreamId new_id, Http2Error &error) } // If we haven't got the peers settings yet, just hope for the best if (check_max_concurrent_limit >= 0 && check_count >= check_max_concurrent_limit) { - Counter::increment(is_client_streamid ? http2_rsb.max_concurrent_streams_exceeded_in : - http2_rsb.max_concurrent_streams_exceeded_out); + Metrics::Counter::increment(is_client_streamid ? http2_rsb.max_concurrent_streams_exceeded_in : + http2_rsb.max_concurrent_streams_exceeded_out); error = Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_STREAM, Http2ErrorCode::HTTP2_ERROR_REFUSED_STREAM, "recv headers creating stream beyond max_concurrent limit"); return nullptr; @@ -2441,7 +2441,7 @@ Http2ConnectionState::send_rst_stream_frame(Http2StreamId id, Http2ErrorCode ec) Http2StreamDebug(session, id, "Send RST_STREAM frame"); if (ec != Http2ErrorCode::HTTP2_ERROR_NO_ERROR) { - Counter::increment(http2_rsb.stream_errors_count); + Metrics::Counter::increment(http2_rsb.stream_errors_count); ++stream_error_count; } @@ -2549,7 +2549,7 @@ Http2ConnectionState::send_goaway_frame(Http2StreamId id, Http2ErrorCode ec) Http2ConDebug(session, "Send GOAWAY frame, last_stream_id: %d", id); if (ec != Http2ErrorCode::HTTP2_ERROR_NO_ERROR) { - Counter::increment(http2_rsb.connection_errors_count); + Metrics::Counter::increment(http2_rsb.connection_errors_count); } this->tx_error_code = {ProxyErrorClass::SSN, static_cast(ec)}; @@ -2649,7 +2649,7 @@ Http2ConnectionState::_adjust_concurrent_stream() return max_concurrent_streams; } - int64_t current_client_streams = Counter::read(http2_rsb.current_client_stream_count); + int64_t current_client_streams = Metrics::Counter::read(http2_rsb.current_client_stream_count); Http2ConDebug(session, "current client streams: %" PRId64, current_client_streams); @@ -2718,7 +2718,7 @@ Http2ConnectionState::increment_peer_rwnd(size_t amount) double sum = std::accumulate(this->_recent_rwnd_increment.begin(), this->_recent_rwnd_increment.end(), 0.0); double avg = sum / this->_recent_rwnd_increment.size(); if (avg < Http2::min_avg_window_update) { - Counter::increment(http2_rsb.insufficient_avg_window_update); + Metrics::Counter::increment(http2_rsb.insufficient_avg_window_update); return Http2ErrorCode::HTTP2_ERROR_ENHANCE_YOUR_CALM; } return Http2ErrorCode::HTTP2_ERROR_NO_ERROR; diff --git a/src/proxy/http2/Http2ServerSession.cc b/src/proxy/http2/Http2ServerSession.cc index e53c73a4ba5..5e84494bb82 100644 --- a/src/proxy/http2/Http2ServerSession.cc +++ b/src/proxy/http2/Http2ServerSession.cc @@ -61,7 +61,7 @@ Http2ServerSession::free() { auto mutex_thread = this->mutex->thread_holding; if (Http2CommonSession::common_free(this)) { - Counter::decrement(http2_rsb.current_server_session_count); + Metrics::Counter::decrement(http2_rsb.current_server_session_count); THREAD_FREE(this, http2ServerSessionAllocator, mutex_thread); } } @@ -96,8 +96,8 @@ Http2ServerSession::new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOB { ink_assert(new_vc->mutex->thread_holding == this_ethread()); - Counter::increment(http2_rsb.current_server_session_count); - Counter::increment(http2_rsb.total_server_connection_count); + Metrics::Counter::increment(http2_rsb.current_server_session_count); + Metrics::Counter::increment(http2_rsb.total_server_connection_count); this->_milestones.mark(Http2SsnMilestone::OPEN); // Unique client session identifier. diff --git a/src/proxy/http2/Http2SessionAccept.cc b/src/proxy/http2/Http2SessionAccept.cc index 07e038274ce..e7650741861 100644 --- a/src/proxy/http2/Http2SessionAccept.cc +++ b/src/proxy/http2/Http2SessionAccept.cc @@ -81,8 +81,9 @@ Http2SessionAccept::mainEvent(int event, void *data) // XXX We should hoist the error handling so that all the protocols generate the statistics // without code duplication. if (((long)data) == -ECONNABORTED) { - Counter::increment(http_rsb.ua_counts_errors_pre_accept_hangups); - // Counter::increment(http_rsb.ua_msecs_errors_pre_accept_hangups, 0); // ToDo: This is odd, but we added 0 before as well + Metrics::Counter::increment(http_rsb.ua_counts_errors_pre_accept_hangups); + // Metrics::Counter::increment(http_rsb.ua_msecs_errors_pre_accept_hangups, 0); // ToDo: This is odd, but we added 0 before as + // well } ink_abort("HTTP/2 accept received fatal error: errno = %d", -(static_cast((intptr_t)data))); diff --git a/src/proxy/http2/Http2Stream.cc b/src/proxy/http2/Http2Stream.cc index 91b110cfdd7..a7f36a39d28 100644 --- a/src/proxy/http2/Http2Stream.cc +++ b/src/proxy/http2/Http2Stream.cc @@ -121,7 +121,7 @@ Http2Stream::~Http2Stream() this->_milestones.mark(Http2StreamMilestone::CLOSE); ink_hrtime total_time = this->_milestones.elapsed(Http2StreamMilestone::OPEN, Http2StreamMilestone::CLOSE); - Counter::increment(http2_rsb.total_transactions_time, total_time); + Metrics::Counter::increment(http2_rsb.total_transactions_time, total_time); // Slow Log if (Http2::stream_slow_log_threshold != 0 && ink_hrtime_from_msec(Http2::stream_slow_log_threshold) < total_time) { @@ -1030,11 +1030,11 @@ void Http2Stream::increment_transactions_stat() { if (this->is_outbound_connection()) { - Counter::increment(http2_rsb.current_server_stream_count); - Counter::increment(http2_rsb.total_server_stream_count); + Metrics::Counter::increment(http2_rsb.current_server_stream_count); + Metrics::Counter::increment(http2_rsb.total_server_stream_count); } else { - Counter::increment(http2_rsb.current_client_stream_count); - Counter::increment(http2_rsb.total_client_stream_count); + Metrics::Counter::increment(http2_rsb.current_client_stream_count); + Metrics::Counter::increment(http2_rsb.total_client_stream_count); } } @@ -1042,9 +1042,9 @@ void Http2Stream::decrement_transactions_stat() { if (this->is_outbound_connection()) { - Counter::decrement(http2_rsb.current_server_stream_count); + Metrics::Counter::decrement(http2_rsb.current_server_stream_count); } else { - Counter::decrement(http2_rsb.current_client_stream_count); + Metrics::Counter::decrement(http2_rsb.current_client_stream_count); } } diff --git a/src/proxy/http3/Http3.cc b/src/proxy/http3/Http3.cc index 8c55d79edf7..f2c87063c7a 100644 --- a/src/proxy/http3/Http3.cc +++ b/src/proxy/http3/Http3.cc @@ -37,5 +37,5 @@ Http3::init() // Example (remove comments here when addding) // // Setup statistics - // http3_rsb.current_client_session_count = Counter::CreatePtr("proxy.process.http3.current_client_connections"); + // http3_rsb.current_client_session_count = Metrics::Counter::createPtr("proxy.process.http3.current_client_connections"); } diff --git a/src/proxy/logging/Log.cc b/src/proxy/logging/Log.cc index 8e43209d036..312a599637e 100644 --- a/src/proxy/logging/Log.cc +++ b/src/proxy/logging/Log.cc @@ -1170,7 +1170,7 @@ Log::access(LogAccess *lad) this_sample = sample++; if (this_sample && this_sample % Log::config->sampling_frequency) { Debug("log", "sampling, skipping this entry ..."); - Counter::increment(log_rsb.event_log_access_skip); + Metrics::Counter::increment(log_rsb.event_log_access_skip); ret = Log::SKIP; goto done; } else { @@ -1181,7 +1181,7 @@ Log::access(LogAccess *lad) if (Log::config->log_object_manager.get_num_objects() == 0) { Debug("log", "no log objects, skipping this entry ..."); - Counter::increment(log_rsb.event_log_access_skip); + Metrics::Counter::increment(log_rsb.event_log_access_skip); ret = Log::SKIP; goto done; } @@ -1225,19 +1225,19 @@ Log::va_error(const char *format, va_list ap) switch (ret_val) { case Log::LOG_OK: - Counter::increment(log_rsb.event_log_error_ok); + Metrics::Counter::increment(log_rsb.event_log_error_ok); break; case Log::SKIP: - Counter::increment(log_rsb.event_log_error_skip); + Metrics::Counter::increment(log_rsb.event_log_error_skip); break; case Log::AGGR: - Counter::increment(log_rsb.event_log_error_aggr); + Metrics::Counter::increment(log_rsb.event_log_error_aggr); break; case Log::FULL: - Counter::increment(log_rsb.event_log_error_full); + Metrics::Counter::increment(log_rsb.event_log_error_full); break; case Log::FAIL: - Counter::increment(log_rsb.event_log_error_fail); + Metrics::Counter::increment(log_rsb.event_log_error_fail); break; default: ink_release_assert(!"Unexpected result"); @@ -1246,7 +1246,7 @@ Log::va_error(const char *format, va_list ap) return ret_val; } - Counter::increment(log_rsb.event_log_error_skip); + Metrics::Counter::increment(log_rsb.event_log_error_skip); return ret_val; } @@ -1349,7 +1349,7 @@ Log::flush_thread_main(void * /* args ATS_UNUSED */) if (!logfile->is_open()) { SiteThrottledWarning("File:%s was closed, have dropped (%d) bytes.", logfile->get_name(), total_bytes); - Counter::increment(log_rsb.bytes_lost_before_written_to_disk, total_bytes); + Metrics::Counter::increment(log_rsb.bytes_lost_before_written_to_disk, total_bytes); delete fdata; continue; } @@ -1365,7 +1365,7 @@ Log::flush_thread_main(void * /* args ATS_UNUSED */) Debug("log", "logging space exhausted, failed to write file:%s, have dropped (%d) bytes.", logfile->get_name(), (total_bytes - bytes_written)); - Counter::increment(log_rsb.bytes_lost_before_written_to_disk, total_bytes - bytes_written); + Metrics::Counter::increment(log_rsb.bytes_lost_before_written_to_disk, total_bytes - bytes_written); break; } @@ -1375,14 +1375,14 @@ Log::flush_thread_main(void * /* args ATS_UNUSED */) SiteThrottledError("Failed to write log to %s: [tried %d, wrote %d, %s]", logfile->get_name(), total_bytes - bytes_written, bytes_written, strerror(errno)); - Counter::increment(log_rsb.bytes_lost_before_written_to_disk, total_bytes - bytes_written); + Metrics::Counter::increment(log_rsb.bytes_lost_before_written_to_disk, total_bytes - bytes_written); break; } Debug("log", "Successfully wrote some stuff to %s", logfile->get_name()); bytes_written += len; } - Counter::increment(log_rsb.bytes_written_to_disk, bytes_written); + Metrics::Counter::increment(log_rsb.bytes_written_to_disk, bytes_written); if (logfile->m_log) { ink_atomic_increment(&logfile->m_log->m_bytes_written, bytes_written); diff --git a/src/proxy/logging/LogAccess.cc b/src/proxy/logging/LogAccess.cc index 555369ab0c1..c3f4f175d64 100644 --- a/src/proxy/logging/LogAccess.cc +++ b/src/proxy/logging/LogAccess.cc @@ -216,10 +216,10 @@ LogAccess::marshal_record(char *record, char *buf) // Since, for now at least, String metrics are still in librecords, do that lookup // first, and only do the new metrics lookup on a miss. if (RecGetRecordDataType(record, &stype) != REC_ERR_OKAY) { - ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); - ts::Metrics::Counter::IdType mid = metrics[record]; + ts::Metrics &metrics = ts::Metrics::instance(); + ts::Metrics::IdType mid = metrics[record]; - if (mid != ts::Metrics::Counter::NOT_FOUND) { + if (mid != ts::Metrics::NOT_FOUND) { int64_t val = metrics[mid]; out_buf = int64_to_str(ascii_buf, max_chars, val, &num_chars); diff --git a/src/proxy/logging/LogConfig.cc b/src/proxy/logging/LogConfig.cc index 9c2a42979ea..e9c2fca1efc 100644 --- a/src/proxy/logging/LogConfig.cc +++ b/src/proxy/logging/LogConfig.cc @@ -508,31 +508,31 @@ LogConfig::register_stat_callbacks() // // events // - log_rsb.event_log_error_skip = Counter::CreatePtr("proxy.process.log.event_log_error_skip"); - log_rsb.event_log_error_ok = Counter::CreatePtr("proxy.process.log.event_log_error_ok"); - log_rsb.event_log_error_aggr = Counter::CreatePtr("proxy.process.log.event_log_error_aggr"); - log_rsb.event_log_error_full = Counter::CreatePtr("proxy.process.log.event_log_error_full"); - log_rsb.event_log_error_fail = Counter::CreatePtr("proxy.process.log.event_log_error_fail"); - log_rsb.event_log_access_ok = Counter::CreatePtr("proxy.process.log.event_log_access_ok"); - log_rsb.event_log_access_skip = Counter::CreatePtr("proxy.process.log.event_log_access_skip"); - log_rsb.event_log_access_aggr = Counter::CreatePtr("proxy.process.log.event_log_access_aggr"); - log_rsb.event_log_access_full = Counter::CreatePtr("proxy.process.log.event_log_access_full"); - log_rsb.event_log_access_fail = Counter::CreatePtr("proxy.process.log.event_log_access_fail"); - log_rsb.num_sent_to_network = Counter::CreatePtr("proxy.process.log.num_sent_to_network"); - log_rsb.num_lost_before_sent_to_network = Counter::CreatePtr("proxy.process.log.num_lost_before_sent_to_network"); - log_rsb.num_received_from_network = Counter::CreatePtr("proxy.process.log.num_received_from_network"); - log_rsb.num_flush_to_disk = Counter::CreatePtr("proxy.process.log.num_flush_to_disk"); - log_rsb.num_lost_before_flush_to_disk = Counter::CreatePtr("proxy.process.log.num_lost_before_flush_to_disk"); - log_rsb.bytes_lost_before_preproc = Counter::CreatePtr("proxy.process.log.bytes_lost_before_preproc"); - log_rsb.bytes_sent_to_network = Counter::CreatePtr("proxy.process.log.bytes_sent_to_network"); - log_rsb.bytes_lost_before_sent_to_network = Counter::CreatePtr("proxy.process.log.bytes_lost_before_sent_to_network"); - log_rsb.bytes_received_from_network = Counter::CreatePtr("proxy.process.log.bytes_received_from_network"); - log_rsb.bytes_flush_to_disk = Counter::CreatePtr("proxy.process.log.bytes_flush_to_disk"); - log_rsb.bytes_lost_before_flush_to_disk = Counter::CreatePtr("proxy.process.log.bytes_lost_before_flush_to_disk"); - log_rsb.bytes_written_to_disk = Counter::CreatePtr("proxy.process.log.bytes_written_to_disk"); - log_rsb.bytes_lost_before_written_to_disk = Counter::CreatePtr("proxy.process.log.bytes_lost_before_written_to_disk"); - log_rsb.log_files_open = Counter::CreatePtr("proxy.process.log.log_files_open"); - log_rsb.log_files_space_used = Counter::CreatePtr("proxy.process.log.log_files_space_used"); + log_rsb.event_log_error_skip = Metrics::Counter::createPtr("proxy.process.log.event_log_error_skip"); + log_rsb.event_log_error_ok = Metrics::Counter::createPtr("proxy.process.log.event_log_error_ok"); + log_rsb.event_log_error_aggr = Metrics::Counter::createPtr("proxy.process.log.event_log_error_aggr"); + log_rsb.event_log_error_full = Metrics::Counter::createPtr("proxy.process.log.event_log_error_full"); + log_rsb.event_log_error_fail = Metrics::Counter::createPtr("proxy.process.log.event_log_error_fail"); + log_rsb.event_log_access_ok = Metrics::Counter::createPtr("proxy.process.log.event_log_access_ok"); + log_rsb.event_log_access_skip = Metrics::Counter::createPtr("proxy.process.log.event_log_access_skip"); + log_rsb.event_log_access_aggr = Metrics::Counter::createPtr("proxy.process.log.event_log_access_aggr"); + log_rsb.event_log_access_full = Metrics::Counter::createPtr("proxy.process.log.event_log_access_full"); + log_rsb.event_log_access_fail = Metrics::Counter::createPtr("proxy.process.log.event_log_access_fail"); + log_rsb.num_sent_to_network = Metrics::Counter::createPtr("proxy.process.log.num_sent_to_network"); + log_rsb.num_lost_before_sent_to_network = Metrics::Counter::createPtr("proxy.process.log.num_lost_before_sent_to_network"); + log_rsb.num_received_from_network = Metrics::Counter::createPtr("proxy.process.log.num_received_from_network"); + log_rsb.num_flush_to_disk = Metrics::Counter::createPtr("proxy.process.log.num_flush_to_disk"); + log_rsb.num_lost_before_flush_to_disk = Metrics::Counter::createPtr("proxy.process.log.num_lost_before_flush_to_disk"); + log_rsb.bytes_lost_before_preproc = Metrics::Counter::createPtr("proxy.process.log.bytes_lost_before_preproc"); + log_rsb.bytes_sent_to_network = Metrics::Counter::createPtr("proxy.process.log.bytes_sent_to_network"); + log_rsb.bytes_lost_before_sent_to_network = Metrics::Counter::createPtr("proxy.process.log.bytes_lost_before_sent_to_network"); + log_rsb.bytes_received_from_network = Metrics::Counter::createPtr("proxy.process.log.bytes_received_from_network"); + log_rsb.bytes_flush_to_disk = Metrics::Counter::createPtr("proxy.process.log.bytes_flush_to_disk"); + log_rsb.bytes_lost_before_flush_to_disk = Metrics::Counter::createPtr("proxy.process.log.bytes_lost_before_flush_to_disk"); + log_rsb.bytes_written_to_disk = Metrics::Counter::createPtr("proxy.process.log.bytes_written_to_disk"); + log_rsb.bytes_lost_before_written_to_disk = Metrics::Counter::createPtr("proxy.process.log.bytes_lost_before_written_to_disk"); + log_rsb.log_files_open = Metrics::Counter::createPtr("proxy.process.log.log_files_open"); + log_rsb.log_files_space_used = Metrics::Counter::createPtr("proxy.process.log.log_files_space_used"); } /*------------------------------------------------------------------------- @@ -658,7 +658,7 @@ LogConfig::update_space_used() // m_space_used = total_space_used; m_partition_space_left = partition_space_left; - Counter::write(log_rsb.log_files_space_used, m_space_used); + Metrics::Counter::write(log_rsb.log_files_space_used, m_space_used); Debug("logspace", "%" PRId64 " bytes being used for logs", m_space_used); Debug("logspace", "%" PRId64 " bytes left on partition", m_partition_space_left); diff --git a/src/proxy/logging/LogFile.cc b/src/proxy/logging/LogFile.cc index 459aa8ff703..269ccaa004b 100644 --- a/src/proxy/logging/LogFile.cc +++ b/src/proxy/logging/LogFile.cc @@ -223,7 +223,7 @@ LogFile::open_file() } } - Counter::increment(log_rsb.log_files_open); + Metrics::Counter::increment(log_rsb.log_files_open); Debug("log", "exiting LogFile::open_file(), file=%s presumably open", m_name); return LOG_FILE_NO_ERROR; @@ -244,7 +244,7 @@ LogFile::close_file() Error("Error closing LogFile %s: %s.", m_name, strerror(errno)); } else { Debug("log-file", "LogFile %s (fd=%d) is closed", m_name, m_fd); - Counter::decrement(log_rsb.log_files_open); + Metrics::Counter::decrement(log_rsb.log_files_open); } m_fd = -1; } else if (m_log) { @@ -252,7 +252,7 @@ LogFile::close_file() Error("Error closing LogFile %s: %s.", m_log->get_name(), strerror(errno)); } else { Debug("log-file", "LogFile %s is closed", m_log->get_name()); - Counter::decrement(log_rsb.log_files_open); + Metrics::Counter::decrement(log_rsb.log_files_open); } } else { Warning("LogFile %s is open but was not closed", m_name); @@ -454,8 +454,8 @@ LogFile::preproc_and_try_delete(LogBuffer *lb) // LogFlushData *flush_data = new LogFlushData(this, lb); - Counter::increment(log_rsb.num_flush_to_disk, lb->header()->entry_count); - Counter::increment(log_rsb.bytes_flush_to_disk, lb->header()->byte_count); + Metrics::Counter::increment(log_rsb.num_flush_to_disk, lb->header()->entry_count); + Metrics::Counter::increment(log_rsb.bytes_flush_to_disk, lb->header()->byte_count); ink_atomiclist_push(Log::flush_data_list, flush_data); @@ -613,8 +613,8 @@ LogFile::write_ascii_logbuffer3(LogBufferHeader *buffer_header, const char *alt_ } else { Note("Failed to convert LogBuffer to ascii, have dropped (%" PRIu32 ") bytes.", entry_header->entry_len); - Counter::increment(log_rsb.num_lost_before_flush_to_disk, fmt_entry_count); - Counter::increment(log_rsb.bytes_lost_before_flush_to_disk, fmt_buf_bytes); + Metrics::Counter::increment(log_rsb.num_lost_before_flush_to_disk, fmt_entry_count); + Metrics::Counter::increment(log_rsb.bytes_lost_before_flush_to_disk, fmt_buf_bytes); } // if writing to a pipe, fill the buffer with a single // record to avoid as much as possible overflowing the @@ -633,8 +633,8 @@ LogFile::write_ascii_logbuffer3(LogBufferHeader *buffer_header, const char *alt_ // LogFlushData *flush_data = new LogFlushData(this, ascii_buffer, fmt_buf_bytes); - Counter::increment(log_rsb.num_flush_to_disk, fmt_entry_count); - Counter::increment(log_rsb.bytes_flush_to_disk, fmt_buf_bytes); + Metrics::Counter::increment(log_rsb.num_flush_to_disk, fmt_entry_count); + Metrics::Counter::increment(log_rsb.bytes_flush_to_disk, fmt_buf_bytes); ink_atomiclist_push(Log::flush_data_list, flush_data); diff --git a/src/proxy/logging/LogObject.cc b/src/proxy/logging/LogObject.cc index e39ea2de4e0..e0dfba210fe 100644 --- a/src/proxy/logging/LogObject.cc +++ b/src/proxy/logging/LogObject.cc @@ -66,7 +66,7 @@ LogBufferManager::preproc_buffers(LogBufferSink *sink) } else if (_num_flush_buffers > FLUSH_ARRAY_SIZE) { ink_atomic_increment(&_num_flush_buffers, -1); Warning("Dropping log buffer, can't keep up."); - Counter::increment(log_rsb.bytes_lost_before_preproc, b->header()->byte_count); + Metrics::Counter::increment(log_rsb.bytes_lost_before_preproc, b->header()->byte_count); delete b; } else { new_q.push(b); @@ -1349,15 +1349,15 @@ LogObjectManager::log(LogAccess *lad) // The if-statement should keep step with the priority order. // if (unlikely(ret & Log::FAIL)) { - Counter::increment(log_rsb.event_log_access_fail); + Metrics::Counter::increment(log_rsb.event_log_access_fail); } else if (unlikely(ret & Log::FULL)) { - Counter::increment(log_rsb.event_log_access_full); + Metrics::Counter::increment(log_rsb.event_log_access_full); } else if (likely(ret & Log::LOG_OK)) { - Counter::increment(log_rsb.event_log_access_ok); + Metrics::Counter::increment(log_rsb.event_log_access_ok); } else if (unlikely(ret & Log::AGGR)) { - Counter::increment(log_rsb.event_log_access_aggr); + Metrics::Counter::increment(log_rsb.event_log_access_aggr); } else if (likely(ret & Log::SKIP)) { - Counter::increment(log_rsb.event_log_access_skip); + Metrics::Counter::increment(log_rsb.event_log_access_skip); } else { ink_release_assert(!"Unexpected result"); } diff --git a/src/records/RecCore.cc b/src/records/RecCore.cc index c89defde616..1d41cebb413 100644 --- a/src/records/RecCore.cc +++ b/src/records/RecCore.cc @@ -36,12 +36,6 @@ #include "tscpp/util/ts_errata.h" #include "api/Metrics.h" -#include -#include - -#include -#include - using ts::Metrics; // This is needed to manage the size of the librecords record. It can't be static, because it needs to be modified @@ -516,9 +510,9 @@ RecGetRecordBool(const char *name, RecBool *rec_bool, bool lock) RecErrT RecLookupRecord(const char *name, void (*callback)(const RecRecord *, void *), void *data, bool lock) { - RecErrT err = REC_ERR_FAIL; - ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); - auto it = metrics.find(name); + RecErrT err = REC_ERR_FAIL; + ts::Metrics &metrics = ts::Metrics::instance(); + auto it = metrics.find(name); if (it != metrics.end()) { RecRecord r; @@ -570,7 +564,7 @@ RecLookupMatchingRecords(unsigned rec_type, const char *match, void (*callback)( tmp.rec_type = RECT_ALL; tmp.data_type = RECD_INT; - for (auto &&[name, val] : ts::Metrics::Counter::getInstance()) { + for (auto &&[name, val] : ts::Metrics::instance()) { if (regex.match(name.data()) >= 0) { tmp.name = name.data(); tmp.data.rec_int = val; @@ -902,7 +896,7 @@ RecDumpRecords(RecT rec_type, RecDumpEntryCb callback, void *edata) // Dump all new metrics as well (no "type" for them) RecData datum; - for (auto &&[name, val] : ts::Metrics::Counter::getInstance()) { + for (auto &&[name, val] : ts::Metrics::instance()) { datum.rec_int = val; callback(RECT_PLUGIN, edata, true, name.data(), TS_RECORDDATATYPE_INT, &datum); } diff --git a/src/traffic_server/traffic_server.cc b/src/traffic_server/traffic_server.cc index ccade8a76c9..fe5c2203b1a 100644 --- a/src/traffic_server/traffic_server.cc +++ b/src/traffic_server/traffic_server.cc @@ -269,8 +269,8 @@ class SignalContinuation : public Continuation int periodic(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */) { - ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); - static auto drain_id = metrics.lookup("proxy.process.proxy.draining"); + ts::Metrics &metrics = ts::Metrics::instance(); + static auto drain_id = metrics.lookup("proxy.process.proxy.draining"); if (signal_received[SIGUSR1]) { signal_received[SIGUSR1] = false; @@ -426,11 +426,9 @@ class MemoryLimit : public Continuation public: MemoryLimit() : Continuation(new_ProxyMutex()) { - ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); - memset(&_usage, 0, sizeof(_usage)); SET_HANDLER(&MemoryLimit::periodic); - memory_rss = Counter::CreatePtr("proxy.process.traffic_server.memory.rss"); + memory_rss = Metrics::Counter::createPtr("proxy.process.traffic_server.memory.rss"); } ~MemoryLimit() override { mutex = nullptr; } @@ -478,7 +476,7 @@ class MemoryLimit : public Continuation private: int64_t _memory_limit = 0; struct rusage _usage; - Counter::AtomicType *memory_rss; + Metrics::Counter::AtomicType *memory_rss; }; /** Gate the emission of the "Traffic Server is fuly initialized" log message. @@ -805,8 +803,8 @@ CB_After_Cache_Init() emit_fully_initialized_message(); } - ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); - auto id = metrics.lookup("proxy.process.proxy.cache_ready_time"); + ts::Metrics &metrics = ts::Metrics::instance(); + auto id = metrics.lookup("proxy.process.proxy.cache_ready_time"); metrics[id].store(time(nullptr)); @@ -1412,24 +1410,24 @@ struct ShowStats : public Continuation { if (!(cycle++ % 24)) { printf("r:rr w:ww r:rbs w:wbs open polls\n"); } - int64_t d_rb = Counter::read(net_rsb.calls_to_readfromnet) - last_rb; + int64_t d_rb = Metrics::Counter::read(net_rsb.calls_to_readfromnet) - last_rb; last_rb += d_rb; - int64_t d_wb = Counter::read(net_rsb.calls_to_writetonet) - last_wb; + int64_t d_wb = Metrics::Counter::read(net_rsb.calls_to_writetonet) - last_wb; last_wb += d_wb; - int64_t d_nrb = Counter::read(net_rsb.read_bytes) - last_nrb; + int64_t d_nrb = Metrics::Counter::read(net_rsb.read_bytes) - last_nrb; last_nrb += d_nrb; - int64_t d_nr = Counter::read(net_rsb.read_bytes_count) - last_nr; + int64_t d_nr = Metrics::Counter::read(net_rsb.read_bytes_count) - last_nr; last_nr += d_nr; - int64_t d_nwb = Counter::read(net_rsb.write_bytes) - last_nwb; + int64_t d_nwb = Metrics::Counter::read(net_rsb.write_bytes) - last_nwb; last_nwb += d_nwb; - int64_t d_nw = Counter::read(net_rsb.write_bytes_count) - last_nw; + int64_t d_nw = Metrics::Counter::read(net_rsb.write_bytes_count) - last_nw; last_nw += d_nw; - int64_t d_o = Counter::read(net_rsb.connections_currently_open); - int64_t d_p = Counter::read(net_rsb.handler_run) - last_p; + int64_t d_o = Metrics::Counter::read(net_rsb.connections_currently_open); + int64_t d_p = Metrics::Counter::read(net_rsb.handler_run) - last_p; last_p += d_p; printf("%" PRId64 ":%" PRId64 ":%" PRId64 ":%" PRId64 " %" PRId64 ":%" PRId64 " %" PRId64 " %" PRId64 "\n", d_rb, d_wb, d_nrb, @@ -1856,19 +1854,19 @@ main(int /* argc ATS_UNUSED */, const char **argv) syslog_log_configure(); // Register stats - ts::Metrics::Counter &metrics = ts::Metrics::Counter::getInstance(); + ts::Metrics &metrics = ts::Metrics::instance(); int32_t id; - id = metrics.create("proxy.process.proxy.reconfigure_time"); + id = Metrics::Counter::create("proxy.process.proxy.reconfigure_time"); metrics[id] = time(nullptr); - id = metrics.create("proxy.process.proxy.start_time"); + id = Metrics::Counter::create("proxy.process.proxy.start_time"); metrics[id] = time(nullptr); // These all gets initialied to 0 - metrics.create("proxy.process.proxy.reconfigure_required"); - metrics.create("proxy.process.proxy.restart_required"); - metrics.create("proxy.process.proxy.draining"); + Metrics::Counter::create("proxy.process.proxy.reconfigure_required"); + Metrics::Counter::create("proxy.process.proxy.restart_required"); + Metrics::Counter::create("proxy.process.proxy.draining"); // This gets updated later (in the callback) - metrics.create("proxy.process.proxy.cache_ready_time"); + Metrics::Counter::create("proxy.process.proxy.cache_ready_time"); // init huge pages int enabled; From 41f21857055a6865a6c9c375f1a7217f0389e21d Mon Sep 17 00:00:00 2001 From: Leif Hedstrom Date: Fri, 27 Oct 2023 15:29:53 -0600 Subject: [PATCH 4/6] First phase of restricting the Counter class --- include/api/Metrics.h | 83 +++++++----- include/proxy/http/PreWarmManager.h | 16 ++- include/proxy/logging/LogConfig.h | 2 +- src/api/InkAPI.cc | 16 +-- src/api/Metrics.cc | 12 +- src/iocore/aio/test_AIO.cc | 4 +- src/iocore/cache/Cache.cc | 120 +++++++++--------- src/iocore/cache/CacheDir.cc | 40 +++--- src/iocore/cache/CacheDisk.cc | 4 +- src/iocore/cache/P_CacheStats.h | 64 +++++----- src/iocore/io_uring/unit_tests/test_diskIO.cc | 4 +- src/iocore/net/P_UnixNet.h | 2 +- src/iocore/net/SSLStats.cc | 48 +++---- src/iocore/net/SSLStats.h | 8 +- src/mgmt/rpc/handlers/config/Configuration.cc | 4 +- src/mgmt/rpc/handlers/server/Server.cc | 4 +- src/proxy/http/HttpSM.cc | 2 +- src/proxy/http/HttpTransact.cc | 2 +- src/proxy/http/PreWarmManager.cc | 101 +++++++++++---- src/proxy/http2/Http2ConnectionState.cc | 2 +- src/proxy/logging/LogAccess.cc | 2 +- src/proxy/logging/LogConfig.cc | 4 +- src/traffic_server/traffic_server.cc | 40 +++--- 23 files changed, 328 insertions(+), 256 deletions(-) diff --git a/include/api/Metrics.h b/include/api/Metrics.h index a06ba575f75..0d120826f1c 100644 --- a/include/api/Metrics.h +++ b/include/api/Metrics.h @@ -43,8 +43,32 @@ namespace ts class Metrics { private: - using self_type = Metrics; - using AtomicType = std::atomic; // Make sure users don't use this, rather than a proper Counter/Gauge + using self_type = Metrics; + + class AtomicType + { + friend class Metrics; + + public: + AtomicType() = default; + virtual ~AtomicType() = default; + + int64_t + load() + { + return _value.load(); + } + + // ToDo: This is a little sketchy + void + store(int64_t val) + { + _value.store(val); + } + + protected: + std::atomic _value{0}; + }; public: using IdType = int32_t; // Could be a tuple, but one way or another, they have to be combined to an int32_t. @@ -120,7 +144,7 @@ class Metrics { auto metric = lookup(id); - return (metric ? metric->fetch_add(val, MEMORY_ORDER) : NOT_FOUND); + return (metric ? metric->_value.fetch_add(val, MEMORY_ORDER) : NOT_FOUND); } int64_t @@ -128,7 +152,7 @@ class Metrics { auto metric = lookup(id); - return (metric ? metric->fetch_sub(val, MEMORY_ORDER) : NOT_FOUND); + return (metric ? metric->_value.fetch_sub(val, MEMORY_ORDER) : NOT_FOUND); } std::string_view name(IdType id) const; @@ -177,7 +201,7 @@ class Metrics std::string_view name; auto metric = _metrics.lookup(_it, &name); - return std::make_tuple(name, metric->load()); + return std::make_tuple(name, metric->_value.load()); } bool @@ -265,9 +289,12 @@ class Metrics class Gauge { public: - using self_type = Gauge; - using AtomicType = Metrics::AtomicType; - using SpanType = Metrics::SpanType; + using self_type = Gauge; + using SpanType = Metrics::SpanType; + + class AtomicType : public Metrics::AtomicType + { + }; static Metrics::IdType create(const std::string_view name) @@ -282,7 +309,7 @@ class Metrics { auto &instance = Metrics::instance(); - return instance.lookup(instance._create(name)); + return reinterpret_cast(instance.lookup(instance._create(name))); } static Metrics::Gauge::SpanType @@ -297,28 +324,28 @@ class Metrics increment(AtomicType *metric, uint64_t val = 1) { ink_assert(metric); - metric->fetch_add(val, MEMORY_ORDER); + metric->_value.fetch_add(val, MEMORY_ORDER); } static void decrement(AtomicType *metric, uint64_t val = 1) { ink_assert(metric); - metric->fetch_sub(val, MEMORY_ORDER); + metric->_value.fetch_sub(val, MEMORY_ORDER); } static int64_t - read(AtomicType *metric) + load(AtomicType *metric) { ink_assert(metric); - return metric->load(); + return metric->_value.load(); } static void - write(AtomicType *metric, int64_t val) + store(AtomicType *metric, int64_t val) { ink_assert(metric); - return metric->store(val); + return metric->_value.store(val); } }; // class Gauge @@ -326,9 +353,12 @@ class Metrics class Counter { public: - using self_type = Counter; - using AtomicType = Metrics::AtomicType; - using SpanType = Metrics::SpanType; + using self_type = Counter; + using SpanType = Metrics::SpanType; + + class AtomicType : public Metrics::AtomicType + { + }; static Metrics::IdType create(const std::string_view name) @@ -343,7 +373,7 @@ class Metrics { auto &instance = Metrics::instance(); - return instance.lookup(instance._create(name)); + return reinterpret_cast(instance.lookup(instance._create(name))); } static Metrics::Counter::SpanType @@ -358,28 +388,21 @@ class Metrics increment(AtomicType *metric, uint64_t val = 1) { ink_assert(metric); - metric->fetch_add(val, MEMORY_ORDER); + metric->_value.fetch_add(val, MEMORY_ORDER); } static void decrement(AtomicType *metric, uint64_t val = 1) { ink_assert(metric); - metric->fetch_sub(val, MEMORY_ORDER); + metric->_value.fetch_sub(val, MEMORY_ORDER); } static int64_t - read(AtomicType *metric) - { - ink_assert(metric); - return metric->load(); - } - - static void - write(AtomicType *metric, int64_t val) + load(AtomicType *metric) { ink_assert(metric); - return metric->store(val); + return metric->_value.load(); } }; // class Counter diff --git a/include/proxy/http/PreWarmManager.h b/include/proxy/http/PreWarmManager.h index dd37fc09484..f18cec51df4 100644 --- a/include/proxy/http/PreWarmManager.h +++ b/include/proxy/http/PreWarmManager.h @@ -112,10 +112,8 @@ struct Conf { using SPtrConstConf = std::shared_ptr; using ParsedSNIConf = std::unordered_map; -enum class Stat { - INIT_LIST_SIZE = 0, - OPEN_LIST_SIZE, - HIT, +enum class CounterStat { + HIT = 0, MISS, HANDSHAKE_TIME, HANDSHAKE_COUNT, @@ -123,7 +121,15 @@ enum class Stat { LAST_ENTRY, }; -using StatsIds = std::array(PreWarm::Stat::LAST_ENTRY)>; +enum class GaugeStat { + INIT_LIST_SIZE = 0, + OPEN_LIST_SIZE, + LAST_ENTRY, +}; + +using CounterIds = std::array(PreWarm::CounterStat::LAST_ENTRY)>; +using GaugeIds = std::array(PreWarm::GaugeStat::LAST_ENTRY)>; +using StatsIds = std::tuple; using SPtrConstStatsIds = std::shared_ptr; using StatsIdMap = std::unordered_map; } // namespace PreWarm diff --git a/include/proxy/logging/LogConfig.h b/include/proxy/logging/LogConfig.h index ece1f3c30ca..b7e7f00b8bb 100644 --- a/include/proxy/logging/LogConfig.h +++ b/include/proxy/logging/LogConfig.h @@ -61,7 +61,7 @@ struct LogsStatsBlock { Metrics::Counter::AtomicType *bytes_written_to_disk; Metrics::Counter::AtomicType *bytes_lost_before_written_to_disk; Metrics::Counter::AtomicType *log_files_open; - Metrics::Counter::AtomicType *log_files_space_used; + Metrics::Gauge::AtomicType *log_files_space_used; }; extern LogsStatsBlock log_rsb; diff --git a/src/api/InkAPI.cc b/src/api/InkAPI.cc index 9213340547c..a1bf5d1ccea 100644 --- a/src/api/InkAPI.cc +++ b/src/api/InkAPI.cc @@ -6165,20 +6165,20 @@ tsapi::c::TSHttpTxnLookingUpTypeGet(TSHttpTxn txnp) int tsapi::c::TSHttpCurrentClientConnectionsGet() { - return Metrics::Counter::read(http_rsb.current_client_connections); + return Metrics::Counter::load(http_rsb.current_client_connections); } int tsapi::c::TSHttpCurrentActiveClientConnectionsGet() { - return Metrics::Counter::read(http_rsb.current_active_client_connections); + return Metrics::Counter::load(http_rsb.current_active_client_connections); } int tsapi::c::TSHttpCurrentIdleClientConnectionsGet() { - int64_t total = Metrics::Counter::read(http_rsb.current_client_connections); - int64_t active = Metrics::Counter::read(http_rsb.current_active_client_connections); + int64_t total = Metrics::Counter::load(http_rsb.current_client_connections); + int64_t active = Metrics::Counter::load(http_rsb.current_active_client_connections); if (total >= active) { return static_cast(total - active); @@ -6190,13 +6190,13 @@ tsapi::c::TSHttpCurrentIdleClientConnectionsGet() int tsapi::c::TSHttpCurrentCacheConnectionsGet() { - return Metrics::Counter::read(http_rsb.current_cache_connections); + return Metrics::Counter::load(http_rsb.current_cache_connections); } int tsapi::c::TSHttpCurrentServerConnectionsGet() { - return Metrics::Counter::read(http_rsb.current_server_connections); + return Metrics::Counter::load(http_rsb.current_server_connections); } /* HTTP alternate selection */ @@ -7012,14 +7012,14 @@ void tsapi::c::TSStatIntIncrement(int id, TSMgmtInt amount) { sdk_assert(sdk_sanity_check_stat_id(id) == TS_SUCCESS); - global_api_metrics[id].fetch_add(amount, ts::Metrics::MEMORY_ORDER); + global_api_metrics.increment(id, amount); } void tsapi::c::TSStatIntDecrement(int id, TSMgmtInt amount) { sdk_assert(sdk_sanity_check_stat_id(id) == TS_SUCCESS); - global_api_metrics[id].fetch_sub(amount, ts::Metrics::MEMORY_ORDER); + global_api_metrics.decrement(id, amount); } tsapi::c::TSMgmtInt diff --git a/src/api/Metrics.cc b/src/api/Metrics.cc index 6736bcfb750..e7d77cad57d 100644 --- a/src/api/Metrics.cc +++ b/src/api/Metrics.cc @@ -57,12 +57,10 @@ Metrics::_create(std::string_view name) return it->second; } - Metrics::IdType id = _makeId(_cur_blob, _cur_off); - Metrics::NamesAndAtomics *blob = _blobs[_cur_blob]; - Metrics::NameStorage &names = std::get<0>(*blob); - Metrics::AtomicStorage &atomics = std::get<1>(*blob); + Metrics::IdType id = _makeId(_cur_blob, _cur_off); + Metrics::NamesAndAtomics *blob = _blobs[_cur_blob]; + Metrics::NameStorage &names = std::get<0>(*blob); - atomics[_cur_off].store(0); names[_cur_off] = std::make_tuple(std::string(name), id); _lookups.emplace(std::get<0>(names[_cur_off]), id); @@ -86,7 +84,7 @@ Metrics::lookup(const std::string_view name) const return NOT_FOUND; } -Metrics::Counter::AtomicType * +Metrics::AtomicType * Metrics::lookup(Metrics::IdType id, std::string_view *name) const { auto [blob_ix, offset] = _splitID(id); @@ -137,8 +135,6 @@ Metrics::_createSpan(size_t size, Metrics::IdType *id) Metrics::AtomicStorage &atomics = std::get<1>(*blob); Metrics::SpanType span = Metrics::SpanType(&atomics[_cur_off], size); - std::fill(span.begin(), span.end(), 0); - if (id) { *id = span_start; } diff --git a/src/iocore/aio/test_AIO.cc b/src/iocore/aio/test_AIO.cc index 998d8d5a64e..4a54f6563f6 100644 --- a/src/iocore/aio/test_AIO.cc +++ b/src/iocore/aio/test_AIO.cc @@ -226,8 +226,8 @@ dump_summary() Metrics::Counter::AtomicType *completed = m.lookup(m.lookup("proxy.process.io_uring.completed")); Metrics::Counter::AtomicType *submitted = m.lookup(m.lookup("proxy.process.io_uring.submitted")); - printf("submissions: %lu\n", Metrics::Counter::read(submitted)); - printf("completions: %lu\n", Metrics::Counter::read(completed)); + printf("submissions: %lu\n", Metrics::Counter::load(submitted)); + printf("completions: %lu\n", Metrics::Counter::load(completed)); #endif if (delete_disks) { diff --git a/src/iocore/cache/Cache.cc b/src/iocore/cache/Cache.cc index d7912dc251f..3fe2c9be848 100644 --- a/src/iocore/cache/Cache.cc +++ b/src/iocore/cache/Cache.cc @@ -158,38 +158,38 @@ register_cache_stats(CacheStatsBlock *rsb, const std::string prefix) rsb->fragment_document_count[2] = Metrics::Counter::createPtr(prefix + ".frags_per_doc.3+"); // And then everything else - rsb->bytes_used = Metrics::Counter::createPtr(prefix + ".bytes_used"); - rsb->bytes_total = Metrics::Counter::createPtr(prefix + ".bytes_total"); - rsb->stripes = Metrics::Counter::createPtr(prefix + ".stripes"); - rsb->ram_cache_bytes_total = Metrics::Counter::createPtr(prefix + ".ram_cache.total_bytes"); - rsb->ram_cache_bytes = Metrics::Counter::createPtr(prefix + ".ram_cache.bytes_used"); - rsb->ram_cache_hits = Metrics::Counter::createPtr(prefix + ".ram_cache.hits"); - rsb->ram_cache_misses = Metrics::Counter::createPtr(prefix + ".ram_cache.misses"); - rsb->pread_count = Metrics::Counter::createPtr(prefix + ".pread_count"); - rsb->percent_full = Metrics::Counter::createPtr(prefix + ".percent_full"); - rsb->read_seek_fail = Metrics::Counter::createPtr(prefix + ".read.seek.failure"); - rsb->read_invalid = Metrics::Counter::createPtr(prefix + ".read.invalid"); - rsb->write_backlog_failure = Metrics::Counter::createPtr(prefix + ".write.backlog.failure"); - rsb->direntries_total = Metrics::Counter::createPtr(prefix + ".direntries.total"); - rsb->direntries_used = Metrics::Counter::createPtr(prefix + ".direntries.used"); - rsb->directory_collision_count = Metrics::Counter::createPtr(prefix + ".directory_collision"); - rsb->read_busy_success = Metrics::Counter::createPtr(prefix + ".read_busy.success"); - rsb->read_busy_failure = Metrics::Counter::createPtr(prefix + ".read_busy.failure"); - rsb->write_bytes = Metrics::Counter::createPtr(prefix + ".write_bytes_stat"); - rsb->hdr_vector_marshal = Metrics::Counter::createPtr(prefix + ".vector_marshals"); - rsb->hdr_marshal = Metrics::Counter::createPtr(prefix + ".hdr_marshals"); - rsb->hdr_marshal_bytes = Metrics::Counter::createPtr(prefix + ".hdr_marshal_bytes"); - rsb->gc_bytes_evacuated = Metrics::Counter::createPtr(prefix + ".gc_bytes_evacuated"); - rsb->gc_frags_evacuated = Metrics::Counter::createPtr(prefix + ".gc_frags_evacuated"); - rsb->directory_wrap = Metrics::Counter::createPtr(prefix + ".wrap_count"); - rsb->directory_sync_count = Metrics::Counter::createPtr(prefix + ".sync.count"); - rsb->directory_sync_bytes = Metrics::Counter::createPtr(prefix + ".sync.bytes"); - rsb->directory_sync_time = Metrics::Counter::createPtr(prefix + ".sync.time"); - rsb->span_errors_read = Metrics::Counter::createPtr(prefix + ".span.errors.read"); - rsb->span_errors_write = Metrics::Counter::createPtr(prefix + ".span.errors.write"); - rsb->span_failing = Metrics::Counter::createPtr(prefix + ".span.failing"); - rsb->span_offline = Metrics::Counter::createPtr(prefix + ".span.offline"); - rsb->span_online = Metrics::Counter::createPtr(prefix + ".span.online"); + rsb->bytes_used = Metrics::Gauge::createPtr(prefix + ".bytes_used"); + rsb->bytes_total = Metrics::Gauge::createPtr(prefix + ".bytes_total"); + rsb->stripes = Metrics::Gauge::createPtr(prefix + ".stripes"); + rsb->ram_cache_bytes_total = Metrics::Gauge::createPtr(prefix + ".ram_cache.total_bytes"); + rsb->ram_cache_bytes = Metrics::Counter::createPtr(prefix + ".ram_cache.bytes_used"); + rsb->ram_cache_hits = Metrics::Counter::createPtr(prefix + ".ram_cache.hits"); + rsb->ram_cache_misses = Metrics::Counter::createPtr(prefix + ".ram_cache.misses"); + rsb->pread_count = Metrics::Counter::createPtr(prefix + ".pread_count"); + rsb->percent_full = Metrics::Gauge::createPtr(prefix + ".percent_full"); + rsb->read_seek_fail = Metrics::Counter::createPtr(prefix + ".read.seek.failure"); + rsb->read_invalid = Metrics::Counter::createPtr(prefix + ".read.invalid"); + rsb->write_backlog_failure = Metrics::Counter::createPtr(prefix + ".write.backlog.failure"); + rsb->direntries_total = Metrics::Gauge::createPtr(prefix + ".direntries.total"); + rsb->direntries_used = Metrics::Gauge::createPtr(prefix + ".direntries.used"); + rsb->directory_collision = Metrics::Counter::createPtr(prefix + ".directory_collision"); + rsb->read_busy_success = Metrics::Counter::createPtr(prefix + ".read_busy.success"); + rsb->read_busy_failure = Metrics::Counter::createPtr(prefix + ".read_busy.failure"); + rsb->write_bytes = Metrics::Counter::createPtr(prefix + ".write_bytes_stat"); + rsb->hdr_vector_marshal = Metrics::Counter::createPtr(prefix + ".vector_marshals"); + rsb->hdr_marshal = Metrics::Counter::createPtr(prefix + ".hdr_marshals"); + rsb->hdr_marshal_bytes = Metrics::Counter::createPtr(prefix + ".hdr_marshal_bytes"); + rsb->gc_bytes_evacuated = Metrics::Counter::createPtr(prefix + ".gc_bytes_evacuated"); + rsb->gc_frags_evacuated = Metrics::Counter::createPtr(prefix + ".gc_frags_evacuated"); + rsb->directory_wrap = Metrics::Counter::createPtr(prefix + ".wrap_count"); + rsb->directory_sync_count = Metrics::Counter::createPtr(prefix + ".sync.count"); + rsb->directory_sync_bytes = Metrics::Counter::createPtr(prefix + ".sync.bytes"); + rsb->directory_sync_time = Metrics::Counter::createPtr(prefix + ".sync.time"); + rsb->span_errors_read = Metrics::Counter::createPtr(prefix + ".span.errors.read"); + rsb->span_errors_write = Metrics::Counter::createPtr(prefix + ".span.errors.write"); + rsb->span_failing = Metrics::Gauge::createPtr(prefix + ".span.failing"); + rsb->span_offline = Metrics::Gauge::createPtr(prefix + ".span.offline"); + rsb->span_online = Metrics::Gauge::createPtr(prefix + ".span.online"); } // ToDo: This gets called as part of librecords collection continuation, probably change this later. @@ -216,7 +216,7 @@ CachePeriodicMetricsUpdate() // volume metric more than once (once per disk). This happens once every sync // period (5s), and nothing else modifies these metrics. for (int vol_ix = 0; vol_ix < gnvol; ++vol_ix) { - Metrics::Counter::write(gvol[vol_ix]->cache_vol->vol_rsb.bytes_used, 0); + Metrics::Gauge::store(gvol[vol_ix]->cache_vol->vol_rsb.bytes_used, 0); } if (cacheProcessor.initialized == CACHE_INITIALIZED) { @@ -224,15 +224,15 @@ CachePeriodicMetricsUpdate() Stripe *v = gvol[vol_ix]; int64_t used = cache_bytes_used(vol_ix); - Metrics::Counter::increment(v->cache_vol->vol_rsb.bytes_used, used); // This assumes they start at zero + Metrics::Gauge::increment(v->cache_vol->vol_rsb.bytes_used, used); // This assumes they start at zero total_sum += used; } // Also update the global (not per volume) metrics - int64_t total = Metrics::Counter::read(cache_rsb.bytes_total); + int64_t total = Metrics::Gauge::load(cache_rsb.bytes_total); - Metrics::Counter::write(cache_rsb.bytes_used, total_sum); - Metrics::Counter::write(cache_rsb.percent_full, total ? (total_sum * 100) / total : 0); + Metrics::Gauge::store(cache_rsb.bytes_used, total_sum); + Metrics::Gauge::store(cache_rsb.percent_full, total ? (total_sum * 100) / total : 0); } } @@ -509,9 +509,9 @@ CacheProcessor::diskInitialized() /* Practically just took all bad_disks offline so update the stats. */ // ToDo: These don't get update on the per-volume metrics :-/ - Metrics::Counter::write(cache_rsb.span_offline, bad_disks); - Metrics::Counter::decrement(cache_rsb.span_failing, bad_disks); - Metrics::Counter::write(cache_rsb.span_online, gndisks); + Metrics::Gauge::store(cache_rsb.span_offline, bad_disks); + Metrics::Gauge::decrement(cache_rsb.span_failing, bad_disks); + Metrics::Gauge::store(cache_rsb.span_online, gndisks); /* create the cachevol list only if num volumes are greater than 0. */ if (config_volumes.num_volumes == 0) { @@ -657,21 +657,21 @@ CacheProcessor::cacheInitialized() ram_cache_bytes += gvol[i]->dirlen(); Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized - ram_cache_bytes = %" PRId64 " = %" PRId64 "Mb", ram_cache_bytes, ram_cache_bytes / (1024 * 1024)); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes_total, gvol[i]->dirlen()); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.ram_cache_bytes_total, gvol[i]->dirlen()); } vol_total_cache_bytes = gvol[i]->len - gvol[i]->dirlen(); total_cache_bytes += vol_total_cache_bytes; Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized - total_cache_bytes = %" PRId64 " = %" PRId64 "Mb", total_cache_bytes, total_cache_bytes / (1024 * 1024)); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.bytes_total, vol_total_cache_bytes); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.bytes_total, vol_total_cache_bytes); vol_total_direntries = gvol[i]->buckets * gvol[i]->segments * DIR_DEPTH; total_direntries += vol_total_direntries; - Metrics::Counter::increment(vol->cache_vol->vol_rsb.direntries_total, vol_total_direntries); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.direntries_total, vol_total_direntries); vol_used_direntries = dir_entries_used(gvol[i]); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.direntries_used, vol_used_direntries); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.direntries_used, vol_used_direntries); used_direntries += vol_used_direntries; } @@ -704,8 +704,8 @@ CacheProcessor::cacheInitialized() Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized - factor = %f", factor); gvol[i]->ram_cache->init(static_cast(http_ram_cache_size * factor), vol); ram_cache_bytes += static_cast(http_ram_cache_size * factor); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes_total, - static_cast(http_ram_cache_size * factor)); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.ram_cache_bytes_total, + static_cast(http_ram_cache_size * factor)); } else if (gvol[i]->cache_vol->ramcache_enabled) { ink_release_assert(!"Unexpected non-HTTP cache volume"); } @@ -713,17 +713,17 @@ CacheProcessor::cacheInitialized() ram_cache_bytes, ram_cache_bytes / (1024 * 1024)); vol_total_cache_bytes = gvol[i]->len - gvol[i]->dirlen(); total_cache_bytes += vol_total_cache_bytes; - Metrics::Counter::increment(vol->cache_vol->vol_rsb.bytes_total, vol_total_cache_bytes); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.stripes); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.bytes_total, vol_total_cache_bytes); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.stripes); Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized - total_cache_bytes = %" PRId64 " = %" PRId64 "Mb", total_cache_bytes, total_cache_bytes / (1024 * 1024)); vol_total_direntries = gvol[i]->buckets * gvol[i]->segments * DIR_DEPTH; total_direntries += vol_total_direntries; - Metrics::Counter::increment(vol->cache_vol->vol_rsb.direntries_total, vol_total_direntries); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.direntries_total, vol_total_direntries); vol_used_direntries = dir_entries_used(gvol[i]); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.direntries_used, vol_used_direntries); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.direntries_used, vol_used_direntries); used_direntries += vol_used_direntries; } } @@ -742,10 +742,10 @@ CacheProcessor::cacheInitialized() break; } - Metrics::Counter::write(cache_rsb.ram_cache_bytes_total, ram_cache_bytes); - Metrics::Counter::write(cache_rsb.bytes_total, total_cache_bytes); - Metrics::Counter::write(cache_rsb.direntries_total, total_direntries); - Metrics::Counter::write(cache_rsb.direntries_used, used_direntries); + Metrics::Gauge::store(cache_rsb.ram_cache_bytes_total, ram_cache_bytes); + Metrics::Gauge::store(cache_rsb.bytes_total, total_cache_bytes); + Metrics::Gauge::store(cache_rsb.direntries_total, total_direntries); + Metrics::Gauge::store(cache_rsb.direntries_used, used_direntries); if (!check) { dir_sync_init(); @@ -1015,14 +1015,14 @@ CacheProcessor::mark_storage_offline(CacheDisk *d, ///< Target disk } } - Metrics::Counter::decrement(cache_rsb.bytes_total, total_bytes_delete); - Metrics::Counter::decrement(cache_rsb.direntries_total, total_dir_delete); - Metrics::Counter::decrement(cache_rsb.direntries_used, used_dir_delete); + Metrics::Gauge::decrement(cache_rsb.bytes_total, total_bytes_delete); + Metrics::Gauge::decrement(cache_rsb.direntries_total, total_dir_delete); + Metrics::Gauge::decrement(cache_rsb.direntries_used, used_dir_delete); /* Update the span metrics, if failing then move the span from "failing" to "offline" bucket * if operator took it offline, move it from "online" to "offline" bucket */ - Metrics::Counter::decrement(admin ? cache_rsb.span_online : cache_rsb.span_failing); - Metrics::Counter::increment(cache_rsb.span_offline); + Metrics::Gauge::decrement(admin ? cache_rsb.span_online : cache_rsb.span_failing); + Metrics::Gauge::increment(cache_rsb.span_offline); if (theCache) { rebuild_host_table(theCache); @@ -1690,7 +1690,7 @@ cplist_reconfigure() } } - Metrics::Counter::write(cache_rsb.stripes, gnvol + assignedVol); + Metrics::Gauge::store(cache_rsb.stripes, gnvol + assignedVol); return 0; } diff --git a/src/iocore/cache/CacheDir.cc b/src/iocore/cache/CacheDir.cc index ae4baa6394e..c989aa680d4 100644 --- a/src/iocore/cache/CacheDir.cc +++ b/src/iocore/cache/CacheDir.cc @@ -367,8 +367,8 @@ dir_clean_bucket(Dir *b, int s, Stripe *vol) dir_tag(e), dir_offset(e), b, p, dir_bucket_length(b, s, vol)); } if (dir_offset(e)) { - Metrics::Counter::decrement(cache_rsb.direntries_used); - Metrics::Counter::decrement(vol->cache_vol->vol_rsb.direntries_used); + Metrics::Gauge::decrement(cache_rsb.direntries_used); + Metrics::Gauge::decrement(vol->cache_vol->vol_rsb.direntries_used); } e = dir_delete_entry(e, p, s, vol); continue; @@ -403,8 +403,8 @@ dir_clear_range(off_t start, off_t end, Stripe *vol) for (off_t i = 0; i < vol->buckets * DIR_DEPTH * vol->segments; i++) { Dir *e = dir_index(vol, i); if (dir_offset(e) >= static_cast(start) && dir_offset(e) < static_cast(end)) { - Metrics::Counter::decrement(cache_rsb.direntries_used); - Metrics::Counter::decrement(vol->cache_vol->vol_rsb.direntries_used); + Metrics::Gauge::decrement(cache_rsb.direntries_used); + Metrics::Gauge::decrement(vol->cache_vol->vol_rsb.direntries_used); dir_set_offset(e, 0); // delete } } @@ -439,8 +439,8 @@ freelist_clean(int s, Stripe *vol) for (int l = 0; l < DIR_DEPTH; l++) { Dir *e = dir_bucket_row(b, l); if (dir_head(e) && !(n++ % 10)) { - Metrics::Counter::decrement(cache_rsb.direntries_used); - Metrics::Counter::decrement(vol->cache_vol->vol_rsb.direntries_used); + Metrics::Gauge::decrement(cache_rsb.direntries_used); + Metrics::Gauge::decrement(vol->cache_vol->vol_rsb.direntries_used); dir_set_offset(e, 0); // delete } } @@ -567,8 +567,8 @@ dir_probe(const CacheKey *key, Stripe *vol, Dir *result, Dir **last_collision) // may not accurately reflect the number of documents // having the same first_key DDbg(dbg_ctl_cache_stats, "Incrementing dir collisions"); - Metrics::Counter::increment(cache_rsb.directory_collision_count); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.directory_collision_count); + Metrics::Counter::increment(cache_rsb.directory_collision); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.directory_collision); } goto Lcont; } @@ -580,8 +580,8 @@ dir_probe(const CacheKey *key, Stripe *vol, Dir *result, Dir **last_collision) ink_assert(dir_offset(e) * CACHE_BLOCK_SIZE < vol->len); return 1; } else { // delete the invalid entry - Metrics::Counter::decrement(cache_rsb.direntries_used); - Metrics::Counter::decrement(vol->cache_vol->vol_rsb.direntries_used); + Metrics::Gauge::decrement(cache_rsb.direntries_used); + Metrics::Gauge::decrement(vol->cache_vol->vol_rsb.direntries_used); e = dir_delete_entry(e, p, s, vol); continue; } @@ -595,8 +595,8 @@ dir_probe(const CacheKey *key, Stripe *vol, Dir *result, Dir **last_collision) } if (collision) { // last collision no longer in the list, retry DDbg(dbg_ctl_cache_stats, "Incrementing dir collisions"); - Metrics::Counter::increment(cache_rsb.directory_collision_count); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.directory_collision_count); + Metrics::Counter::increment(cache_rsb.directory_collision); + Metrics::Counter::increment(vol->cache_vol->vol_rsb.directory_collision); collision = nullptr; goto Lagain; } @@ -667,8 +667,8 @@ dir_insert(const CacheKey *key, Stripe *vol, Dir *to_part) bi, e, key->slice32(1), dir_tag(e), dir_offset(e)); CHECK_DIR(d); vol->header->dirty = 1; - Metrics::Counter::increment(cache_rsb.direntries_used); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.direntries_used); + Metrics::Gauge::increment(cache_rsb.direntries_used); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.direntries_used); return 1; } @@ -718,8 +718,8 @@ dir_overwrite(const CacheKey *key, Stripe *vol, Dir *dir, Dir *overwrite, bool m // get from this row first e = b; if (dir_is_empty(e)) { - Metrics::Counter::increment(cache_rsb.direntries_used); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.direntries_used); + Metrics::Gauge::increment(cache_rsb.direntries_used); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.direntries_used); goto Lfill; } for (l = 1; l < DIR_DEPTH; l++) { @@ -735,8 +735,8 @@ dir_overwrite(const CacheKey *key, Stripe *vol, Dir *dir, Dir *overwrite, bool m goto Lagain; } Llink: - Metrics::Counter::increment(cache_rsb.direntries_used); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.direntries_used); + Metrics::Gauge::increment(cache_rsb.direntries_used); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.direntries_used); // as with dir_insert above, need to insert new entries at the tail of the linked list Dir *prev, *last; @@ -784,8 +784,8 @@ dir_delete(const CacheKey *key, Stripe *vol, Dir *del) } #endif if (dir_compare_tag(e, key) && dir_offset(e) == dir_offset(del)) { - Metrics::Counter::decrement(cache_rsb.direntries_used); - Metrics::Counter::decrement(vol->cache_vol->vol_rsb.direntries_used); + Metrics::Gauge::decrement(cache_rsb.direntries_used); + Metrics::Gauge::decrement(vol->cache_vol->vol_rsb.direntries_used); dir_delete_entry(e, p, s, vol); CHECK_DIR(d); return 1; diff --git a/src/iocore/cache/CacheDisk.cc b/src/iocore/cache/CacheDisk.cc index 4b47e426448..808d8960e93 100644 --- a/src/iocore/cache/CacheDisk.cc +++ b/src/iocore/cache/CacheDisk.cc @@ -29,8 +29,8 @@ CacheDisk::incrErrors(const AIOCallback *io) if (0 == this->num_errors) { /* This it the first read/write error on this span since ATS started. * Move the newly failing span from "online" to "failing" bucket. */ - Metrics::Counter::decrement(cache_rsb.span_online); - Metrics::Counter::increment(cache_rsb.span_failing); + Metrics::Gauge::decrement(cache_rsb.span_online); + Metrics::Gauge::increment(cache_rsb.span_failing); } this->num_errors++; diff --git a/src/iocore/cache/P_CacheStats.h b/src/iocore/cache/P_CacheStats.h index dc23047da71..09fe4781f17 100644 --- a/src/iocore/cache/P_CacheStats.h +++ b/src/iocore/cache/P_CacheStats.h @@ -35,36 +35,36 @@ struct CacheStatsBlock { Metrics::Counter::AtomicType *fragment_document_count[3] = {nullptr, nullptr, nullptr}; // For 1, 2 and 3+ fragments - Metrics::Counter::AtomicType *bytes_used = nullptr; - Metrics::Counter::AtomicType *bytes_total = nullptr; - Metrics::Counter::AtomicType *stripes = nullptr; - Metrics::Counter::AtomicType *ram_cache_bytes = nullptr; - Metrics::Counter::AtomicType *ram_cache_bytes_total = nullptr; - Metrics::Counter::AtomicType *direntries_total = nullptr; - Metrics::Counter::AtomicType *direntries_used = nullptr; - Metrics::Counter::AtomicType *ram_cache_hits = nullptr; - Metrics::Counter::AtomicType *ram_cache_misses = nullptr; - Metrics::Counter::AtomicType *pread_count = nullptr; - Metrics::Counter::AtomicType *percent_full = nullptr; - Metrics::Counter::AtomicType *read_seek_fail = nullptr; - Metrics::Counter::AtomicType *read_invalid = nullptr; - Metrics::Counter::AtomicType *write_backlog_failure = nullptr; - Metrics::Counter::AtomicType *directory_collision_count = nullptr; - Metrics::Counter::AtomicType *read_busy_success = nullptr; - Metrics::Counter::AtomicType *read_busy_failure = nullptr; - Metrics::Counter::AtomicType *gc_bytes_evacuated = nullptr; - Metrics::Counter::AtomicType *gc_frags_evacuated = nullptr; - Metrics::Counter::AtomicType *write_bytes = nullptr; - Metrics::Counter::AtomicType *hdr_vector_marshal = nullptr; - Metrics::Counter::AtomicType *hdr_marshal = nullptr; - Metrics::Counter::AtomicType *hdr_marshal_bytes = nullptr; - Metrics::Counter::AtomicType *directory_wrap = nullptr; - Metrics::Counter::AtomicType *directory_sync_count = nullptr; - Metrics::Counter::AtomicType *directory_sync_time = nullptr; - Metrics::Counter::AtomicType *directory_sync_bytes = nullptr; - Metrics::Counter::AtomicType *span_errors_read = nullptr; - Metrics::Counter::AtomicType *span_errors_write = nullptr; - Metrics::Counter::AtomicType *span_offline = nullptr; - Metrics::Counter::AtomicType *span_online = nullptr; - Metrics::Counter::AtomicType *span_failing = nullptr; + Metrics::Gauge::AtomicType *bytes_used = nullptr; + Metrics::Gauge::AtomicType *bytes_total = nullptr; + Metrics::Gauge::AtomicType *stripes = nullptr; + Metrics::Counter::AtomicType *ram_cache_bytes = nullptr; + Metrics::Gauge::AtomicType *ram_cache_bytes_total = nullptr; + Metrics::Gauge::AtomicType *direntries_total = nullptr; + Metrics::Gauge::AtomicType *direntries_used = nullptr; + Metrics::Counter::AtomicType *ram_cache_hits = nullptr; + Metrics::Counter::AtomicType *ram_cache_misses = nullptr; + Metrics::Counter::AtomicType *pread_count = nullptr; + Metrics::Gauge::AtomicType *percent_full = nullptr; + Metrics::Counter::AtomicType *read_seek_fail = nullptr; + Metrics::Counter::AtomicType *read_invalid = nullptr; + Metrics::Counter::AtomicType *write_backlog_failure = nullptr; + Metrics::Counter::AtomicType *directory_collision = nullptr; + Metrics::Counter::AtomicType *read_busy_success = nullptr; + Metrics::Counter::AtomicType *read_busy_failure = nullptr; + Metrics::Counter::AtomicType *gc_bytes_evacuated = nullptr; + Metrics::Counter::AtomicType *gc_frags_evacuated = nullptr; + Metrics::Counter::AtomicType *write_bytes = nullptr; + Metrics::Counter::AtomicType *hdr_vector_marshal = nullptr; + Metrics::Counter::AtomicType *hdr_marshal = nullptr; + Metrics::Counter::AtomicType *hdr_marshal_bytes = nullptr; + Metrics::Counter::AtomicType *directory_wrap = nullptr; + Metrics::Counter::AtomicType *directory_sync_count = nullptr; + Metrics::Counter::AtomicType *directory_sync_time = nullptr; + Metrics::Counter::AtomicType *directory_sync_bytes = nullptr; + Metrics::Counter::AtomicType *span_errors_read = nullptr; + Metrics::Counter::AtomicType *span_errors_write = nullptr; + Metrics::Gauge::AtomicType *span_offline = nullptr; + Metrics::Gauge::AtomicType *span_online = nullptr; + Metrics::Gauge::AtomicType *span_failing = nullptr; }; diff --git a/src/iocore/io_uring/unit_tests/test_diskIO.cc b/src/iocore/io_uring/unit_tests/test_diskIO.cc index b9e06031fdf..712a181e27b 100644 --- a/src/iocore/io_uring/unit_tests/test_diskIO.cc +++ b/src/iocore/io_uring/unit_tests/test_diskIO.cc @@ -269,10 +269,10 @@ TEST_CASE("net_io", "[io_uring]") Metrics::Counter::AtomicType *completed = m.lookup(m.lookup("proxy.process.io_uring.completed")); - uint64_t completions_before = Metrics::Counter::read(completed); + uint64_t completions_before = Metrics::Counter::load(completed); uint64_t needed = 2; - while ((Metrics::Counter::read(completed) - completions_before) < needed) { + while ((Metrics::Counter::load(completed) - completions_before) < needed) { ctx.submit_and_wait(1 * HRTIME_SECOND); } diff --git a/src/iocore/net/P_UnixNet.h b/src/iocore/net/P_UnixNet.h index 1a2ec3d12e2..80a438482ba 100644 --- a/src/iocore/net/P_UnixNet.h +++ b/src/iocore/net/P_UnixNet.h @@ -93,7 +93,7 @@ TS_INLINE int net_connections_to_throttle(ThrottleType t) { double headroom = t == ACCEPT ? NET_THROTTLE_ACCEPT_HEADROOM : NET_THROTTLE_CONNECT_HEADROOM; - int currently_open = static_cast(Metrics::Counter::read(net_rsb.connections_currently_open)); + int currently_open = static_cast(Metrics::Counter::load(net_rsb.connections_currently_open)); // deal with race if we got to multiple net threads if (currently_open < 0) { diff --git a/src/iocore/net/SSLStats.cc b/src/iocore/net/SSLStats.cc index 8dcd631900c..2407bb7aad3 100644 --- a/src/iocore/net/SSLStats.cc +++ b/src/iocore/net/SSLStats.cc @@ -60,10 +60,10 @@ SSLPeriodicMetricsUpdate() } } - Metrics::Counter::write(ssl_rsb.user_agent_sessions, sessions); - Metrics::Counter::write(ssl_rsb.user_agent_session_hit, hits); - Metrics::Counter::write(ssl_rsb.user_agent_session_miss, misses); - Metrics::Counter::write(ssl_rsb.user_agent_session_timeout, timeouts); + Metrics::Gauge::store(ssl_rsb.user_agent_sessions, sessions); + Metrics::Gauge::store(ssl_rsb.user_agent_session_hit, hits); + Metrics::Gauge::store(ssl_rsb.user_agent_session_miss, misses); + Metrics::Gauge::store(ssl_rsb.user_agent_session_timeout, timeouts); } static void @@ -126,26 +126,26 @@ SSLInitializeStatistics() ssl_rsb.total_ticket_keys_renewed = Metrics::Counter::createPtr("proxy.process.ssl.total_ticket_keys_renewed"); ssl_rsb.total_tickets_created = Metrics::Counter::createPtr("proxy.process.ssl.total_tickets_created"); ssl_rsb.total_tickets_not_found = Metrics::Counter::createPtr("proxy.process.ssl.total_tickets_not_found"); - ssl_rsb.total_tickets_renewed = Metrics::Counter::createPtr("proxy.process.ssl.total_tickets_renewed"); // ToDo: Not used? - ssl_rsb.total_tickets_verified = Metrics::Counter::createPtr("proxy.process.ssl.total_tickets_verified"); - ssl_rsb.total_tickets_verified_old_key = Metrics::Counter::createPtr("proxy.process.ssl.total_tickets_verified_old_key"); - ssl_rsb.total_tlsv1 = Metrics::Counter::createPtr("proxy.process.ssl.ssl_total_tlsv1"); - ssl_rsb.total_tlsv11 = Metrics::Counter::createPtr("proxy.process.ssl.ssl_total_tlsv11"); - ssl_rsb.total_tlsv12 = Metrics::Counter::createPtr("proxy.process.ssl.ssl_total_tlsv12"); - ssl_rsb.total_tlsv13 = Metrics::Counter::createPtr("proxy.process.ssl.ssl_total_tlsv13"); - ssl_rsb.user_agent_bad_cert = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_bad_cert"); - ssl_rsb.user_agent_cert_verify_failed = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_cert_verify_failed"); - ssl_rsb.user_agent_decryption_failed = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_decryption_failed"); - ssl_rsb.user_agent_expired_cert = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_expired_cert"); - ssl_rsb.user_agent_other_errors = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_other_errors"); - ssl_rsb.user_agent_revoked_cert = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_revoked_cert"); - ssl_rsb.user_agent_session_hit = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_session_hit"); - ssl_rsb.user_agent_session_miss = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_session_miss"); - ssl_rsb.user_agent_session_timeout = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_session_timeout"); - ssl_rsb.user_agent_sessions = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_sessions"); - ssl_rsb.user_agent_unknown_ca = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_unknown_ca"); - ssl_rsb.user_agent_unknown_cert = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_unknown_cert"); - ssl_rsb.user_agent_wrong_version = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_wrong_version"); + ssl_rsb.total_tickets_renewed = Metrics::Counter::createPtr("proxy.process.ssl.total_tickets_renewed"); + ssl_rsb.total_tickets_verified = Metrics::Counter::createPtr("proxy.process.ssl.total_tickets_verified"); + ssl_rsb.total_tickets_verified_old_key = Metrics::Counter::createPtr("proxy.process.ssl.total_tickets_verified_old_key"); + ssl_rsb.total_tlsv1 = Metrics::Counter::createPtr("proxy.process.ssl.ssl_total_tlsv1"); + ssl_rsb.total_tlsv11 = Metrics::Counter::createPtr("proxy.process.ssl.ssl_total_tlsv11"); + ssl_rsb.total_tlsv12 = Metrics::Counter::createPtr("proxy.process.ssl.ssl_total_tlsv12"); + ssl_rsb.total_tlsv13 = Metrics::Counter::createPtr("proxy.process.ssl.ssl_total_tlsv13"); + ssl_rsb.user_agent_bad_cert = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_bad_cert"); + ssl_rsb.user_agent_cert_verify_failed = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_cert_verify_failed"); + ssl_rsb.user_agent_decryption_failed = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_decryption_failed"); + ssl_rsb.user_agent_expired_cert = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_expired_cert"); + ssl_rsb.user_agent_other_errors = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_other_errors"); + ssl_rsb.user_agent_revoked_cert = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_revoked_cert"); + ssl_rsb.user_agent_session_hit = Metrics::Gauge::createPtr("proxy.process.ssl.user_agent_session_hit"); + ssl_rsb.user_agent_session_miss = Metrics::Gauge::createPtr("proxy.process.ssl.user_agent_session_miss"); + ssl_rsb.user_agent_session_timeout = Metrics::Gauge::createPtr("proxy.process.ssl.user_agent_session_timeout"); + ssl_rsb.user_agent_sessions = Metrics::Gauge::createPtr("proxy.process.ssl.user_agent_sessions"); + ssl_rsb.user_agent_unknown_ca = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_unknown_ca"); + ssl_rsb.user_agent_unknown_cert = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_unknown_cert"); + ssl_rsb.user_agent_wrong_version = Metrics::Counter::createPtr("proxy.process.ssl.user_agent_wrong_version"); // Get and register the SSL cipher stats. Note that we are using the default SSL context to obtain // the cipher list. This means that the set of ciphers is fixed by the build configuration and not diff --git a/src/iocore/net/SSLStats.h b/src/iocore/net/SSLStats.h index 39da1b9b2c1..4b46d4876bb 100644 --- a/src/iocore/net/SSLStats.h +++ b/src/iocore/net/SSLStats.h @@ -88,10 +88,10 @@ struct SSLStatsBlock { Metrics::Counter::AtomicType *user_agent_expired_cert = nullptr; Metrics::Counter::AtomicType *user_agent_other_errors = nullptr; Metrics::Counter::AtomicType *user_agent_revoked_cert = nullptr; - Metrics::Counter::AtomicType *user_agent_session_hit = nullptr; - Metrics::Counter::AtomicType *user_agent_session_miss = nullptr; - Metrics::Counter::AtomicType *user_agent_session_timeout = nullptr; - Metrics::Counter::AtomicType *user_agent_sessions = nullptr; + Metrics::Gauge::AtomicType *user_agent_session_hit = nullptr; + Metrics::Gauge::AtomicType *user_agent_session_miss = nullptr; + Metrics::Gauge::AtomicType *user_agent_session_timeout = nullptr; + Metrics::Gauge::AtomicType *user_agent_sessions = nullptr; Metrics::Counter::AtomicType *user_agent_unknown_ca = nullptr; Metrics::Counter::AtomicType *user_agent_unknown_cert = nullptr; Metrics::Counter::AtomicType *user_agent_wrong_version = nullptr; diff --git a/src/mgmt/rpc/handlers/config/Configuration.cc b/src/mgmt/rpc/handlers/config/Configuration.cc index 7f0877a46ef..4d2ae044016 100644 --- a/src/mgmt/rpc/handlers/config/Configuration.cc +++ b/src/mgmt/rpc/handlers/config/Configuration.cc @@ -196,8 +196,8 @@ reload_config(std::string_view const &id, YAML::Node const ¶ms) // If any callback was register(TSMgmtUpdateRegister) for config notifications, then it will be eventually notify. FileManager::instance().invokeConfigPluginCallbacks(); - metrics[reconf_time] = time(nullptr); - metrics[reconf_req] = 0; + metrics[reconf_time].store(time(nullptr)); + metrics[reconf_req].store(0); return resp; } diff --git a/src/mgmt/rpc/handlers/server/Server.cc b/src/mgmt/rpc/handlers/server/Server.cc index 3a927deb093..e6639cc6dd6 100644 --- a/src/mgmt/rpc/handlers/server/Server.cc +++ b/src/mgmt/rpc/handlers/server/Server.cc @@ -66,7 +66,7 @@ is_server_draining() ts::Metrics &metrics = ts::Metrics::instance(); static auto drain_id = metrics.lookup("proxy.process.proxy.draining"); - return (metrics[drain_id] != 0); + return (metrics[drain_id].load() != 0); } static void @@ -76,7 +76,7 @@ set_server_drain(bool drain) static auto drain_id = metrics.lookup("proxy.process.proxy.draining"); TSSystemState::drain(drain); - metrics[drain_id] = TSSystemState::is_draining() ? 1 : 0; + metrics[drain_id].store(TSSystemState::is_draining() ? 1 : 0); } ts::Rv diff --git a/src/proxy/http/HttpSM.cc b/src/proxy/http/HttpSM.cc index 5c3e240fd64..692fa10bc7f 100644 --- a/src/proxy/http/HttpSM.cc +++ b/src/proxy/http/HttpSM.cc @@ -5472,7 +5472,7 @@ HttpSM::do_http_server_open(bool raw, bool only_direct) // Atomically read the current number of connections and check to see // if we have gone above the max allowed. if (t_state.http_config_param->server_max_connections > 0) { - if (Metrics::Counter::read(http_rsb.current_server_connections) >= t_state.http_config_param->server_max_connections) { + if (Metrics::Counter::load(http_rsb.current_server_connections) >= t_state.http_config_param->server_max_connections) { httpSessionManager.purge_keepalives(); // Eventually may want to have a queue as the origin_max_connection does to allow for a combination // of retries and errors. But at this point, we are just going to allow the error case. diff --git a/src/proxy/http/HttpTransact.cc b/src/proxy/http/HttpTransact.cc index c4d716b6b64..68b295f0616 100644 --- a/src/proxy/http/HttpTransact.cc +++ b/src/proxy/http/HttpTransact.cc @@ -1517,7 +1517,7 @@ HttpTransact::HandleRequest(State *s) initialize_state_variables_from_request(s, &s->hdr_info.client_request); // The following chunk of code will limit the maximum number of websocket connections (TS-3659) if (s->is_upgrade_request && s->is_websocket && s->http_config_param->max_websocket_connections >= 0) { - if (Metrics::Counter::read(http_rsb.websocket_current_active_client_connections) >= + if (Metrics::Counter::load(http_rsb.websocket_current_active_client_connections) >= s->http_config_param->max_websocket_connections) { s->is_websocket = false; // unset to avoid screwing up stats. TxnDebug("http_trans", "Rejecting websocket connection because the limit has been exceeded"); diff --git a/src/proxy/http/PreWarmManager.cc b/src/proxy/http/PreWarmManager.cc index 99c3e8a8215..b6cfa4ea0a4 100644 --- a/src/proxy/http/PreWarmManager.cc +++ b/src/proxy/http/PreWarmManager.cc @@ -85,17 +85,20 @@ parse_authority(std::string &fqdn, int32_t &port, std::string_view authority) // constexpr std::string_view STAT_NAME_PREFIX = "proxy.process.tunnel.prewarm"sv; -// the order is the same as PreWarm::Stat +// the order is the same as PreWarm::CounterStat / GaugeStat // clang-format off -constexpr std::string_view STAT_ENTRIES[] = { - "current_init"sv, - "current_open"sv, +constexpr std::string_view COUNTER_STAT_ENTRIES[] = { "total_hit"sv, "total_miss"sv, "total_handshake_time"sv, "total_handshake_count"sv, "total_retry"sv, }; + +constexpr std::string_view GAUGE_STAT_ENTRIES[] = { + "current_init"sv, + "current_open"sv, +}; // clang-format on } // namespace @@ -138,7 +141,9 @@ PreWarmSM::retry() ink_hrtime delay = HRTIME_SECONDS(1 << _retry_counter); ++_retry_counter; - ts::Metrics::Counter::increment(_stats_ids->at(static_cast(PreWarm::Stat::RETRY))); + auto &[counters, _] = *_stats_ids; + + ts::Metrics::Counter::increment(counters[static_cast(PreWarm::CounterStat::RETRY)]); EThread *ethread = this_ethread(); _retry_event = ethread->schedule_in_local(this, delay, EVENT_IMMEDIATE); @@ -628,8 +633,10 @@ PreWarmSM::_record_handshake_time() return; } - ts::Metrics::Counter::increment(_stats_ids->at(static_cast(PreWarm::Stat::HANDSHAKE_TIME)), duration); - ts::Metrics::Counter::increment(_stats_ids->at(static_cast(PreWarm::Stat::HANDSHAKE_COUNT)), 1); + auto &[counters, _] = *_stats_ids; + + ts::Metrics::Counter::increment(counters[static_cast(PreWarm::CounterStat::HANDSHAKE_TIME)], duration); + ts::Metrics::Counter::increment(counters[static_cast(PreWarm::CounterStat::HANDSHAKE_COUNT)]); } //// @@ -702,10 +709,12 @@ PreWarmQueue::state_running(int event, void *data) dst->port, (int)dst->type, dst->alpn_index, info.stat.miss, info.stat.hit, (int)info.init_list->size(), (int)info.open_list->size()); - ts::Metrics::Counter::write(info.stats_ids->at(static_cast(PreWarm::Stat::INIT_LIST_SIZE)), info.init_list->size()); - ts::Metrics::Counter::write(info.stats_ids->at(static_cast(PreWarm::Stat::OPEN_LIST_SIZE)), info.open_list->size()); - ts::Metrics::Counter::increment(info.stats_ids->at(static_cast(PreWarm::Stat::HIT)), info.stat.hit); - ts::Metrics::Counter::increment(info.stats_ids->at(static_cast(PreWarm::Stat::MISS)), info.stat.miss); + auto &[counters, gauges] = *info.stats_ids; + + ts::Metrics::Gauge::store(gauges[static_cast(PreWarm::GaugeStat::INIT_LIST_SIZE)], info.init_list->size()); + ts::Metrics::Gauge::store(gauges[static_cast(PreWarm::GaugeStat::OPEN_LIST_SIZE)], info.open_list->size()); + ts::Metrics::Counter::increment(counters[static_cast(PreWarm::CounterStat::HIT)], info.stat.hit); + ts::Metrics::Counter::increment(counters[static_cast(PreWarm::CounterStat::MISS)], info.stat.miss); // clear PreWarmQueue::Stat info.stat.miss = 0; @@ -927,8 +936,10 @@ PreWarmQueue::_reconfigure() // free unexisting entries for (auto &[dst, info] : _map) { if (auto entry = new_conf_list.find(dst); entry == new_conf_list.end()) { - ts::Metrics::Counter::write(info.stats_ids->at(static_cast(PreWarm::Stat::INIT_LIST_SIZE)), 0); - ts::Metrics::Counter::write(info.stats_ids->at(static_cast(PreWarm::Stat::OPEN_LIST_SIZE)), 0); + auto &[_, gauges] = *info.stats_ids; + + ts::Metrics::Gauge::store(gauges[static_cast(PreWarm::GaugeStat::INIT_LIST_SIZE)], 0); + ts::Metrics::Gauge::store(gauges[static_cast(PreWarm::GaugeStat::OPEN_LIST_SIZE)], 0); _make_queue_empty(info.init_list); delete info.init_list; @@ -1122,6 +1133,22 @@ PreWarmManager::_parse_sni_conf(PreWarm::ParsedSNIConf &parsed_conf, const SNICo Create stats per pool. Registered stats id is stored in _stat_id_map. */ + +// This is a little helper, since this is reused twice for making counters and gauges +void +_makeName(const PreWarm::SPtrConstDst &dst, std::string_view statname, char *name, size_t namesize) +{ + if (dst->alpn_index != SessionProtocolNameRegistry::INVALID) { + std::string_view alpn_name = alpn_name_for_stat(dst->alpn_index); + + snprintf(name, namesize, "%s.%.*s:%d.tls.%s.%s", STAT_NAME_PREFIX.data(), static_cast(dst->host.size()), dst->host.data(), + dst->port, alpn_name.data(), statname.data()); + } else { + snprintf(name, namesize, "%s.%.*s:%d.%s.%s", STAT_NAME_PREFIX.data(), static_cast(dst->host.size()), dst->host.data(), + dst->port, (dst->type == SNIRoutingType::PARTIAL_BLIND) ? "tls" : "tcp", statname.data()); + } +} + void PreWarmManager::_register_stats(const PreWarm::ParsedSNIConf &parsed_conf) { @@ -1131,19 +1158,13 @@ PreWarmManager::_register_stats(const PreWarm::ParsedSNIConf &parsed_conf) for (auto &entry : parsed_conf) { const PreWarm::SPtrConstDst &dst = entry.first; PreWarm::StatsIds ids; + auto &[counters, gauges] = ids; - for (int j = 0; j < static_cast(PreWarm::Stat::LAST_ENTRY); ++j) { + // First the Counters + for (int j = 0; j < static_cast(PreWarm::CounterStat::LAST_ENTRY); ++j) { char name[STAT_NAME_BUF_LEN]; - if (dst->alpn_index != SessionProtocolNameRegistry::INVALID) { - std::string_view alpn_name = alpn_name_for_stat(dst->alpn_index); - - snprintf(name, sizeof(name), "%s.%.*s:%d.tls.%s.%s", STAT_NAME_PREFIX.data(), static_cast(dst->host.size()), - dst->host.data(), dst->port, alpn_name.data(), STAT_ENTRIES[j].data()); - } else { - snprintf(name, sizeof(name), "%s.%.*s:%d.%s.%s", STAT_NAME_PREFIX.data(), static_cast(dst->host.size()), - dst->host.data(), dst->port, (dst->type == SNIRoutingType::PARTIAL_BLIND) ? "tls" : "tcp", STAT_ENTRIES[j].data()); - } + _makeName(dst, COUNTER_STAT_ENTRIES[j], name, sizeof(name)); ts::Metrics::IdType stats_id = metrics.lookup(name); Metrics::Counter::AtomicType *metric = nullptr; @@ -1152,17 +1173,43 @@ PreWarmManager::_register_stats(const PreWarm::ParsedSNIConf &parsed_conf) metric = Metrics::Counter::createPtr(name); if (metric == nullptr) { - Error("couldn't register stat name=%s", name); + Error("couldn't register counter stat name=%s", name); + } else { + ++stats_counter; + } + } else { + metric = dynamic_cast(metrics.lookup(stats_id)); + } + + counters[j] = metric; + + Debug("v_prewarm_init", "conter stat id=%d name=%s", stats_id, name); + } + + // Gauges next + for (int j = 0; j < static_cast(PreWarm::GaugeStat::LAST_ENTRY); ++j) { + char name[STAT_NAME_BUF_LEN]; + + _makeName(dst, GAUGE_STAT_ENTRIES[j], name, sizeof(name)); + + ts::Metrics::IdType stats_id = metrics.lookup(name); + Metrics::Gauge::AtomicType *metric = nullptr; + + if (stats_id == ts::Metrics::NOT_FOUND) { + metric = Metrics::Gauge::createPtr(name); + + if (metric == nullptr) { + Error("couldn't register gauge stat name=%s", name); } else { ++stats_counter; } } else { - metric = metrics.lookup(stats_id); + metric = dynamic_cast(metrics.lookup(stats_id)); } - ids[j] = metric; + gauges[j] = metric; - Debug("v_prewarm_init", "stat id=%d name=%s", stats_id, name); + Debug("v_prewarm_init", "gauge stat id=%d name=%s", stats_id, name); } _stats_id_map[dst] = std::make_shared(ids); diff --git a/src/proxy/http2/Http2ConnectionState.cc b/src/proxy/http2/Http2ConnectionState.cc index f244a3c817b..d0d62d3992b 100644 --- a/src/proxy/http2/Http2ConnectionState.cc +++ b/src/proxy/http2/Http2ConnectionState.cc @@ -2649,7 +2649,7 @@ Http2ConnectionState::_adjust_concurrent_stream() return max_concurrent_streams; } - int64_t current_client_streams = Metrics::Counter::read(http2_rsb.current_client_stream_count); + int64_t current_client_streams = Metrics::Counter::load(http2_rsb.current_client_stream_count); Http2ConDebug(session, "current client streams: %" PRId64, current_client_streams); diff --git a/src/proxy/logging/LogAccess.cc b/src/proxy/logging/LogAccess.cc index c3f4f175d64..a1cd9222c92 100644 --- a/src/proxy/logging/LogAccess.cc +++ b/src/proxy/logging/LogAccess.cc @@ -220,7 +220,7 @@ LogAccess::marshal_record(char *record, char *buf) ts::Metrics::IdType mid = metrics[record]; if (mid != ts::Metrics::NOT_FOUND) { - int64_t val = metrics[mid]; + int64_t val = metrics[mid].load(); out_buf = int64_to_str(ascii_buf, max_chars, val, &num_chars); ink_assert(out_buf); diff --git a/src/proxy/logging/LogConfig.cc b/src/proxy/logging/LogConfig.cc index e9c2fca1efc..b3683b24486 100644 --- a/src/proxy/logging/LogConfig.cc +++ b/src/proxy/logging/LogConfig.cc @@ -532,7 +532,7 @@ LogConfig::register_stat_callbacks() log_rsb.bytes_written_to_disk = Metrics::Counter::createPtr("proxy.process.log.bytes_written_to_disk"); log_rsb.bytes_lost_before_written_to_disk = Metrics::Counter::createPtr("proxy.process.log.bytes_lost_before_written_to_disk"); log_rsb.log_files_open = Metrics::Counter::createPtr("proxy.process.log.log_files_open"); - log_rsb.log_files_space_used = Metrics::Counter::createPtr("proxy.process.log.log_files_space_used"); + log_rsb.log_files_space_used = Metrics::Gauge::createPtr("proxy.process.log.log_files_space_used"); } /*------------------------------------------------------------------------- @@ -658,7 +658,7 @@ LogConfig::update_space_used() // m_space_used = total_space_used; m_partition_space_left = partition_space_left; - Metrics::Counter::write(log_rsb.log_files_space_used, m_space_used); + Metrics::Gauge::store(log_rsb.log_files_space_used, m_space_used); Debug("logspace", "%" PRId64 " bytes being used for logs", m_space_used); Debug("logspace", "%" PRId64 " bytes left on partition", m_partition_space_left); diff --git a/src/traffic_server/traffic_server.cc b/src/traffic_server/traffic_server.cc index fe5c2203b1a..5ab5943dcdd 100644 --- a/src/traffic_server/traffic_server.cc +++ b/src/traffic_server/traffic_server.cc @@ -308,7 +308,7 @@ class SignalContinuation : public Continuation RecInt timeout = 0; if (RecGetRecordInt("proxy.config.stop.shutdown_timeout", &timeout) == REC_ERR_OKAY && timeout) { - metrics[drain_id] = 1; + metrics[drain_id].store(1); TSSystemState::drain(true); // Close listening sockets here only if TS is running standalone RecInt close_sockets = 0; @@ -428,7 +428,7 @@ class MemoryLimit : public Continuation { memset(&_usage, 0, sizeof(_usage)); SET_HANDLER(&MemoryLimit::periodic); - memory_rss = Metrics::Counter::createPtr("proxy.process.traffic_server.memory.rss"); + memory_rss = Metrics::Gauge::createPtr("proxy.process.traffic_server.memory.rss"); } ~MemoryLimit() override { mutex = nullptr; } @@ -448,7 +448,7 @@ class MemoryLimit : public Continuation _memory_limit = _memory_limit >> 10; // divide by 1024 if (getrusage(RUSAGE_SELF, &_usage) == 0) { - ts::Metrics::Counter::write(memory_rss, _usage.ru_maxrss << 10); // * 1024 + ts::Metrics::Gauge::store(memory_rss, _usage.ru_maxrss << 10); // * 1024 Debug("server", "memory usage - ru_maxrss: %ld memory limit: %" PRId64, _usage.ru_maxrss, _memory_limit); if (_memory_limit > 0) { if (_usage.ru_maxrss > _memory_limit) { @@ -476,7 +476,7 @@ class MemoryLimit : public Continuation private: int64_t _memory_limit = 0; struct rusage _usage; - Metrics::Counter::AtomicType *memory_rss; + Metrics::Gauge::AtomicType *memory_rss; }; /** Gate the emission of the "Traffic Server is fuly initialized" log message. @@ -1410,24 +1410,24 @@ struct ShowStats : public Continuation { if (!(cycle++ % 24)) { printf("r:rr w:ww r:rbs w:wbs open polls\n"); } - int64_t d_rb = Metrics::Counter::read(net_rsb.calls_to_readfromnet) - last_rb; + int64_t d_rb = Metrics::Counter::load(net_rsb.calls_to_readfromnet) - last_rb; last_rb += d_rb; - int64_t d_wb = Metrics::Counter::read(net_rsb.calls_to_writetonet) - last_wb; + int64_t d_wb = Metrics::Counter::load(net_rsb.calls_to_writetonet) - last_wb; last_wb += d_wb; - int64_t d_nrb = Metrics::Counter::read(net_rsb.read_bytes) - last_nrb; + int64_t d_nrb = Metrics::Counter::load(net_rsb.read_bytes) - last_nrb; last_nrb += d_nrb; - int64_t d_nr = Metrics::Counter::read(net_rsb.read_bytes_count) - last_nr; + int64_t d_nr = Metrics::Counter::load(net_rsb.read_bytes_count) - last_nr; last_nr += d_nr; - int64_t d_nwb = Metrics::Counter::read(net_rsb.write_bytes) - last_nwb; + int64_t d_nwb = Metrics::Counter::load(net_rsb.write_bytes) - last_nwb; last_nwb += d_nwb; - int64_t d_nw = Metrics::Counter::read(net_rsb.write_bytes_count) - last_nw; + int64_t d_nw = Metrics::Counter::load(net_rsb.write_bytes_count) - last_nw; last_nw += d_nw; - int64_t d_o = Metrics::Counter::read(net_rsb.connections_currently_open); - int64_t d_p = Metrics::Counter::read(net_rsb.handler_run) - last_p; + int64_t d_o = Metrics::Counter::load(net_rsb.connections_currently_open); + int64_t d_p = Metrics::Counter::load(net_rsb.handler_run) - last_p; last_p += d_p; printf("%" PRId64 ":%" PRId64 ":%" PRId64 ":%" PRId64 " %" PRId64 ":%" PRId64 " %" PRId64 " %" PRId64 "\n", d_rb, d_wb, d_nrb, @@ -1857,16 +1857,16 @@ main(int /* argc ATS_UNUSED */, const char **argv) ts::Metrics &metrics = ts::Metrics::instance(); int32_t id; - id = Metrics::Counter::create("proxy.process.proxy.reconfigure_time"); - metrics[id] = time(nullptr); - id = Metrics::Counter::create("proxy.process.proxy.start_time"); - metrics[id] = time(nullptr); + id = Metrics::Gauge::create("proxy.process.proxy.reconfigure_time"); + metrics[id].store(time(nullptr)); + id = Metrics::Gauge::create("proxy.process.proxy.start_time"); + metrics[id].store(time(nullptr)); // These all gets initialied to 0 - Metrics::Counter::create("proxy.process.proxy.reconfigure_required"); - Metrics::Counter::create("proxy.process.proxy.restart_required"); - Metrics::Counter::create("proxy.process.proxy.draining"); + Metrics::Gauge::create("proxy.process.proxy.reconfigure_required"); + Metrics::Gauge::create("proxy.process.proxy.restart_required"); + Metrics::Gauge::create("proxy.process.proxy.draining"); // This gets updated later (in the callback) - Metrics::Counter::create("proxy.process.proxy.cache_ready_time"); + Metrics::Gauge::create("proxy.process.proxy.cache_ready_time"); // init huge pages int enabled; From d64a7e136531755d8ef75201425521850f7023f0 Mon Sep 17 00:00:00 2001 From: Leif Hedstrom Date: Mon, 30 Oct 2023 10:26:02 -0600 Subject: [PATCH 5/6] Switches to Gauge/Counter abstractions --- .../api/functions/TSStat.en.rst | 5 +++ include/api/Metrics.h | 11 ++---- include/proxy/http/HttpCacheSM.h | 8 ++--- include/proxy/http/HttpConfig.h | 22 ++++++------ include/proxy/http2/HTTP2.h | 12 +++---- include/proxy/http2/Http2ServerSession.h | 4 +-- include/proxy/logging/LogConfig.h | 2 +- src/api/InkAPI.cc | 12 +++---- src/api/unit_tests/test_Metrics.cc | 12 ++++--- src/iocore/aio/test_AIO.cc | 4 +-- src/iocore/cache/Cache.cc | 24 ++++++------- src/iocore/cache/CacheRead.cc | 8 ++--- src/iocore/cache/CacheWrite.cc | 12 +++---- src/iocore/cache/P_CacheInternal.h | 4 +-- src/iocore/cache/P_CacheStats.h | 4 +-- src/iocore/cache/RamCacheCLFUS.cc | 36 +++++++++---------- src/iocore/cache/RamCacheLRU.cc | 8 ++--- src/iocore/dns/DNS.cc | 12 +++---- src/iocore/dns/P_DNSProcessor.h | 7 +++- src/iocore/hostdb/P_RefCountCache.h | 16 ++++----- src/iocore/io_uring/unit_tests/test_diskIO.cc | 4 +-- src/iocore/net/Net.cc | 23 ++++++------ src/iocore/net/P_Net.h | 20 +++++------ src/iocore/net/P_UnixNet.h | 2 +- src/iocore/net/SSLNetVConnection.cc | 11 +++--- src/iocore/net/UnixNetAccept.cc | 14 ++++---- src/iocore/net/UnixNetProcessor.cc | 2 +- src/iocore/net/UnixNetVConnection.cc | 10 +++--- src/proxy/http/Http1ClientSession.cc | 8 ++--- src/proxy/http/Http1ClientTransaction.cc | 4 +-- src/proxy/http/Http1ServerSession.cc | 6 ++-- src/proxy/http/Http1ServerTransaction.cc | 4 +-- src/proxy/http/HttpCacheSM.cc | 4 +-- src/proxy/http/HttpConfig.cc | 22 ++++++------ src/proxy/http/HttpSM.cc | 16 ++++----- src/proxy/http/HttpSessionManager.cc | 4 +-- src/proxy/http/HttpTransact.cc | 2 +- src/proxy/http/HttpTunnel.cc | 8 ++--- src/proxy/http2/HTTP2.cc | 12 +++---- src/proxy/http2/Http2ClientSession.cc | 8 ++--- src/proxy/http2/Http2ConnectionState.cc | 2 +- src/proxy/http2/Http2ServerSession.cc | 4 +-- src/proxy/http2/Http2Stream.cc | 8 ++--- src/proxy/http3/Http3.cc | 2 +- src/proxy/logging/LogConfig.cc | 2 +- src/proxy/logging/LogFile.cc | 6 ++-- src/traffic_server/traffic_server.cc | 2 +- 47 files changed, 219 insertions(+), 214 deletions(-) diff --git a/doc/developer-guide/api/functions/TSStat.en.rst b/doc/developer-guide/api/functions/TSStat.en.rst index fe3c6a59f11..786955f26b5 100644 --- a/doc/developer-guide/api/functions/TSStat.en.rst +++ b/doc/developer-guide/api/functions/TSStat.en.rst @@ -25,6 +25,11 @@ A plugin can create statistics (metrics) that are accessible in the same way as statistics. In general monitoring the behavior of plugins in production is easier to do in this way in contrast to processing log files. + .. note:: + + These APIs are deprecated as of ATS v10.0.0, and will likely be removed in v11. Instead, + use the new APIs in `Metrics.h` diretly. + Synopsis ======== diff --git a/include/api/Metrics.h b/include/api/Metrics.h index 0d120826f1c..fc5b2faa397 100644 --- a/include/api/Metrics.h +++ b/include/api/Metrics.h @@ -54,12 +54,12 @@ class Metrics virtual ~AtomicType() = default; int64_t - load() + load() const { return _value.load(); } - // ToDo: This is a little sketchy + // ToDo: This is a little sketchy, but needed for the old InkAPI metrics. void store(int64_t val) { @@ -391,13 +391,6 @@ class Metrics metric->_value.fetch_add(val, MEMORY_ORDER); } - static void - decrement(AtomicType *metric, uint64_t val = 1) - { - ink_assert(metric); - metric->_value.fetch_sub(val, MEMORY_ORDER); - } - static int64_t load(AtomicType *metric) { diff --git a/include/proxy/http/HttpCacheSM.h b/include/proxy/http/HttpCacheSM.h index 6a8b74ed547..a10d9c94334 100644 --- a/include/proxy/http/HttpCacheSM.h +++ b/include/proxy/http/HttpCacheSM.h @@ -160,7 +160,7 @@ class HttpCacheSM : public Continuation abort_read() { if (cache_read_vc) { - Metrics::Counter::decrement(http_rsb.current_cache_connections); + Metrics::Gauge::decrement(http_rsb.current_cache_connections); cache_read_vc->do_io_close(0); // passing zero as aborting read is not an error cache_read_vc = nullptr; } @@ -169,7 +169,7 @@ class HttpCacheSM : public Continuation abort_write() { if (cache_write_vc) { - Metrics::Counter::decrement(http_rsb.current_cache_connections); + Metrics::Gauge::decrement(http_rsb.current_cache_connections); cache_write_vc->do_io_close(0); // passing zero as aborting write is not an error cache_write_vc = nullptr; } @@ -178,7 +178,7 @@ class HttpCacheSM : public Continuation close_write() { if (cache_write_vc) { - Metrics::Counter::decrement(http_rsb.current_cache_connections); + Metrics::Gauge::decrement(http_rsb.current_cache_connections); cache_write_vc->do_io_close(); cache_write_vc = nullptr; } @@ -187,7 +187,7 @@ class HttpCacheSM : public Continuation close_read() { if (cache_read_vc) { - Metrics::Counter::decrement(http_rsb.current_cache_connections); + Metrics::Gauge::decrement(http_rsb.current_cache_connections); cache_read_vc->do_io_close(); cache_read_vc = nullptr; } diff --git a/include/proxy/http/HttpConfig.h b/include/proxy/http/HttpConfig.h index 1bdff09c907..2abc899c93a 100644 --- a/include/proxy/http/HttpConfig.h +++ b/include/proxy/http/HttpConfig.h @@ -64,7 +64,7 @@ struct HttpStatsBlock { // Need two stats for these for counts and times Metrics::Counter::AtomicType *background_fill_bytes_aborted; Metrics::Counter::AtomicType *background_fill_bytes_completed; - Metrics::Counter::AtomicType *background_fill_current_count; + Metrics::Gauge::AtomicType *background_fill_current_count; Metrics::Counter::AtomicType *background_fill_total_count; Metrics::Counter::AtomicType *broken_server_connections; Metrics::Counter::AtomicType *cache_deletes; @@ -92,13 +92,13 @@ struct HttpStatsBlock { Metrics::Counter::AtomicType *cache_writes; Metrics::Counter::AtomicType *completed_requests; Metrics::Counter::AtomicType *connect_requests; - Metrics::Counter::AtomicType *current_active_client_connections; - Metrics::Counter::AtomicType *current_cache_connections; - Metrics::Counter::AtomicType *current_client_connections; - Metrics::Counter::AtomicType *current_client_transactions; - Metrics::Counter::AtomicType *current_parent_proxy_connections; - Metrics::Counter::AtomicType *current_server_connections; - Metrics::Counter::AtomicType *current_server_transactions; + Metrics::Gauge::AtomicType *current_active_client_connections; + Metrics::Gauge::AtomicType *current_cache_connections; + Metrics::Gauge::AtomicType *current_client_connections; + Metrics::Gauge::AtomicType *current_client_transactions; + Metrics::Gauge::AtomicType *current_parent_proxy_connections; + Metrics::Gauge::AtomicType *current_server_connections; + Metrics::Gauge::AtomicType *current_server_transactions; Metrics::Counter::AtomicType *delete_requests; Metrics::Counter::AtomicType *disallowed_post_100_continue; Metrics::Counter::AtomicType *dns_lookup_begin_time; @@ -164,7 +164,7 @@ struct HttpStatsBlock { Metrics::Counter::AtomicType *parent_proxy_request_total_bytes; Metrics::Counter::AtomicType *parent_proxy_response_total_bytes; Metrics::Counter::AtomicType *parent_proxy_transaction_time; - Metrics::Counter::AtomicType *pooled_server_connections; + Metrics::Gauge::AtomicType *pooled_server_connections; Metrics::Counter::AtomicType *post_body_too_large; Metrics::Counter::AtomicType *post_requests; Metrics::Counter::AtomicType *proxy_loop_detected; @@ -265,7 +265,7 @@ struct HttpStatsBlock { Metrics::Counter::AtomicType *total_transactions_time; Metrics::Counter::AtomicType *total_x_redirect; Metrics::Counter::AtomicType *trace_requests; - Metrics::Counter::AtomicType *tunnel_current_active_connections; + Metrics::Gauge::AtomicType *tunnel_current_active_connections; Metrics::Counter::AtomicType *tunnels; Metrics::Counter::AtomicType *ua_begin_time; Metrics::Counter::AtomicType *ua_begin_write_time; @@ -302,7 +302,7 @@ struct HttpStatsBlock { Metrics::Counter::AtomicType *user_agent_request_header_total_size; Metrics::Counter::AtomicType *user_agent_response_document_total_size; Metrics::Counter::AtomicType *user_agent_response_header_total_size; - Metrics::Counter::AtomicType *websocket_current_active_client_connections; + Metrics::Gauge::AtomicType *websocket_current_active_client_connections; }; enum CacheOpenWriteFailAction_t { diff --git a/include/proxy/http2/HTTP2.h b/include/proxy/http2/HTTP2.h index 18e136c1454..6b8b37bbed4 100644 --- a/include/proxy/http2/HTTP2.h +++ b/include/proxy/http2/HTTP2.h @@ -77,12 +77,12 @@ const uint8_t HTTP2_PRIORITY_DEFAULT_WEIGHT = 15; // Statistics struct Http2StatsBlock { - Metrics::Counter::AtomicType *current_client_session_count; - Metrics::Counter::AtomicType *current_server_session_count; - Metrics::Counter::AtomicType *current_active_client_connection_count; - Metrics::Counter::AtomicType *current_active_server_connection_count; - Metrics::Counter::AtomicType *current_client_stream_count; - Metrics::Counter::AtomicType *current_server_stream_count; + Metrics::Gauge::AtomicType *current_client_session_count; + Metrics::Gauge::AtomicType *current_server_session_count; + Metrics::Gauge::AtomicType *current_active_client_connection_count; + Metrics::Gauge::AtomicType *current_active_server_connection_count; + Metrics::Gauge::AtomicType *current_client_stream_count; + Metrics::Gauge::AtomicType *current_server_stream_count; Metrics::Counter::AtomicType *total_client_stream_count; Metrics::Counter::AtomicType *total_server_stream_count; Metrics::Counter::AtomicType *total_transactions_time; diff --git a/include/proxy/http2/Http2ServerSession.h b/include/proxy/http2/Http2ServerSession.h index 9500299d55c..472c5947003 100644 --- a/include/proxy/http2/Http2ServerSession.h +++ b/include/proxy/http2/Http2ServerSession.h @@ -72,13 +72,13 @@ class Http2ServerSession : public PoolableSession, public Http2CommonSession void increment_current_active_connections_stat() override { - Metrics::Counter::increment(http2_rsb.current_active_server_connection_count); + Metrics::Gauge::increment(http2_rsb.current_active_server_connection_count); } void decrement_current_active_connections_stat() override { - Metrics::Counter::decrement(http2_rsb.current_active_server_connection_count); + Metrics::Gauge::decrement(http2_rsb.current_active_server_connection_count); } // noncopyable diff --git a/include/proxy/logging/LogConfig.h b/include/proxy/logging/LogConfig.h index b7e7f00b8bb..8a02bb1e497 100644 --- a/include/proxy/logging/LogConfig.h +++ b/include/proxy/logging/LogConfig.h @@ -60,7 +60,7 @@ struct LogsStatsBlock { Metrics::Counter::AtomicType *bytes_lost_before_flush_to_disk; Metrics::Counter::AtomicType *bytes_written_to_disk; Metrics::Counter::AtomicType *bytes_lost_before_written_to_disk; - Metrics::Counter::AtomicType *log_files_open; + Metrics::Gauge::AtomicType *log_files_open; Metrics::Gauge::AtomicType *log_files_space_used; }; diff --git a/src/api/InkAPI.cc b/src/api/InkAPI.cc index a1bf5d1ccea..bc1a212b568 100644 --- a/src/api/InkAPI.cc +++ b/src/api/InkAPI.cc @@ -6165,20 +6165,20 @@ tsapi::c::TSHttpTxnLookingUpTypeGet(TSHttpTxn txnp) int tsapi::c::TSHttpCurrentClientConnectionsGet() { - return Metrics::Counter::load(http_rsb.current_client_connections); + return Metrics::Gauge::load(http_rsb.current_client_connections); } int tsapi::c::TSHttpCurrentActiveClientConnectionsGet() { - return Metrics::Counter::load(http_rsb.current_active_client_connections); + return Metrics::Gauge::load(http_rsb.current_active_client_connections); } int tsapi::c::TSHttpCurrentIdleClientConnectionsGet() { - int64_t total = Metrics::Counter::load(http_rsb.current_client_connections); - int64_t active = Metrics::Counter::load(http_rsb.current_active_client_connections); + int64_t total = Metrics::Gauge::load(http_rsb.current_client_connections); + int64_t active = Metrics::Gauge::load(http_rsb.current_active_client_connections); if (total >= active) { return static_cast(total - active); @@ -6190,13 +6190,13 @@ tsapi::c::TSHttpCurrentIdleClientConnectionsGet() int tsapi::c::TSHttpCurrentCacheConnectionsGet() { - return Metrics::Counter::load(http_rsb.current_cache_connections); + return Metrics::Gauge::load(http_rsb.current_cache_connections); } int tsapi::c::TSHttpCurrentServerConnectionsGet() { - return Metrics::Counter::load(http_rsb.current_server_connections); + return Metrics::Gauge::load(http_rsb.current_server_connections); } /* HTTP alternate selection */ diff --git a/src/api/unit_tests/test_Metrics.cc b/src/api/unit_tests/test_Metrics.cc index 946f5b7d052..a05c6edf988 100644 --- a/src/api/unit_tests/test_Metrics.cc +++ b/src/api/unit_tests/test_Metrics.cc @@ -57,22 +57,24 @@ TEST_CASE("Metrics", "[libtsapi][Metrics]") REQUIRE(m[fooid].load() == 1); } - SECTION("operator[]") + SECTION("operator[] & store") { - m[0].store(42); + auto storeid = Metrics::Gauge::create("store"); - REQUIRE(m[0].load() == 42); + m[storeid].store(42); + + REQUIRE(m[storeid].load() == 42); } SECTION("Span allocation") { ts::Metrics::IdType span_id; - auto fooid = Metrics::Counter::create("foo"); // To see that span_id gets to 2 + auto fooid = m.lookup("foo"); auto span = Metrics::Counter::createSpan(17, &span_id); REQUIRE(span.size() == 17); REQUIRE(fooid == 1); - REQUIRE(span_id == 2); + REQUIRE(span_id == 3); m.rename(span_id + 0, "span.0"); m.rename(span_id + 1, "span.1"); diff --git a/src/iocore/aio/test_AIO.cc b/src/iocore/aio/test_AIO.cc index 4a54f6563f6..0b3b3984190 100644 --- a/src/iocore/aio/test_AIO.cc +++ b/src/iocore/aio/test_AIO.cc @@ -226,8 +226,8 @@ dump_summary() Metrics::Counter::AtomicType *completed = m.lookup(m.lookup("proxy.process.io_uring.completed")); Metrics::Counter::AtomicType *submitted = m.lookup(m.lookup("proxy.process.io_uring.submitted")); - printf("submissions: %lu\n", Metrics::Counter::load(submitted)); - printf("completions: %lu\n", Metrics::Counter::load(completed)); + printf("submissions: %lu\n", Metrics::Gauge::load(submitted)); + printf("completions: %lu\n", Metrics::Gauge::load(completed)); #endif if (delete_disks) { diff --git a/src/iocore/cache/Cache.cc b/src/iocore/cache/Cache.cc index 3fe2c9be848..c700251b838 100644 --- a/src/iocore/cache/Cache.cc +++ b/src/iocore/cache/Cache.cc @@ -130,25 +130,25 @@ static void register_cache_stats(CacheStatsBlock *rsb, const std::string prefix) { // These are special, in that we have 7 x 3 metrics here in a structure based on cache operation done - rsb->status[static_cast(CacheOpType::Lookup)].active = Metrics::Counter::createPtr(prefix + ".lookup.active"); + rsb->status[static_cast(CacheOpType::Lookup)].active = Metrics::Gauge::createPtr(prefix + ".lookup.active"); rsb->status[static_cast(CacheOpType::Lookup)].success = Metrics::Counter::createPtr(prefix + ".lookup.success"); rsb->status[static_cast(CacheOpType::Lookup)].failure = Metrics::Counter::createPtr(prefix + ".lookup.failure"); - rsb->status[static_cast(CacheOpType::Read)].active = Metrics::Counter::createPtr(prefix + ".read.active"); + rsb->status[static_cast(CacheOpType::Read)].active = Metrics::Gauge::createPtr(prefix + ".read.active"); rsb->status[static_cast(CacheOpType::Read)].success = Metrics::Counter::createPtr(prefix + ".read.success"); rsb->status[static_cast(CacheOpType::Read)].failure = Metrics::Counter::createPtr(prefix + ".read.failure"); - rsb->status[static_cast(CacheOpType::Write)].active = Metrics::Counter::createPtr(prefix + ".write.active"); + rsb->status[static_cast(CacheOpType::Write)].active = Metrics::Gauge::createPtr(prefix + ".write.active"); rsb->status[static_cast(CacheOpType::Write)].success = Metrics::Counter::createPtr(prefix + ".write.success"); rsb->status[static_cast(CacheOpType::Write)].failure = Metrics::Counter::createPtr(prefix + ".write.failure"); - rsb->status[static_cast(CacheOpType::Update)].active = Metrics::Counter::createPtr(prefix + ".update.active"); + rsb->status[static_cast(CacheOpType::Update)].active = Metrics::Gauge::createPtr(prefix + ".update.active"); rsb->status[static_cast(CacheOpType::Update)].success = Metrics::Counter::createPtr(prefix + ".update.success"); rsb->status[static_cast(CacheOpType::Update)].failure = Metrics::Counter::createPtr(prefix + ".update.failure"); - rsb->status[static_cast(CacheOpType::Remove)].active = Metrics::Counter::createPtr(prefix + ".remove.active"); + rsb->status[static_cast(CacheOpType::Remove)].active = Metrics::Gauge::createPtr(prefix + ".remove.active"); rsb->status[static_cast(CacheOpType::Remove)].success = Metrics::Counter::createPtr(prefix + ".remove.success"); rsb->status[static_cast(CacheOpType::Remove)].failure = Metrics::Counter::createPtr(prefix + ".remove.failure"); - rsb->status[static_cast(CacheOpType::Evacuate)].active = Metrics::Counter::createPtr(prefix + ".evacuate.active"); + rsb->status[static_cast(CacheOpType::Evacuate)].active = Metrics::Gauge::createPtr(prefix + ".evacuate.active"); rsb->status[static_cast(CacheOpType::Evacuate)].success = Metrics::Counter::createPtr(prefix + ".evacuate.success"); rsb->status[static_cast(CacheOpType::Evacuate)].failure = Metrics::Counter::createPtr(prefix + ".evacuate.failure"); - rsb->status[static_cast(CacheOpType::Scan)].active = Metrics::Counter::createPtr(prefix + ".scan.active"); + rsb->status[static_cast(CacheOpType::Scan)].active = Metrics::Gauge::createPtr(prefix + ".scan.active"); rsb->status[static_cast(CacheOpType::Scan)].success = Metrics::Counter::createPtr(prefix + ".scan.success"); rsb->status[static_cast(CacheOpType::Scan)].failure = Metrics::Counter::createPtr(prefix + ".scan.failure"); @@ -162,7 +162,7 @@ register_cache_stats(CacheStatsBlock *rsb, const std::string prefix) rsb->bytes_total = Metrics::Gauge::createPtr(prefix + ".bytes_total"); rsb->stripes = Metrics::Gauge::createPtr(prefix + ".stripes"); rsb->ram_cache_bytes_total = Metrics::Gauge::createPtr(prefix + ".ram_cache.total_bytes"); - rsb->ram_cache_bytes = Metrics::Counter::createPtr(prefix + ".ram_cache.bytes_used"); + rsb->ram_cache_bytes = Metrics::Gauge::createPtr(prefix + ".ram_cache.bytes_used"); rsb->ram_cache_hits = Metrics::Counter::createPtr(prefix + ".ram_cache.hits"); rsb->ram_cache_misses = Metrics::Counter::createPtr(prefix + ".ram_cache.misses"); rsb->pread_count = Metrics::Counter::createPtr(prefix + ".pread_count"); @@ -1199,8 +1199,8 @@ Cache::lookup(Continuation *cont, const CacheKey *key, CacheFragType type, const SET_CONTINUATION_HANDLER(c, &CacheVC::openReadStartHead); c->vio.op = VIO::READ; c->op_type = static_cast(CacheOpType::Lookup); - Metrics::Counter::increment(cache_rsb.status[c->op_type].active); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); + Metrics::Gauge::increment(cache_rsb.status[c->op_type].active); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); c->first_key = c->key = *key; c->frag_type = type; c->f.lookup = 1; @@ -1241,8 +1241,8 @@ Cache::remove(Continuation *cont, const CacheKey *key, CacheFragType type, const c->vio.op = VIO::NONE; c->frag_type = type; c->op_type = static_cast(CacheOpType::Remove); - Metrics::Counter::increment(cache_rsb.status[c->op_type].active); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); + Metrics::Gauge::increment(cache_rsb.status[c->op_type].active); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); c->first_key = c->key = *key; c->vol = vol; c->dir = result; diff --git a/src/iocore/cache/CacheRead.cc b/src/iocore/cache/CacheRead.cc index a12dd85816d..19c35e96d22 100644 --- a/src/iocore/cache/CacheRead.cc +++ b/src/iocore/cache/CacheRead.cc @@ -61,8 +61,8 @@ Cache::open_read(Continuation *cont, const CacheKey *key, CacheFragType type, co SET_CONTINUATION_HANDLER(c, &CacheVC::openReadStartHead); c->vio.op = VIO::READ; c->op_type = static_cast(CacheOpType::Read); - Metrics::Counter::increment(cache_rsb.status[c->op_type].active); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); + Metrics::Gauge::increment(cache_rsb.status[c->op_type].active); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); c->first_key = c->key = c->earliest_key = *key; c->vol = vol; c->frag_type = type; @@ -131,8 +131,8 @@ Cache::open_read(Continuation *cont, const CacheKey *key, CacheHTTPHdr *request, c->vol = vol; c->vio.op = VIO::READ; c->op_type = static_cast(CacheOpType::Read); - Metrics::Counter::increment(cache_rsb.status[c->op_type].active); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); + Metrics::Gauge::increment(cache_rsb.status[c->op_type].active); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); c->request.copy_shallow(request); c->frag_type = CACHE_FRAG_TYPE_HTTP; c->params = params; diff --git a/src/iocore/cache/CacheWrite.cc b/src/iocore/cache/CacheWrite.cc index 22f2e6a771d..916c242826b 100644 --- a/src/iocore/cache/CacheWrite.cc +++ b/src/iocore/cache/CacheWrite.cc @@ -441,8 +441,8 @@ new_DocEvacuator(int nbytes, Stripe *vol) { CacheEvacuateDocVC *c = new_CacheEvacuateDocVC(vol); c->op_type = static_cast(CacheOpType::Evacuate); - Metrics::Counter::increment(cache_rsb.status[c->op_type].active); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); + Metrics::Gauge::increment(cache_rsb.status[c->op_type].active); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); c->buf = new_IOBufferData(iobuffer_size_to_index(nbytes, MAX_BUFFER_SIZE_INDEX), MEMALIGNED); c->vol = vol; c->f.evacuator = 1; @@ -1570,8 +1570,8 @@ Cache::open_write(Continuation *cont, const CacheKey *key, CacheFragType frag_ty c->op_type = static_cast(CacheOpType::Write); c->vol = key_to_vol(key, hostname, host_len); Stripe *vol = c->vol; - Metrics::Counter::increment(cache_rsb.status[c->op_type].active); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); + Metrics::Gauge::increment(cache_rsb.status[c->op_type].active); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); c->first_key = c->key = *key; c->frag_type = frag_type; /* @@ -1690,8 +1690,8 @@ Cache::open_write(Continuation *cont, const CacheKey *key, CacheHTTPInfo *info, c->op_type = static_cast(CacheOpType::Write); } - Metrics::Counter::increment(cache_rsb.status[c->op_type].active); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); + Metrics::Gauge::increment(cache_rsb.status[c->op_type].active); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); // coverity[Y2K38_SAFETY:FALSE] c->pin_in_cache = static_cast(apin_in_cache); diff --git a/src/iocore/cache/P_CacheInternal.h b/src/iocore/cache/P_CacheInternal.h index 53b5d90c77a..4023565194f 100644 --- a/src/iocore/cache/P_CacheInternal.h +++ b/src/iocore/cache/P_CacheInternal.h @@ -187,8 +187,8 @@ free_CacheVC(CacheVC *cont) Stripe *vol = cont->vol; if (vol) { - Metrics::Counter::decrement(cache_rsb.status[cont->op_type].active); - Metrics::Counter::decrement(vol->cache_vol->vol_rsb.status[cont->op_type].active); + Metrics::Gauge::decrement(cache_rsb.status[cont->op_type].active); + Metrics::Gauge::decrement(vol->cache_vol->vol_rsb.status[cont->op_type].active); if (cont->closed > 0) { Metrics::Counter::increment(cache_rsb.status[cont->op_type].success); Metrics::Counter::increment(vol->cache_vol->vol_rsb.status[cont->op_type].success); diff --git a/src/iocore/cache/P_CacheStats.h b/src/iocore/cache/P_CacheStats.h index 09fe4781f17..be8abd2309a 100644 --- a/src/iocore/cache/P_CacheStats.h +++ b/src/iocore/cache/P_CacheStats.h @@ -28,7 +28,7 @@ enum class CacheOpType { Lookup = 0, Read, Write, Update, Remove, Evacuate, Scan struct CacheStatsBlock { struct { - Metrics::Counter::AtomicType *active = nullptr; + Metrics::Gauge::AtomicType *active = nullptr; Metrics::Counter::AtomicType *success = nullptr; Metrics::Counter::AtomicType *failure = nullptr; } status[static_cast(CacheOpType::Last)]; @@ -38,7 +38,7 @@ struct CacheStatsBlock { Metrics::Gauge::AtomicType *bytes_used = nullptr; Metrics::Gauge::AtomicType *bytes_total = nullptr; Metrics::Gauge::AtomicType *stripes = nullptr; - Metrics::Counter::AtomicType *ram_cache_bytes = nullptr; + Metrics::Gauge::AtomicType *ram_cache_bytes = nullptr; Metrics::Gauge::AtomicType *ram_cache_bytes_total = nullptr; Metrics::Gauge::AtomicType *direntries_total = nullptr; Metrics::Gauge::AtomicType *direntries_used = nullptr; diff --git a/src/iocore/cache/RamCacheCLFUS.cc b/src/iocore/cache/RamCacheCLFUS.cc index 302b6776898..d3a58f78afb 100644 --- a/src/iocore/cache/RamCacheCLFUS.cc +++ b/src/iocore/cache/RamCacheCLFUS.cc @@ -301,8 +301,8 @@ RamCacheCLFUS::get(CryptoHash *key, Ptr *ret_data, uint64_t auxkey if (!e->flag_bits.copy) { // don't bother if we have to copy anyway int64_t delta = (static_cast(e->compressed_len)) - static_cast(e->size); this->_bytes += delta; - Metrics::Counter::increment(cache_rsb.ram_cache_bytes, delta); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); + Metrics::Gauge::increment(cache_rsb.ram_cache_bytes, delta); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); e->size = e->compressed_len; check_accounting(this); e->flag_bits.compressed = 0; @@ -407,8 +407,8 @@ RamCacheCLFUS::_destroy(RamCacheCLFUSEntry *e) if (!e->flag_bits.lru) { this->_objects--; this->_bytes -= e->size + ENTRY_OVERHEAD; - Metrics::Counter::decrement(cache_rsb.ram_cache_bytes, e->size); - Metrics::Counter::decrement(vol->cache_vol->vol_rsb.ram_cache_bytes, e->size); + Metrics::Gauge::decrement(cache_rsb.ram_cache_bytes, e->size); + Metrics::Gauge::decrement(vol->cache_vol->vol_rsb.ram_cache_bytes, e->size); e->data = nullptr; } else { this->_history--; @@ -536,8 +536,8 @@ RamCacheCLFUS::compress_entries(EThread *thread, int do_at_most) e->compressed_len = l; int64_t delta = (static_cast(l)) - static_cast(e->size); this->_bytes += delta; - Metrics::Counter::increment(cache_rsb.ram_cache_bytes, delta); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); + Metrics::Gauge::increment(cache_rsb.ram_cache_bytes, delta); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); e->size = l; } else { ats_free(b); @@ -546,8 +546,8 @@ RamCacheCLFUS::compress_entries(EThread *thread, int do_at_most) memcpy(bb, e->data->data(), e->len); int64_t delta = (static_cast(e->len)) - static_cast(e->size); this->_bytes += delta; - Metrics::Counter::increment(cache_rsb.ram_cache_bytes, delta); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); + Metrics::Gauge::increment(cache_rsb.ram_cache_bytes, delta); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); e->size = e->len; l = e->len; } @@ -578,8 +578,8 @@ RamCacheCLFUS::_requeue_victims(Que(RamCacheCLFUSEntry, lru_link) & victims) RamCacheCLFUSEntry *victim = nullptr; while ((victim = victims.dequeue())) { this->_bytes += victim->size + ENTRY_OVERHEAD; - Metrics::Counter::increment(cache_rsb.ram_cache_bytes, victim->size); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, victim->size); + Metrics::Gauge::increment(cache_rsb.ram_cache_bytes, victim->size); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, victim->size); victim->hits = REQUEUE_HITS(victim->hits); this->_lru[0].enqueue(victim); } @@ -614,8 +614,8 @@ RamCacheCLFUS::put(CryptoHash *key, IOBufferData *data, uint32_t len, bool copy, this->_lru[e->flag_bits.lru].enqueue(e); int64_t delta = (static_cast(size)) - static_cast(e->size); this->_bytes += delta; - Metrics::Counter::increment(cache_rsb.ram_cache_bytes, delta); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); + Metrics::Gauge::increment(cache_rsb.ram_cache_bytes, delta); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); if (!copy) { e->size = size; e->data = data; @@ -676,8 +676,8 @@ RamCacheCLFUS::put(CryptoHash *key, IOBufferData *data, uint32_t len, bool copy, continue; } this->_bytes -= victim->size + ENTRY_OVERHEAD; - Metrics::Counter::decrement(cache_rsb.ram_cache_bytes, victim->size); - Metrics::Counter::decrement(vol->cache_vol->vol_rsb.ram_cache_bytes, victim->size); + Metrics::Gauge::decrement(cache_rsb.ram_cache_bytes, victim->size); + Metrics::Gauge::decrement(vol->cache_vol->vol_rsb.ram_cache_bytes, victim->size); victims.enqueue(victim); if (victim == this->_compressed) { this->_compressed = nullptr; @@ -705,8 +705,8 @@ RamCacheCLFUS::put(CryptoHash *key, IOBufferData *data, uint32_t len, bool copy, while ((victim = victims.dequeue())) { if (this->_bytes + size + victim->size <= this->_max_bytes) { this->_bytes += victim->size + ENTRY_OVERHEAD; - Metrics::Counter::increment(cache_rsb.ram_cache_bytes, victim->size); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, victim->size); + Metrics::Gauge::increment(cache_rsb.ram_cache_bytes, victim->size); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, victim->size); victim->hits = REQUEUE_HITS(victim->hits); this->_lru[0].enqueue(victim); } else { @@ -738,8 +738,8 @@ RamCacheCLFUS::put(CryptoHash *key, IOBufferData *data, uint32_t len, bool copy, } e->flag_bits.copy = copy; this->_bytes += size + ENTRY_OVERHEAD; - Metrics::Counter::increment(cache_rsb.ram_cache_bytes, size); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, size); + Metrics::Gauge::increment(cache_rsb.ram_cache_bytes, size); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, size); e->size = size; this->_objects++; this->_lru[0].enqueue(e); diff --git a/src/iocore/cache/RamCacheLRU.cc b/src/iocore/cache/RamCacheLRU.cc index 2b055a030e0..74acf736c25 100644 --- a/src/iocore/cache/RamCacheLRU.cc +++ b/src/iocore/cache/RamCacheLRU.cc @@ -163,8 +163,8 @@ RamCacheLRU::remove(RamCacheLRUEntry *e) bucket[b].remove(e); lru.remove(e); bytes -= ENTRY_OVERHEAD + e->data->block_size(); - Metrics::Counter::decrement(cache_rsb.ram_cache_bytes, ENTRY_OVERHEAD + e->data->block_size()); - Metrics::Counter::decrement(vol->cache_vol->vol_rsb.ram_cache_bytes, ENTRY_OVERHEAD + e->data->block_size()); + Metrics::Gauge::decrement(cache_rsb.ram_cache_bytes, ENTRY_OVERHEAD + e->data->block_size()); + Metrics::Gauge::decrement(vol->cache_vol->vol_rsb.ram_cache_bytes, ENTRY_OVERHEAD + e->data->block_size()); DDbg(dbg_ctl_ram_cache, "put %X %" PRIu64 " FREED", e->key.slice32(3), e->auxkey); e->data = nullptr; @@ -212,8 +212,8 @@ RamCacheLRU::put(CryptoHash *key, IOBufferData *data, uint32_t len, bool, uint64 lru.enqueue(e); bytes += ENTRY_OVERHEAD + data->block_size(); objects++; - Metrics::Counter::increment(cache_rsb.ram_cache_bytes, ENTRY_OVERHEAD + data->block_size()); - Metrics::Counter::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, ENTRY_OVERHEAD + data->block_size()); + Metrics::Gauge::increment(cache_rsb.ram_cache_bytes, ENTRY_OVERHEAD + data->block_size()); + Metrics::Gauge::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, ENTRY_OVERHEAD + data->block_size()); while (bytes > max_bytes) { RamCacheLRUEntry *ee = lru.dequeue(); if (ee) { diff --git a/src/iocore/dns/DNS.cc b/src/iocore/dns/DNS.cc index 73de5bcbea3..c65b68f1445 100644 --- a/src/iocore/dns/DNS.cc +++ b/src/iocore/dns/DNS.cc @@ -824,7 +824,7 @@ DNSHandler::rr_failure(int ndx) ++(e->retries); // give them another chance } --in_flight; - Metrics::Counter::decrement(dns_rsb.in_flight); + Metrics::Gauge::decrement(dns_rsb.in_flight); } } else { // move outstanding requests that were sent to this nameserver to another @@ -835,7 +835,7 @@ DNSHandler::rr_failure(int ndx) ++(e->retries); // give them another chance } --in_flight; - Metrics::Counter::decrement(dns_rsb.in_flight); + Metrics::Gauge::decrement(dns_rsb.in_flight); } } } @@ -1217,7 +1217,7 @@ write_dns_event(DNSHandler *h, DNSEntry *e, bool over_tcp) e->which_ns = h->name_server; e->once_written_flag = true; ++h->in_flight; - Metrics::Counter::increment(dns_rsb.in_flight); + Metrics::Gauge::increment(dns_rsb.in_flight); e->send_time = ink_get_hrtime(); @@ -1302,7 +1302,7 @@ DNSEntry::mainEvent(int event, Event *e) Dbg(dbg_ctl_dns, "marking %s as not-written", qname); written_flag = false; --(dnsH->in_flight); - Metrics::Counter::decrement(dns_rsb.in_flight); + Metrics::Gauge::decrement(dns_rsb.in_flight); } timeout = nullptr; dns_result(dnsH, this, result_ent.get(), true); @@ -1559,7 +1559,7 @@ dns_process(DNSHandler *handler, HostEnt *buf, int len) // e->written_flag = false; --(handler->in_flight); - Metrics::Counter::decrement(dns_rsb.in_flight); + Metrics::Gauge::decrement(dns_rsb.in_flight); // These are rolling averages ink_hrtime diff = (ink_get_hrtime() - e->send_time) / HRTIME_MSECOND; @@ -1908,7 +1908,7 @@ ink_dns_init(ts::ModuleVersion v) // Register statistics callbacks // dns_rsb.fail_time = Metrics::Counter::createPtr("proxy.process.dns.fail_time"); - dns_rsb.in_flight = Metrics::Counter::createPtr("proxy.process.dns.in_flight"); + dns_rsb.in_flight = Metrics::Gauge::createPtr("proxy.process.dns.in_flight"); dns_rsb.lookup_fail = Metrics::Counter::createPtr("proxy.process.dns.lookup_failures"); dns_rsb.lookup_success = Metrics::Counter::createPtr("proxy.process.dns.lookup_successes"); dns_rsb.max_retries_exceeded = Metrics::Counter::createPtr("proxy.process.dns.max_retries_exceeded"); diff --git a/src/iocore/dns/P_DNSProcessor.h b/src/iocore/dns/P_DNSProcessor.h index a14c44fecfa..28f7168a0b2 100644 --- a/src/iocore/dns/P_DNSProcessor.h +++ b/src/iocore/dns/P_DNSProcessor.h @@ -23,6 +23,9 @@ #pragma once +#include +#include + #include "iocore/dns/DNSProcessor.h" #include "P_DNSConnection.h" @@ -43,6 +46,8 @@ #include "ts/DbgCtl.h" +#include + #include "api/Metrics.h" using ts::Metrics; @@ -98,7 +103,7 @@ extern unsigned int dns_sequence_number; // Stats struct DNSStatsBlock { Metrics::Counter::AtomicType *fail_time; - Metrics::Counter::AtomicType *in_flight; + Metrics::Gauge::AtomicType *in_flight; Metrics::Counter::AtomicType *lookup_fail; Metrics::Counter::AtomicType *lookup_success; Metrics::Counter::AtomicType *max_retries_exceeded; diff --git a/src/iocore/hostdb/P_RefCountCache.h b/src/iocore/hostdb/P_RefCountCache.h index cf18cc6449a..d72e939ebb7 100644 --- a/src/iocore/hostdb/P_RefCountCache.h +++ b/src/iocore/hostdb/P_RefCountCache.h @@ -51,8 +51,8 @@ static constexpr ts::VersionNumber REFCOUNTCACHE_VERSION(1, 0); // Stats struct RefCountCacheBlock { - Metrics::Counter::AtomicType *refcountcache_current_items; - Metrics::Counter::AtomicType *refcountcache_current_size; + Metrics::Gauge::AtomicType *refcountcache_current_items; + Metrics::Gauge::AtomicType *refcountcache_current_size; Metrics::Counter::AtomicType *refcountcache_total_inserts; Metrics::Counter::AtomicType *refcountcache_total_failed_inserts; Metrics::Counter::AtomicType *refcountcache_total_lookups; @@ -247,8 +247,8 @@ RefCountCachePartition::put(uint64_t key, C *item, int size, int expire_time) this->item_map.insert(val); this->size += val->meta.size; this->items++; - Metrics::Counter::increment(this->rsb->refcountcache_current_size, (int64_t)val->meta.size); - Metrics::Counter::increment(this->rsb->refcountcache_current_items); + Metrics::Gauge::increment(this->rsb->refcountcache_current_size, (int64_t)val->meta.size); + Metrics::Gauge::increment(this->rsb->refcountcache_current_items); } template @@ -273,8 +273,8 @@ RefCountCachePartition::dealloc_entry(hash_type::iterator ptr) this->size -= ptr->meta.size; this->items--; - Metrics::Counter::decrement(this->rsb->refcountcache_current_size, ptr->meta.size); - Metrics::Counter::decrement(this->rsb->refcountcache_current_items); + Metrics::Gauge::decrement(this->rsb->refcountcache_current_size, ptr->meta.size); + Metrics::Gauge::decrement(this->rsb->refcountcache_current_items); // remove from expiry queue if (ptr->expiry_entry != nullptr) { @@ -432,8 +432,8 @@ RefCountCache::RefCountCache(unsigned int num_partitions, int size, int items this->max_items = items; this->num_partitions = num_partitions; - this->rsb.refcountcache_current_items = Metrics::Counter::createPtr((metrics_prefix + "current_items").c_str()); - this->rsb.refcountcache_current_size = Metrics::Counter::createPtr((metrics_prefix + "current_size").c_str()); + this->rsb.refcountcache_current_items = Metrics::Gauge::createPtr((metrics_prefix + "current_items").c_str()); + this->rsb.refcountcache_current_size = Metrics::Gauge::createPtr((metrics_prefix + "current_size").c_str()); this->rsb.refcountcache_total_inserts = Metrics::Counter::createPtr((metrics_prefix + "total_inserts").c_str()); this->rsb.refcountcache_total_failed_inserts = Metrics::Counter::createPtr((metrics_prefix + "total_failed_inserts").c_str()); this->rsb.refcountcache_total_lookups = Metrics::Counter::createPtr((metrics_prefix + "total_lookups").c_str()); diff --git a/src/iocore/io_uring/unit_tests/test_diskIO.cc b/src/iocore/io_uring/unit_tests/test_diskIO.cc index 712a181e27b..c6a6124d9a5 100644 --- a/src/iocore/io_uring/unit_tests/test_diskIO.cc +++ b/src/iocore/io_uring/unit_tests/test_diskIO.cc @@ -269,10 +269,10 @@ TEST_CASE("net_io", "[io_uring]") Metrics::Counter::AtomicType *completed = m.lookup(m.lookup("proxy.process.io_uring.completed")); - uint64_t completions_before = Metrics::Counter::load(completed); + uint64_t completions_before = Metrics::Gauge::load(completed); uint64_t needed = 2; - while ((Metrics::Counter::load(completed) - completions_before) < needed) { + while ((Metrics::Gauge::load(completed) - completions_before) < needed) { ctx.submit_and_wait(1 * HRTIME_SECOND); } diff --git a/src/iocore/net/Net.cc b/src/iocore/net/Net.cc index 41a402932bf..e13fe18ee73 100644 --- a/src/iocore/net/Net.cc +++ b/src/iocore/net/Net.cc @@ -80,43 +80,42 @@ configure_net() static inline void register_net_stats() { - net_rsb.accepts_currently_open = Metrics::Counter::createPtr("proxy.process.net.accepts_currently_open"); + net_rsb.accepts_currently_open = Metrics::Gauge::createPtr("proxy.process.net.accepts_currently_open"); net_rsb.calls_to_read = Metrics::Counter::createPtr("proxy.process.net.calls_to_read"); net_rsb.calls_to_read_nodata = Metrics::Counter::createPtr("proxy.process.net.calls_to_read_nodata"); net_rsb.calls_to_readfromnet = Metrics::Counter::createPtr("proxy.process.net.calls_to_readfromnet"); net_rsb.calls_to_write = Metrics::Counter::createPtr("proxy.process.net.calls_to_write"); net_rsb.calls_to_write_nodata = Metrics::Counter::createPtr("proxy.process.net.calls_to_write_nodata"); net_rsb.calls_to_writetonet = Metrics::Counter::createPtr("proxy.process.net.calls_to_writetonet"); - net_rsb.connections_currently_open = Metrics::Counter::createPtr("proxy.process.net.connections_currently_open"); + net_rsb.connections_currently_open = Metrics::Gauge::createPtr("proxy.process.net.connections_currently_open"); net_rsb.connections_throttled_in = Metrics::Counter::createPtr("proxy.process.net.connections_throttled_in"); net_rsb.connections_throttled_out = Metrics::Counter::createPtr("proxy.process.net.connections_throttled_out"); net_rsb.tunnel_total_client_connections_blind_tcp = Metrics::Counter::createPtr("proxy.process.tunnel.total_client_connections_blind_tcp"); net_rsb.tunnel_current_client_connections_blind_tcp = - Metrics::Counter::createPtr("proxy.process.tunnel.current_client_connections_blind_tcp"); + Metrics::Gauge::createPtr("proxy.process.tunnel.current_client_connections_blind_tcp"); net_rsb.tunnel_total_server_connections_blind_tcp = Metrics::Counter::createPtr("proxy.process.tunnel.total_server_connections_blind_tcp"); net_rsb.tunnel_current_server_connections_blind_tcp = - Metrics::Counter::createPtr("proxy.process.tunnel.current_server_connections_blind_tcp"); + Metrics::Gauge::createPtr("proxy.process.tunnel.current_server_connections_blind_tcp"); net_rsb.tunnel_total_client_connections_tls_tunnel = Metrics::Counter::createPtr("proxy.process.tunnel.total_client_connections_tls_tunnel"); net_rsb.tunnel_current_client_connections_tls_tunnel = - Metrics::Counter::createPtr("proxy.process.tunnel.current_client_connections_tls_tunnel"); + Metrics::Gauge::createPtr("proxy.process.tunnel.current_client_connections_tls_tunnel"); net_rsb.tunnel_total_client_connections_tls_forward = Metrics::Counter::createPtr("proxy.process.tunnel.total_client_connections_tls_forward"); net_rsb.tunnel_current_client_connections_tls_forward = - Metrics::Counter::createPtr("proxy.process.tunnel.current_client_connections_tls_forward"); + Metrics::Gauge::createPtr("proxy.process.tunnel.current_client_connections_tls_forward"); net_rsb.tunnel_total_client_connections_tls_partial_blind = Metrics::Counter::createPtr("proxy.process.tunnel.total_client_connections_tls_partial_blind"); net_rsb.tunnel_current_client_connections_tls_partial_blind = - Metrics::Counter::createPtr("proxy.process.tunnel.current_client_connections_tls_partial_blind"); + Metrics::Gauge::createPtr("proxy.process.tunnel.current_client_connections_tls_partial_blind"); net_rsb.tunnel_total_client_connections_tls_http = Metrics::Counter::createPtr("proxy.process.tunnel.total_client_connections_tls_http"); net_rsb.tunnel_current_client_connections_tls_http = - Metrics::Counter::createPtr("proxy.process.tunnel.current_client_connections_tls_http"); - net_rsb.tunnel_total_server_connections_tls = Metrics::Counter::createPtr("proxy.process.tunnel.total_server_connections_tls"); - net_rsb.tunnel_current_server_connections_tls = - Metrics::Counter::createPtr("proxy.process.tunnel.current_server_connections_tls"); + Metrics::Gauge::createPtr("proxy.process.tunnel.current_client_connections_tls_http"); + net_rsb.tunnel_total_server_connections_tls = Metrics::Counter::createPtr("proxy.process.tunnel.total_server_connections_tls"); + net_rsb.tunnel_current_server_connections_tls = Metrics::Gauge::createPtr("proxy.process.tunnel.current_server_connections_tls"); net_rsb.default_inactivity_timeout_applied = Metrics::Counter::createPtr("proxy.process.net.default_inactivity_timeout_applied"); net_rsb.default_inactivity_timeout_count = Metrics::Counter::createPtr("proxy.process.net.default_inactivity_timeout_count"); net_rsb.fastopen_attempts = Metrics::Counter::createPtr("proxy.process.net.fastopen_out.attempts"); @@ -129,7 +128,7 @@ register_net_stats() net_rsb.read_bytes = Metrics::Counter::createPtr("proxy.process.net.read_bytes"); net_rsb.read_bytes_count = Metrics::Counter::createPtr("proxy.process.net.read_bytes_count"); net_rsb.requests_max_throttled_in = Metrics::Counter::createPtr("proxy.process.net.max.requests_throttled_in"); - net_rsb.socks_connections_currently_open = Metrics::Counter::createPtr("proxy.process.socks.connections_currently_open"); + net_rsb.socks_connections_currently_open = Metrics::Gauge::createPtr("proxy.process.socks.connections_currently_open"); net_rsb.socks_connections_successful = Metrics::Counter::createPtr("proxy.process.socks.connections_successful"); net_rsb.socks_connections_unsuccessful = Metrics::Counter::createPtr("proxy.process.socks.connections_unsuccessful"); net_rsb.tcp_accept = Metrics::Counter::createPtr("proxy.process.tcp.total_accepts"); diff --git a/src/iocore/net/P_Net.h b/src/iocore/net/P_Net.h index 4d3a5db89ad..bf5849d75c3 100644 --- a/src/iocore/net/P_Net.h +++ b/src/iocore/net/P_Net.h @@ -35,14 +35,14 @@ using ts::Metrics; struct NetStatsBlock { - Metrics::Counter::AtomicType *accepts_currently_open; + Metrics::Gauge::AtomicType *accepts_currently_open; Metrics::Counter::AtomicType *calls_to_read_nodata; Metrics::Counter::AtomicType *calls_to_read; Metrics::Counter::AtomicType *calls_to_readfromnet; Metrics::Counter::AtomicType *calls_to_write_nodata; Metrics::Counter::AtomicType *calls_to_write; Metrics::Counter::AtomicType *calls_to_writetonet; - Metrics::Counter::AtomicType *connections_currently_open; + Metrics::Gauge::AtomicType *connections_currently_open; Metrics::Counter::AtomicType *connections_throttled_in; Metrics::Counter::AtomicType *connections_throttled_out; Metrics::Counter::AtomicType *default_inactivity_timeout_applied; @@ -58,20 +58,20 @@ struct NetStatsBlock { Metrics::Counter::AtomicType *read_bytes_count; Metrics::Counter::AtomicType *requests_max_throttled_in; Metrics::Counter::AtomicType *tunnel_total_client_connections_blind_tcp; - Metrics::Counter::AtomicType *tunnel_current_client_connections_blind_tcp; + Metrics::Gauge::AtomicType *tunnel_current_client_connections_blind_tcp; Metrics::Counter::AtomicType *tunnel_total_server_connections_blind_tcp; - Metrics::Counter::AtomicType *tunnel_current_server_connections_blind_tcp; + Metrics::Gauge::AtomicType *tunnel_current_server_connections_blind_tcp; Metrics::Counter::AtomicType *tunnel_total_client_connections_tls_tunnel; - Metrics::Counter::AtomicType *tunnel_current_client_connections_tls_tunnel; + Metrics::Gauge::AtomicType *tunnel_current_client_connections_tls_tunnel; Metrics::Counter::AtomicType *tunnel_total_server_connections_tls; - Metrics::Counter::AtomicType *tunnel_current_server_connections_tls; + Metrics::Gauge::AtomicType *tunnel_current_server_connections_tls; Metrics::Counter::AtomicType *tunnel_total_client_connections_tls_forward; - Metrics::Counter::AtomicType *tunnel_current_client_connections_tls_forward; + Metrics::Gauge::AtomicType *tunnel_current_client_connections_tls_forward; Metrics::Counter::AtomicType *tunnel_total_client_connections_tls_partial_blind; - Metrics::Counter::AtomicType *tunnel_current_client_connections_tls_partial_blind; + Metrics::Gauge::AtomicType *tunnel_current_client_connections_tls_partial_blind; Metrics::Counter::AtomicType *tunnel_total_client_connections_tls_http; - Metrics::Counter::AtomicType *tunnel_current_client_connections_tls_http; - Metrics::Counter::AtomicType *socks_connections_currently_open; + Metrics::Gauge::AtomicType *tunnel_current_client_connections_tls_http; + Metrics::Gauge::AtomicType *socks_connections_currently_open; Metrics::Counter::AtomicType *socks_connections_successful; Metrics::Counter::AtomicType *socks_connections_unsuccessful; Metrics::Counter::AtomicType *tcp_accept; diff --git a/src/iocore/net/P_UnixNet.h b/src/iocore/net/P_UnixNet.h index 80a438482ba..e875edbc5e6 100644 --- a/src/iocore/net/P_UnixNet.h +++ b/src/iocore/net/P_UnixNet.h @@ -93,7 +93,7 @@ TS_INLINE int net_connections_to_throttle(ThrottleType t) { double headroom = t == ACCEPT ? NET_THROTTLE_ACCEPT_HEADROOM : NET_THROTTLE_CONNECT_HEADROOM; - int currently_open = static_cast(Metrics::Counter::load(net_rsb.connections_currently_open)); + int currently_open = static_cast(Metrics::Gauge::load(net_rsb.connections_currently_open)); // deal with race if we got to multiple net threads if (currently_open < 0) { diff --git a/src/iocore/net/SSLNetVConnection.cc b/src/iocore/net/SSLNetVConnection.cc index 04c34b11e08..70d27a74cfa 100644 --- a/src/iocore/net/SSLNetVConnection.cc +++ b/src/iocore/net/SSLNetVConnection.cc @@ -1031,14 +1031,14 @@ SSLNetVConnection::free_thread(EThread *t) // close socket fd if (con.fd != NO_FD) { - Metrics::Counter::decrement(net_rsb.connections_currently_open); + Metrics::Gauge::decrement(net_rsb.connections_currently_open); } con.close(); if (is_tunnel_endpoint()) { ink_assert(get_context() != NET_VCONNECTION_UNSET); - Metrics::Counter::decrement(([&]() -> Metrics::Counter::AtomicType * { + Metrics::Gauge::decrement(([&]() -> Metrics::Gauge::AtomicType * { if (get_context() == NET_VCONNECTION_IN) { switch (get_tunnel_type()) { case SNIRoutingType::BLIND: @@ -1986,7 +1986,8 @@ SSLNetVConnection::_in_context_tunnel() { ink_assert(get_context() == NET_VCONNECTION_IN); - Metrics::Counter::AtomicType *t, *c; + Metrics::Counter::AtomicType *t; + Metrics::Gauge::AtomicType *c; switch (get_tunnel_type()) { case SNIRoutingType::BLIND: @@ -2007,7 +2008,7 @@ SSLNetVConnection::_in_context_tunnel() break; } Metrics::Counter::increment(t); - Metrics::Counter::increment(c); + Metrics::Gauge::increment(c); } void @@ -2019,7 +2020,7 @@ SSLNetVConnection::_out_context_tunnel() ink_assert(get_tunnel_type() == SNIRoutingType::NONE); Metrics::Counter::increment(net_rsb.tunnel_total_server_connections_tls); - Metrics::Counter::increment(net_rsb.tunnel_current_server_connections_tls); + Metrics::Gauge::increment(net_rsb.tunnel_current_server_connections_tls); } void diff --git a/src/iocore/net/UnixNetAccept.cc b/src/iocore/net/UnixNetAccept.cc index 76aa8ed5703..36e7079fc71 100644 --- a/src/iocore/net/UnixNetAccept.cc +++ b/src/iocore/net/UnixNetAccept.cc @@ -88,7 +88,7 @@ net_accept(NetAccept *na, void *ep, bool blockable) } count++; - Metrics::Counter::increment(net_rsb.connections_currently_open); + Metrics::Gauge::increment(net_rsb.connections_currently_open); vc->id = net_next_connection_number(); vc->con.move(con); vc->set_remote_addr(con.addr); @@ -355,7 +355,7 @@ NetAccept::do_blocking_accept(EThread *t) } count++; - Metrics::Counter::increment(net_rsb.connections_currently_open); + Metrics::Gauge::increment(net_rsb.connections_currently_open); vc->id = net_next_connection_number(); vc->con.move(con); vc->set_remote_addr(con.addr); @@ -410,14 +410,14 @@ NetAccept::acceptEvent(int event, void *ep) if (lock.is_locked()) { if (action_->cancelled) { e->cancel(); - Metrics::Counter::decrement(net_rsb.accepts_currently_open); + Metrics::Gauge::decrement(net_rsb.accepts_currently_open); delete this; return EVENT_DONE; } int res; if ((res = accept_fn(this, e, false)) < 0) { - Metrics::Counter::decrement(net_rsb.accepts_currently_open); + Metrics::Gauge::decrement(net_rsb.accepts_currently_open); /* INKqa11179 */ Warning("Accept on port %d failed with error no %d", ats_ip_port_host_order(&server.addr), res); Warning("Traffic Server may be unable to accept more network" @@ -512,7 +512,7 @@ NetAccept::acceptFastEvent(int event, void *ep) ink_release_assert(vc); count++; - Metrics::Counter::increment(net_rsb.connections_currently_open); + Metrics::Gauge::increment(net_rsb.connections_currently_open); vc->id = net_next_connection_number(); vc->con.move(con); vc->set_remote_addr(con.addr); @@ -560,7 +560,7 @@ NetAccept::acceptFastEvent(int event, void *ep) Lerror: server.close(); e->cancel(); - Metrics::Counter::decrement(net_rsb.accepts_currently_open); + Metrics::Gauge::decrement(net_rsb.accepts_currently_open); delete this; return EVENT_DONE; } @@ -577,7 +577,7 @@ NetAccept::acceptLoopEvent(int event, Event *e) } // Don't think this ever happens ... - Metrics::Counter::decrement(net_rsb.accepts_currently_open); + Metrics::Gauge::decrement(net_rsb.accepts_currently_open); delete this; return EVENT_DONE; } diff --git a/src/iocore/net/UnixNetProcessor.cc b/src/iocore/net/UnixNetProcessor.cc index a5b0158f7f8..f722f5ec6ea 100644 --- a/src/iocore/net/UnixNetProcessor.cc +++ b/src/iocore/net/UnixNetProcessor.cc @@ -97,7 +97,7 @@ UnixNetProcessor::accept_internal(Continuation *cont, int fd, AcceptOptions cons Fatal("Please disable accept_threads or exec_thread.listen"); } - Metrics::Counter::increment(net_rsb.accepts_currently_open); + Metrics::Gauge::increment(net_rsb.accepts_currently_open); // We've handled the config stuff at start up, but there are a few cases // we must handle at this point. diff --git a/src/iocore/net/UnixNetVConnection.cc b/src/iocore/net/UnixNetVConnection.cc index e91ff9dceed..d449889e668 100644 --- a/src/iocore/net/UnixNetVConnection.cc +++ b/src/iocore/net/UnixNetVConnection.cc @@ -1212,7 +1212,7 @@ UnixNetVConnection::connectUp(EThread *t, int fd) } // Did not fail, increment connection count - Metrics::Counter::increment(net_rsb.connections_currently_open); + Metrics::Gauge::increment(net_rsb.connections_currently_open); ink_release_assert(con.fd != NO_FD); // Setup a timeout callback handler. @@ -1290,14 +1290,14 @@ UnixNetVConnection::free_thread(EThread *t) // close socket fd if (con.fd != NO_FD) { - Metrics::Counter::decrement(net_rsb.connections_currently_open); + Metrics::Gauge::decrement(net_rsb.connections_currently_open); } con.close(); if (is_tunnel_endpoint()) { Debug("iocore_net", "Freeing UnixNetVConnection that is tunnel endpoint"); - Metrics::Counter::decrement(([&]() -> Metrics::Counter::AtomicType * { + Metrics::Gauge::decrement(([&]() -> Metrics::Gauge::AtomicType * { switch (get_context()) { case NET_VCONNECTION_IN: return net_rsb.tunnel_current_client_connections_blind_tcp; @@ -1534,12 +1534,12 @@ void UnixNetVConnection::_in_context_tunnel() { Metrics::Counter::increment(net_rsb.tunnel_total_client_connections_blind_tcp); - Metrics::Counter::increment(net_rsb.tunnel_current_client_connections_blind_tcp); + Metrics::Gauge::increment(net_rsb.tunnel_current_client_connections_blind_tcp); } void UnixNetVConnection::_out_context_tunnel() { Metrics::Counter::increment(net_rsb.tunnel_total_server_connections_blind_tcp); - Metrics::Counter::increment(net_rsb.tunnel_current_server_connections_blind_tcp); + Metrics::Gauge::increment(net_rsb.tunnel_current_server_connections_blind_tcp); } diff --git a/src/proxy/http/Http1ClientSession.cc b/src/proxy/http/Http1ClientSession.cc index a36e942bc40..91ac594419b 100644 --- a/src/proxy/http/Http1ClientSession.cc +++ b/src/proxy/http/Http1ClientSession.cc @@ -118,7 +118,7 @@ Http1ClientSession::free() #endif if (conn_decrease) { - Metrics::Counter::decrement(http_rsb.current_client_connections); + Metrics::Gauge::decrement(http_rsb.current_client_connections); conn_decrease = false; } @@ -154,7 +154,7 @@ Http1ClientSession::new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOB schedule_event = nullptr; - Metrics::Counter::increment(http_rsb.current_client_connections); + Metrics::Gauge::increment(http_rsb.current_client_connections); conn_decrease = true; Metrics::Counter::increment(http_rsb.total_client_connections); if (static_cast(new_vc->attributes) == HttpProxyPort::TRANSPORT_SSL) { @@ -513,12 +513,12 @@ Http1ClientSession::attach_server_session(PoolableSession *ssession, bool transa void Http1ClientSession::increment_current_active_connections_stat() { - Metrics::Counter::increment(http_rsb.current_active_client_connections); + Metrics::Gauge::increment(http_rsb.current_active_client_connections); } void Http1ClientSession::decrement_current_active_connections_stat() { - Metrics::Counter::decrement(http_rsb.current_active_client_connections); + Metrics::Gauge::decrement(http_rsb.current_active_client_connections); } void diff --git a/src/proxy/http/Http1ClientTransaction.cc b/src/proxy/http/Http1ClientTransaction.cc index b02448944f3..2e3672f5fbc 100644 --- a/src/proxy/http/Http1ClientTransaction.cc +++ b/src/proxy/http/Http1ClientTransaction.cc @@ -59,11 +59,11 @@ Http1ClientTransaction::allow_half_open() const void Http1ClientTransaction::increment_transactions_stat() { - Metrics::Counter::increment(http_rsb.current_client_transactions); + Metrics::Gauge::increment(http_rsb.current_client_transactions); } void Http1ClientTransaction::decrement_transactions_stat() { - Metrics::Counter::decrement(http_rsb.current_client_transactions); + Metrics::Gauge::decrement(http_rsb.current_client_transactions); } diff --git a/src/proxy/http/Http1ServerSession.cc b/src/proxy/http/Http1ServerSession.cc index 808c93a9254..6db6eacef2c 100644 --- a/src/proxy/http/Http1ServerSession.cc +++ b/src/proxy/http/Http1ServerSession.cc @@ -80,7 +80,7 @@ Http1ServerSession::new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOB con_id = ProxySession::next_connection_id(); magic = HTTP_SS_MAGIC_ALIVE; - Metrics::Counter::increment(http_rsb.current_server_connections); + Metrics::Gauge::increment(http_rsb.current_server_connections); Metrics::Counter::increment(http_rsb.total_server_connections); if (iobuf == nullptr) { @@ -110,7 +110,7 @@ Http1ServerSession::do_io_close(int alerrno) w.print("[{}] session close: nevtc {:x}", con_id, _vc); } - Metrics::Counter::decrement(http_rsb.current_server_connections); + Metrics::Gauge::decrement(http_rsb.current_server_connections); // Update upstream connection tracking data if present. this->release_outbound_connection_tracking(); @@ -125,7 +125,7 @@ Http1ServerSession::do_io_close(int alerrno) _vc = nullptr; if (to_parent_proxy) { - Metrics::Counter::decrement(http_rsb.current_parent_proxy_connections); + Metrics::Gauge::decrement(http_rsb.current_parent_proxy_connections); } } diff --git a/src/proxy/http/Http1ServerTransaction.cc b/src/proxy/http/Http1ServerTransaction.cc index e51918179d0..bfe88da67b8 100644 --- a/src/proxy/http/Http1ServerTransaction.cc +++ b/src/proxy/http/Http1ServerTransaction.cc @@ -33,13 +33,13 @@ Http1ServerTransaction::release() void Http1ServerTransaction::increment_transactions_stat() { - Metrics::Counter::increment(http_rsb.current_server_transactions); + Metrics::Gauge::increment(http_rsb.current_server_transactions); } void Http1ServerTransaction::decrement_transactions_stat() { - Metrics::Counter::decrement(http_rsb.current_server_transactions); + Metrics::Gauge::decrement(http_rsb.current_server_transactions); } void diff --git a/src/proxy/http/HttpCacheSM.cc b/src/proxy/http/HttpCacheSM.cc index c6ef0cf3d4a..08004c347cd 100644 --- a/src/proxy/http/HttpCacheSM.cc +++ b/src/proxy/http/HttpCacheSM.cc @@ -107,7 +107,7 @@ HttpCacheSM::state_cache_open_read(int event, void *data) switch (event) { case CACHE_EVENT_OPEN_READ: - Metrics::Counter::increment(http_rsb.current_cache_connections); + Metrics::Gauge::increment(http_rsb.current_cache_connections); ink_assert((cache_read_vc == nullptr) || master_sm->t_state.redirect_info.redirect_in_process); if (cache_read_vc) { // redirect follow in progress, close the previous cache_read_vc @@ -186,7 +186,7 @@ HttpCacheSM::state_cache_open_write(int event, void *data) switch (event) { case CACHE_EVENT_OPEN_WRITE: - Metrics::Counter::increment(http_rsb.current_cache_connections); + Metrics::Gauge::increment(http_rsb.current_cache_connections); ink_assert(cache_write_vc == nullptr); cache_write_vc = static_cast(data); open_write_cb = true; diff --git a/src/proxy/http/HttpConfig.cc b/src/proxy/http/HttpConfig.cc index ce90af072da..153a5ccf373 100644 --- a/src/proxy/http/HttpConfig.cc +++ b/src/proxy/http/HttpConfig.cc @@ -261,7 +261,7 @@ register_stat_callbacks() { http_rsb.background_fill_bytes_aborted = Metrics::Counter::createPtr("proxy.process.http.background_fill_bytes_aborted"); http_rsb.background_fill_bytes_completed = Metrics::Counter::createPtr("proxy.process.http.background_fill_bytes_completed"); - http_rsb.background_fill_current_count = Metrics::Counter::createPtr("proxy.process.http.background_fill_current_count"); + http_rsb.background_fill_current_count = Metrics::Gauge::createPtr("proxy.process.http.background_fill_current_count"); http_rsb.background_fill_total_count = Metrics::Counter::createPtr("proxy.process.http.background_fill_total_count"); http_rsb.broken_server_connections = Metrics::Counter::createPtr("proxy.process.http.broken_server_connections"); http_rsb.cache_deletes = Metrics::Counter::createPtr("proxy.process.http.cache_deletes"); @@ -289,13 +289,13 @@ register_stat_callbacks() http_rsb.cache_writes = Metrics::Counter::createPtr("proxy.process.http.cache_writes"); http_rsb.completed_requests = Metrics::Counter::createPtr("proxy.process.http.completed_requests"); http_rsb.connect_requests = Metrics::Counter::createPtr("proxy.process.http.connect_requests"); - http_rsb.current_active_client_connections = Metrics::Counter::createPtr("proxy.process.http.current_active_client_connections"); - http_rsb.current_cache_connections = Metrics::Counter::createPtr("proxy.process.http.current_cache_connections"); - http_rsb.current_client_connections = Metrics::Counter::createPtr("proxy.process.http.current_client_connections"); - http_rsb.current_client_transactions = Metrics::Counter::createPtr("proxy.process.http.current_client_transactions"); - http_rsb.current_parent_proxy_connections = Metrics::Counter::createPtr("proxy.process.http.current_parent_proxy_connections"); - http_rsb.current_server_connections = Metrics::Counter::createPtr("proxy.process.http.current_server_connections"); - http_rsb.current_server_transactions = Metrics::Counter::createPtr("proxy.process.http.current_server_transactions"); + http_rsb.current_active_client_connections = Metrics::Gauge::createPtr("proxy.process.http.current_active_client_connections"); + http_rsb.current_cache_connections = Metrics::Gauge::createPtr("proxy.process.http.current_cache_connections"); + http_rsb.current_client_connections = Metrics::Gauge::createPtr("proxy.process.http.current_client_connections"); + http_rsb.current_client_transactions = Metrics::Gauge::createPtr("proxy.process.http.current_client_transactions"); + http_rsb.current_parent_proxy_connections = Metrics::Gauge::createPtr("proxy.process.http.current_parent_proxy_connections"); + http_rsb.current_server_connections = Metrics::Gauge::createPtr("proxy.process.http.current_server_connections"); + http_rsb.current_server_transactions = Metrics::Gauge::createPtr("proxy.process.http.current_server_transactions"); http_rsb.delete_requests = Metrics::Counter::createPtr("proxy.process.http.delete_requests"); http_rsb.disallowed_post_100_continue = Metrics::Counter::createPtr("proxy.process.http.disallowed_post_100_continue"); http_rsb.dns_lookup_begin_time = Metrics::Counter::createPtr("proxy.process.http.milestone.dns_lookup_begin"); @@ -378,7 +378,7 @@ register_stat_callbacks() http_rsb.parent_proxy_request_total_bytes = Metrics::Counter::createPtr("proxy.process.http.parent_proxy_request_total_bytes"); http_rsb.parent_proxy_response_total_bytes = Metrics::Counter::createPtr("proxy.process.http.parent_proxy_response_total_bytes"); http_rsb.parent_proxy_transaction_time = Metrics::Counter::createPtr("proxy.process.http.parent_proxy_transaction_time"); - http_rsb.pooled_server_connections = Metrics::Counter::createPtr("proxy.process.http.pooled_server_connections"); + http_rsb.pooled_server_connections = Metrics::Gauge::createPtr("proxy.process.http.pooled_server_connections"); http_rsb.post_body_too_large = Metrics::Counter::createPtr("proxy.process.http.post_body_too_large"); http_rsb.post_requests = Metrics::Counter::createPtr("proxy.process.http.post_requests"); http_rsb.proxy_loop_detected = Metrics::Counter::createPtr("proxy.process.http.http_proxy_loop_detected"); @@ -484,7 +484,7 @@ register_stat_callbacks() http_rsb.total_transactions_time = Metrics::Counter::createPtr("proxy.process.http.total_transactions_time"); http_rsb.total_x_redirect = Metrics::Counter::createPtr("proxy.process.http.total_x_redirect_count"); http_rsb.trace_requests = Metrics::Counter::createPtr("proxy.process.http.trace_requests"); - http_rsb.tunnel_current_active_connections = Metrics::Counter::createPtr("proxy.process.tunnel.current_active_connections"); + http_rsb.tunnel_current_active_connections = Metrics::Gauge::createPtr("proxy.process.tunnel.current_active_connections"); http_rsb.tunnels = Metrics::Counter::createPtr("proxy.process.http.tunnels"); http_rsb.ua_begin_time = Metrics::Counter::createPtr("proxy.process.http.milestone.ua_begin"); http_rsb.ua_begin_write_time = Metrics::Counter::createPtr("proxy.process.http.milestone.ua_begin_write"); @@ -534,7 +534,7 @@ register_stat_callbacks() http_rsb.user_agent_response_header_total_size = Metrics::Counter::createPtr("proxy.process.http.user_agent_response_header_total_size"); http_rsb.websocket_current_active_client_connections = - Metrics::Counter::createPtr("proxy.process.http.websocket.current_active_client_connections"); + Metrics::Gauge::createPtr("proxy.process.http.websocket.current_active_client_connections"); } static bool diff --git a/src/proxy/http/HttpSM.cc b/src/proxy/http/HttpSM.cc index 692fa10bc7f..5b39ebf3f0c 100644 --- a/src/proxy/http/HttpSM.cc +++ b/src/proxy/http/HttpSM.cc @@ -1609,7 +1609,7 @@ HttpSM::handle_api_return() // a blind tunnel. IOBufferReader *initial_data = nullptr; if (t_state.is_websocket) { - Metrics::Counter::increment(http_rsb.websocket_current_active_client_connections); + Metrics::Gauge::increment(http_rsb.websocket_current_active_client_connections); if (server_txn) { initial_data = server_txn->get_remote_reader(); } @@ -1726,7 +1726,7 @@ HttpSM::create_server_txn(PoolableSession *new_session) server_txn->attach_transaction(this); if (t_state.current.request_to == ResolveInfo::PARENT_PROXY) { new_session->to_parent_proxy = true; - Metrics::Counter::increment(http_rsb.current_parent_proxy_connections); + Metrics::Gauge::increment(http_rsb.current_parent_proxy_connections); Metrics::Counter::increment(http_rsb.total_parent_proxy_connections); } else { new_session->to_parent_proxy = false; @@ -3009,7 +3009,7 @@ HttpSM::tunnel_handler(int event, void *data) terminate_sm = true; if (unlikely(t_state.is_websocket)) { - Metrics::Counter::decrement(http_rsb.websocket_current_active_client_connections); + Metrics::Gauge::decrement(http_rsb.websocket_current_active_client_connections); } return 0; @@ -3202,7 +3202,7 @@ HttpSM::tunnel_handler_server(int event, HttpTunnelProducer *p) // If we had a ground fill, check update our status if (background_fill == BACKGROUND_FILL_STARTED) { background_fill = p->read_success ? BACKGROUND_FILL_COMPLETED : BACKGROUND_FILL_ABORTED; - Metrics::Counter::decrement(http_rsb.background_fill_current_count); + Metrics::Gauge::decrement(http_rsb.background_fill_current_count); } // We handled the event. Now either shutdown the connection or // setup it up for keep-alive @@ -3449,7 +3449,7 @@ HttpSM::tunnel_handler_ua(int event, HttpTunnelConsumer *c) // There is another consumer (cache write) so // detach the user agent if (background_fill == BACKGROUND_FILL_STARTED) { - Metrics::Counter::increment(http_rsb.background_fill_current_count); + Metrics::Gauge::increment(http_rsb.background_fill_current_count); Metrics::Counter::increment(http_rsb.background_fill_total_count); ink_assert(c->is_downstream_from(server_txn)); @@ -3688,7 +3688,7 @@ HttpSM::tunnel_handler_cache_read(int event, HttpTunnelProducer *p) break; } - Metrics::Counter::decrement(http_rsb.current_cache_connections); + Metrics::Gauge::decrement(http_rsb.current_cache_connections); return 0; } @@ -3743,7 +3743,7 @@ HttpSM::tunnel_handler_cache_write(int event, HttpTunnelConsumer *c) server_response_body_bytes = c->bytes_written; } - Metrics::Counter::decrement(http_rsb.current_cache_connections); + Metrics::Gauge::decrement(http_rsb.current_cache_connections); return 0; } @@ -5472,7 +5472,7 @@ HttpSM::do_http_server_open(bool raw, bool only_direct) // Atomically read the current number of connections and check to see // if we have gone above the max allowed. if (t_state.http_config_param->server_max_connections > 0) { - if (Metrics::Counter::load(http_rsb.current_server_connections) >= t_state.http_config_param->server_max_connections) { + if (Metrics::Gauge::load(http_rsb.current_server_connections) >= t_state.http_config_param->server_max_connections) { httpSessionManager.purge_keepalives(); // Eventually may want to have a queue as the origin_max_connection does to allow for a combination // of retries and errors. But at this point, we are just going to allow the error case. diff --git a/src/proxy/http/HttpSessionManager.cc b/src/proxy/http/HttpSessionManager.cc index 07a621372ee..9f4a28e4e95 100644 --- a/src/proxy/http/HttpSessionManager.cc +++ b/src/proxy/http/HttpSessionManager.cc @@ -536,7 +536,7 @@ ServerSessionPool::removeSession(PoolableSession *to_remove) } m_fqdn_pool.erase(to_remove); if (m_ip_pool.erase(to_remove)) { - Metrics::Counter::decrement(http_rsb.pooled_server_connections); + Metrics::Gauge::decrement(http_rsb.pooled_server_connections); } if (is_debug_tag_set("http_ss")) { Debug("http_ss", "After Remove session %p m_fqdn_pool size=%zu m_ip_pool_size=%zu", to_remove, m_fqdn_pool.count(), @@ -552,7 +552,7 @@ ServerSessionPool::addSession(PoolableSession *ss) // put it in the pools. m_ip_pool.insert(ss); m_fqdn_pool.insert(ss); - Metrics::Counter::increment(http_rsb.pooled_server_connections); + Metrics::Gauge::increment(http_rsb.pooled_server_connections); if (is_debug_tag_set("http_ss")) { char peer_ip[INET6_ADDRPORTSTRLEN]; diff --git a/src/proxy/http/HttpTransact.cc b/src/proxy/http/HttpTransact.cc index 68b295f0616..2f8ea0c5066 100644 --- a/src/proxy/http/HttpTransact.cc +++ b/src/proxy/http/HttpTransact.cc @@ -1517,7 +1517,7 @@ HttpTransact::HandleRequest(State *s) initialize_state_variables_from_request(s, &s->hdr_info.client_request); // The following chunk of code will limit the maximum number of websocket connections (TS-3659) if (s->is_upgrade_request && s->is_websocket && s->http_config_param->max_websocket_connections >= 0) { - if (Metrics::Counter::load(http_rsb.websocket_current_active_client_connections) >= + if (Metrics::Gauge::load(http_rsb.websocket_current_active_client_connections) >= s->http_config_param->max_websocket_connections) { s->is_websocket = false; // unset to avoid screwing up stats. TxnDebug("http_trans", "Rejecting websocket connection because the limit has been exceeded"); diff --git a/src/proxy/http/HttpTunnel.cc b/src/proxy/http/HttpTunnel.cc index dcfd0293bf9..d26e57b1e0a 100644 --- a/src/proxy/http/HttpTunnel.cc +++ b/src/proxy/http/HttpTunnel.cc @@ -1601,7 +1601,7 @@ HttpTunnel::chain_abort_cache_write(HttpTunnelProducer *p) c->write_vio = nullptr; c->vc->do_io_close(EHTTP_ERROR); c->alive = false; - Metrics::Counter::decrement(http_rsb.current_cache_connections); + Metrics::Gauge::decrement(http_rsb.current_cache_connections); } else if (c->self_producer) { chain_abort_cache_write(c->self_producer); } @@ -1715,7 +1715,7 @@ HttpTunnel::update_stats_after_abort(HttpTunnelType_t t) switch (t) { case HT_CACHE_READ: case HT_CACHE_WRITE: - Metrics::Counter::decrement(http_rsb.current_cache_connections); + Metrics::Gauge::decrement(http_rsb.current_cache_connections); break; default: // Handled here: @@ -1740,7 +1740,7 @@ HttpTunnel::mark_tls_tunnel_active() } _tls_tunnel_active = true; - Metrics::Counter::increment(http_rsb.tunnel_current_active_connections); + Metrics::Gauge::increment(http_rsb.tunnel_current_active_connections); _schedule_tls_tunnel_activity_check_event(); } @@ -1753,7 +1753,7 @@ HttpTunnel::mark_tls_tunnel_inactive() } _tls_tunnel_active = false; - Metrics::Counter::decrement(http_rsb.tunnel_current_active_connections); + Metrics::Gauge::decrement(http_rsb.tunnel_current_active_connections); if (_tls_tunnel_activity_check_event) { _tls_tunnel_activity_check_event->cancel(); diff --git a/src/proxy/http2/HTTP2.cc b/src/proxy/http2/HTTP2.cc index bbf0837c7e3..97429311a92 100644 --- a/src/proxy/http2/HTTP2.cc +++ b/src/proxy/http2/HTTP2.cc @@ -563,14 +563,14 @@ Http2::init() ink_release_assert(http2_settings_parameter_is_valid({HTTP2_SETTINGS_MAX_HEADER_LIST_SIZE, max_header_list_size})); // Setup statistics - http2_rsb.current_client_session_count = Metrics::Counter::createPtr("proxy.process.http2.current_client_connections"); - http2_rsb.current_server_session_count = Metrics::Counter::createPtr("proxy.process.http2.current_server_connections"); + http2_rsb.current_client_session_count = Metrics::Gauge::createPtr("proxy.process.http2.current_client_connections"); + http2_rsb.current_server_session_count = Metrics::Gauge::createPtr("proxy.process.http2.current_server_connections"); http2_rsb.current_active_client_connection_count = - Metrics::Counter::createPtr("proxy.process.http2.current_active_client_connections"); + Metrics::Gauge::createPtr("proxy.process.http2.current_active_client_connections"); http2_rsb.current_active_server_connection_count = - Metrics::Counter::createPtr("proxy.process.http2.current_active_server_connections"); - http2_rsb.current_client_stream_count = Metrics::Counter::createPtr("proxy.process.http2.current_client_streams"); - http2_rsb.current_server_stream_count = Metrics::Counter::createPtr("proxy.process.http2.current_server_streams"); + Metrics::Gauge::createPtr("proxy.process.http2.current_active_server_connections"); + http2_rsb.current_client_stream_count = Metrics::Gauge::createPtr("proxy.process.http2.current_client_streams"); + http2_rsb.current_server_stream_count = Metrics::Gauge::createPtr("proxy.process.http2.current_server_streams"); http2_rsb.total_client_stream_count = Metrics::Counter::createPtr("proxy.process.http2.total_client_streams"); http2_rsb.total_server_stream_count = Metrics::Counter::createPtr("proxy.process.http2.total_server_streams"); http2_rsb.total_transactions_time = Metrics::Counter::createPtr("proxy.process.http2.total_transactions_time"); diff --git a/src/proxy/http2/Http2ClientSession.cc b/src/proxy/http2/Http2ClientSession.cc index a044618e5b3..f343a6b1c54 100644 --- a/src/proxy/http2/Http2ClientSession.cc +++ b/src/proxy/http2/Http2ClientSession.cc @@ -60,7 +60,7 @@ Http2ClientSession::free() { auto mutex_thread = this->mutex->thread_holding; if (Http2CommonSession::common_free(this)) { - Metrics::Counter::decrement(http2_rsb.current_client_session_count); + Metrics::Gauge::decrement(http2_rsb.current_client_session_count); THREAD_FREE(this, http2ClientSessionAllocator, mutex_thread); } } @@ -88,7 +88,7 @@ void Http2ClientSession::new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOBufferReader *reader) { ink_assert(new_vc->mutex->thread_holding == this_ethread()); - Metrics::Counter::increment(http2_rsb.current_client_session_count); + Metrics::Gauge::increment(http2_rsb.current_client_session_count); Metrics::Counter::increment(http2_rsb.total_client_connection_count); this->_milestones.mark(Http2SsnMilestone::OPEN); @@ -254,13 +254,13 @@ Http2ClientSession::main_event_handler(int event, void *edata) void Http2ClientSession::increment_current_active_connections_stat() { - Metrics::Counter::increment(http2_rsb.current_active_client_connection_count); + Metrics::Gauge::increment(http2_rsb.current_active_client_connection_count); } void Http2ClientSession::decrement_current_active_connections_stat() { - Metrics::Counter::decrement(http2_rsb.current_active_client_connection_count); + Metrics::Gauge::decrement(http2_rsb.current_active_client_connection_count); } sockaddr const * diff --git a/src/proxy/http2/Http2ConnectionState.cc b/src/proxy/http2/Http2ConnectionState.cc index d0d62d3992b..7afdadb0648 100644 --- a/src/proxy/http2/Http2ConnectionState.cc +++ b/src/proxy/http2/Http2ConnectionState.cc @@ -2649,7 +2649,7 @@ Http2ConnectionState::_adjust_concurrent_stream() return max_concurrent_streams; } - int64_t current_client_streams = Metrics::Counter::load(http2_rsb.current_client_stream_count); + int64_t current_client_streams = Metrics::Gauge::load(http2_rsb.current_client_stream_count); Http2ConDebug(session, "current client streams: %" PRId64, current_client_streams); diff --git a/src/proxy/http2/Http2ServerSession.cc b/src/proxy/http2/Http2ServerSession.cc index 5e84494bb82..10896ac6aaf 100644 --- a/src/proxy/http2/Http2ServerSession.cc +++ b/src/proxy/http2/Http2ServerSession.cc @@ -61,7 +61,7 @@ Http2ServerSession::free() { auto mutex_thread = this->mutex->thread_holding; if (Http2CommonSession::common_free(this)) { - Metrics::Counter::decrement(http2_rsb.current_server_session_count); + Metrics::Gauge::decrement(http2_rsb.current_server_session_count); THREAD_FREE(this, http2ServerSessionAllocator, mutex_thread); } } @@ -96,7 +96,7 @@ Http2ServerSession::new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOB { ink_assert(new_vc->mutex->thread_holding == this_ethread()); - Metrics::Counter::increment(http2_rsb.current_server_session_count); + Metrics::Gauge::increment(http2_rsb.current_server_session_count); Metrics::Counter::increment(http2_rsb.total_server_connection_count); this->_milestones.mark(Http2SsnMilestone::OPEN); diff --git a/src/proxy/http2/Http2Stream.cc b/src/proxy/http2/Http2Stream.cc index a7f36a39d28..fac543b6bfa 100644 --- a/src/proxy/http2/Http2Stream.cc +++ b/src/proxy/http2/Http2Stream.cc @@ -1030,10 +1030,10 @@ void Http2Stream::increment_transactions_stat() { if (this->is_outbound_connection()) { - Metrics::Counter::increment(http2_rsb.current_server_stream_count); + Metrics::Gauge::increment(http2_rsb.current_server_stream_count); Metrics::Counter::increment(http2_rsb.total_server_stream_count); } else { - Metrics::Counter::increment(http2_rsb.current_client_stream_count); + Metrics::Gauge::increment(http2_rsb.current_client_stream_count); Metrics::Counter::increment(http2_rsb.total_client_stream_count); } } @@ -1042,9 +1042,9 @@ void Http2Stream::decrement_transactions_stat() { if (this->is_outbound_connection()) { - Metrics::Counter::decrement(http2_rsb.current_server_stream_count); + Metrics::Gauge::decrement(http2_rsb.current_server_stream_count); } else { - Metrics::Counter::decrement(http2_rsb.current_client_stream_count); + Metrics::Gauge::decrement(http2_rsb.current_client_stream_count); } } diff --git a/src/proxy/http3/Http3.cc b/src/proxy/http3/Http3.cc index f2c87063c7a..f46c1b933c0 100644 --- a/src/proxy/http3/Http3.cc +++ b/src/proxy/http3/Http3.cc @@ -37,5 +37,5 @@ Http3::init() // Example (remove comments here when addding) // // Setup statistics - // http3_rsb.current_client_session_count = Metrics::Counter::createPtr("proxy.process.http3.current_client_connections"); + // http3_rsb.current_client_session_count = Metrics::Gauge::createPtr("proxy.process.http3.current_client_connections"); } diff --git a/src/proxy/logging/LogConfig.cc b/src/proxy/logging/LogConfig.cc index b3683b24486..4ef25ef8cfc 100644 --- a/src/proxy/logging/LogConfig.cc +++ b/src/proxy/logging/LogConfig.cc @@ -531,7 +531,7 @@ LogConfig::register_stat_callbacks() log_rsb.bytes_lost_before_flush_to_disk = Metrics::Counter::createPtr("proxy.process.log.bytes_lost_before_flush_to_disk"); log_rsb.bytes_written_to_disk = Metrics::Counter::createPtr("proxy.process.log.bytes_written_to_disk"); log_rsb.bytes_lost_before_written_to_disk = Metrics::Counter::createPtr("proxy.process.log.bytes_lost_before_written_to_disk"); - log_rsb.log_files_open = Metrics::Counter::createPtr("proxy.process.log.log_files_open"); + log_rsb.log_files_open = Metrics::Gauge::createPtr("proxy.process.log.log_files_open"); log_rsb.log_files_space_used = Metrics::Gauge::createPtr("proxy.process.log.log_files_space_used"); } diff --git a/src/proxy/logging/LogFile.cc b/src/proxy/logging/LogFile.cc index 269ccaa004b..0e4e7bc3f1d 100644 --- a/src/proxy/logging/LogFile.cc +++ b/src/proxy/logging/LogFile.cc @@ -223,7 +223,7 @@ LogFile::open_file() } } - Metrics::Counter::increment(log_rsb.log_files_open); + Metrics::Gauge::increment(log_rsb.log_files_open); Debug("log", "exiting LogFile::open_file(), file=%s presumably open", m_name); return LOG_FILE_NO_ERROR; @@ -244,7 +244,7 @@ LogFile::close_file() Error("Error closing LogFile %s: %s.", m_name, strerror(errno)); } else { Debug("log-file", "LogFile %s (fd=%d) is closed", m_name, m_fd); - Metrics::Counter::decrement(log_rsb.log_files_open); + Metrics::Gauge::decrement(log_rsb.log_files_open); } m_fd = -1; } else if (m_log) { @@ -252,7 +252,7 @@ LogFile::close_file() Error("Error closing LogFile %s: %s.", m_log->get_name(), strerror(errno)); } else { Debug("log-file", "LogFile %s is closed", m_log->get_name()); - Metrics::Counter::decrement(log_rsb.log_files_open); + Metrics::Gauge::decrement(log_rsb.log_files_open); } } else { Warning("LogFile %s is open but was not closed", m_name); diff --git a/src/traffic_server/traffic_server.cc b/src/traffic_server/traffic_server.cc index 5ab5943dcdd..b20e72e8cea 100644 --- a/src/traffic_server/traffic_server.cc +++ b/src/traffic_server/traffic_server.cc @@ -1426,7 +1426,7 @@ struct ShowStats : public Continuation { int64_t d_nw = Metrics::Counter::load(net_rsb.write_bytes_count) - last_nw; last_nw += d_nw; - int64_t d_o = Metrics::Counter::load(net_rsb.connections_currently_open); + int64_t d_o = Metrics::Gauge::load(net_rsb.connections_currently_open); int64_t d_p = Metrics::Counter::load(net_rsb.handler_run) - last_p; last_p += d_p; From 8e6333d1c4047b4f9d3dbef763a4a332efc346ee Mon Sep 17 00:00:00 2001 From: Leif Hedstrom Date: Mon, 6 Nov 2023 22:06:21 -0700 Subject: [PATCH 6/6] Fixes from Walt's review comments --- include/api/Metrics.h | 70 ++++++++++++++++++++++-------- src/api/Metrics.cc | 23 ++++++++-- src/api/unit_tests/test_Metrics.cc | 16 +++---- src/iocore/aio/test_AIO.cc | 6 +-- src/proxy/http/PreWarmManager.cc | 45 ++++++------------- src/records/RecCore.cc | 3 ++ 6 files changed, 98 insertions(+), 65 deletions(-) diff --git a/include/api/Metrics.h b/include/api/Metrics.h index fc5b2faa397..ad5313f6a06 100644 --- a/include/api/Metrics.h +++ b/include/api/Metrics.h @@ -24,7 +24,6 @@ #pragma once #include -#include #include #include #include @@ -50,8 +49,7 @@ class Metrics friend class Metrics; public: - AtomicType() = default; - virtual ~AtomicType() = default; + AtomicType() = default; int64_t load() const @@ -113,18 +111,8 @@ class Metrics // Yes, we don't return objects here, but rather ID's and atomic's directly. Treat // the std::atomic as the underlying class for a single metric, and be happy. IdType lookup(const std::string_view name) const; - AtomicType *lookup(IdType id, std::string_view *name = nullptr) const; - - std::optional - lookupPtr(const std::string_view name) const - { - IdType id = lookup(name); - if (id != NOT_FOUND) { - return lookup(id); - } - return std::nullopt; - } - + AtomicType *lookup(const std::string_view name, IdType *out_id) const; + AtomicType *lookup(IdType id, std::string_view *out_name = nullptr) const; bool rename(IdType id, const std::string_view name); AtomicType & @@ -296,6 +284,30 @@ class Metrics { }; + static IdType + lookup(const std::string_view name) + { + auto &instance = Metrics::instance(); + + return instance.lookup(name); + } + + static AtomicType * + lookup(const IdType id, std::string_view *out_name = nullptr) + { + auto &instance = Metrics::instance(); + + return reinterpret_cast(instance.lookup(id, out_name)); + } + + static AtomicType * + lookup(const std::string_view name, IdType *id) + { + auto &instance = Metrics::instance(); + + return reinterpret_cast(instance.lookup(name, id)); + } + static Metrics::IdType create(const std::string_view name) { @@ -335,7 +347,7 @@ class Metrics } static int64_t - load(AtomicType *metric) + load(const AtomicType *metric) { ink_assert(metric); return metric->_value.load(); @@ -360,6 +372,30 @@ class Metrics { }; + static IdType + lookup(const std::string_view name) + { + auto &instance = Metrics::instance(); + + return instance.lookup(name); + } + + static AtomicType * + lookup(const IdType id, std::string_view *out_name = nullptr) + { + auto &instance = Metrics::instance(); + + return reinterpret_cast(instance.lookup(id, out_name)); + } + + static AtomicType * + lookup(const std::string_view name, IdType *id) + { + auto &instance = Metrics::instance(); + + return reinterpret_cast(instance.lookup(name, id)); + } + static Metrics::IdType create(const std::string_view name) { @@ -392,7 +428,7 @@ class Metrics } static int64_t - load(AtomicType *metric) + load(const AtomicType *metric) { ink_assert(metric); return metric->_value.load(); diff --git a/src/api/Metrics.cc b/src/api/Metrics.cc index e7d77cad57d..c3ab95459e5 100644 --- a/src/api/Metrics.cc +++ b/src/api/Metrics.cc @@ -85,7 +85,7 @@ Metrics::lookup(const std::string_view name) const } Metrics::AtomicType * -Metrics::lookup(Metrics::IdType id, std::string_view *name) const +Metrics::lookup(Metrics::IdType id, std::string_view *out_name) const { auto [blob_ix, offset] = _splitID(id); Metrics::NamesAndAtomics *blob = _blobs[blob_ix]; @@ -96,13 +96,30 @@ Metrics::lookup(Metrics::IdType id, std::string_view *name) const offset = 0; } - if (name) { - *name = std::get<0>(std::get<0>(*blob)[offset]); + if (out_name) { + *out_name = std::get<0>(std::get<0>(*blob)[offset]); } return &((std::get<1>(*blob)[offset])); } +Metrics::AtomicType * +Metrics::lookup(const std::string_view name, Metrics::IdType *out_id) const +{ + Metrics::IdType id = lookup(name); + Metrics::AtomicType *result = nullptr; + + if (id != NOT_FOUND) { + result = lookup(id); + } + + if (nullptr != out_id) { + *out_id = id; + } + + return result; +} + std::string_view Metrics::name(Metrics::IdType id) const { diff --git a/src/api/unit_tests/test_Metrics.cc b/src/api/unit_tests/test_Metrics.cc index a05c6edf988..f141ed9dfa0 100644 --- a/src/api/unit_tests/test_Metrics.cc +++ b/src/api/unit_tests/test_Metrics.cc @@ -91,14 +91,12 @@ TEST_CASE("Metrics", "[libtsapi][Metrics]") SECTION("lookup") { - auto nm = m.lookupPtr("notametric"); - REQUIRE(!nm); - - auto mid = Metrics::Counter::create("ametric"); - auto fm = m.lookupPtr("ametric"); - REQUIRE(fm.has_value()); - REQUIRE(fm.value()); - REQUIRE(fm.value() == m.lookup(mid)); - REQUIRE(m.lookup("ametric") == mid); + auto nm = m.lookup("notametric"); + REQUIRE(nm == ts::Metrics::NOT_FOUND); + + auto mid = Metrics::Counter::create("ametric"); + auto fmid = m.lookup("ametric"); + + REQUIRE(mid == fmid); } } diff --git a/src/iocore/aio/test_AIO.cc b/src/iocore/aio/test_AIO.cc index 0b3b3984190..4de1ba8c56a 100644 --- a/src/iocore/aio/test_AIO.cc +++ b/src/iocore/aio/test_AIO.cc @@ -221,10 +221,8 @@ dump_summary() printf("IO_URING results\n"); printf("-----------------\n"); - auto &m = Metrics::getInstance(); - - Metrics::Counter::AtomicType *completed = m.lookup(m.lookup("proxy.process.io_uring.completed")); - Metrics::Counter::AtomicType *submitted = m.lookup(m.lookup("proxy.process.io_uring.submitted")); + auto completed = Metrics::Counter::lookup("proxy.process.io_uring.completed", nullptr); + auto completed = Metrics::Counter::lookup("proxy.process.io_uring.submitted", nullptr); printf("submissions: %lu\n", Metrics::Gauge::load(submitted)); printf("completions: %lu\n", Metrics::Gauge::load(completed)); diff --git a/src/proxy/http/PreWarmManager.cc b/src/proxy/http/PreWarmManager.cc index b6cfa4ea0a4..82ce2411dc2 100644 --- a/src/proxy/http/PreWarmManager.cc +++ b/src/proxy/http/PreWarmManager.cc @@ -1152,8 +1152,7 @@ _makeName(const PreWarm::SPtrConstDst &dst, std::string_view statname, char *nam void PreWarmManager::_register_stats(const PreWarm::ParsedSNIConf &parsed_conf) { - int stats_counter = 0; - ts::Metrics &metrics = ts::Metrics::instance(); + int stats_counter = 0; for (auto &entry : parsed_conf) { const PreWarm::SPtrConstDst &dst = entry.first; @@ -1166,24 +1165,15 @@ PreWarmManager::_register_stats(const PreWarm::ParsedSNIConf &parsed_conf) _makeName(dst, COUNTER_STAT_ENTRIES[j], name, sizeof(name)); - ts::Metrics::IdType stats_id = metrics.lookup(name); - Metrics::Counter::AtomicType *metric = nullptr; + auto metric = Metrics::Counter::createPtr(name); // This will do a lookup if it already exists - if (stats_id == ts::Metrics::NOT_FOUND) { - metric = Metrics::Counter::createPtr(name); - - if (metric == nullptr) { - Error("couldn't register counter stat name=%s", name); - } else { - ++stats_counter; - } + if (metric == nullptr) { + Error("couldn't register counter stat name=%s", name); } else { - metric = dynamic_cast(metrics.lookup(stats_id)); + ++stats_counter; + counters[j] = metric; + Debug("v_prewarm_init", "conter stat id=%d name=%s", Metrics::Counter::lookup(name), name); } - - counters[j] = metric; - - Debug("v_prewarm_init", "conter stat id=%d name=%s", stats_id, name); } // Gauges next @@ -1192,24 +1182,15 @@ PreWarmManager::_register_stats(const PreWarm::ParsedSNIConf &parsed_conf) _makeName(dst, GAUGE_STAT_ENTRIES[j], name, sizeof(name)); - ts::Metrics::IdType stats_id = metrics.lookup(name); - Metrics::Gauge::AtomicType *metric = nullptr; + auto metric = Metrics::Gauge::createPtr(name); // This will do a lookup if it already exists - if (stats_id == ts::Metrics::NOT_FOUND) { - metric = Metrics::Gauge::createPtr(name); - - if (metric == nullptr) { - Error("couldn't register gauge stat name=%s", name); - } else { - ++stats_counter; - } + if (metric == nullptr) { + Error("couldn't register gauge stat name=%s", name); } else { - metric = dynamic_cast(metrics.lookup(stats_id)); + ++stats_counter; + gauges[j] = metric; + Debug("v_prewarm_init", "gauge stat id=%d name=%s", Metrics::Gauge::lookup(name), name); } - - gauges[j] = metric; - - Debug("v_prewarm_init", "gauge stat id=%d name=%s", stats_id, name); } _stats_id_map[dst] = std::make_shared(ids); diff --git a/src/records/RecCore.cc b/src/records/RecCore.cc index 1d41cebb413..b2686d0881b 100644 --- a/src/records/RecCore.cc +++ b/src/records/RecCore.cc @@ -21,6 +21,9 @@ limitations under the License. */ +#include +#include + #include "swoc/swoc_file.h" #include "tscore/ink_platform.h"