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 89845c2b65a..ad5313f6a06 100644 --- a/include/api/Metrics.h +++ b/include/api/Metrics.h @@ -24,7 +24,6 @@ #pragma once #include -#include #include #include #include @@ -45,23 +44,46 @@ class Metrics private: using self_type = Metrics; + class AtomicType + { + friend class Metrics; + + public: + AtomicType() = default; + + int64_t + load() const + { + return _value.load(); + } + + // ToDo: This is a little sketchy, but needed for the old InkAPI metrics. + void + store(int64_t val) + { + _value.store(val); + } + + protected: + std::atomic _value{0}; + }; + 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; + 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 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; + 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 NameContainer = std::array; - using AtomicContainer = std::array; - using MetricStorage = std::tuple; - using MetricBlobs = std::array; 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; @@ -78,41 +100,22 @@ class Metrics Metrics() { - _blobs[0] = new MetricStorage(); + _blobs[0] = new NamesAndAtomics(); 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 + ink_release_assert(0 == _create("proxy.process.api.metrics.bad_id")); // Reserve slot 0 for errors, this should always be 0 } - // Singleton - static Metrics &getInstance(); + // The singleton instance, owned by the Metrics class + static Metrics &instance(); // 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; - } - - // 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)); - } - + 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); - IntType & + AtomicType & operator[](IdType id) { return *lookup(id); @@ -129,16 +132,15 @@ 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); } - // ToDo: Do we even need these inc/dec functions? int64_t decrement(IdType id, uint64_t val = 1) { 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; @@ -148,38 +150,10 @@ class Metrics { auto [blob, entry] = _splitID(id); - return (id >= 0 && ((blob < _cur_blob && entry < METRICS_MAX_SIZE) || (blob == _cur_blob && entry <= _cur_off))); + return (id >= 0 && ((blob < _cur_blob && entry < MAX_SIZE) || (blob == _cur_blob && entry <= _cur_off))); } // 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); - } - - static void - decrement(IntType *metric, uint64_t val = 1) - { - ink_assert(metric); - metric->fetch_sub(val, MEMORY_ORDER); - } - - static int64_t - read(IntType *metric) - { - ink_assert(metric); - return metric->load(); - } - - static void - write(IntType *metric, int64_t val) - { - ink_assert(metric); - return metric->store(val); - } - class iterator { public: @@ -215,7 +189,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 @@ -234,7 +208,7 @@ class Metrics void next(); const Metrics &_metrics; - IdType _it; + Metrics::IdType _it; }; iterator @@ -267,6 +241,11 @@ class Metrics } 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) { @@ -289,10 +268,174 @@ class Metrics mutable std::mutex _mutex; LookupTable _lookups; - MetricBlobs _blobs; + BlobStorage _blobs; uint16_t _cur_blob = 0; uint16_t _cur_off = 0; +public: + // These are sort of factory classes, using the Metrics singleton for all storage etc. + class Gauge + { + public: + using self_type = Gauge; + using SpanType = Metrics::SpanType; + + class AtomicType : public Metrics::AtomicType + { + }; + + 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) + { + auto &instance = Metrics::instance(); + + return instance._create(name); + } + + static AtomicType * + createPtr(const std::string_view name) + { + auto &instance = Metrics::instance(); + + return reinterpret_cast(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 + increment(AtomicType *metric, uint64_t val = 1) + { + ink_assert(metric); + 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(const AtomicType *metric) + { + ink_assert(metric); + return metric->_value.load(); + } + + static void + store(AtomicType *metric, int64_t val) + { + ink_assert(metric); + return metric->_value.store(val); + } + + }; // class Gauge + + class Counter + { + public: + using self_type = Counter; + using SpanType = Metrics::SpanType; + + class AtomicType : public Metrics::AtomicType + { + }; + + 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) + { + auto &instance = Metrics::instance(); + + return instance._create(name); + } + + static AtomicType * + createPtr(const std::string_view name) + { + auto &instance = Metrics::instance(); + + return reinterpret_cast(instance.lookup(instance._create(name))); + } + + static Metrics::Counter::SpanType + createSpan(size_t size, IdType *id = nullptr) + { + auto &instance = Metrics::instance(); + + return instance._createSpan(size, id); + } + + static void + increment(AtomicType *metric, uint64_t val = 1) + { + ink_assert(metric); + metric->_value.fetch_add(val, MEMORY_ORDER); + } + + static int64_t + load(const AtomicType *metric) + { + ink_assert(metric); + return metric->_value.load(); + } + + }; // class Counter + }; // class Metrics } // namespace ts diff --git a/include/iocore/net/quic/QUICStats.h b/include/iocore/net/quic/QUICStats.h index c429f836616..ce48effbb1a 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; struct QuicStatsBlock { - Metrics::IntType *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 cb4cd7a10d1..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::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::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::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::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 da253a150fb..2abc899c93a 100644 --- a/include/proxy/http/HttpConfig.h +++ b/include/proxy/http/HttpConfig.h @@ -62,247 +62,247 @@ 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; + Metrics::Counter::AtomicType *background_fill_bytes_aborted; + Metrics::Counter::AtomicType *background_fill_bytes_completed; + 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; + 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::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; + 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::Gauge::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::Gauge::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::Gauge::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..f18cec51df4 100644 --- a/include/proxy/http/PreWarmManager.h +++ b/include/proxy/http/PreWarmManager.h @@ -39,6 +39,8 @@ #include "api/Metrics.h" +using ts::Metrics; + // tscore #include "tscore/CryptoHash.h" #include "tscore/ink_hrtime.h" @@ -110,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, @@ -121,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/http2/HTTP2.h b/include/proxy/http2/HTTP2.h index a424981f227..6b8b37bbed4 100644 --- a/include/proxy/http2/HTTP2.h +++ b/include/proxy/http2/HTTP2.h @@ -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; + 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; + 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 7599f3d4d48..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::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::decrement(http2_rsb.current_active_server_connection_count); + Metrics::Gauge::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..8e916418563 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; + 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: Metrics::Counter::AtomicType *current_client_session_count; // Once created, e.g. - // Metrics::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 45d9436bfc3..8a02bb1e497 100644 --- a/include/proxy/logging/LogConfig.h +++ b/include/proxy/logging/LogConfig.h @@ -37,31 +37,31 @@ using ts::Metrics; 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; + 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::Gauge::AtomicType *log_files_open; + Metrics::Gauge::AtomicType *log_files_space_used; }; extern LogsStatsBlock log_rsb; diff --git a/src/api/InkAPI.cc b/src/api/InkAPI.cc index b4c791e874e..bc1a212b568 100644 --- a/src/api/InkAPI.cc +++ b/src/api/InkAPI.cc @@ -394,7 +394,7 @@ namespace c } // end namespace tsapi ConfigUpdateCbTable *global_config_cbs = nullptr; -static ts::Metrics &global_api_metrics = ts::Metrics::getInstance(); +static ts::Metrics &global_api_metrics = ts::Metrics::instance(); static char traffic_server_version[128] = ""; static int ts_major_version = 0; @@ -6165,20 +6165,20 @@ tsapi::c::TSHttpTxnLookingUpTypeGet(TSHttpTxn txnp) int tsapi::c::TSHttpCurrentClientConnectionsGet() { - return Metrics::read(http_rsb.current_client_connections); + return Metrics::Gauge::load(http_rsb.current_client_connections); } int tsapi::c::TSHttpCurrentActiveClientConnectionsGet() { - return Metrics::read(http_rsb.current_active_client_connections); + return Metrics::Gauge::load(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 = 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::read(http_rsb.current_cache_connections); + return Metrics::Gauge::load(http_rsb.current_cache_connections); } int tsapi::c::TSHttpCurrentServerConnectionsGet() { - return Metrics::read(http_rsb.current_server_connections); + return Metrics::Gauge::load(http_rsb.current_server_connections); } /* HTTP alternate selection */ @@ -6999,7 +6999,7 @@ 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 = Metrics::Gauge::create(the_name); // Gauges allows for all "int" operations 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::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 8a67f9a8b54..c3ab95459e5 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 Metrics::Counter API class. @section license License @@ -28,9 +28,9 @@ namespace ts // This is the singleton instance of the metrics class. Metrics & -Metrics::getInstance() +Metrics::instance() { - static ts::Metrics _instance; + static Metrics _instance; return _instance; } @@ -38,17 +38,17 @@ Metrics::getInstance() void Metrics::_addBlob() // The mutex must be held before calling this! { - auto blob = new Metrics::MetricStorage(); + auto blob = new Metrics::NamesAndAtomics(); ink_assert(blob); - ink_assert(_cur_blob < Metrics::METRICS_MAX_BLOBS); + ink_assert(_cur_blob < MAX_BLOBS); _blobs[++_cur_blob] = blob; _cur_off = 0; } Metrics::IdType -Metrics::newMetric(std::string_view name) +Metrics::_create(std::string_view name) { std::lock_guard lock(_mutex); auto it = _lookups.find(name); @@ -57,16 +57,14 @@ Metrics::newMetric(std::string_view name) return it->second; } - 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); + 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); - if (++_cur_off >= Metrics::METRICS_MAX_SIZE) { + if (++_cur_off >= MAX_SIZE) { _addBlob(); // This resets _cur_off to 0 as well } @@ -86,11 +84,11 @@ Metrics::lookup(const std::string_view name) const return NOT_FOUND; } -Metrics::IntType * -Metrics::lookup(IdType id, std::string_view *name) const +Metrics::AtomicType * +Metrics::lookup(Metrics::IdType id, std::string_view *out_name) const { - auto [blob_ix, offset] = _splitID(id); - Metrics::MetricStorage *blob = _blobs[blob_ix]; + auto [blob_ix, offset] = _splitID(id); + Metrics::NamesAndAtomics *blob = _blobs[blob_ix]; // 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)) { @@ -98,18 +96,35 @@ Metrics::lookup(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 { - auto [blob_ix, offset] = _splitID(id); - Metrics::MetricStorage *blob = _blobs[blob_ix]; + auto [blob_ix, offset] = _splitID(id); + Metrics::NamesAndAtomics *blob = _blobs[blob_ix]; // 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)) { @@ -122,22 +137,20 @@ Metrics::name(Metrics::IdType id) const return result; } -Metrics::SpanIntType -Metrics::newMetricSpan(size_t size, IdType *id) +Metrics::SpanType +Metrics::_createSpan(size_t size, Metrics::IdType *id) { - ink_release_assert(size <= Metrics::METRICS_MAX_SIZE); + ink_release_assert(size <= MAX_SIZE); std::lock_guard lock(_mutex); - if (_cur_off + size > Metrics::METRICS_MAX_SIZE) { + if (_cur_off + size > MAX_SIZE) { _addBlob(); } - 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); - - std::fill(span.begin(), span.end(), 0); + 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 (id) { *id = span_start; @@ -151,17 +164,17 @@ Metrics::newMetricSpan(size_t size, IdType *id) bool Metrics::rename(Metrics::IdType id, std::string_view name) { - auto [blob_ix, offset] = _splitID(id); - Metrics::MetricStorage *blob = _blobs[blob_ix]; + auto [blob_ix, offset] = _splitID(id); + Metrics::NamesAndAtomics *blob = _blobs[blob_ix]; - // We can only rename metrics that are already allocated + // We can only rename Metrics 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); } @@ -177,7 +190,7 @@ Metrics::iterator::next() { auto [blob, offset] = _metrics._splitID(_it); - if (++offset == METRICS_MAX_SIZE) { + if (++offset == MAX_SIZE) { ++blob; offset = 0; } diff --git a/src/api/unit_tests/test_Metrics.cc b/src/api/unit_tests/test_Metrics.cc index b08b5e046c3..f141ed9dfa0 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 m; + auto &m = Metrics::instance(); SECTION("iterator") { @@ -46,7 +47,7 @@ TEST_CASE("Metrics", "[libtsapi][Metrics]") SECTION("New metric") { - auto fooid = m.newMetric("foo"); + auto fooid = Metrics::Counter::create("foo"); REQUIRE(fooid == 1); REQUIRE(m.name(fooid) == "foo"); @@ -56,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 = m.newMetric("foo"); // To see that span_id gets to 2 - auto span = m.newMetricSpan(17, &span_id); + 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"); @@ -88,14 +91,12 @@ TEST_CASE("Metrics", "[libtsapi][Metrics]") SECTION("lookup") { - auto nm = m.lookupPtr("notametric"); - REQUIRE(!nm); - - auto mid = m.newMetric("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/AIO.cc b/src/iocore/aio/AIO.cc index 2b517f7d7a2..46c9bbee068 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 &intm = ts::Metrics::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::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); @@ -442,11 +440,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); + Metrics::Counter::increment(aio_rsb.write_count); + Metrics::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); + 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); @@ -578,11 +576,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); + Metrics::Counter::increment(aio_rsb.write_count); + Metrics::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); + 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 22336a85a59..1cd0556e053 100644 --- a/src/iocore/aio/P_AIO.h +++ b/src/iocore/aio/P_AIO.h @@ -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; + 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 cc2dac542a0..4de1ba8c56a 100644 --- a/src/iocore/aio/test_AIO.cc +++ b/src/iocore/aio/test_AIO.cc @@ -221,13 +221,11 @@ dump_summary() printf("IO_URING results\n"); printf("-----------------\n"); - auto &m = Metrics::getInstance(); + auto completed = Metrics::Counter::lookup("proxy.process.io_uring.completed", nullptr); + auto completed = Metrics::Counter::lookup("proxy.process.io_uring.submitted", nullptr); - Metrics::IntType *completed = m.lookup(m.lookup("proxy.process.io_uring.completed")); - Metrics::IntType *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", 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 76c264072cb..c700251b838 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 &intm = ts::Metrics::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::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::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::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::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::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::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::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"); // 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::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 = 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::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::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"); + 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. @@ -218,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::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) { @@ -226,15 +224,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 + 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::read(cache_rsb.bytes_total); + int64_t total = Metrics::Gauge::load(cache_rsb.bytes_total); - Metrics::write(cache_rsb.bytes_used, total_sum); - Metrics::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); } } @@ -511,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::write(cache_rsb.span_offline, bad_disks); - Metrics::decrement(cache_rsb.span_failing, bad_disks); - Metrics::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) { @@ -659,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::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::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::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::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; } @@ -706,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); - Metrics::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"); } @@ -714,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::increment(vol->cache_vol->vol_rsb.bytes_total, vol_total_cache_bytes); - Metrics::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::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::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; } } @@ -743,10 +742,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); + 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(); @@ -1016,14 +1015,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); + 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::decrement(admin ? cache_rsb.span_online : cache_rsb.span_failing); - Metrics::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); @@ -1200,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::increment(cache_rsb.status[c->op_type].active); - Metrics::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; @@ -1242,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::increment(cache_rsb.status[c->op_type].active); - Metrics::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; @@ -1691,7 +1690,7 @@ cplist_reconfigure() } } - Metrics::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 50cb4508cff..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::decrement(cache_rsb.direntries_used); - Metrics::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::decrement(cache_rsb.direntries_used); - Metrics::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::decrement(cache_rsb.direntries_used); - Metrics::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::increment(cache_rsb.directory_collision_count); - Metrics::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::decrement(cache_rsb.direntries_used); - Metrics::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::increment(cache_rsb.directory_collision_count); - Metrics::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::increment(cache_rsb.direntries_used); - Metrics::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::increment(cache_rsb.direntries_used); - Metrics::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::increment(cache_rsb.direntries_used); - Metrics::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::decrement(cache_rsb.direntries_used); - Metrics::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; @@ -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); + 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; - 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); + 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 701fbae0a12..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::decrement(cache_rsb.span_online); - Metrics::increment(cache_rsb.span_failing); + Metrics::Gauge::decrement(cache_rsb.span_online); + Metrics::Gauge::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); + Metrics::Counter::increment(cache_rsb.span_errors_read); break; case LIO_WRITE: opname = "WRITE"; - Metrics::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 264905b47e9..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++; } - Metrics::increment(cache_rsb.hdr_vector_marshal); - Metrics::increment(cache_rsb.hdr_marshal, count); - Metrics::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 5a3f5d3e9a0..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::increment(cache_rsb.status[c->op_type].active); - Metrics::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; @@ -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); + 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); - Metrics::increment(cache_rsb.status[c->op_type].active); - Metrics::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; @@ -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); + 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); - 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); + 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); - Metrics::increment(cache_rsb.read_busy_success); - Metrics::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); - Metrics::increment(cache_rsb.read_busy_success); - Metrics::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; - Metrics::increment(cache_rsb.read_seek_fail); - Metrics::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); } } - Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); - Metrics::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) { - Metrics::increment(cache_rsb.read_busy_success); - Metrics::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 */ } } - Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); - Metrics::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); - Metrics::increment(cache_rsb.read_invalid); - Metrics::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) { - Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); - Metrics::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 { - Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Lookup)].failure); - Metrics::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: - Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Lookup)].failure); - Metrics::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 b749c4a35a0..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 - Metrics::increment(cache_rsb.pread_count); - Metrics::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: - Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Remove)].failure); - Metrics::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 b3a04363f6e..916c242826b 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); + 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); - Metrics::increment(cache_rsb.status[c->op_type].active); - Metrics::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; @@ -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); + 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 - Metrics::increment(cache_rsb.gc_frags_evacuated); - Metrics::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; - Metrics::increment(cache_rsb.directory_wrap); - Metrics::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); - 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)]); + 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: - Metrics::increment(cache_rsb.status[op_type].failure); - Metrics::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)) { - Metrics::increment(cache_rsb.status[op_type].failure); - Metrics::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; - Metrics::increment(cache_rsb.status[c->op_type].active); - Metrics::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; /* @@ -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); + 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); } - Metrics::increment(cache_rsb.status[c->op_type].active); - Metrics::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); @@ -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); + 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 d6d38e424d6..4023565194f 100644 --- a/src/iocore/cache/P_CacheInternal.h +++ b/src/iocore/cache/P_CacheInternal.h @@ -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); + 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::increment(cache_rsb.status[cont->op_type].success); - Metrics::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) { - Metrics::increment(cache_rsb.write_backlog_failure); - Metrics::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 f5d7b5767f1..be8abd2309a 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; + Metrics::Gauge::AtomicType *active = nullptr; + Metrics::Counter::AtomicType *success = nullptr; + Metrics::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 + Metrics::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; + Metrics::Gauge::AtomicType *bytes_used = nullptr; + Metrics::Gauge::AtomicType *bytes_total = nullptr; + Metrics::Gauge::AtomicType *stripes = 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; + 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/cache/RamCacheCLFUS.cc b/src/iocore/cache/RamCacheCLFUS.cc index 47fe8b90b8b..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::increment(cache_rsb.ram_cache_bytes, delta); - Metrics::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; @@ -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); + 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 { - Metrics::increment(cache_rsb.ram_cache_misses); - Metrics::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: - Metrics::increment(cache_rsb.ram_cache_misses); - Metrics::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; - Metrics::decrement(cache_rsb.ram_cache_bytes, e->size); - Metrics::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::increment(cache_rsb.ram_cache_bytes, delta); - Metrics::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::increment(cache_rsb.ram_cache_bytes, delta); - Metrics::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::increment(cache_rsb.ram_cache_bytes, victim->size); - Metrics::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::increment(cache_rsb.ram_cache_bytes, delta); - Metrics::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::decrement(cache_rsb.ram_cache_bytes, victim->size); - Metrics::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::increment(cache_rsb.ram_cache_bytes, victim->size); - Metrics::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::increment(cache_rsb.ram_cache_bytes, size); - Metrics::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 e8e33706b27..74acf736c25 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); + 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); - Metrics::increment(cache_rsb.ram_cache_misses); - Metrics::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(); - 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()); + 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::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()); + 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 b1bf81d0acf..c65b68f1445 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); + 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; - Metrics::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::decrement(dns_rsb.in_flight); + Metrics::Gauge::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); + 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; - Metrics::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::decrement(dns_rsb.in_flight); + Metrics::Gauge::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); + 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) { - Metrics::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) { - Metrics::increment(dns_rsb.fail_time, diff); - Metrics::increment(dns_rsb.lookup_fail); + Metrics::Counter::increment(dns_rsb.fail_time, diff); + Metrics::Counter::increment(dns_rsb.lookup_fail); } else { - Metrics::increment(dns_rsb.success_time, diff); + Metrics::Counter::increment(dns_rsb.success_time, diff); - Metrics::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); - Metrics::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; - Metrics::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; - Metrics::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:; - Metrics::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,19 +1907,17 @@ 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"); + dns_rsb.fail_time = Metrics::Counter::createPtr("proxy.process.dns.fail_time"); + 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"); + 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 f3536ea2540..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" @@ -31,8 +34,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" @@ -47,8 +48,7 @@ #include -#include -#include +#include "api/Metrics.h" using ts::Metrics; @@ -102,17 +102,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; + Metrics::Counter::AtomicType *fail_time; + Metrics::Gauge::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 64932273cb3..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()) { - Metrics::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())) { - Metrics::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) { - Metrics::increment(hostdb_rsb.re_dns_on_reload); + Metrics::Counter::increment(hostdb_rsb.re_dns_on_reload); } } - Metrics::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) : ""); } - Metrics::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; - Metrics::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; } - Metrics::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) { - Metrics::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)) { - Metrics::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,15 +1790,13 @@ 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"); + 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 f91f1316078..bdfeb1d26f6 100644 --- a/src/iocore/hostdb/P_HostDBProcessor.h +++ b/src/iocore/hostdb/P_HostDBProcessor.h @@ -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; + 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 7adc5588454..d72e939ebb7 100644 --- a/src/iocore/hostdb/P_RefCountCache.h +++ b/src/iocore/hostdb/P_RefCountCache.h @@ -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; + 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; + 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) { - Metrics::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 - Metrics::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) { - Metrics::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); - Metrics::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++; - Metrics::increment(this->rsb->refcountcache_current_size, (int64_t)val->meta.size); - Metrics::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::decrement(this->rsb->refcountcache_current_size, ptr->meta.size); - Metrics::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) { @@ -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 &intm = ts::Metrics::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::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()); + 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 81ab2318c83..d80d2341656 100644 --- a/src/iocore/io_uring/io_uring.cc +++ b/src/iocore/io_uring/io_uring.cc @@ -33,7 +33,6 @@ Linux io_uring helper library #include "tscore/Diags.h" #include - using ts::Metrics; std::atomic main_wq_fd; @@ -41,14 +40,14 @@ std::atomic main_wq_fd; IOUringConfig IOUringContext::config; struct IOUringStatsBlock { - Metrics::IntType *io_uring_submitted; - Metrics::IntType *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{intm.newMetricPtr("proxy.process.io_uring.submitted"), - intm.newMetricPtr("proxy.process.io_uring.completed")}; + return IOUringStatsBlock{Metrics::Counter::createPtr("proxy.process.io_uring.submitted"), + Metrics::Counter::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)); + Metrics::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); + Metrics::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); + Metrics::Counter::increment(io_uring_rsb.io_uring_submitted, count); while (cqe) { handle_cqe(cqe); - Metrics::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 7f536419478..c6a6124d9a5 100644 --- a/src/iocore/io_uring/unit_tests/test_diskIO.cc +++ b/src/iocore/io_uring/unit_tests/test_diskIO.cc @@ -36,7 +36,6 @@ #include "tscore/ink_hrtime.h" #include "api/Metrics.h" - using ts::Metrics; swoc::file::path @@ -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")); + Metrics::Counter::AtomicType *completed = m.lookup(m.lookup("proxy.process.io_uring.completed")); - uint64_t completions_before = Metrics::read(completed); + uint64_t completions_before = Metrics::Gauge::load(completed); uint64_t needed = 2; - while ((Metrics::read(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/BIO_fastopen.cc b/src/iocore/net/BIO_fastopen.cc index 822d7e81ef3..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)); - Metrics::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) { - Metrics::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 8c5c55727cc..e13fe18ee73 100644 --- a/src/iocore/net/Net.cc +++ b/src/iocore/net/Net.cc @@ -80,58 +80,60 @@ 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"); + 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::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 = - 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::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 = - intm.newMetricPtr("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 = - intm.newMetricPtr("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 = - intm.newMetricPtr("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 = - intm.newMetricPtr("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 = - intm.newMetricPtr("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 = - intm.newMetricPtr("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 = - 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::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 = - 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::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"); + 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::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"); + 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 ead1ac8c0be..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 - Metrics::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; - Metrics::increment(net_rsb.keep_alive_queue_timeout_total, diff); - Metrics::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 - Metrics::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 f427cf85493..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: - Metrics::increment(ssl_rsb.ocsp_revoked_cert); + Metrics::Counter::increment(ssl_rsb.ocsp_revoked_cert); break; case TS_OCSP_CERTSTATUS_UNKNOWN: - Metrics::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); - Metrics::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); - Metrics::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 2a141ec2c2c..bf5849d75c3 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; 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; + 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::Gauge::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::Gauge::AtomicType *tunnel_current_client_connections_blind_tcp; + Metrics::Counter::AtomicType *tunnel_total_server_connections_blind_tcp; + Metrics::Gauge::AtomicType *tunnel_current_server_connections_blind_tcp; + Metrics::Counter::AtomicType *tunnel_total_client_connections_tls_tunnel; + Metrics::Gauge::AtomicType *tunnel_current_client_connections_tls_tunnel; + Metrics::Counter::AtomicType *tunnel_total_server_connections_tls; + Metrics::Gauge::AtomicType *tunnel_current_server_connections_tls; + Metrics::Counter::AtomicType *tunnel_total_client_connections_tls_forward; + Metrics::Gauge::AtomicType *tunnel_current_client_connections_tls_forward; + Metrics::Counter::AtomicType *tunnel_total_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::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; + 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 e4a8b00fddd..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::read(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/QUICNetProcessor.cc b/src/iocore/net/QUICNetProcessor.cc index 2c734c41be0..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"); } - Metrics::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 ff94792663f..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"); } - Metrics::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 ed2cefc5e73..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()); - Metrics::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 d2e5483bfc8..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)) { - Metrics::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: - Metrics::increment(ssl_rsb.user_agent_expired_cert); + Metrics::Counter::increment(ssl_rsb.user_agent_expired_cert); break; case SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED: - Metrics::increment(ssl_rsb.user_agent_revoked_cert); + Metrics::Counter::increment(ssl_rsb.user_agent_revoked_cert); break; case SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN: - Metrics::increment(ssl_rsb.user_agent_unknown_cert); + Metrics::Counter::increment(ssl_rsb.user_agent_unknown_cert); break; case SSL_R_CERTIFICATE_VERIFY_FAILED: - Metrics::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: - Metrics::increment(ssl_rsb.user_agent_bad_cert); + Metrics::Counter::increment(ssl_rsb.user_agent_bad_cert); break; case SSL_R_TLSV1_ALERT_DECRYPTION_FAILED: - Metrics::increment(ssl_rsb.user_agent_decryption_failed); + Metrics::Counter::increment(ssl_rsb.user_agent_decryption_failed); break; case SSL_R_WRONG_VERSION_NUMBER: - Metrics::increment(ssl_rsb.user_agent_wrong_version); + Metrics::Counter::increment(ssl_rsb.user_agent_wrong_version); break; case SSL_R_TLSV1_ALERT_UNKNOWN_CA: - Metrics::increment(ssl_rsb.user_agent_unknown_ca); + Metrics::Counter::increment(ssl_rsb.user_agent_unknown_ca); break; default: - Metrics::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)) { - Metrics::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: - Metrics::increment(ssl_rsb.origin_server_expired_cert); + Metrics::Counter::increment(ssl_rsb.origin_server_expired_cert); break; case SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED: - Metrics::increment(ssl_rsb.origin_server_revoked_cert); + Metrics::Counter::increment(ssl_rsb.origin_server_revoked_cert); break; case SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN: - Metrics::increment(ssl_rsb.origin_server_unknown_cert); + Metrics::Counter::increment(ssl_rsb.origin_server_unknown_cert); break; case SSL_R_CERTIFICATE_VERIFY_FAILED: - Metrics::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: - Metrics::increment(ssl_rsb.origin_server_bad_cert); + Metrics::Counter::increment(ssl_rsb.origin_server_bad_cert); break; case SSL_R_TLSV1_ALERT_DECRYPTION_FAILED: - Metrics::increment(ssl_rsb.origin_server_decryption_failed); + Metrics::Counter::increment(ssl_rsb.origin_server_decryption_failed); break; case SSL_R_WRONG_VERSION_NUMBER: - Metrics::increment(ssl_rsb.origin_server_wrong_version); + Metrics::Counter::increment(ssl_rsb.origin_server_wrong_version); break; case SSL_R_TLSV1_ALERT_UNKNOWN_CA: - Metrics::increment(ssl_rsb.origin_server_unknown_ca); + Metrics::Counter::increment(ssl_rsb.origin_server_unknown_ca); break; default: - Metrics::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 4f36f41ff12..70d27a74cfa 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); + 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); - Metrics::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); - Metrics::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; } } - Metrics::increment(net_rsb.read_bytes, r); - Metrics::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) { - Metrics::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; - Metrics::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; - Metrics::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); - Metrics::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; - Metrics::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); - Metrics::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) { - Metrics::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::decrement(([&]() -> Metrics::IntType * { + Metrics::Gauge::decrement(([&]() -> Metrics::Gauge::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); + 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) { - Metrics::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(); - Metrics::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: - Metrics::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) { - Metrics::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); } - Metrics::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; - Metrics::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); - Metrics::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,8 @@ SSLNetVConnection::_in_context_tunnel() { ink_assert(get_context() == NET_VCONNECTION_IN); - Metrics::IntType *t, *c; + Metrics::Counter::AtomicType *t; + Metrics::Gauge::AtomicType *c; switch (get_tunnel_type()) { case SNIRoutingType::BLIND: @@ -2006,8 +2007,8 @@ SSLNetVConnection::_in_context_tunnel() c = net_rsb.tunnel_current_client_connections_tls_http; break; } - Metrics::increment(t); - Metrics::increment(c); + Metrics::Counter::increment(t); + Metrics::Gauge::increment(c); } void @@ -2018,8 +2019,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); + Metrics::Counter::increment(net_rsb.tunnel_total_server_connections_tls); + Metrics::Gauge::increment(net_rsb.tunnel_current_server_connections_tls); } void @@ -2027,20 +2028,20 @@ SSLNetVConnection::increment_ssl_version_metric(int version) const { switch (version) { case SSL3_VERSION: - Metrics::increment(ssl_rsb.total_sslv3); + Metrics::Counter::increment(ssl_rsb.total_sslv3); break; case TLS1_VERSION: - Metrics::increment(ssl_rsb.total_tlsv1); + Metrics::Counter::increment(ssl_rsb.total_tlsv1); break; case TLS1_1_VERSION: - Metrics::increment(ssl_rsb.total_tlsv11); + Metrics::Counter::increment(ssl_rsb.total_tlsv11); break; case TLS1_2_VERSION: - Metrics::increment(ssl_rsb.total_tlsv12); + Metrics::Counter::increment(ssl_rsb.total_tlsv12); break; #ifdef TLS1_3_VERSION case TLS1_3_VERSION: - Metrics::increment(ssl_rsb.total_tlsv13); + Metrics::Counter::increment(ssl_rsb.total_tlsv13); break; #endif default: @@ -2384,7 +2385,7 @@ SSLNetVConnection::_ssl_accept() } block->fill(nread); this->_early_data_buf->append_block(block); - Metrics::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 +2460,7 @@ SSLNetVConnection::_ssl_connect() if (ret > 0) { if (SSL_session_reused(ssl)) { - Metrics::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 +2612,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); + 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 e978ffc3d22..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); } - Metrics::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()) { - Metrics::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()) { - Metrics::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) { - Metrics::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()) { - Metrics::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()) { - Metrics::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 6518d937f6c..2407bb7aad3 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); + 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 @@ -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 &intm = ts::Metrics::getInstance(); - ts::Metrics::IntType *metric = intm.newMetricPtr(statName); + Metrics::Counter::AtomicType *metric = Metrics::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 &intm = ts::Metrics::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::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"); + 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 b57150846f3..4b46d4876bb 100644 --- a/src/iocore/net/SSLStats.h +++ b/src/iocore/net/SSLStats.h @@ -37,68 +37,68 @@ using ts::Metrics; // 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; + 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::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; }; 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..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) } } - Metrics::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) { - Metrics::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()); } - Metrics::increment(it->second); + Metrics::Counter::increment(it->second); } } } diff --git a/src/iocore/net/Socks.cc b/src/iocore/net/Socks.cc index 9a198bc3a71..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); - Metrics::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"); - Metrics::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 5bae93d0050..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); - Metrics::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 1e213eb7dbe..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)) { - Metrics::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 { - Metrics::increment(ssl_rsb.session_cache_hit); + Metrics::Counter::increment(ssl_rsb.session_cache_hit); this->_setSSLSessionCacheHit(true); this->_setSSLCurveNID(exdata->curve); } } else { - Metrics::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())) { - Metrics::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 { - Metrics::increment(ssl_rsb.origin_session_cache_hit); + Metrics::Counter::increment(ssl_rsb.origin_session_cache_hit); this->_setSSLOriginSessionCacheHit(true); this->_setSSLCurveNID(curve); } } else { - Metrics::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."); - Metrics::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. - Metrics::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. - Metrics::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."); - Metrics::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 3f970c6f611..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()) { - Metrics::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; - Metrics::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); - Metrics::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; - Metrics::increment(net_rsb.keep_alive_queue_timeout_total, diff); - Metrics::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 f08e5d8b43b..36e7079fc71 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); + 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++; - Metrics::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); @@ -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); + Metrics::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); + 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++; - Metrics::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::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::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" @@ -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); + Metrics::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); + 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++; - Metrics::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::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::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 45e199a9201..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::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 a8b03640f4b..d449889e668 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); + 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) { - Metrics::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; } - Metrics::increment(net_rsb.read_bytes, r); - Metrics::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) { - Metrics::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) { - Metrics::increment(net_rsb.write_bytes, total_written); - Metrics::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) { - Metrics::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) { - Metrics::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 { - Metrics::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; } - Metrics::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; - Metrics::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 - Metrics::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::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::decrement(([&]() -> Metrics::IntType * { + Metrics::Gauge::decrement(([&]() -> Metrics::Gauge::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); + Metrics::Counter::increment(net_rsb.tunnel_total_client_connections_blind_tcp); + Metrics::Gauge::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); + Metrics::Counter::increment(net_rsb.tunnel_total_server_connections_blind_tcp); + Metrics::Gauge::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..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 &intm = ts::Metrics::getInstance(); + ts::Metrics::Counter &metrics = ts::Metrics::instance(); // Transferred packet counts - quic_rsb.total_packets_sent = intm.newMetricPtr("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 = 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::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 06999267ebd..4d2ae044016 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 &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. @@ -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].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 1a87f251a7e..e6639cc6dd6 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 &metrics = ts::Metrics::instance(); + static auto drain_id = metrics.lookup("proxy.process.proxy.draining"); - return (intm[drain_id] != 0); + return (metrics[drain_id].load() != 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 &metrics = ts::Metrics::instance(); + static auto drain_id = metrics.lookup("proxy.process.proxy.draining"); TSSystemState::drain(drain); - intm[drain_id] = TSSystemState::is_draining() ? 1 : 0; + metrics[drain_id].store(TSSystemState::is_draining() ? 1 : 0); } ts::Rv diff --git a/src/proxy/http/Http1ClientSession.cc b/src/proxy/http/Http1ClientSession.cc index cd06da46004..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::decrement(http_rsb.current_client_connections); + Metrics::Gauge::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); + Metrics::Gauge::increment(http_rsb.current_client_connections); conn_decrease = true; - Metrics::increment(http_rsb.total_client_connections); + Metrics::Counter::increment(http_rsb.total_client_connections); if (static_cast(new_vc->attributes) == HttpProxyPort::TRANSPORT_SSL) { - Metrics::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 */ - Metrics::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: - Metrics::increment(http_rsb.total_client_connections_ipv4); + Metrics::Counter::increment(http_rsb.total_client_connections_ipv4); break; case AF_INET6: - Metrics::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() { - Metrics::increment(http_rsb.current_active_client_connections); + Metrics::Gauge::increment(http_rsb.current_active_client_connections); } void Http1ClientSession::decrement_current_active_connections_stat() { - Metrics::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 f5ebdb25ee0..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::increment(http_rsb.current_client_transactions); + Metrics::Gauge::increment(http_rsb.current_client_transactions); } void Http1ClientTransaction::decrement_transactions_stat() { - Metrics::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 ed6e6fdac80..6db6eacef2c 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); + Metrics::Gauge::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); } - Metrics::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::decrement(http_rsb.current_parent_proxy_connections); + Metrics::Gauge::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); + 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); - Metrics::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 ed20bc06917..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::increment(http_rsb.current_server_transactions); + Metrics::Gauge::increment(http_rsb.current_server_transactions); } void Http1ServerTransaction::decrement_transactions_stat() { - Metrics::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 fdfadc44a40..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::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::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 d938d390957..153a5ccf373 100644 --- a/src/proxy/http/HttpConfig.cc +++ b/src/proxy/http/HttpConfig.cc @@ -259,262 +259,282 @@ 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"); + 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::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"); + 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::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"); + 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 = - 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::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 = - intm.newMetricPtr("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 = - intm.newMetricPtr("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 = - intm.newMetricPtr("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 = - 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::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 = - intm.newMetricPtr("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 = - 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::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 = - intm.newMetricPtr("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 = - 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::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::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"); + 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::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"); + 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 = - 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::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 = - 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::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 = - 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::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 = - intm.newMetricPtr("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 e987911eafc..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::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,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); + 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; } @@ -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); + 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()) { - Metrics::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)) { - Metrics::decrement(http_rsb.websocket_current_active_client_connections); + Metrics::Gauge::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); + Metrics::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); + Metrics::Counter::increment(http_rsb.origin_shutdown_tunnel_server_eos); } else { - Metrics::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; } - Metrics::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; - Metrics::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; - Metrics::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,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); + 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)); 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); + 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; } - Metrics::decrement(http_rsb.current_cache_connections); + Metrics::Gauge::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); + 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; } - Metrics::decrement(http_rsb.current_cache_connections); + Metrics::Gauge::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); + 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; - Metrics::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: - Metrics::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: - Metrics::increment(http_rsb.origin_not_found); + Metrics::Counter::increment(http_rsb.origin_not_found); hsm_release_assert(server_txn == nullptr); break; case HSM_RETRY: - Metrics::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) { - Metrics::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) { - Metrics::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)) { - Metrics::increment(http_rsb.origin_body); + Metrics::Counter::increment(http_rsb.origin_body); } else if (is_private()) { - Metrics::increment(http_rsb.origin_private); + Metrics::Counter::increment(http_rsb.origin_private); } else if (raw) { - Metrics::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 (Metrics::read(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. @@ -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); + 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) { - Metrics::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) { - Metrics::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) { - Metrics::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()) { - Metrics::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()) { - Metrics::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)) { - Metrics::increment(http_rsb.origin_shutdown_release_modified); + Metrics::Counter::increment(http_rsb.origin_shutdown_release_modified); } else { - Metrics::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; - Metrics::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 803af838dac..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 - 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 + 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 93602388f2b..9f4a28e4e95 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); + 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)) { - Metrics::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::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 55b646ca691..2f8ea0c5066 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); + 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) { - Metrics::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(); - Metrics::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"); - Metrics::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"); - Metrics::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()); - Metrics::increment(http_rsb.incoming_requests); + Metrics::Counter::increment(http_rsb.incoming_requests); if (s->client_info.port_attribute == HttpProxyPort::TRANSPORT_SSL) { - Metrics::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))) { - Metrics::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 (Metrics::read(http_rsb.websocket_current_active_client_connections) >= s->http_config_param->max_websocket_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"); 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); - Metrics::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."); - Metrics::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; - Metrics::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; - Metrics::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"); - Metrics::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)) { - Metrics::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 - Metrics::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()); - Metrics::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 - Metrics::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); - Metrics::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); - Metrics::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); - Metrics::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); - Metrics::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); - Metrics::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. - Metrics::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; - Metrics::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; - Metrics::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) { - Metrics::increment(http_rsb.get_requests); + Metrics::Counter::increment(http_rsb.get_requests); } else if (method == HTTP_WKSIDX_HEAD) { - Metrics::increment(http_rsb.head_requests); + Metrics::Counter::increment(http_rsb.head_requests); } else if (method == HTTP_WKSIDX_POST) { - Metrics::increment(http_rsb.post_requests); + Metrics::Counter::increment(http_rsb.post_requests); } else if (method == HTTP_WKSIDX_PUT) { - Metrics::increment(http_rsb.put_requests); + Metrics::Counter::increment(http_rsb.put_requests); } else if (method == HTTP_WKSIDX_CONNECT) { - Metrics::increment(http_rsb.connect_requests); + Metrics::Counter::increment(http_rsb.connect_requests); } else if (method == HTTP_WKSIDX_DELETE) { - Metrics::increment(http_rsb.delete_requests); + Metrics::Counter::increment(http_rsb.delete_requests); } else if (method == HTTP_WKSIDX_PURGE) { - Metrics::increment(http_rsb.purge_requests); + Metrics::Counter::increment(http_rsb.purge_requests); } else if (method == HTTP_WKSIDX_TRACE) { - Metrics::increment(http_rsb.trace_requests); + Metrics::Counter::increment(http_rsb.trace_requests); } else if (method == HTTP_WKSIDX_PUSH) { - Metrics::increment(http_rsb.push_requests); + Metrics::Counter::increment(http_rsb.push_requests); } else if (method == HTTP_WKSIDX_OPTIONS) { - Metrics::increment(http_rsb.options_requests); + Metrics::Counter::increment(http_rsb.options_requests); } else { - Metrics::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); - Metrics::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); - Metrics::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"); - Metrics::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: - Metrics::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: - Metrics::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: - Metrics::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. - Metrics::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: - Metrics::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: - Metrics::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: - Metrics::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)) { - Metrics::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? - Metrics::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: - Metrics::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: - Metrics::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: - Metrics::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: - Metrics::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: - Metrics::increment(http_rsb.response_status_100_count); + Metrics::Counter::increment(http_rsb.response_status_100_count); break; case 101: - Metrics::increment(http_rsb.response_status_101_count); + Metrics::Counter::increment(http_rsb.response_status_101_count); break; case 200: - Metrics::increment(http_rsb.response_status_200_count); + Metrics::Counter::increment(http_rsb.response_status_200_count); break; case 201: - Metrics::increment(http_rsb.response_status_201_count); + Metrics::Counter::increment(http_rsb.response_status_201_count); break; case 202: - Metrics::increment(http_rsb.response_status_202_count); + Metrics::Counter::increment(http_rsb.response_status_202_count); break; case 203: - Metrics::increment(http_rsb.response_status_203_count); + Metrics::Counter::increment(http_rsb.response_status_203_count); break; case 204: - Metrics::increment(http_rsb.response_status_204_count); + Metrics::Counter::increment(http_rsb.response_status_204_count); break; case 205: - Metrics::increment(http_rsb.response_status_205_count); + Metrics::Counter::increment(http_rsb.response_status_205_count); break; case 206: - Metrics::increment(http_rsb.response_status_206_count); + Metrics::Counter::increment(http_rsb.response_status_206_count); break; case 300: - Metrics::increment(http_rsb.response_status_300_count); + Metrics::Counter::increment(http_rsb.response_status_300_count); break; case 301: - Metrics::increment(http_rsb.response_status_301_count); + Metrics::Counter::increment(http_rsb.response_status_301_count); break; case 302: - Metrics::increment(http_rsb.response_status_302_count); + Metrics::Counter::increment(http_rsb.response_status_302_count); break; case 303: - Metrics::increment(http_rsb.response_status_303_count); + Metrics::Counter::increment(http_rsb.response_status_303_count); break; case 304: - Metrics::increment(http_rsb.response_status_304_count); + Metrics::Counter::increment(http_rsb.response_status_304_count); break; case 305: - Metrics::increment(http_rsb.response_status_305_count); + Metrics::Counter::increment(http_rsb.response_status_305_count); break; case 307: - Metrics::increment(http_rsb.response_status_307_count); + Metrics::Counter::increment(http_rsb.response_status_307_count); break; case 308: - Metrics::increment(http_rsb.response_status_308_count); + Metrics::Counter::increment(http_rsb.response_status_308_count); break; case 400: - Metrics::increment(http_rsb.response_status_400_count); + Metrics::Counter::increment(http_rsb.response_status_400_count); break; case 401: - Metrics::increment(http_rsb.response_status_401_count); + Metrics::Counter::increment(http_rsb.response_status_401_count); break; case 402: - Metrics::increment(http_rsb.response_status_402_count); + Metrics::Counter::increment(http_rsb.response_status_402_count); break; case 403: - Metrics::increment(http_rsb.response_status_403_count); + Metrics::Counter::increment(http_rsb.response_status_403_count); break; case 404: - Metrics::increment(http_rsb.response_status_404_count); + Metrics::Counter::increment(http_rsb.response_status_404_count); break; case 405: - Metrics::increment(http_rsb.response_status_405_count); + Metrics::Counter::increment(http_rsb.response_status_405_count); break; case 406: - Metrics::increment(http_rsb.response_status_406_count); + Metrics::Counter::increment(http_rsb.response_status_406_count); break; case 407: - Metrics::increment(http_rsb.response_status_407_count); + Metrics::Counter::increment(http_rsb.response_status_407_count); break; case 408: - Metrics::increment(http_rsb.response_status_408_count); + Metrics::Counter::increment(http_rsb.response_status_408_count); break; case 409: - Metrics::increment(http_rsb.response_status_409_count); + Metrics::Counter::increment(http_rsb.response_status_409_count); break; case 410: - Metrics::increment(http_rsb.response_status_410_count); + Metrics::Counter::increment(http_rsb.response_status_410_count); break; case 411: - Metrics::increment(http_rsb.response_status_411_count); + Metrics::Counter::increment(http_rsb.response_status_411_count); break; case 412: - Metrics::increment(http_rsb.response_status_412_count); + Metrics::Counter::increment(http_rsb.response_status_412_count); break; case 413: - Metrics::increment(http_rsb.response_status_413_count); + Metrics::Counter::increment(http_rsb.response_status_413_count); break; case 414: - Metrics::increment(http_rsb.response_status_414_count); + Metrics::Counter::increment(http_rsb.response_status_414_count); break; case 415: - Metrics::increment(http_rsb.response_status_415_count); + Metrics::Counter::increment(http_rsb.response_status_415_count); break; case 416: - Metrics::increment(http_rsb.response_status_416_count); + Metrics::Counter::increment(http_rsb.response_status_416_count); break; case 500: - Metrics::increment(http_rsb.response_status_500_count); + Metrics::Counter::increment(http_rsb.response_status_500_count); break; case 501: - Metrics::increment(http_rsb.response_status_501_count); + Metrics::Counter::increment(http_rsb.response_status_501_count); break; case 502: - Metrics::increment(http_rsb.response_status_502_count); + Metrics::Counter::increment(http_rsb.response_status_502_count); break; case 503: - Metrics::increment(http_rsb.response_status_503_count); + Metrics::Counter::increment(http_rsb.response_status_503_count); break; case 504: - Metrics::increment(http_rsb.response_status_504_count); + Metrics::Counter::increment(http_rsb.response_status_504_count); break; case 505: - Metrics::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: - Metrics::increment(http_rsb.response_status_1xx_count); + Metrics::Counter::increment(http_rsb.response_status_1xx_count); break; case 2: - Metrics::increment(http_rsb.response_status_2xx_count); + Metrics::Counter::increment(http_rsb.response_status_2xx_count); break; case 3: - Metrics::increment(http_rsb.response_status_3xx_count); + Metrics::Counter::increment(http_rsb.response_status_3xx_count); break; case 4: - Metrics::increment(http_rsb.response_status_4xx_count); + Metrics::Counter::increment(http_rsb.response_status_4xx_count); break; case 5: - Metrics::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 - Metrics::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: - 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); + 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: - Metrics::increment(http_rsb.ua_counts_hit_reval); - Metrics::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: - Metrics::increment(http_rsb.ua_counts_miss_cold); - Metrics::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: - Metrics::increment(http_rsb.ua_counts_miss_changed); - Metrics::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: - Metrics::increment(http_rsb.ua_counts_miss_client_no_cache); - Metrics::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: - Metrics::increment(http_rsb.ua_counts_miss_uncacheable); - Metrics::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: - Metrics::increment(http_rsb.ua_counts_errors_aborts); - Metrics::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: - Metrics::increment(http_rsb.ua_counts_errors_possible_aborts); - Metrics::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: - Metrics::increment(http_rsb.ua_counts_errors_connect_failed); - Metrics::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: - Metrics::increment(http_rsb.ua_counts_errors_other); - Metrics::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: - Metrics::increment(http_rsb.ua_counts_other_unclassified); - Metrics::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); - Metrics::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; } - Metrics::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. - 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); + 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: - 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); + 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: - 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); + 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: - 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); + 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: - 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); + 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: - 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); + 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: - 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); + 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: - 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); + 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: - 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); + 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: - 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); + 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: - 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); + 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: - 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); + 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 - Metrics::increment(http_rsb.total_transactions_time, total_time); + Metrics::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); + 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) { - Metrics::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, - origin_server_response_header_size + origin_server_response_body_size); - Metrics::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) { - 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); + 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) { - 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); + 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 - 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, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_READ_HEADER_DONE, 0)); - Metrics::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, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_FIRST_CONNECT, 0)); - Metrics::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, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_CONNECT_END, 0)); - Metrics::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, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_FIRST_READ, 0)); - Metrics::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, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_CACHE_OPEN_READ_BEGIN, 0)); - Metrics::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, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_CACHE_OPEN_WRITE_BEGIN, 0)); - Metrics::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, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_DNS_LOOKUP_BEGIN, 0)); - Metrics::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)); + 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 b263fef5df3..d26e57b1e0a 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); + 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; - Metrics::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::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::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::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/http/HttpVCTable.cc b/src/proxy/http/HttpVCTable.cc index 47c81be5f3f..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) { - Metrics::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 f6d067a35d2..82ce2411dc2 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::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::increment(_stats_ids->at(static_cast(PreWarm::Stat::HANDSHAKE_TIME)), duration); - ts::Metrics::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::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); + 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::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); + 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,48 +1133,64 @@ 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) { int stats_counter = 0; - ts::Metrics &intm = ts::Metrics::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) { + auto &[counters, gauges] = ids; + + // 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); + _makeName(dst, COUNTER_STAT_ENTRIES[j], name, sizeof(name)); + + auto metric = Metrics::Counter::createPtr(name); // This will do a lookup if it already exists - 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()); + if (metric == nullptr) { + Error("couldn't register counter stat name=%s", name); } 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()); + ++stats_counter; + counters[j] = metric; + Debug("v_prewarm_init", "conter stat id=%d name=%s", Metrics::Counter::lookup(name), name); } + } - ts::Metrics::IdType stats_id = intm.lookup(name); - ts::Metrics::IntType *metric = nullptr; + // Gauges next + for (int j = 0; j < static_cast(PreWarm::GaugeStat::LAST_ENTRY); ++j) { + char name[STAT_NAME_BUF_LEN]; - if (stats_id == ts::Metrics::NOT_FOUND) { - metric = intm.newMetricPtr(name); + _makeName(dst, GAUGE_STAT_ENTRIES[j], name, sizeof(name)); - if (metric == nullptr) { - Error("couldn't register stat name=%s", name); - } else { - ++stats_counter; - } + auto metric = Metrics::Gauge::createPtr(name); // This will do a lookup if it already exists + + if (metric == nullptr) { + Error("couldn't register gauge stat name=%s", name); } else { - metric = intm.lookup(stats_id); + ++stats_counter; + gauges[j] = metric; + Debug("v_prewarm_init", "gauge stat id=%d name=%s", Metrics::Gauge::lookup(name), name); } - - ids[j] = metric; - - Debug("v_prewarm_init", "stat id=%d name=%s", stats_id, name); } _stats_id_map[dst] = std::make_shared(ids); diff --git a/src/proxy/http2/HTTP2.cc b/src/proxy/http2/HTTP2.cc index 8abaec309e0..97429311a92 100644 --- a/src/proxy/http2/HTTP2.cc +++ b/src/proxy/http2/HTTP2.cc @@ -563,40 +563,43 @@ 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"); + 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::Gauge::createPtr("proxy.process.http2.current_active_client_connections"); + http2_rsb.current_active_server_connection_count = + 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"); + 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 = - 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::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 = - intm.newMetricPtr("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 = - 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::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 dd232abbb76..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::decrement(http2_rsb.current_client_session_count); + Metrics::Gauge::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); + Metrics::Gauge::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() { - Metrics::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::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/Http2CommonSession.cc b/src/proxy/http2/Http2CommonSession.cc index bea3e8ab983..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: - Metrics::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. - Metrics::increment(http2_rsb.session_die_other); + Metrics::Counter::increment(http2_rsb.session_die_other); break; } } else { switch (dying_event) { case VC_EVENT_NONE: - Metrics::increment(http2_rsb.session_die_default); + Metrics::Counter::increment(http2_rsb.session_die_default); break; case VC_EVENT_ACTIVE_TIMEOUT: - Metrics::increment(http2_rsb.session_die_active); + Metrics::Counter::increment(http2_rsb.session_die_active); break; case VC_EVENT_INACTIVITY_TIMEOUT: - Metrics::increment(http2_rsb.session_die_inactive); + Metrics::Counter::increment(http2_rsb.session_die_inactive); break; case VC_EVENT_ERROR: - Metrics::increment(http2_rsb.session_die_error); + Metrics::Counter::increment(http2_rsb.session_die_error); break; case VC_EVENT_EOS: - Metrics::increment(http2_rsb.session_die_eos); + Metrics::Counter::increment(http2_rsb.session_die_eos); break; default: - Metrics::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 ba50b7e3118..7afdadb0648 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); + 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) { - Metrics::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) { - Metrics::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) { - Metrics::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) { - Metrics::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) { - Metrics::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) { - Metrics::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) { - Metrics::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) { - Metrics::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 = Metrics::read(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); @@ -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); + 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 4d6f50031ff..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::decrement(http2_rsb.current_server_session_count); + Metrics::Gauge::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); + Metrics::Gauge::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 02575aa04de..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) { - 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 + 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 2d2af92645f..fac543b6bfa 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); + 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()) { - Metrics::increment(http2_rsb.current_server_stream_count); - Metrics::increment(http2_rsb.total_server_stream_count); + Metrics::Gauge::increment(http2_rsb.current_server_stream_count); + Metrics::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); + 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::decrement(http2_rsb.current_server_stream_count); + Metrics::Gauge::decrement(http2_rsb.current_server_stream_count); } else { - Metrics::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 3ec27026176..f46c1b933c0 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 &intm = ts::Metrics::getInstance(); - // - // http3_rsb.current_client_session_count = intm.newMetricPtr("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/Log.cc b/src/proxy/logging/Log.cc index bb2cb5629f9..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 ..."); - Metrics::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 ..."); - Metrics::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: - Metrics::increment(log_rsb.event_log_error_ok); + Metrics::Counter::increment(log_rsb.event_log_error_ok); break; case Log::SKIP: - Metrics::increment(log_rsb.event_log_error_skip); + Metrics::Counter::increment(log_rsb.event_log_error_skip); break; case Log::AGGR: - Metrics::increment(log_rsb.event_log_error_aggr); + Metrics::Counter::increment(log_rsb.event_log_error_aggr); break; case Log::FULL: - Metrics::increment(log_rsb.event_log_error_full); + Metrics::Counter::increment(log_rsb.event_log_error_full); break; case Log::FAIL: - Metrics::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; } - Metrics::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); - Metrics::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)); - Metrics::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)); - Metrics::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; } - Metrics::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 069a3a79e9e..a1cd9222c92 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 &metrics = ts::Metrics::instance(); + ts::Metrics::IdType mid = metrics[record]; - if (metric != ts::Metrics::NOT_FOUND) { - int64_t val = intm[metric]; + if (mid != ts::Metrics::NOT_FOUND) { + 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 7254b36d171..4ef25ef8cfc 100644 --- a/src/proxy/logging/LogConfig.cc +++ b/src/proxy/logging/LogConfig.cc @@ -508,32 +508,31 @@ 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"); + 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::Gauge::createPtr("proxy.process.log.log_files_open"); + log_rsb.log_files_space_used = Metrics::Gauge::createPtr("proxy.process.log.log_files_space_used"); } /*------------------------------------------------------------------------- @@ -659,7 +658,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); + 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/proxy/logging/LogFile.cc b/src/proxy/logging/LogFile.cc index 16aef2f5577..0e4e7bc3f1d 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); + 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::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::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); @@ -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); + 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); - 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); + 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); - Metrics::increment(log_rsb.num_flush_to_disk, fmt_entry_count); - Metrics::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 d2c98a70149..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."); - Metrics::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)) { - Metrics::increment(log_rsb.event_log_access_fail); + Metrics::Counter::increment(log_rsb.event_log_access_fail); } else if (unlikely(ret & Log::FULL)) { - Metrics::increment(log_rsb.event_log_access_full); + Metrics::Counter::increment(log_rsb.event_log_access_full); } else if (likely(ret & Log::LOG_OK)) { - Metrics::increment(log_rsb.event_log_access_ok); + Metrics::Counter::increment(log_rsb.event_log_access_ok); } else if (unlikely(ret & Log::AGGR)) { - Metrics::increment(log_rsb.event_log_access_aggr); + Metrics::Counter::increment(log_rsb.event_log_access_aggr); } else if (likely(ret & Log::SKIP)) { - Metrics::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 9b735d7be62..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" @@ -36,9 +39,6 @@ #include "tscpp/util/ts_errata.h" #include "api/Metrics.h" -#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 +513,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 &metrics = ts::Metrics::instance(); + auto it = metrics.find(name); - if (it != intm.end()) { + if (it != metrics.end()) { RecRecord r; auto &&[name, val] = *it; @@ -567,7 +567,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::instance()) { if (regex.match(name.data()) >= 0) { tmp.name = name.data(); tmp.data.rec_int = val; @@ -899,7 +899,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::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 1e66c85cfbb..b20e72e8cea 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 &metrics = ts::Metrics::instance(); + 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].store(1); TSSystemState::drain(true); // Close listening sockets here only if TS is running standalone RecInt close_sockets = 0; @@ -426,11 +426,9 @@ class MemoryLimit : public Continuation public: MemoryLimit() : Continuation(new_ProxyMutex()) { - ts::Metrics &intm = ts::Metrics::getInstance(); - memset(&_usage, 0, sizeof(_usage)); SET_HANDLER(&MemoryLimit::periodic); - memory_rss = intm.newMetricPtr("proxy.process.traffic_server.memory.rss"); + memory_rss = Metrics::Gauge::createPtr("proxy.process.traffic_server.memory.rss"); } ~MemoryLimit() override { mutex = nullptr; } @@ -450,7 +448,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::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) { @@ -478,7 +476,7 @@ class MemoryLimit : public Continuation private: int64_t _memory_limit = 0; struct rusage _usage; - ts::Metrics::IntType *memory_rss; + Metrics::Gauge::AtomicType *memory_rss; }; /** Gate the emission of the "Traffic Server is fuly initialized" log message. @@ -805,10 +803,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 &metrics = ts::Metrics::instance(); + 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 +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::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::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::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::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::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::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::read(net_rsb.connections_currently_open); - int64_t d_p = Metrics::read(net_rsb.handler_run) - last_p; + 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; 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 &intm = ts::Metrics::getInstance(); + ts::Metrics &metrics = ts::Metrics::instance(); 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::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 - intm.newMetric("proxy.process.proxy.reconfigure_required"); - intm.newMetric("proxy.process.proxy.restart_required"); - intm.newMetric("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) - intm.newMetric("proxy.process.proxy.cache_ready_time"); + Metrics::Gauge::create("proxy.process.proxy.cache_ready_time"); // init huge pages int enabled;